[clang] [Clang] Adjust concept definition locus (PR #103867)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 24 23:15:18 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:

Or rather, I think we should inject the concept decl in `ActOnFinishConceptDefinition()` instead of here.

https://github.com/llvm/llvm-project/pull/103867


More information about the cfe-commits mailing list