[clang] [openmp] [Clang][OpenMP] Mixed signed/unsigned trip counts fix (PR #226462)

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 27 07:53:59 PDT 2026


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/226462


More information about the cfe-commits mailing list