[clang] [clang][analyzer] Fix crash in CXXDeleteChecker (PR #70638)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 30 02:38:18 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-static-analyzer-1
Author: Discookie (Discookie)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/70638.diff
1 Files Affected:
- (modified) clang/lib/StaticAnalyzer/Checkers/CXXDeleteChecker.cpp (+6)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/70638
More information about the cfe-commits
mailing list