Refactorization: Removed unnecessary code. Variable::typeStartToken() and Variable::typeEndToken() never point to "const".
Ran AStyle
This commit is contained in:
parent
704f285c90
commit
17b720ef7d
|
@ -491,8 +491,6 @@ const char *CheckMemoryLeak::functionArgAlloc(const Function *func, unsigned int
|
|||
if (!arg->isPointer())
|
||||
return "";
|
||||
const Token* tok = arg->typeEndToken();
|
||||
if (tok->str() == "const")
|
||||
tok = tok->previous();
|
||||
tok = tok->previous();
|
||||
if (tok->str() != "*")
|
||||
return "";
|
||||
|
@ -2283,8 +2281,6 @@ void CheckMemoryLeakInClass::check()
|
|||
if (!var->isStatic() && var->isPointer()) {
|
||||
// allocation but no deallocation of private variables in public function..
|
||||
const Token *tok = var->typeStartToken();
|
||||
if (tok->str() == "const")
|
||||
tok = tok->next();
|
||||
if (tok->isStandardType()) {
|
||||
if (var->isPrivate())
|
||||
checkPublicFunctions(&(*scope), var->nameToken());
|
||||
|
|
|
@ -120,7 +120,7 @@ void CheckStl::iterators()
|
|||
const Variable *variableInfo = symbolDatabase->getVariableFromVarId(tok2->varId());
|
||||
const Token *decltok = variableInfo ? variableInfo->typeStartToken() : NULL;
|
||||
|
||||
if (Token::Match(decltok, "const| std :: set"))
|
||||
if (Token::simpleMatch(decltok, "std :: set"))
|
||||
continue; // No warning
|
||||
|
||||
// skip error message if the iterator is erased/inserted by value
|
||||
|
@ -795,8 +795,6 @@ void CheckStl::if_find()
|
|||
// Is the variable a std::string or STL container?
|
||||
const Token * decl = var->typeStartToken();
|
||||
|
||||
if (decl->str() == "const")
|
||||
decl = decl->next();
|
||||
// stl container
|
||||
if (Token::Match(decl, "std :: %var% < %type% > &| %varid%", varid))
|
||||
if_findError(tok, false);
|
||||
|
@ -826,9 +824,6 @@ void CheckStl::if_find()
|
|||
// Is the variable a std::string or STL container?
|
||||
const Token * decl = var->typeStartToken();
|
||||
|
||||
//jump next to 'const'
|
||||
if (decl->str() == "const")
|
||||
decl = decl->next();
|
||||
//pretty bad limitation.. but it is there in order to avoid
|
||||
//own implementations of 'find' or any container
|
||||
if (!Token::simpleMatch(decl, "std ::"))
|
||||
|
@ -901,10 +896,6 @@ bool CheckStl::isStlContainer(unsigned int varid)
|
|||
// find where this tokens type starts
|
||||
const Token *type = var->typeStartToken();
|
||||
|
||||
// ignore "const"
|
||||
if (type->str() == "const")
|
||||
type = type->next();
|
||||
|
||||
// discard namespace if supplied
|
||||
if (Token::simpleMatch(type, "std ::"))
|
||||
type = type->tokAt(2);
|
||||
|
|
|
@ -7672,8 +7672,8 @@ private:
|
|||
ASSERT_EQUALS("int foo ( ) { }", tok("__inline int foo ( ) { }", true));
|
||||
ASSERT_EQUALS("int foo ( ) { }", tok("__forceinline int foo ( ) { }", true));
|
||||
ASSERT_EQUALS("int foo ( ) { }", tok("constexpr int foo() { }", true));
|
||||
ASSERT_EQUALS("class C { int f ( ) ; } ;", tok("class C { int f() override ; };", true));
|
||||
ASSERT_EQUALS("class C { int f ( ) ; } ;", tok("class C { int f() final ; };", true));
|
||||
ASSERT_EQUALS("class C { int f ( ) ; } ;", tok("class C { int f() override ; };", true));
|
||||
ASSERT_EQUALS("class C { int f ( ) ; } ;", tok("class C { int f() final ; };", true));
|
||||
ASSERT_EQUALS("if ( a ) { }", tok("if ( likely ( a ) ) { }", true));
|
||||
ASSERT_EQUALS("if ( a ) { }", tok("if ( unlikely ( a ) ) { }", true));
|
||||
ASSERT_EQUALS("int * p ;", tok("int * __restrict p;", "test.c"));
|
||||
|
|
Loading…
Reference in New Issue