[analyzer] Don't crash with assertion failure on structured bindings

Proper modeling still remains to be done.
Note that BindingDecl#getHoldingVar() is almost always null, and this
should probably be handled by dealing with DecompositionDecl beforehand.

rdar://36852163

Differential Revision: https://reviews.llvm.org/D44183

llvm-svn: 326951
This commit is contained in:
George Karpenkov 2018-03-07 22:20:35 +00:00
parent 7a5fa21ae2
commit 065962375d
2 changed files with 16 additions and 1 deletions

View File

@ -2463,7 +2463,12 @@ void ExprEngine::VisitCommonDeclRefExpr(const Expr *Ex, const NamedDecl *D,
currBldrCtx->blockCount());
state = state->assume(V.castAs<DefinedOrUnknownSVal>(), true);
Bldr.generateNode(Ex, Pred, state->BindExpr(Ex, LCtx, V), nullptr,
ProgramPoint::PostLValueKind);
ProgramPoint::PostLValueKind);
return;
}
if (const auto* BD = dyn_cast<BindingDecl>(D)) {
// FIXME: proper support for bound declarations.
// For now, let's just prevent crashing.
return;
}

View File

@ -0,0 +1,10 @@
// RUN: %clang_analyze_cc1 -std=c++17 -analyzer-checker=core -verify %s
// expected-no-diagnostics
struct s { int a; };
int foo() {
auto[a] = s{1}; // FIXME: proper modelling
if (a) {
}
}