Fixed #521 (Tokenizer: improve static variable detection)
Also change cppcheck default behavior to don't show "If you see this, there is a bug" message for each variable without varId. This feature was very helpful for developers but may annoying users. http://sourceforge.net/apps/trac/cppcheck/ticket/521
This commit is contained in:
parent
fa8e1c82f0
commit
8588012df7
|
@ -304,6 +304,9 @@ void CheckStl::pushback()
|
||||||
if (Token::Match(tok2, "for ( %varid% = %var% . begin ( ) ; %varid% != %var% . end ( ) ; ++ %varid% ) {", iteratorid))
|
if (Token::Match(tok2, "for ( %varid% = %var% . begin ( ) ; %varid% != %var% . end ( ) ; ++ %varid% ) {", iteratorid))
|
||||||
{
|
{
|
||||||
const unsigned int vectorid(tok2->tokAt(4)->varId());
|
const unsigned int vectorid(tok2->tokAt(4)->varId());
|
||||||
|
if (vectorid == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
const Token *pushback = 0;
|
const Token *pushback = 0;
|
||||||
int indent3 = 0;
|
int indent3 = 0;
|
||||||
for (const Token *tok3 = tok2->tokAt(22); tok3; tok3 = tok3->next())
|
for (const Token *tok3 = tok2->tokAt(22); tok3; tok3 = tok3->next())
|
||||||
|
|
|
@ -745,7 +745,7 @@ void Tokenizer::setVarId()
|
||||||
if (Token::Match(tok, "else|return|typedef|delete"))
|
if (Token::Match(tok, "else|return|typedef|delete"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (tok->str() == "const")
|
if (Token::Match(tok, "const|static|extern"))
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
|
|
||||||
while (Token::Match(tok, "%var% ::"))
|
while (Token::Match(tok, "%var% ::"))
|
||||||
|
|
|
@ -1278,6 +1278,8 @@ private:
|
||||||
"std::map<int, int> coords;\n"
|
"std::map<int, int> coords;\n"
|
||||||
"std::tr1::unordered_map<int, int> xy;\n"
|
"std::tr1::unordered_map<int, int> xy;\n"
|
||||||
"std::list<boost::wave::token_id> tokens;\n"
|
"std::list<boost::wave::token_id> tokens;\n"
|
||||||
|
"static std::vector<CvsProcess*> ex1;\n"
|
||||||
|
"extern std::vector<CvsProcess*> ex2;\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
// tokenize..
|
// tokenize..
|
||||||
|
@ -1295,6 +1297,8 @@ private:
|
||||||
"4: std :: map < int , int > coords@4 ;\n"
|
"4: std :: map < int , int > coords@4 ;\n"
|
||||||
"5: std :: tr1 :: unordered_map < int , int > xy@5 ;\n"
|
"5: std :: tr1 :: unordered_map < int , int > xy@5 ;\n"
|
||||||
"6: std :: list < boost :: wave :: token_id > tokens@6 ;\n"
|
"6: std :: list < boost :: wave :: token_id > tokens@6 ;\n"
|
||||||
|
"7: static std :: vector < CvsProcess * > ex1@7 ;\n"
|
||||||
|
"8: extern std :: vector < CvsProcess * > ex2@8 ;\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
ASSERT_EQUALS(expected, actual);
|
ASSERT_EQUALS(expected, actual);
|
||||||
|
|
Loading…
Reference in New Issue