================
@@ -1104,9 +1104,13 @@ void Sema::ActOnStartOfTranslationUnit() {
 }
 
 void Sema::ActOnEndOfTranslationUnitFragment(TUFragmentKind Kind) {
-  // No explicit actions are required at the end of the global module fragment.
-  if (Kind == TUFragmentKind::Global)
+  if (Kind == TUFragmentKind::Global) {
+    // Perform Pending Instantiations at the end of global module fragment so
+    // that the module ownership of TU-level decls won't get messed.
+    llvm::TimeTraceScope TimeScope("PerformPendingInstantiations");
+    PerformPendingInstantiations();
----------------
mizvekov wrote:

The distinction lexical vs semantic context does not matter here, they are both 
properties of the pattern and of the instantiation, and they do not depend on 
the template parameters, so we shouldn't change them when instantiating.

Well you say it works fine, but surely it does not work fine in this case. And 
I remember someone on discord was recently complaining about our 
inconsistencies in this area.

https://github.com/llvm/llvm-project/pull/126842
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to