[clang] [clang][OpenMP] Fix crashes on target regions inside namespace-scope lambdas and blocks (PR #226691)
Akash Manna via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 27 09:53:25 PDT 2026
akash-manna-sky wrote:
> 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));
> ```
I applied your suggestions.
https://github.com/llvm/llvm-project/pull/226691
More information about the cfe-commits
mailing list