From c66b0afed4cb1233888f97cd8dfe03f1e3a5d60f Mon Sep 17 00:00:00 2001 From: swasti16 Date: Tue, 13 Aug 2024 19:14:13 +0530 Subject: [PATCH] Fix #6690: Add isFunctionPointer to typeDef-info --- lib/tokenize.cpp | 10 ++++++++++ lib/tokenize.h | 1 + 2 files changed, 11 insertions(+) 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;