-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[clang] Improve nested name specifier AST representation #147835
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
This fixes a regression introduced in #147835 When parsing a lambda where the call operator has a late parsed attribute, we would try to build a 'this' type for the lambda, but in a lambda 'this' never refers to the lambda class itself. This late parsed attribute can be added implicitly by the -ftrapping-math flag. This patch patch makes it so CXXThisScopeRAII ignores lambdas. This became observable in #147835 because that made clang lazily create tag types, and it removed a workaround for a lambda dependency bug where any previously created tag type for the lambda is dicarded after its dependency is recalculated. But the 'this' scope created above would defeat this laziness and create the lambda type too soon, before its dependency was updated. Since this regression was never released, there are no release notes. Fixes #161657
This fixes a regression introduced in #147835 When parsing a lambda where the call operator has a late parsed attribute, we would try to build a 'this' type for the lambda, but in a lambda 'this' never refers to the lambda class itself. This late parsed attribute can be added implicitly by the -ftrapping-math flag. This patch patch makes it so CXXThisScopeRAII ignores lambdas. This became observable in #147835 because that made clang lazily create tag types, and it removed a workaround for a lambda dependency bug where any previously created tag type for the lambda is discarded after its dependency is recalculated. But the 'this' scope created above would defeat this laziness and create the lambda type too soon, before its dependency was updated. Since this regression was never released, there are no release notes. Fixes #161657
…161765) This fixes a regression introduced in llvm#147835 When parsing a lambda where the call operator has a late parsed attribute, we would try to build a 'this' type for the lambda, but in a lambda 'this' never refers to the lambda class itself. This late parsed attribute can be added implicitly by the -ftrapping-math flag. This patch patch makes it so CXXThisScopeRAII ignores lambdas. This became observable in llvm#147835 because that made clang lazily create tag types, and it removed a workaround for a lambda dependency bug where any previously created tag type for the lambda is discarded after its dependency is recalculated. But the 'this' scope created above would defeat this laziness and create the lambda type too soon, before its dependency was updated. Since this regression was never released, there are no release notes. Fixes llvm#161657
…161765) This fixes a regression introduced in llvm#147835 When parsing a lambda where the call operator has a late parsed attribute, we would try to build a 'this' type for the lambda, but in a lambda 'this' never refers to the lambda class itself. This late parsed attribute can be added implicitly by the -ftrapping-math flag. This patch patch makes it so CXXThisScopeRAII ignores lambdas. This became observable in llvm#147835 because that made clang lazily create tag types, and it removed a workaround for a lambda dependency bug where any previously created tag type for the lambda is discarded after its dependency is recalculated. But the 'this' scope created above would defeat this laziness and create the lambda type too soon, before its dependency was updated. Since this regression was never released, there are no release notes. Fixes llvm#161657
|
Hello, did these changes modify the semantics of |
I think the documentation is right and matches what's happening. Sounds like you want to get the beginning of the range as something like: if (auto TL = NNSL->getAsTypeLoc())
return TL.getNonPrefixBeginLoc();
else
return NNSL->getLocalBeginLoc();I didn't add a helper for this because there was just a single user in the llvm codebase using this pattern. |
Just my two cents. I think the term "local" is ambiguous, and my mental model has always been that it refers to the last specifier in a qualified name. This seems to have been the behavior, and the public API doc implies it. This recent change seems to break that model and introduces behavior that feels inconsistent:
This difference is confusing. While I understand the reasoning behind the internal implementation, API users aren't likely to be aware of it, and the "last piece" model seems more intuitive. If this new behavior is intended, could we update the comments for |
|
Yeah, all except one user of I propose adding a note about this in the documentation, add a new helper which does what |
Thanks, this workaround works for me. It's just that such subtle changes of the API (the function interface wasn't changed, its documentation wasn't changed and changelog wasn't clear on this backwards-incompatible change) are very hard to pinpoint&address in downstream projects. |
This adds a note to the documentation of getLocalSourceRange, and cleans up one of the users of this function which was changed in #147835
This adds a note to the documentation of getLocalSourceRange, and cleans up one of the users of this function which was changed in #147835 This also removes `TypeLoc::getNonPrefixBeginLoc`, which was recently introduced in the above patch, as that became unused.
|
After another look at this, we can remove that single potential user and that's a simplification over the status quo. See #163206 Also removes TypeLoc::getNonPrefixBeginLoc, which becomes unused after this change. @emaxx-google see if your problem can be solved with a change similar to the above patch, that would be better than the solution I posted earlier. I added the note on this patch, but also see that the example in that documentation already reflected that change. |
This adds a note to the documentation of getLocalSourceRange, and cleans up one of the users of this function which was changed in #147835 This also removes `TypeLoc::getNonPrefixBeginLoc`, which was recently introduced in the above patch, as that became unused.
This adds a note to the documentation of getLocalSourceRange, and cleans up one of the users of this function which was changed in #147835 This also removes `TypeLoc::getNonPrefixBeginLoc`, which was recently introduced in the above patch, as that became unused.
This adds a note to the documentation of getLocalSourceRange, and cleans up one of the users of this function which was changed in llvm/llvm-project#147835 This also removes `TypeLoc::getNonPrefixBeginLoc`, which was recently introduced in the above patch, as that became unused.
This rename was made as part of #147835 in order to ease rebasing the PR, and give a nice window for other patches to get rebased as well. This has been a while already, so lets go ahead and rename it back.
This rename was made as part of #147835 in order to ease rebasing the PR, and give a nice window for other patches to get rebased as well. This has been a while already, so lets go ahead and rename it back.
|
I just posted #163271 which will rename getOriginalDecl back to getDecl, as I think enough time has passed and there has been a big enough window to facilitate any rebases. Let me know if anyone needs more time. Ideally we would like to get this in before the release, so that upstream users that need to support multiple clang versions don't need a bunch of extra |
This adds a note to the documentation of getLocalSourceRange, and cleans up one of the users of this function which was changed in llvm#147835 This also removes `TypeLoc::getNonPrefixBeginLoc`, which was recently introduced in the above patch, as that became unused.
This rename was made as part of #147835 in order to ease rebasing the PR, and give a nice window for other patches to get rebased as well. This has been a while already, so lets go ahead and rename it back.
This rename was made as part of #147835 in order to ease rebasing the PR, and give a nice window for other patches to get rebased as well. It has been a while already, so lets go ahead and rename it back.
…cl (#163271) This rename was made as part of llvm/llvm-project#147835 in order to ease rebasing the PR, and give a nice window for other patches to get rebased as well. It has been a while already, so lets go ahead and rename it back.
This is a major change on how we represent nested name qualifications in the AST.
This patch offers a great performance benefit.
It greatly improves compilation time for stdexec. For one datapoint, for
test_on2.cppin that project, which is the slowest compiling test, this patch improves-ccompilation time by about 7.2%, with the-fsyntax-onlyimprovement being at ~12%.This has great results on compile-time-tracker as well:

This patch also further enables other optimziations in the future, and will reduce the performance impact of template specialization resugaring when that lands.
It has some other miscelaneous drive-by fixes.
About the review: Yes the patch is huge, sorry about that. Part of the reason is that I started by the nested name specifier part, before the ElaboratedType part, but that had a huge performance downside, as ElaboratedType is a big performance hog. I didn't have the steam to go back and change the patch after the fact.
There is also a lot of internal API changes, and it made sense to remove ElaboratedType in one go, versus removing it from one type at a time, as that would present much more churn to the users. Also, the nested name specifier having a different API avoids missing changes related to how prefixes work now, which could make existing code compile but not work.
How to review: The important changes are all in
clang/include/clang/ASTandclang/lib/AST, with also important changes inclang/lib/Sema/TreeTransform.h.The rest and bulk of the changes are mostly consequences of the changes in API.
PS: TagType::getDecl is renamed to
getOriginalDeclin this patch, just for easier to rebasing. I plan to rename it back after this lands.Fixes #136624
Fixes #43179
Fixes #68670
Fixes #92757