[clang] [clang][analyzer] Fix crash in CXXDeleteChecker (PR #70638)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 30 02:37:16 PDT 2023
https://github.com/Discookie created https://github.com/llvm/llvm-project/pull/70638
While inheritance can only be expressed if the class has a definition, in this case one of the types might be opaque to the analyzer.
Fixes a crash encountered whie analyzing LLVM.
>From 910445aacf8b87503990bd3d9d3239726c30f508 Mon Sep 17 00:00:00 2001
From: Viktor Cseh <viktor.cseh at ericsson.com>
Date: Mon, 30 Oct 2023 09:35:46 +0000
Subject: [PATCH] [clang][analyzer] Fix crash in CXXDeleteChecker
While inheritance can only be expressed if the class has a definition, in this case one of the types might be opaque to the analyzer.
---
clang/lib/StaticAnalyzer/Checkers/CXXDeleteChecker.cpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/clang/lib/StaticAnalyzer/Checkers/CXXDeleteChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CXXDeleteChecker.cpp
index 1a1f5c530294038..eb265f4dde68bc2 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CXXDeleteChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CXXDeleteChecker.cpp
@@ -114,6 +114,9 @@ void DeleteWithNonVirtualDtorChecker::checkTypedDeleteExpr(
if (!BaseClass || !DerivedClass)
return;
+ if (!BaseClass->hasDefinition() || !DerivedClass->hasDefinition())
+ return;
+
if (BaseClass->getDestructor()->isVirtual())
return;
@@ -148,6 +151,9 @@ void CXXArrayDeleteChecker::checkTypedDeleteExpr(
if (!BaseClass || !DerivedClass)
return;
+ if (!BaseClass->hasDefinition() || !DerivedClass->hasDefinition())
+ return;
+
if (DE->getOperatorDelete()->getOverloadedOperator() != OO_Array_Delete)
return;
More information about the cfe-commits
mailing list