Skip to content

Commit

Permalink
Add isFunctionPointer to typeDef-info
Browse files Browse the repository at this point in the history
  • Loading branch information
swasti16 committed Aug 13, 2024
1 parent 35a0df1 commit 28c6e11
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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();
Expand Down Expand Up @@ -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';
}
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 28c6e11

Please sign in to comment.