[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 29 06:30:10 PDT 2024


================
@@ -1841,9 +1872,71 @@ Decl *TemplateInstantiator::TransformDecl(SourceLocation Loc, Decl *D) {
     // template parameter.
   }
 
+  if (auto *PVD = dyn_cast<ParmVarDecl>(D);
+      PVD && PVD->getDeclContext() == FunctionDCForParameterDeclInstantiation &&
+      !ParameterInstantiationScope->findInstantiationUnsafe(PVD)) {
+    // Fall through to the default lookup even if we have failed to instantiate
+    // anything. We're likely to crash thereafter.
+    instantiateParameterToScope(PVD, *ParameterInstantiationScope);
+  }
+
   return SemaRef.FindInstantiatedDecl(Loc, cast<NamedDecl>(D), TemplateArgs);
 }
 
+bool TemplateInstantiator::instantiateParameterToScope(
----------------
cor3ntin wrote:

Can we reuse the logic of `SetupConstraintScope` / `addInstantiatedParametersToScope` ? It seems very similar

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


More information about the cfe-commits mailing list