diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-09-05 17:11:26 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-09-05 17:11:26 +0000 |
commit | 6ebea89be233eaba5e29de8cf3524ad150c860bb (patch) | |
tree | 68df18a7da0db02be83366a8d97a83193d69cd54 /lib/StaticAnalyzer/Core/ExprEngineCXX.cpp | |
parent | 4e45dba1c0234eec7b7c348dbbf568c5ac9fc471 (diff) |
[analyzer] Be more forgiving about calling methods on struct rvalues.
The problem is that the value of 'this' in a C++ member function call
should always be a region (or NULL). However, if the object is an rvalue,
it has no associated region (only a conjured symbol or LazyCompoundVal).
For now, we handle this in two ways:
1) Actually respect MaterializeTemporaryExpr. Before, it was relying on
CXXConstructExpr to create temporary regions for all struct values.
Now it just does the right thing: if the value is not in a temporary
region, create one.
2) Have CallEvent recognize the case where its 'this' pointer is a
non-region, and just return UnknownVal to keep from confusing clients.
The long-term problem is being tracked internally in <rdar://problem/12137950>,
but this makes many test cases pass.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163220 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/ExprEngineCXX.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/ExprEngineCXX.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp b/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp index 84001d3a0c..d3d2837fe5 100644 --- a/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp @@ -34,9 +34,10 @@ void ExprEngine::CreateCXXTemporaryObject(const MaterializeTemporaryExpr *ME, // the expression to the location of the object. SVal V = state->getSVal(tempExpr, LCtx); - // If the object is a record, the constructor will have already created - // a temporary object region. If it is not, we need to copy the value over. - if (!ME->getType()->isRecordType()) { + // If the value is already a CXXTempObjectRegion, it is fine as it is. + // Otherwise, create a new CXXTempObjectRegion, and copy the value into it. + const MemRegion *MR = V.getAsRegion(); + if (!MR || !isa<CXXTempObjectRegion>(MR)) { const MemRegion *R = svalBuilder.getRegionManager().getCXXTempObjectRegion(ME, LCtx); |