Skip to content

Commit d7b5469

Browse files
authored
[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`.
1 parent 258cb46 commit d7b5469

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

clang/lib/Analysis/Consumed.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,12 +1354,13 @@ void ConsumedAnalyzer::run(AnalysisDeclContext &AC) {
13541354

13551355
case CFGElement::AutomaticObjectDtor: {
13561356
const CFGAutomaticObjDtor &DTor = B.castAs<CFGAutomaticObjDtor>();
1357+
const auto *DD = DTor.getDestructorDecl(AC.getASTContext());
1358+
if (!DD)
1359+
break;
1360+
13571361
SourceLocation Loc = DTor.getTriggerStmt()->getEndLoc();
13581362
const VarDecl *Var = DTor.getVarDecl();
1359-
1360-
Visitor.checkCallability(PropagationInfo(Var),
1361-
DTor.getDestructorDecl(AC.getASTContext()),
1362-
Loc);
1363+
Visitor.checkCallability(PropagationInfo(Var), DD, Loc);
13631364
break;
13641365
}
13651366

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %clang_cc1 -fsyntax-only -verify -Wconsumed -fcxx-exceptions -std=c++11 %s
2+
// expected-no-diagnostics
3+
4+
struct foo {
5+
~foo();
6+
};
7+
struct bar : foo {};
8+
struct baz : bar {};
9+
baz foobar(baz a) { return a; }

0 commit comments

Comments
 (0)