]> granicus.if.org Git - clang/commitdiff
Use "VisitLValue" when processing the base for "x.f" field accesses, and "Visit"...
authorTed Kremenek <kremenek@apple.com>
Sat, 18 Oct 2008 03:28:48 +0000 (03:28 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 18 Oct 2008 03:28:48 +0000 (03:28 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57754 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/GRExprEngine.cpp
test/Analysis/fields.c [new file with mode: 0644]

index 98e8427a69a668704c9986fdbbdd1f45eb63015b..ee7141782f99b854eb63206f4091211908a07be1 100644 (file)
@@ -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/test/Analysis/fields.c b/test/Analysis/fields.c
new file mode 100644 (file)
index 0000000..72de12c
--- /dev/null
@@ -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;
+}