diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index f4bcf9574770..640e0e3cf3fe 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1134,6 +1134,12 @@ void Tokenizer::simplifyTypedef() if (!typedefs.empty()) { // remove typedefs + auto isFunctionPointer = [](const Token* start, const Token* end) { + for (const Token* t = start; t != end; t = t->next()) { + if (Token::Match(t, "* %name% ) (")) + return true; + } + }; for (auto &t: typedefs) { if (t.second.replaceFailed()) { syntaxError(t.second.getTypedefToken()); @@ -1145,6 +1151,7 @@ void Tokenizer::simplifyTypedef() typedefInfo.lineNumber = typedefToken->linenr(); typedefInfo.column = typedefToken->column(); typedefInfo.used = t.second.isUsed(); + typedefInfo.isFunctionPointer = isFunctionPointer(typedefToken->next(), t.second.endToken()); mTypedefInfo.push_back(std::move(typedefInfo)); t.second.removeDeclaration(); @@ -6184,6 +6191,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;