[cfe-commits] r158681 - /cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
Jordan Rose
jordan_rose at apple.com
Mon Jun 18 14:31:27 PDT 2012
Author: jrose
Date: Mon Jun 18 16:31:27 2012
New Revision: 158681
URL: http://llvm.org/viewvc/llvm-project?rev=158681&view=rev
Log:
[analyzer] Add a comment: why we treat array compound literals as lvalues.
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp?rev=158681&r1=158680&r2=158681&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp Mon Jun 18 16:31:27 2012
@@ -407,7 +407,15 @@
SVal ILV = state->getSVal(ILE, Pred->getLocationContext());
const LocationContext *LC = Pred->getLocationContext();
state = state->bindCompoundLiteral(CL, LC, ILV);
-
+
+ // Compound literal expressions are a GNU extension in C++.
+ // Unlike in C, where CLs are lvalues, in C++ CLs are prvalues,
+ // and like temporary objects created by the functional notation T()
+ // CLs are destroyed at the end of the containing full-expression.
+ // HOWEVER, an rvalue of array type is not something the analyzer can
+ // reason about, since we expect all regions to be wrapped in Locs.
+ // So we treat array CLs as lvalues as well, knowing that they will decay
+ // to pointers as soon as they are used.
if (CL->isGLValue() || CL->getType()->isArrayType())
B.generateNode(CL, Pred, state->BindExpr(CL, LC, state->getLValue(CL, LC)));
else
More information about the cfe-commits
mailing list