[clang] [Clang][Sema] fix noexecpt mismatch of friend declaration (PR #102267)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 4 02:11:45 PDT 2024


================
@@ -4698,7 +4698,22 @@ void Sema::InstantiateExceptionSpec(SourceLocation PointOfInstantiation,
   // Enter the scope of this instantiation. We don't use
   // PushDeclContext because we don't have a scope.
   Sema::ContextRAII savedContext(*this, Decl);
+
+  FunctionDecl *Source = Proto->getExtProtoInfo().ExceptionSpec.SourceTemplate;
+  FunctionTemplateDecl *SourceTemplate = Source->getDescribedFunctionTemplate();
+  llvm::SmallDenseMap<clang::Decl *, clang::Decl *> InstTemplateParams;
+  if (CurrentInstantiationScope && SourceTemplate)
+    if (TemplateParameterList *TPL = SourceTemplate->getTemplateParameters())
+      for (NamedDecl *TemplateParam : *TPL)
+        if (auto *Found =
+                CurrentInstantiationScope->findInstantiationOf(TemplateParam))
+          if (auto *InstTemplateParam = Found->dyn_cast<clang::Decl *>())
+            InstTemplateParams[TemplateParam] = InstTemplateParam;
+
----------------
zyn0217 wrote:

Not that I’m aware of. I think we can wait for @sdkrystian‘s refactoring patch of MLTAL which might make such things easier.

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


More information about the cfe-commits mailing list