summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-10-17 19:35:37 +0000
committerJordan Rose <jordan_rose@apple.com>2012-10-17 19:35:37 +0000
commit29fc261cd7062f5015918193c6ad0e1de3ba0732 (patch)
treebb455273d5d97ac641abc9b9767618df71cd85f8 /clang/lib/StaticAnalyzer/Core/CallEvent.cpp
parent13ac0e253d0955248e66a2fa34064ed70e3daca1 (diff)
downloadbcm5719-llvm-29fc261cd7062f5015918193c6ad0e1de3ba0732.tar.gz
bcm5719-llvm-29fc261cd7062f5015918193c6ad0e1de3ba0732.zip
[analyzer] Create a temporary region when accessing a struct rvalue.
In C++, rvalues that need to have their address taken (for example, to be passed to a function by const reference) will be wrapped in a MaterializeTemporaryExpr, which lets CodeGen know to create a temporary region to store this value. However, MaterializeTemporaryExprs are /not/ created when a method is called on an rvalue struct, even though the 'this' pointer needs a valid value. CodeGen works around this by creating a temporary region anyway; now, so does the analyzer. The analyzer also does this when accessing a field of a struct rvalue. This is a little unfortunate, since the rest of the struct will soon be thrown away, but it does make things consistent with the rest of the analyzer. This allows us to bring back the assumption that all known 'this' values are Locs. This is a revised version of r164828-9, reverted in r164876-7. <rdar://problem/12137950> llvm-svn: 166120
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/CallEvent.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/CallEvent.cpp10
1 files changed, 1 insertions, 9 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
index 3b4c13471b1..31e4cf05d99 100644
--- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -401,15 +401,7 @@ SVal CXXInstanceCall::getCXXThisVal() const {
return UnknownVal();
SVal ThisVal = getSVal(Base);
-
- // FIXME: This is only necessary because we can call member functions on
- // struct rvalues, which do not have regions we can use for a 'this' pointer.
- // Ideally this should eventually be changed to an assert, i.e. all
- // non-Unknown, non-null 'this' values should be loc::MemRegionVals.
- if (isa<DefinedSVal>(ThisVal))
- if (!ThisVal.getAsRegion() && !ThisVal.isConstant())
- return UnknownVal();
-
+ assert(ThisVal.isUnknownOrUndef() || isa<Loc>(ThisVal));
return ThisVal;
}
OpenPOWER on IntegriCloud