Skip to content

Commit 564e016

Browse files
authored
[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.
1 parent 292f34b commit 564e016

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

clang/lib/StaticAnalyzer/Checkers/CXXDeleteChecker.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ void DeleteWithNonVirtualDtorChecker::checkTypedDeleteExpr(
114114
if (!BaseClass || !DerivedClass)
115115
return;
116116

117+
if (!BaseClass->hasDefinition() || !DerivedClass->hasDefinition())
118+
return;
119+
117120
if (BaseClass->getDestructor()->isVirtual())
118121
return;
119122

@@ -148,6 +151,9 @@ void CXXArrayDeleteChecker::checkTypedDeleteExpr(
148151
if (!BaseClass || !DerivedClass)
149152
return;
150153

154+
if (!BaseClass->hasDefinition() || !DerivedClass->hasDefinition())
155+
return;
156+
151157
if (DE->getOperatorDelete()->getOverloadedOperator() != OO_Array_Delete)
152158
return;
153159

0 commit comments

Comments
 (0)