-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[clang] Add 'instantiated_from' for enums to the output of TextNodeDumper #124409
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
Conversation
|
@llvm/pr-subscribers-clang Author: André Brand (thebrandre) ChangesThis enhances consistency with CXXRecordDecl and FunctionDecl, which also provide this information in the AST dump. Full diff: https://github.com/llvm/llvm-project/pull/124409.diff 1 Files Affected:
diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index 670641242cae2f..7ce8e3ae95743e 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -2123,6 +2123,11 @@ void TextNodeDumper::VisitEnumDecl(const EnumDecl *D) {
OS << " __module_private__";
if (D->isFixed())
dumpType(D->getIntegerType());
+
+ if (const auto *Instance = D->getInstantiatedFromMemberEnum()) {
+ OS << " instantiated_from";
+ dumpPointer(Instance);
+ }
}
void TextNodeDumper::VisitRecordDecl(const RecordDecl *D) {
|
|
... and the information was very helpful when tracking down enum related issues like #124405. |
Sirraide
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, but it still needs a test
shafik
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely makes sense. Definitely we need a test, I think the right test to add an example to is ast-dump-decl.cpp.
Could you also put a few more details in the summary, basically explain you are modifying TextNodeDumper::VisitEnumDecl to be more consistent ...
It would be better to spell out TextNodeDumper::VisitFunctionDecl and TextNodeDumper::VisitCXXRecordDecl as well.
cf9c5e1 to
183df5e
Compare
183df5e to
866e04a
Compare
|
@shafik @Sirraide I rechecked everything and I fixed some non-relative line numbers. I only just noticed now that I probably should have checked that by inserting some line numbers just before my test code to see if this doesn't break the test. 🙈 If there is still something wrong/bad practice/etc. in the test, I'd be grateful for any advice on how to improve it. 😊 |
Sirraide
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM; the tests are definitely thorough enough (honestly, probably more thorough than how I would have written them ;Þ).
Maybe wait a few days to see if @shafik has any more comments, but if not, please @ me again so I can merge this for you.
…mper This enhances consistency with CXXRecordDecl and FunctionDecl, which also provide this information
7828a94 to
2a52ba6
Compare
|
@Sirraide I just rebased the branch on main and ran the unit tests locally in case you'd like to merge it now. |
Ah, sorry, I’ve been a bit busy so it took me a bit to notice. |
) This commit adds "instantiated_from" to the AST dump for EnumDecl, improving consistency with CXXRecordDecl and FunctionDecl, which also include this information. To achieve this, TextNodeDumper::VisitEnumDecl is updated with analogous lines found in TextNodeDumper::VisitFunctionDecl and TextNodeDumper::VisitCXXRecordDecl.
This commit adds "instantiated_from" to the AST dump for EnumDecl, improving consistency with CXXRecordDecl and FunctionDecl, which also include this information. To achieve this, TextNodeDumper::VisitEnumDecl is updated with analogous lines found in TextNodeDumper::VisitFunctionDecl and TextNodeDumper::VisitCXXRecordDecl.