SymbolDatabase: Fixed handling of nested types for function arguments
Removed unnecessary loops between var->typeStartToken() and var->typeEndToken()
This commit is contained in:
parent
69b7f91034
commit
8188578cf2
|
@ -175,14 +175,7 @@ void CheckClass::constructors()
|
|||
if (!var->isPointer() &&
|
||||
!(var->type() && var->type()->needInitialization != Type::True) &&
|
||||
(func->type == Function::eCopyConstructor || func->type == Function::eOperatorEqual)) {
|
||||
bool stdtype = false;
|
||||
for (const Token *type = var->typeStartToken(); type && type->isName(); type = type->next()) {
|
||||
if (type->isStandardType()) {
|
||||
stdtype = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!stdtype) {
|
||||
if (!var->typeStartToken()->isStandardType()) {
|
||||
if (_settings->inconclusive)
|
||||
inconclusive = true;
|
||||
else
|
||||
|
@ -962,20 +955,6 @@ void CheckClass::checkMemset()
|
|||
|
||||
if (derefs == 0)
|
||||
type = var->typeScope();
|
||||
|
||||
// TODO: The SymbolDatabase mix up variables in nested structs.
|
||||
// So we must bailout right now if there are nested structs.
|
||||
bool bailout = false;
|
||||
for (const Token *typetok2 = var->typeStartToken(); typetok2 && typetok2 != var->typeEndToken(); typetok2 = typetok2->next()) {
|
||||
if (typetok2->str() == "::")
|
||||
bailout = true;
|
||||
else if (typetok2->str() == "{") {
|
||||
bailout = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bailout)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -433,13 +433,7 @@ private:
|
|||
if (var2->isPointer())
|
||||
checks.push_back(new UninitVar(owner, var2, symbolDatabase, library, isC));
|
||||
else if (var2->typeEndToken()->str() != ">") {
|
||||
bool stdtype = false; // TODO: change to isC to handle unknown types better
|
||||
for (const Token* tok2 = var2->typeStartToken(); tok2 != var2->nameToken(); tok2 = tok2->next()) {
|
||||
if (tok2->isStandardType()) {
|
||||
stdtype = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool stdtype = var2->typeStartToken()->isStandardType(); // TODO: change to isC to handle unknown types better
|
||||
if (stdtype && (!var2->isArray() || var2->nameToken()->linkAt(1)->strAt(1) == ";"))
|
||||
checks.push_back(new UninitVar(owner, var2, symbolDatabase, library, isC));
|
||||
}
|
||||
|
|
|
@ -2222,6 +2222,8 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s
|
|||
const Token *typeTok = startTok->tokAt(startTok->str() == "const" ? 1 : 0);
|
||||
if (typeTok->str() == "struct")
|
||||
typeTok = typeTok->next();
|
||||
if (Token::Match(typeTok, "%type% ::"))
|
||||
typeTok = typeTok->tokAt(2);
|
||||
|
||||
// check for argument with no name or missing varid
|
||||
if (!endTok) {
|
||||
|
|
|
@ -2204,7 +2204,7 @@ private:
|
|||
" n1::Fred fred;\n"
|
||||
" memset(&fred, 0, sizeof(fred));\n"
|
||||
"}");
|
||||
TODO_ASSERT_EQUALS("[test.cpp:10]: (error) Using 'memset' on class that contains a 'std::string'.\n", "", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:10]: (error) Using 'memset' on class that contains a 'std::string'.\n", errout.str());
|
||||
|
||||
checkNoMemset("class A {\n"
|
||||
" virtual ~A() { }\n"
|
||||
|
|
Loading…
Reference in New Issue