Skip to content

Commit

Permalink
Fix danmar#6690: Add isFunctionPointer to typeDef-info
Browse files Browse the repository at this point in the history
  • Loading branch information
swasti16 committed Aug 14, 2024
1 parent 35a0df1 commit c66b0af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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%"))
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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';
}
Expand Down
1 change: 1 addition & 0 deletions lib/tokenize.h
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ class CPPCHECKLIB Tokenizer {
int lineNumber;
int column;
bool used;
bool isFunctionPointer;
};
std::vector<TypedefInfo> mTypedefInfo;

Expand Down

0 comments on commit c66b0af

Please sign in to comment.