https://github.com/alexey-bataev commented:

Block and variable-template cases still crash, in CodeGen — 
clang/test/OpenMP/target_global_ref_namespace_scope_lambda.cpp
```
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -7544,9 +7544,13 @@
-  assert(CGF.CurFuncDecl && "No parent declaration for target region!");
   StringRef ParentName;
   // In case we have Ctors/Dtors we use the complete type variant to produce
   // the mangling of the device outlined kernel.
-  if (const auto *D = dyn_cast<CXXConstructorDecl>(CGF.CurFuncDecl))
+  if (!CGF.CurFuncDecl)
+    // A target region in a namespace-scope block or a variable template
+    // initializer has no parent function declaration; use the name of the
+    // function being emitted.
+    ParentName = CGF.CurFn->getName();
+  else if (const auto *D = dyn_cast<CXXConstructorDecl>(CGF.CurFuncDecl))
     ParentName = CGM.getMangledName(GlobalDecl(D, Ctor_Complete));

```

https://github.com/llvm/llvm-project/pull/226691
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to