summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2017-11-27 17:37:09 +0000
committerArtem Dergachev <artem.dergachev@gmail.com>2017-11-27 17:37:09 +0000
commit052436f76868808789b403a246a60859d5c9c60f (patch)
tree780dd4457ab778f49607536db984961d911573bf /clang
parent85db2bf7b6e59e0d3a419c713010e31e5460ae55 (diff)
downloadbcm5719-llvm-052436f76868808789b403a246a60859d5c9c60f.tar.gz
bcm5719-llvm-052436f76868808789b403a246a60859d5c9c60f.zip
[analyzer] pr34766: Fix a crash on explicit std::initializer_list constructor.
We didn't support the following syntax: (std::initializer_list<int>){12} which suddenly produces CompoundLiteralExpr that contains CXXStdInitializerListExpr. Lift the assertion and instead pass the value through CompoundLiteralExpr transparently, as it doesn't add much. Differential Revision: https://reviews.llvm.org/D39803 llvm-svn: 319058
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp2
-rw-r--r--clang/test/Analysis/initializer.cpp6
2 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
index d6feabea534..e0e1c3617de 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -535,7 +535,7 @@ void ExprEngine::VisitCompoundLiteralExpr(const CompoundLiteralExpr *CL,
const Expr *Init = CL->getInitializer();
SVal V = State->getSVal(CL->getInitializer(), LCtx);
- if (isa<CXXConstructExpr>(Init)) {
+ if (isa<CXXConstructExpr>(Init) || isa<CXXStdInitializerListExpr>(Init)) {
// No work needed. Just pass the value up to this expression.
} else {
assert(isa<InitListExpr>(Init));
diff --git a/clang/test/Analysis/initializer.cpp b/clang/test/Analysis/initializer.cpp
index e9658a067c2..6359b93d0a2 100644
--- a/clang/test/Analysis/initializer.cpp
+++ b/clang/test/Analysis/initializer.cpp
@@ -211,7 +211,7 @@ namespace CXX_initializer_lists {
struct C {
C(std::initializer_list<int *> list);
};
-void foo() {
+void testPointerEscapeIntoLists() {
C empty{}; // no-crash
// Do not warn that 'x' leaks. It might have been deleted by
@@ -219,4 +219,8 @@ void foo() {
int *x = new int;
C c{x}; // no-warning
}
+
+void testPassListsWithExplicitConstructors() {
+ (void)(std::initializer_list<int>){12}; // no-crash
+}
}
OpenPOWER on IntegriCloud