Skip to content

Commit 830d1eb

Browse files
committed
Revert "Fixed cppcheck-opensource#6538 (Symboldatabase: improve isFunction)"
This reverts commit d7ef89b. There was crashes in a Travis job.
1 parent d7ef89b commit 830d1eb

5 files changed

Lines changed: 7 additions & 71 deletions

File tree

lib/symboldatabase.cpp

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,53 +1288,6 @@ bool SymbolDatabase::isFunction(const Token *tok, const Scope* outerScope, const
12881288
(tok->previous()->isName() || tok->strAt(-1) == ">" || tok->strAt(-1) == "&" || tok->strAt(-1) == "*" || // Either a return type in front of tok
12891289
tok->strAt(-1) == "::" || tok->strAt(-1) == "~" || // or a scope qualifier in front of tok
12901290
outerScope->isClassOrStruct())) { // or a ctor/dtor
1291-
1292-
const Token* tok1 = tok->previous();
1293-
1294-
// skip over destructor "~"
1295-
if (tok1->str() == "~")
1296-
tok1 = tok1->previous();
1297-
1298-
// skip over qualification
1299-
while (Token::simpleMatch(tok1, "::")) {
1300-
if (Token::Match(tok1->tokAt(-1), "%name%"))
1301-
tok1 = tok1->tokAt(-2);
1302-
else
1303-
tok1 = tok1->tokAt(-1);
1304-
}
1305-
1306-
// skip over pointers and references
1307-
while (Token::Match(tok1, "[*&]"))
1308-
tok1 = tok1->tokAt(-1);
1309-
1310-
// skip over template
1311-
if (tok1 && tok1->str() == ">")
1312-
tok1 = tok1->link()->previous();
1313-
1314-
// function can't have number or variable as return type
1315-
if (tok1 && (tok1->isNumber() || tok1->varId()))
1316-
return false;
1317-
1318-
// skip over return type
1319-
if (Token::Match(tok1, "%name%"))
1320-
tok1 = tok1->previous();
1321-
1322-
// skip over qualification
1323-
while (Token::simpleMatch(tok1, "::")) {
1324-
if (Token::Match(tok1->tokAt(-1), "%name%"))
1325-
tok1 = tok1->tokAt(-2);
1326-
else
1327-
tok1 = tok1->tokAt(-1);
1328-
}
1329-
1330-
// skip over modifiers and other stuff
1331-
while (Token::Match(tok1, "const|static|extern|template|virtual|struct|class"))
1332-
tok1 = tok1->previous();
1333-
1334-
// should be at a sequence point if this is a function
1335-
if (!Token::Match(tok1, ">|{|}|;|public:|protected:|private:") && tok1)
1336-
return false;
1337-
13381291
const Token* tok2 = tok->next()->link()->next();
13391292
if (tok2 &&
13401293
(Token::Match(tok2, "const| ;|{|=") ||

test/testgarbage.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,11 @@ class TestGarbage : public TestFixture {
420420

421421
ASSERT_THROW(checkCode("class Foo {}; class Bar : public Foo"), InternalError);
422422

423-
checkCode("YY_DECL { switch (yy_act) {\n"
424-
" case 65: YY_BREAK\n"
425-
" case YY_STATE_EOF(block):\n"
426-
" yyterminate(); \n"
427-
"} }"); // #5663
423+
ASSERT_THROW(checkCode("YY_DECL { switch (yy_act) {\n"
424+
" case 65: YY_BREAK\n"
425+
" case YY_STATE_EOF(block):\n"
426+
" yyterminate(); \n"
427+
"} }"), InternalError); // #5663
428428
}
429429

430430
void garbageAST() {

test/testother.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3020,7 +3020,7 @@ class TestOther : public TestFixture {
30203020
ASSERT_EQUALS("[test.cpp:4]: (style) Consecutive return, break, continue, goto or throw statements are unnecessary.\n", errout.str());
30213021

30223022
// #5707
3023-
check("extern int i,j;\n"
3023+
check("extern int i,j\n"
30243024
"int foo() {\n"
30253025
" switch(i) {\n"
30263026
" default: j=1; break;\n"

test/testsymboldatabase.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ class TestSymbolDatabase: public TestFixture {
228228
TEST_CASE(symboldatabase48); // #6417
229229
TEST_CASE(symboldatabase49); // #6424
230230
TEST_CASE(symboldatabase50); // #6432
231-
TEST_CASE(symboldatabase51); // #6538
232231

233232
TEST_CASE(isImplicitlyVirtual);
234233

@@ -2129,22 +2128,6 @@ class TestSymbolDatabase: public TestFixture {
21292128
ASSERT_EQUALS(true, db && f && f->function() && f->function()->isConstructor());
21302129
}
21312130

2132-
void symboldatabase51() { // #6538
2133-
GET_SYMBOL_DB("static const float f1 = 2 * foo1(a, b);\n"
2134-
"static const float f2 = 2 * ::foo2(a, b);\n"
2135-
"static const float f3 = 2 * std::foo3(a, b);\n"
2136-
"static const float f4 = c * foo4(a, b);\n"
2137-
"static const int i1 = 2 & foo5(a, b);\n");
2138-
ASSERT(db != nullptr);
2139-
if (db) {
2140-
ASSERT(findFunctionByName("foo1", &db->scopeList.front()) == nullptr);
2141-
ASSERT(findFunctionByName("foo2", &db->scopeList.front()) == nullptr);
2142-
ASSERT(findFunctionByName("foo3", &db->scopeList.front()) == nullptr);
2143-
ASSERT(findFunctionByName("foo4", &db->scopeList.front()) == nullptr);
2144-
ASSERT(findFunctionByName("foo5", &db->scopeList.front()) == nullptr);
2145-
}
2146-
}
2147-
21482131
void isImplicitlyVirtual() {
21492132
{
21502133
GET_SYMBOL_DB("class Base {\n"

test/testunusedprivfunc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ class TestUnusedPrivateFunction : public TestFixture {
418418
"class A\n"
419419
"{\n"
420420
"public:\n"
421-
" A();\n"
421+
" A()\n"
422422
" void a();\n"
423423
"private:\n"
424424
" void b();\n"

0 commit comments

Comments
 (0)