Library: Don't rely on ast in isNotLibraryFunction since it's used in tokenizer

This commit is contained in:
Daniel Marjamäki 2015-01-31 10:24:10 +01:00
parent 36841cfa41
commit 57ec1aea91
3 changed files with 5 additions and 6 deletions

View File

@ -681,10 +681,9 @@ const Library::Container* Library::detectContainer(const Token* typeStart) const
// returns true if ftok is not a library function
bool Library::isNotLibraryFunction(const Token *ftok) const
{
if (!ftok->astParent())
// called from tokenizer, ast is not created properly yet
if (Token::Match(ftok->previous(),"::|."))
return false;
if (ftok->astParent()->str() != "(")
return true;
int callargs = 0;
for (const Token *tok = ftok->tokAt(2); tok && tok->str() != ")"; tok = tok->next()) {

View File

@ -2280,7 +2280,7 @@ private:
" foo::memset(str, 0, 100);\n"
" std::memset(str, 0, 100);\n"
"}");
TODO_ASSERT_EQUALS("[test.cpp:5]: (error) Buffer is accessed out of bounds: str\n", "", errout.str());
ASSERT_EQUALS("[test.cpp:5]: (error) Buffer is accessed out of bounds: str\n", errout.str());
// #5257 - check strings
checkstd("void f() {\n"

View File

@ -2111,10 +2111,10 @@ private:
ASSERT_EQUALS("void f ( ) { return ; }", tokWithStdLib(code1));
const char code2[] = "void f() {\n"
" exit();\n"
" exit(0);\n"
" y();\n"
"}";
ASSERT_EQUALS("void f ( ) { exit ( ) ; }", tokWithStdLib(code2));
ASSERT_EQUALS("void f ( ) { exit ( 0 ) ; }", tokWithStdLib(code2));
const char code3[] = "void f() {\n"
" x.abort();\n"