[cfe-commits] r158588 - in /cfe/trunk: lib/StaticAnalyzer/Core/ExprEngineC.cpp test/Analysis/cxx-crashes.cpp

Jordan Rose jordan_rose at apple.com
Fri Jun 15 18:28:03 PDT 2012


Author: jrose
Date: Fri Jun 15 20:28:03 2012
New Revision: 158588

URL: http://llvm.org/viewvc/llvm-project?rev=158588&view=rev
Log:
[analyzer] Array CompoundLiteralExprs need to be treated like lvalues.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
    cfe/trunk/test/Analysis/cxx-crashes.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp?rev=158588&r1=158587&r2=158588&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp Fri Jun 15 20:28:03 2012
@@ -408,7 +408,7 @@
   const LocationContext *LC = Pred->getLocationContext();
   state = state->bindCompoundLiteral(CL, LC, ILV);
   
-  if (CL->isGLValue())
+  if (CL->isGLValue() || CL->getType()->isArrayType())
     B.generateNode(CL, Pred, state->BindExpr(CL, LC, state->getLValue(CL, LC)));
   else
     B.generateNode(CL, Pred, state->BindExpr(CL, LC, ILV));

Modified: cfe/trunk/test/Analysis/cxx-crashes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cxx-crashes.cpp?rev=158588&r1=158587&r2=158588&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/cxx-crashes.cpp (original)
+++ cfe/trunk/test/Analysis/cxx-crashes.cpp Fri Jun 15 20:28:03 2012
@@ -70,3 +70,8 @@
   clang_analyzer_eval(structs[0].x == 1); // expected-warning{{TRUE}}
 }
 
+void useIntArray(int []);
+void testIntArrayLiteral() {
+  useIntArray((int []){ 1, 2, 3 });
+}
+





More information about the cfe-commits mailing list