[PATCH] D39803: [analyzer] pr34766: Fix a crash on explicit construction of std::initializer_list.

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 27 09:37:33 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL319058: [analyzer] pr34766: Fix a crash on explicit std::initializer_list constructor. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D39803?vs=122094&id=124406#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39803

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  cfe/trunk/test/Analysis/initializer.cpp


Index: cfe/trunk/test/Analysis/initializer.cpp
===================================================================
--- cfe/trunk/test/Analysis/initializer.cpp
+++ cfe/trunk/test/Analysis/initializer.cpp
@@ -211,12 +211,16 @@
 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
   // the destructor of 'c'.
   int *x = new int;
   C c{x}; // no-warning
 }
+
+void testPassListsWithExplicitConstructors() {
+  (void)(std::initializer_list<int>){12}; // no-crash
+}
 }
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
===================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -535,7 +535,7 @@
   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));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39803.124406.patch
Type: text/x-patch
Size: 1202 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171127/4602ffd0/attachment.bin>


More information about the cfe-commits mailing list