-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[Sema] LambdaScopeForCallOperatorInstantiationRAII - fix typo in early out logic #96888
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: Simon Pilgrim (RKSimon) ChangesWe should be checking for a failed dyn_cast on the ParentFD result - not the loop invariant FD root value. Seems to have been introduced in #65193 Noticed by static analyser (I have no specific test case). Full diff: https://github.com/llvm/llvm-project/pull/96888.diff 1 Files Affected:
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index e9476a0c93c5d..ca9c7cb9faadf 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -2391,7 +2391,7 @@ Sema::LambdaScopeForCallOperatorInstantiationRAII::
Pattern =
dyn_cast<FunctionDecl>(getLambdaAwareParentOfDeclContext(Pattern));
- if (!FD || !Pattern)
+ if (!ParentFD || !Pattern)
break;
SemaRef.addInstantiatedParametersToScope(ParentFD, Pattern, Scope, MLTAL);
|
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.
Thanks for the patch.
While I think this makes sense, it still confuses me whether there was some redundancy in the guard condition. Do we have any situation where Pattern
is non-null whereas ParentFD
becomes null? I assume they are always paired, at least for the lambda cases.
It would probably explain why the typo hasn't caused regression - I'm going off static analysis reports here, not crash reports. |
3194b59
to
5a967ae
Compare
Looks like we have hit the assert in |
This is indeed a typo. |
Thanks for this fix! |
…y out logic We should be checking for a failed dyn_cast on the ParentFD result - not the loop invariant FD root value. Seems to have been introduced in llvm#65193 Noticed by static analyser (I have no specific test case).
5a967ae
to
7f6614d
Compare
Cheers - I'll push this (without the assert) in a moment - that shouldn't get in the way of working out why they aren't always paired. |
So, here is the offending case: template <class>
concept True = true;
template <class... U>
using MeowMeow = decltype([]<True>(U...) {}.template operator()<char>(U()...));
void foo() {
using T = MeowMeow<char, int, long, unsigned>;
} In this example, the lambda does not have the |
Thinking more, I still maintain that the check for So, suppose we need to find a case to compromise the previous logic. In that case, we need to find a generic lambda whose That being said, I think keeping the patch as-is is fine because it's more intelligible than explaining the subtle implications above. |
…y out logic (llvm#96888) We should be checking for a failed dyn_cast on the ParentFD result - not the loop invariant FD root value. Seems to have been introduced in llvm#65193 Noticed by static analyser (I have no specific test case).
We should be checking for a failed dyn_cast on the ParentFD result - not the loop invariant FD root value.
Seems to have been introduced in #65193
Noticed by static analyser (I have no specific test case).