diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-10-17 19:35:37 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-10-17 19:35:37 +0000 |
commit | f1e67d75fc922ff905de9faa6326bb1a96685ec1 (patch) | |
tree | 2d916119bc88dc2b893befe8d151b0d5c2a5ca94 /test/Analysis/fields.c | |
parent | 485841a29e1ffb36773481566b96209e4a0f67b5 (diff) |
[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>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166120 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/fields.c')
-rw-r--r-- | test/Analysis/fields.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/test/Analysis/fields.c b/test/Analysis/fields.c index da0847a560..12e8bbf367 100644 --- a/test/Analysis/fields.c +++ b/test/Analysis/fields.c @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core %s -analyzer-store=region -verify +// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core,debug.ExprInspection %s -analyzer-store=region -verify + +void clang_analyzer_eval(int); unsigned foo(); typedef struct bf { unsigned x:2; } bf; @@ -26,3 +28,11 @@ void test() { Point p; (void)(p = getit()).x; } + + +void testLazyCompoundVal() { + Point p = {42, 0}; + Point q; + clang_analyzer_eval((q = p).x == 42); // expected-warning{{TRUE}} + clang_analyzer_eval(q.x == 42); // expected-warning{{TRUE}} +} |