[clang] Handle null dtor decl during consumed analysis (#170180)

See similar PR #169593.

This is another case where null was not handled when returned from
`getDestructorDecl`.
This commit is contained in:
macurtis-amd 2025-12-01 14:41:46 -06:00 committed by GitHub
parent 258cb467e9
commit d7b5469b39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 4 deletions

View File

@ -1354,12 +1354,13 @@ void ConsumedAnalyzer::run(AnalysisDeclContext &AC) {
case CFGElement::AutomaticObjectDtor: {
const CFGAutomaticObjDtor &DTor = B.castAs<CFGAutomaticObjDtor>();
const auto *DD = DTor.getDestructorDecl(AC.getASTContext());
if (!DD)
break;
SourceLocation Loc = DTor.getTriggerStmt()->getEndLoc();
const VarDecl *Var = DTor.getVarDecl();
Visitor.checkCallability(PropagationInfo(Var),
DTor.getDestructorDecl(AC.getASTContext()),
Loc);
Visitor.checkCallability(PropagationInfo(Var), DD, Loc);
break;
}

View File

@ -0,0 +1,9 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wconsumed -fcxx-exceptions -std=c++11 %s
// expected-no-diagnostics
struct foo {
~foo();
};
struct bar : foo {};
struct baz : bar {};
baz foobar(baz a) { return a; }