diff --git a/addons/cppcheckdata.py b/addons/cppcheckdata.py
index b0e53161f3a..dbe36d56a57 100755
--- a/addons/cppcheckdata.py
+++ b/addons/cppcheckdata.py
@@ -1341,7 +1341,7 @@ def iterconfigurations(self):
# Parse tokens
elif node.tag == 'tokenlist' and event == 'start':
continue
- elif node.tag == 'token' and event == 'start' and not iter_directive:
+ elif node.tag == 'token' and event == 'start' and not iter_directive and not iter_typedef_info:
cfg.tokenlist.append(Token(node))
# Parse scopes
diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp
index fd253a2f1ad..482008ae1fc 100644
--- a/lib/tokenize.cpp
+++ b/lib/tokenize.cpp
@@ -1089,6 +1089,17 @@ void Tokenizer::simplifyTypedef()
typedefInfo.column = typedefToken->column();
typedefInfo.used = t.second.isUsed();
typedefInfo.isFunctionPointer = Token::Match(t.second.nameToken(), "%name% ) (");
+ if (typedefInfo.isFunctionPointer) {
+ const Token* tok = typedefToken;
+ while (tok != t.second.endToken()) {
+ TypedefToken ttok;
+ ttok.name = tok->str();
+ ttok.lineNumber = tok->linenr();
+ ttok.column = tok->column();
+ typedefInfo.typedefInfoTokens.emplace_back(ttok);
+ tok = tok->next();
+ }
+ }
mTypedefInfo.push_back(std::move(typedefInfo));
t.second.removeDeclaration();
@@ -1612,6 +1623,17 @@ void Tokenizer::simplifyTypedefCpp()
typedefInfo.column = typeName->column();
typedefInfo.used = false;
typedefInfo.isFunctionPointer = Token::Match(typeName, "%name% ) (");
+ if (typedefInfo.isFunctionPointer) {
+ const Token* t = typeDef;
+ while (t != tok) {
+ TypedefToken ttok;
+ ttok.name = t->str();
+ ttok.lineNumber = t->linenr();
+ ttok.column = t->column();
+ typedefInfo.typedefInfoTokens.emplace_back(ttok);
+ t = t->next();
+ }
+ }
mTypedefInfo.push_back(std::move(typedefInfo));
while (!done) {
@@ -6291,6 +6313,16 @@ std::string Tokenizer::dumpTypedefInfo() const
outs += "/>";
outs += '\n';
+ for (const auto& t : typedefInfo.typedefInfoTokens) {
+ outs += " ";
+ outs += '\n';
+ }
}
outs += " ";
outs += '\n';
diff --git a/lib/tokenize.h b/lib/tokenize.h
index 4a248b8fb97..8ae367a10d0 100644
--- a/lib/tokenize.h
+++ b/lib/tokenize.h
@@ -655,6 +655,11 @@ class CPPCHECKLIB Tokenizer {
/** sizeof information for known types */
std::map mTypeSize;
+ struct TypedefToken {
+ std::string name;
+ int lineNumber;
+ int column;
+ };
struct TypedefInfo {
std::string name;
std::string filename;
@@ -662,6 +667,7 @@ class CPPCHECKLIB Tokenizer {
int column;
bool used;
bool isFunctionPointer;
+ std::vector typedefInfoTokens;
};
std::vector mTypedefInfo;
diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp
index 3a7c491cbad..1f2701043bb 100644
--- a/test/testsimplifytypedef.cpp
+++ b/test/testsimplifytypedef.cpp
@@ -4557,8 +4557,35 @@ class TestSimplifyTypedef : public TestFixture {
"}\n");
ASSERT_EQUALS(" \n"
" \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
" \n"
" \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
" \n",xml);
}