diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-06-18 21:31:27 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-06-18 21:31:27 +0000 |
commit | 333e05f24717c79637e83806fd5142c752a86afa (patch) | |
tree | c1d379114a07c6411d4eea76c97cbbb709dbed90 /lib/StaticAnalyzer/Core/ExprEngineC.cpp | |
parent | 29271fbcef645117df05d5b60e593acb6562422c (diff) |
[analyzer] Add a comment: why we treat array compound literals as lvalues.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158681 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/ExprEngineC.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/ExprEngineC.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/StaticAnalyzer/Core/ExprEngineC.cpp b/lib/StaticAnalyzer/Core/ExprEngineC.cpp index 0056089af9..c2590d5ef2 100644 --- a/lib/StaticAnalyzer/Core/ExprEngineC.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngineC.cpp @@ -407,7 +407,15 @@ void ExprEngine::VisitCompoundLiteralExpr(const CompoundLiteralExpr *CL, 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 |