aboutsummaryrefslogtreecommitdiff
path: root/clang/test/Analysis/reference.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-09-05 17:11:26 +0000
committerJordan Rose <jordan_rose@apple.com>2012-09-05 17:11:26 +0000
commitfcdda36149ba4428bef3c6e3985f086c7b5cd939 (patch)
treed907fe55963f41df30917dab5a8fdefce5fd8146 /clang/test/Analysis/reference.cpp
parentd1a08b6e43761ac7f4b38297a271c7320577aacd (diff)
downloadllvm-fcdda36149ba4428bef3c6e3985f086c7b5cd939.zip
llvm-fcdda36149ba4428bef3c6e3985f086c7b5cd939.tar.gz
llvm-fcdda36149ba4428bef3c6e3985f086c7b5cd939.tar.bz2
[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. llvm-svn: 163220
Diffstat (limited to 'clang/test/Analysis/reference.cpp')
-rw-r--r--clang/test/Analysis/reference.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/clang/test/Analysis/reference.cpp b/clang/test/Analysis/reference.cpp
index 4a2cbb8..374f3f7 100644
--- a/clang/test/Analysis/reference.cpp
+++ b/clang/test/Analysis/reference.cpp
@@ -116,8 +116,13 @@ void testReferenceAddress(int &x) {
struct S { int &x; };
- extern S *getS();
- clang_analyzer_eval(&getS()->x != 0); // expected-warning{{TRUE}}
+ // FIXME: Should be TRUE. Fields of return-by-value structs are not yet
+ // symbolicated. Tracked by <rdar://problem/12137950>.
+ extern S getS();
+ clang_analyzer_eval(&getS().x != 0); // expected-warning{{UNKNOWN}}
+
+ extern S *getSP();
+ clang_analyzer_eval(&getSP()->x != 0); // expected-warning{{TRUE}}
}
@@ -150,10 +155,3 @@ namespace rdar11212286 {
return *x; // should warn here!
}
}
-
-void testReferenceFieldAddress() {
- struct S { int &x; };
-
- extern S getS();
- clang_analyzer_eval(&getS().x != 0); // expected-warning{{UNKNOWN}}
-}