From 57ec1aea91136a934548b4b697060cc0420dd6c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 31 Jan 2015 10:24:10 +0100 Subject: [PATCH] Library: Don't rely on ast in isNotLibraryFunction since it's used in tokenizer --- lib/library.cpp | 5 ++--- test/testbufferoverrun.cpp | 2 +- test/testsimplifytokens.cpp | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/library.cpp b/lib/library.cpp index 7816c6331..e30958028 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -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()) { diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 5c16f496d..308a2253f 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -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" diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index ca341942e..fbfc2f0e1 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -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"