[PATCH] D44183: [analyzer] Don't crash with assertion failure on structured bindings
George Karpenkov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 7 14:23:51 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rC326951: [analyzer] Don't crash with assertion failure on structured bindings (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.
Changed prior to commit:
https://reviews.llvm.org/D44183?vs=137304&id=137479#toc
Repository:
rC Clang
https://reviews.llvm.org/D44183
Files:
lib/StaticAnalyzer/Core/ExprEngine.cpp
test/Analysis/structured_bindings.cc
Index: test/Analysis/structured_bindings.cc
===================================================================
--- test/Analysis/structured_bindings.cc
+++ test/Analysis/structured_bindings.cc
@@ -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) {
+ }
+}
+
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===================================================================
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -2463,7 +2463,12 @@
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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44183.137479.patch
Type: text/x-patch
Size: 1141 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180307/8cc913cc/attachment.bin>
More information about the cfe-commits
mailing list