[cfe-commits] r57754 - in /cfe/trunk: lib/Analysis/GRExprEngine.cpp test/Analysis/fields.c

Ted Kremenek kremenek at apple.com
Fri Oct 17 20:28:48 PDT 2008


Author: kremenek
Date: Fri Oct 17 22:28:48 2008
New Revision: 57754

URL: http://llvm.org/viewvc/llvm-project?rev=57754&view=rev
Log:
Use "VisitLValue" when processing the base for "x.f" field accesses, and "Visit" when processing the base for "x->f" field accesses.

Added:
    cfe/trunk/test/Analysis/fields.c
Modified:
    cfe/trunk/lib/Analysis/GRExprEngine.cpp

Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=57754&r1=57753&r2=57754&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Fri Oct 17 22:28:48 2008
@@ -891,8 +891,12 @@
   
   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

Added: cfe/trunk/test/Analysis/fields.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/fields.c?rev=57754&view=auto

==============================================================================
--- cfe/trunk/test/Analysis/fields.c (added)
+++ cfe/trunk/test/Analysis/fields.c Fri Oct 17 22:28:48 2008
@@ -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;
+}





More information about the cfe-commits mailing list