diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 2075a3bb5..31fc8a0b5 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -426,42 +426,42 @@ bool isWithoutSideEffects(bool cpp, const Token* tok) bool isUniqueExpression(const Token* tok) { - if(!tok) + if (!tok) return true; - if(tok->function()) { + if (tok->function()) { const Function * fun = tok->function(); const Scope * scope = fun->nestedIn; - if(!scope) + if (!scope) return true; - for(const Function& f:scope->functionList) { - if(f.argumentList.size() == fun->argumentList.size() && f.name() != fun->name()) { + for (const Function& f:scope->functionList) { + if (f.argumentList.size() == fun->argumentList.size() && f.name() != fun->name()) { return false; } } - } else if(tok->variable()) { + } else if (tok->variable()) { const Variable * var = tok->variable(); const Scope * scope = var->scope(); - if(!scope) + if (!scope) return true; const Type * varType = var->type(); // Iterate over the variables in scope and the parameters of the function if possible const Function * fun = scope->function; const std::list* setOfVars[] = {&scope->varlist, fun ? &fun->argumentList : nullptr}; if (varType) { - for(const std::list* vars:setOfVars) { - if(!vars) + for (const std::list* vars:setOfVars) { + if (!vars) continue; - for(const Variable& v:*vars) { + for (const Variable& v:*vars) { if (v.type() && v.type()->name() == varType->name() && v.name() != var->name()) { return false; } } } } else { - for(const std::list* vars:setOfVars) { - if(!vars) + for (const std::list* vars:setOfVars) { + if (!vars) continue; - for(const Variable& v:*vars) { + for (const Variable& v:*vars) { if (v.isFloatingType() == var->isFloatingType() && v.isEnumType() == var->isEnumType() && v.isClass() == var->isClass() && @@ -472,7 +472,7 @@ bool isUniqueExpression(const Token* tok) } } } - } else if(!isUniqueExpression(tok->astOperand1())) { + } else if (!isUniqueExpression(tok->astOperand1())) { return false; } diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 81c1e7745..8fce95b8a 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -671,8 +671,8 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::listexperimental) ? nullptr : "callfunc"; } - -static void addtoken(Token **rettail, const Token *tok, const std::string &str) +template +static void addtoken(Token **rettail, const Token *tok, T&& str) { (*rettail)->insertToken(str); (*rettail) = (*rettail)->next(); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 23af4ba27..ee08761ab 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -860,16 +860,16 @@ private: void tokenize37() { // #8550 const char codeC[] = "class name { public: static void init ( ) {} } ; " - "typedef class name N; " - "void foo ( ) { return N :: init ( ) ; }"; + "typedef class name N; " + "void foo ( ) { return N :: init ( ) ; }"; const char expC [] = "class name { public: static void init ( ) { } } ; " - "void foo ( ) { return name :: init ( ) ; }"; + "void foo ( ) { return name :: init ( ) ; }"; ASSERT_EQUALS(expC, tokenizeAndStringify(codeC)); const char codeS[] = "class name { public: static void init ( ) {} } ; " - "typedef struct name N; " - "void foo ( ) { return N :: init ( ) ; }"; + "typedef struct name N; " + "void foo ( ) { return N :: init ( ) ; }"; const char expS [] = "class name { public: static void init ( ) { } } ; " - "void foo ( ) { return name :: init ( ) ; }"; + "void foo ( ) { return name :: init ( ) ; }"; ASSERT_EQUALS(expS, tokenizeAndStringify(codeS)); }