-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix #14413 : Add tag line and column in typedef-info in dump file #8134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1104,18 +1104,26 @@ void Tokenizer::simplifyTypedef() | |
| typedefInfo.filename = list.file(typedefToken); | ||
| typedefInfo.lineNumber = typedefToken->linenr(); | ||
| typedefInfo.column = typedefToken->column(); | ||
| typedefInfo.tagLineNumber = typedefInfo.lineNumber; | ||
| typedefInfo.tagColumn = typedefInfo.column; | ||
| typedefInfo.used = t.second.isUsed(); | ||
| typedefInfo.isFunctionPointer = isFunctionPointer(t.second.nameToken()); | ||
| if (typedefInfo.isFunctionPointer) { | ||
| const Token* tok = typedefToken; | ||
| while (tok != t.second.endToken()) { | ||
| const Token* tok = typedefToken; | ||
| while (tok != t.second.endToken()) { | ||
| if (tok->str() == typedefInfo.name) { | ||
| typedefInfo.tagLineNumber = tok->linenr(); | ||
| typedefInfo.tagColumn = tok->column(); | ||
| if (!typedefInfo.isFunctionPointer) | ||
| break; | ||
| } | ||
| if (typedefInfo.isFunctionPointer) { | ||
| TypedefToken ttok; | ||
| ttok.name = tok->str(); | ||
| ttok.lineNumber = tok->linenr(); | ||
| ttok.column = tok->column(); | ||
| typedefInfo.typedefInfoTokens.emplace_back(ttok); | ||
| tok = tok->next(); | ||
| } | ||
| tok = tok->next(); | ||
| } | ||
| mTypedefInfo.push_back(std::move(typedefInfo)); | ||
|
|
||
|
|
@@ -1638,20 +1646,28 @@ void Tokenizer::simplifyTypedefCpp() | |
| TypedefInfo typedefInfo; | ||
| typedefInfo.name = typeName->str(); | ||
| typedefInfo.filename = list.file(typeName); | ||
| typedefInfo.lineNumber = typeName->linenr(); | ||
| typedefInfo.column = typeName->column(); | ||
| typedefInfo.lineNumber = typeDef->linenr(); | ||
| typedefInfo.column = typeDef->column(); | ||
| typedefInfo.tagLineNumber = typedefInfo.lineNumber; | ||
| typedefInfo.tagColumn = typedefInfo.column; | ||
| typedefInfo.used = false; | ||
| typedefInfo.isFunctionPointer = isFunctionPointer(typeName); | ||
| if (typedefInfo.isFunctionPointer) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know we talked about it but I feel skeptic about removing this condition. Maybe you can search for the tagname like this: There might be some alternative syntax we want to handle later but we could start with this. |
||
| const Token* t = typeDef; | ||
| while (t != tok) { | ||
| const Token* t = typeDef; | ||
| while (t != tok) { | ||
|
||
| if (t->str() == typedefInfo.name) { | ||
| typedefInfo.tagLineNumber = t->linenr(); | ||
| typedefInfo.tagColumn = t->column(); | ||
| if (!typedefInfo.isFunctionPointer) | ||
| break; | ||
| } | ||
| if (typedefInfo.isFunctionPointer) { | ||
| TypedefToken ttok; | ||
| ttok.name = t->str(); | ||
| ttok.lineNumber = t->linenr(); | ||
| ttok.column = t->column(); | ||
| typedefInfo.typedefInfoTokens.emplace_back(ttok); | ||
| t = t->next(); | ||
| } | ||
| t = t->next(); | ||
| } | ||
| mTypedefInfo.push_back(std::move(typedefInfo)); | ||
|
|
||
|
|
@@ -3170,6 +3186,8 @@ bool Tokenizer::simplifyUsing() | |
| usingInfo.filename = list.file(nameToken); | ||
| usingInfo.lineNumber = nameToken->linenr(); | ||
| usingInfo.column = nameToken->column(); | ||
| usingInfo.tagLineNumber = usingInfo.lineNumber; | ||
| usingInfo.tagColumn = usingInfo.column; | ||
| usingInfo.used = true; | ||
| usingInfo.isFunctionPointer = false; | ||
| mTypedefInfo.push_back(std::move(usingInfo)); | ||
|
|
@@ -6327,6 +6345,14 @@ std::string Tokenizer::dumpTypedefInfo() const | |
| outs += std::to_string(typedefInfo.column); | ||
| outs += "\""; | ||
|
|
||
| outs += " tagline=\""; | ||
| outs += std::to_string(typedefInfo.tagLineNumber); | ||
| outs += "\""; | ||
|
|
||
| outs += " tagcolumn=\""; | ||
| outs += std::to_string(typedefInfo.tagColumn); | ||
| outs += "\""; | ||
|
|
||
| outs += " used=\""; | ||
| outs += std::to_string(typedefInfo.used?1:0); | ||
| outs += "\""; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4584,7 +4584,7 @@ class TestSimplifyTypedef : public TestFixture { | |
| void typedefInfo1() { | ||
| const std::string xml = dumpTypedefInfo("typedef int A;\nA x;"); | ||
| ASSERT_EQUALS(" <typedef-info>\n" | ||
| " <info name=\"A\" file=\"file.c\" line=\"1\" column=\"1\" used=\"1\" isFunctionPointer=\"0\"/>\n" | ||
| " <info name=\"A\" file=\"file.c\" line=\"1\" column=\"1\" tagline=\"1\" tagcolumn=\"13\" used=\"1\" isFunctionPointer=\"0\"/>\n" | ||
| " </typedef-info>\n", | ||
| xml); | ||
| } | ||
|
|
@@ -4596,7 +4596,7 @@ class TestSimplifyTypedef : public TestFixture { | |
| " typedef fp16 ( *pfp16 ) ( void );\n" | ||
| "}\n"); | ||
| ASSERT_EQUALS(" <typedef-info>\n" | ||
| " <info name=\"fp16\" file=\"file.c\" line=\"2\" column=\"1\" used=\"1\" isFunctionPointer=\"1\">\n" | ||
| " <info name=\"fp16\" file=\"file.c\" line=\"2\" column=\"1\" tagline=\"2\" tagcolumn=\"17\" used=\"1\" isFunctionPointer=\"1\">\n" | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as far as I see there is no tagname in any typedef in this example. I think a tagname always follows after a struct/enum keyword. |
||
| " <token line=\"2\" column=\"1\" str=\"typedef\"/>\n" | ||
| " <token line=\"2\" column=\"9\" str=\"void\"/>\n" | ||
| " <token line=\"2\" column=\"14\" str=\"(\"/>\n" | ||
|
|
@@ -4608,8 +4608,8 @@ class TestSimplifyTypedef : public TestFixture { | |
| " <token line=\"2\" column=\"33\" str=\"n\"/>\n" | ||
| " <token line=\"2\" column=\"35\" str=\")\"/>\n" | ||
| " </info>\n" | ||
| " <info name=\"int16_t\" file=\"file.c\" line=\"1\" column=\"1\" used=\"1\" isFunctionPointer=\"0\"/>\n" | ||
| " <info name=\"pfp16\" file=\"file.c\" line=\"4\" column=\"20\" used=\"0\" isFunctionPointer=\"1\">\n" | ||
| " <info name=\"int16_t\" file=\"file.c\" line=\"1\" column=\"1\" tagline=\"1\" tagcolumn=\"22\" used=\"1\" isFunctionPointer=\"0\"/>\n" | ||
| " <info name=\"pfp16\" file=\"file.c\" line=\"4\" column=\"4\" tagline=\"4\" tagcolumn=\"20\" used=\"0\" isFunctionPointer=\"1\">\n" | ||
| " <token line=\"4\" column=\"4\" str=\"typedef\"/>\n" | ||
| " <token line=\"4\" column=\"12\" str=\"void\"/>\n" | ||
| " <token line=\"4\" column=\"12\" str=\"(\"/>\n" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.