[clang] [Clang] Adjust concept definition locus (PR #103867)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 24 23:07:09 PDT 2024
================
@@ -8499,23 +8498,63 @@ Decl *Sema::ActOnConceptDefinition(
NewDecl->setInvalidDecl();
}
+ DeclarationNameInfo NameInfo(NewDecl->getDeclName(), NewDecl->getBeginLoc());
+ LookupResult Previous(*this, NameInfo, LookupOrdinaryName,
+ forRedeclarationInCurContext());
+ LookupName(Previous, S);
+ FilterLookupForScope(Previous, CurContext, S, /*ConsiderLinkage=*/false,
+ /*AllowInlineNamespace*/ false);
+
+ // We cannot properly handle redeclarations until we parse the constraint
+ // expression, so only inject the name if we are sure we are not redeclaring a
+ // symbol
+ if (Previous.empty())
+ PushOnScopeChains(NewDecl, S, true);
----------------
zyn0217 wrote:
We need to restore the scope chain outside of `Sema::ActOnStartConceptDefinition()` if the later parsed requires expression turns out to be invalid. Otherwise, the use of the concept would still find the invalid concept Decl, and since the declaration doesn't have the expression anymore, we would run into crashes in evaluation.
https://github.com/llvm/llvm-project/pull/103867
More information about the cfe-commits
mailing list