[clang] 564e016 - [clang][analyzer] Do not analyze opaque types in CXXDeleteChecker (#70638)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 30 07:03:37 PDT 2023
Author: Discookie
Date: 2023-10-30T14:03:33Z
New Revision: 564e0165abc851dcd7a3485d4e728ce63c3d6466
URL: https://github.com/llvm/llvm-project/commit/564e0165abc851dcd7a3485d4e728ce63c3d6466
DIFF: https://github.com/llvm/llvm-project/commit/564e0165abc851dcd7a3485d4e728ce63c3d6466.diff
LOG: [clang][analyzer] Do not analyze opaque types in CXXDeleteChecker (#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 while analyzing LLVM.
Added:
Modified:
clang/lib/StaticAnalyzer/Checkers/CXXDeleteChecker.cpp
Removed:
################################################################################
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