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 16, 2024
1 parent 9d9cf75 commit 434886f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
17 changes: 14 additions & 3 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 @@ -6194,11 +6200,16 @@ std::string Tokenizer::dumpTypedefInfo() const
outs += std::to_string(typedefInfo.used?1:0);
outs += "\"";

outs += "/>";
outs += " isFunctionPointer=\"";
outs += std::to_string(typedefInfo.isFunctionPointer);
outs += "\"";

outs += "/>";
outs += '\n';
}
outs += " </typedef-info>";
outs += '\n';
}
outs += " </typedef-info>";
outs += '\n';

return outs;
}
Expand Down
1 change: 1 addition & 0 deletions lib/tokenize.h
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ class CPPCHECKLIB Tokenizer {
int lineNumber;
int column;
bool used;
bool isFunctionPointer;
};
std::vector<TypedefInfo> mTypedefInfo;

Expand Down

0 comments on commit 434886f

Please sign in to comment.