[llvm-branch-commits] [clang] 85ac560 - [Clang][CodeGen] Fix crash in EmitParmDecl for bodyless destructors with -fextend-variable-liveness (#218830)
Douglas Yung via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sat Sep 19 20:00:25 PDT 2026
Author: AZero13
Date: 2026-09-20T03:00:07Z
New Revision: 85ac560262434c9ccfc0c183ec22d4138ed647fb
URL: https://github.com/llvm/llvm-project/commit/85ac560262434c9ccfc0c183ec22d4138ed647fb
DIFF: https://github.com/llvm/llvm-project/commit/85ac560262434c9ccfc0c183ec22d4138ed647fb.diff
LOG: [Clang][CodeGen] Fix crash in EmitParmDecl for bodyless destructors with -fextend-variable-liveness (#218830)
The fake-use coroutine check in EmitParmDecl calls
FnDecl->getBody()->getStmtClass() without guarding against a null
getBody(). This crashes when processing implicit parameters (e.g.
should_call_delete) of MSVC deleting destructors whose base destructor
is only declared, not defined.
Added:
clang/test/CodeGen/fake-use-msvc-dtor.cpp
Modified:
clang/docs/ReleaseNotes.md
clang/lib/CodeGen/CGDecl.cpp
Removed:
################################################################################
diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index d188f8a75429a..ad5efe5555984 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -999,6 +999,7 @@ latest release, please see the [Clang Web Site](https://clang.llvm.org) or the
- Fixed a crash when passing one sized implicitly casted vector to a `abs` function. (#GH204777)
- Fixed a crash when diagnosing an invalid out-of-line definition of a member class template. (#GH201490)
- Fixed a crash in the parser when a missing semicolon after a tag definition is followed by a template-id not preceded by `::`. (#GH207992)
+- Fixed a crash when generating fake uses for parameters of bodyless destructors with `-fextend-variable-liveness`.
### OpenACC Specific Changes
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 29bc47130c4cd..e84e05e8ee0fd 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -2856,7 +2856,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, ParamValue Arg,
&D == CXXABIThisDecl)) {
// We don't emit fake uses for coroutine parameters, other than `this`.
if (auto *FnDecl = dyn_cast_or_null<FunctionDecl>(CurCodeDecl);
- &D == CXXABIThisDecl || !FnDecl ||
+ &D == CXXABIThisDecl || !FnDecl || !FnDecl->getBody() ||
FnDecl->getBody()->getStmtClass() != Stmt::CoroutineBodyStmtClass) {
if (shouldExtendLifetime(getContext(), CurCodeDecl, D, CXXABIThisDecl))
EHStack.pushCleanup<FakeUse>(NormalFakeUse, DeclPtr);
diff --git a/clang/test/CodeGen/fake-use-msvc-dtor.cpp b/clang/test/CodeGen/fake-use-msvc-dtor.cpp
new file mode 100644
index 0000000000000..3988b4b2242ec
--- /dev/null
+++ b/clang/test/CodeGen/fake-use-msvc-dtor.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -triple x86_64-pc-windows-msvc -emit-llvm -fextend-variable-liveness=all -O1 -mconstructor-aliases -o /dev/null
+// Verify that we do not crash when generating fake uses for parameters
+// of destructor declarations that have no body (the should_call_delete
+// implicit parameter in MSVC deleting destructors).
+
+struct A {
+ virtual ~A(void);
+};
+struct B {
+ virtual ~B(void);
+};
+
+struct C : A, B {};
+
+void foo() {
+ C c;
+}
More information about the llvm-branch-commits
mailing list