Tokenizer: remove some unhandled macros in the global scope. ticket: #2523
This commit is contained in:
parent
0624e418f1
commit
49fc53165c
|
@ -2083,7 +2083,7 @@ bool Tokenizer::tokenize(std::istream &code,
|
|||
}
|
||||
|
||||
|
||||
// remove inline SQL (Oracle PRO*C). Ticket: #1959
|
||||
// replace inline SQL with "asm()" (Oracle PRO*C). Ticket: #1959
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
if (Token::simpleMatch(tok, "EXEC SQL"))
|
||||
|
@ -2123,6 +2123,9 @@ bool Tokenizer::tokenize(std::istream &code,
|
|||
}
|
||||
}
|
||||
|
||||
// remove some unhandled macros in global scope
|
||||
removeMacrosInGlobalScope();
|
||||
|
||||
// specify array size..
|
||||
arraySize();
|
||||
|
||||
|
@ -4383,6 +4386,23 @@ bool Tokenizer::simplifyTokenList()
|
|||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void Tokenizer::removeMacrosInGlobalScope()
|
||||
{
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
if (tok->str() == "(")
|
||||
{
|
||||
tok = tok->link();
|
||||
if (Token::Match(tok, ") %type% {") && tok->strAt(1) != "const")
|
||||
tok->deleteNext();
|
||||
}
|
||||
|
||||
if (tok->str() == "{")
|
||||
tok = tok->link();
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void Tokenizer::removeRedundantAssignment()
|
||||
{
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
|
|
|
@ -186,6 +186,9 @@ public:
|
|||
/** Simplify labels */
|
||||
void labels();
|
||||
|
||||
/** Remove macros in global scope */
|
||||
void removeMacrosInGlobalScope();
|
||||
|
||||
/** Remove redundant assignment */
|
||||
void removeRedundantAssignment();
|
||||
|
||||
|
|
|
@ -298,6 +298,9 @@ private:
|
|||
TEST_CASE(java);
|
||||
|
||||
TEST_CASE(simplifyOperatorName);
|
||||
|
||||
// Some simple cleanups of unhandled macros in the global scope
|
||||
TEST_CASE(removeMacrosInGlobalScope);
|
||||
}
|
||||
|
||||
|
||||
|
@ -5247,6 +5250,12 @@ private:
|
|||
|
||||
ASSERT_EQUALS(result2, tokenizeAndStringify(code2,false));
|
||||
}
|
||||
|
||||
void removeMacrosInGlobalScope()
|
||||
{
|
||||
// remove some unhandled macros in the global scope.
|
||||
ASSERT_EQUALS("void f ( ) { }", tokenizeAndStringify("void f() NOTHROW { }"));
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestTokenizer)
|
||||
|
|
Loading…
Reference in New Issue