Skip to content

[clang] AST Visitor: skip empty qualifiers in QualifiedTemplateName #93926

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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions clang/include/clang/AST/RecursiveASTVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -855,10 +855,14 @@ bool RecursiveASTVisitor<Derived>::TraverseDeclarationNameInfo(

template <typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseTemplateName(TemplateName Template) {
if (DependentTemplateName *DTN = Template.getAsDependentTemplateName())
if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) {
TRY_TO(TraverseNestedNameSpecifier(DTN->getQualifier()));
else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
} else if (QualifiedTemplateName *QTN =
Template.getAsQualifiedTemplateName()) {
if (QTN->getQualifier()) {
TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
}
}
Comment on lines +860 to +865
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} else if (QualifiedTemplateName *QTN =
Template.getAsQualifiedTemplateName()) {
if (QTN->getQualifier()) {
TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
}
}
} else if (QualifiedTemplateName *QTN =
Template.getAsQualifiedTemplateName(); QTN && QTN->getQualifier()) {
TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
}

Copy link
Contributor Author

@mizvekov mizvekov May 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that looks cleaner at first glance, but the intention in the original code was for each arm to match each kind of TemplateName.

For example, this doesn't traverse OverloadTemplateName right now, but if we wanted to add it after this change, this would necessitate to refactor the if branches once again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to merge since this fixes broken build bot.

Let's continue in post.


return true;
}
Expand Down
Loading