diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-09-01 17:39:09 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-09-01 17:39:09 +0000 |
commit | 02df4f0aef142f00d4637cd851e54da2a123ca8e (patch) | |
tree | a7e564ed0f2f841da34570bc09c3362bdd7a0399 /test/Analysis/reference.cpp | |
parent | 5699f62df144545702b91e91836a63db4e5f2627 (diff) |
[analyzer] Treat all struct values as regions (even rvalues).
This allows us to correctly symbolicate the fields of structs returned by
value, as well as get the proper 'this' value for when methods are called
on structs returned by value.
This does require a moderately ugly hack in the StoreManager: if we assign
a "struct value" to a struct region, that now appears as a Loc value being
bound to a region of struct type. We handle this by simply "dereferencing"
the struct value region, which should create a LazyCompoundVal.
This should fix recent crashes analyzing LLVM and on our internal buildbot.
<rdar://problem/12137950>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163066 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/reference.cpp')
-rw-r--r-- | test/Analysis/reference.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/test/Analysis/reference.cpp b/test/Analysis/reference.cpp index 4a2cbb8e25..ce0ee8ed57 100644 --- a/test/Analysis/reference.cpp +++ b/test/Analysis/reference.cpp @@ -116,8 +116,11 @@ void testReferenceAddress(int &x) { struct S { int &x; }; - extern S *getS(); - clang_analyzer_eval(&getS()->x != 0); // expected-warning{{TRUE}} + extern S getS(); + clang_analyzer_eval(&getS().x != 0); // expected-warning{{TRUE}} + + extern S *getSP(); + clang_analyzer_eval(&getSP()->x != 0); // expected-warning{{TRUE}} } @@ -150,10 +153,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}} -} |