Skip to content

Commit

Permalink
[clang][analyzer] Do not analyze opaque types in CXXDeleteChecker (#7…
Browse files Browse the repository at this point in the history
…0638)

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.
  • Loading branch information
Discookie committed Oct 30, 2023
1 parent 292f34b commit 564e016
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions clang/lib/StaticAnalyzer/Checkers/CXXDeleteChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ void DeleteWithNonVirtualDtorChecker::checkTypedDeleteExpr(
if (!BaseClass || !DerivedClass)
return;

if (!BaseClass->hasDefinition() || !DerivedClass->hasDefinition())
return;

if (BaseClass->getDestructor()->isVirtual())
return;

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 564e016

Please sign in to comment.