aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
authorcor3ntin <corentinjabot@gmail.com>2024-09-03 20:36:15 +0200
committerGitHub <noreply@github.com>2024-09-03 20:36:15 +0200
commiteec1fac9b51d06c8afafe9952a20ba7cd4c3ce1c (patch)
tree9f79ea195ea8bc91a2702ab99a0516df996db2bd /clang/lib
parent15fa3ba547bc3ee04af5c32b8f723a97e3feefd8 (diff)
downloadllvm-eec1fac9b51d06c8afafe9952a20ba7cd4c3ce1c.zip
llvm-eec1fac9b51d06c8afafe9952a20ba7cd4c3ce1c.tar.gz
llvm-eec1fac9b51d06c8afafe9952a20ba7cd4c3ce1c.tar.bz2
[Clang] Fix handling of placeholder variables name in init captures (#107055)
We were incorrectly not deduplicating results when looking up `_` which, for a lambda init capture, would result in an ambiguous lookup. The same bug caused some diagnostic notes to be emitted twice. Fixes #107024
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaLambda.cpp1
-rw-r--r--clang/lib/Sema/SemaLookup.cpp2
2 files changed, 1 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index a8461a7..15ed857 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -1323,7 +1323,6 @@ void Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro,
if (C->Init.isUsable()) {
addInitCapture(LSI, cast<VarDecl>(Var), C->Kind == LCK_ByRef);
- PushOnScopeChains(Var, CurScope, false);
} else {
TryCaptureKind Kind = C->Kind == LCK_ByRef ? TryCapture_ExplicitByRef
: TryCapture_ExplicitByVal;
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 7a6a645..d3d4bf27 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -570,7 +570,7 @@ void LookupResult::resolveKind() {
// For non-type declarations, check for a prior lookup result naming this
// canonical declaration.
- if (!D->isPlaceholderVar(getSema().getLangOpts()) && !ExistingI) {
+ if (!ExistingI) {
auto UniqueResult = Unique.insert(std::make_pair(D, I));
if (!UniqueResult.second) {
// We've seen this entity before.