diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index f4bcf9574770..263d332e7a13 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1040,6 +1040,10 @@ namespace { return mEndToken; } + Token* nameToken() const { + return mNameToken; + } + private: static bool isCast(const Token* tok) { if (Token::Match(tok, "( %name% ) (|%name%|%num%")) @@ -1145,6 +1149,7 @@ void Tokenizer::simplifyTypedef() typedefInfo.lineNumber = typedefToken->linenr(); typedefInfo.column = typedefToken->column(); typedefInfo.used = t.second.isUsed(); + typedefInfo.isFunctionPointer = Token::Match(t.second.nameToken(), "%name% ) ("); mTypedefInfo.push_back(std::move(typedefInfo)); t.second.removeDeclaration(); @@ -1645,6 +1650,7 @@ void Tokenizer::simplifyTypedefCpp() typedefInfo.lineNumber = typeName->linenr(); typedefInfo.column = typeName->column(); typedefInfo.used = false; + typedefInfo.isFunctionPointer = Token::Match(typeName, "%name% ) ("); mTypedefInfo.push_back(std::move(typedefInfo)); while (!done) { @@ -6184,6 +6190,10 @@ void Tokenizer::dump(std::ostream &out) const outs += std::to_string(typedefInfo.used?1:0); outs += "\""; + outs += " isFunctionPointer=\""; + outs += std::to_string(typedefInfo.isFunctionPointer); + outs += "\""; + outs += "/>"; outs += '\n'; } diff --git a/lib/tokenize.h b/lib/tokenize.h index 5043c67d73bb..c3cd47cf31f2 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -666,6 +666,7 @@ class CPPCHECKLIB Tokenizer { int lineNumber; int column; bool used; + bool isFunctionPointer; }; std::vector mTypedefInfo;