[clang] [clang][OpenMP] Fix crash on global reference in target region inside a namespace-scope lambda (PR #226691)
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 27 08:00:03 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/226691
More information about the cfe-commits
mailing list