summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-10-18 03:28:48 +0000
committerTed Kremenek <kremenek@apple.com>2008-10-18 03:28:48 +0000
commitfef1f30ea2078f2ad20abcbeb9a003816177044b (patch)
treec750a1b20d3b6de58f0f3b667df14ed96a6806e4 /clang
parent8f477106a4a41b006c007c4e391c4bb8cca13347 (diff)
downloadbcm5719-llvm-fef1f30ea2078f2ad20abcbeb9a003816177044b.tar.gz
bcm5719-llvm-fef1f30ea2078f2ad20abcbeb9a003816177044b.zip
Use "VisitLValue" when processing the base for "x.f" field accesses, and "Visit" when processing the base for "x->f" field accesses.
llvm-svn: 57754
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Analysis/GRExprEngine.cpp8
-rw-r--r--clang/test/Analysis/fields.c10
2 files changed, 16 insertions, 2 deletions
diff --git a/clang/lib/Analysis/GRExprEngine.cpp b/clang/lib/Analysis/GRExprEngine.cpp
index 98e8427a69a..ee7141782f9 100644
--- a/clang/lib/Analysis/GRExprEngine.cpp
+++ b/clang/lib/Analysis/GRExprEngine.cpp
@@ -891,8 +891,12 @@ void GRExprEngine::VisitMemberExpr(MemberExpr* M, NodeTy* Pred,
Expr* Base = M->getBase()->IgnoreParens();
NodeSet Tmp;
- Visit(Base, Pred, Tmp);
-
+
+ if (M->isArrow())
+ Visit(Base, Pred, Tmp); // p->f = ... or ... = p->f
+ else
+ VisitLValue(Base, Pred, Tmp); // x.f = ... or ... = x.f
+
for (NodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I != E; ++I) {
const GRState* St = GetState(*I);
// FIXME: Should we insert some assumption logic in here to determine
diff --git a/clang/test/Analysis/fields.c b/clang/test/Analysis/fields.c
new file mode 100644
index 00000000000..72de12c4dcc
--- /dev/null
+++ b/clang/test/Analysis/fields.c
@@ -0,0 +1,10 @@
+// RUN: clang -checker-cfref %s -verify &&
+// RUN: clang -checker-simple %s -verify
+
+unsigned foo();
+typedef struct bf { unsigned x:2; } bf;
+void bar() {
+ bf y;
+ *(unsigned*)&y = foo();
+ y.x = 1;
+}
OpenPOWER on IntegriCloud