[cfe-commits] r50502 - /cfe/trunk/lib/Analysis/GRExprEngine.cpp

Ted Kremenek kremenek at apple.com
Wed Apr 30 15:17:15 PDT 2008


Author: kremenek
Date: Wed Apr 30 17:17:15 2008
New Revision: 50502

URL: http://llvm.org/viewvc/llvm-project?rev=50502&view=rev
Log:
Add placeholder code in the static analyzer for MemberExprs involving struct temporaries.

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=50502&r1=50501&r2=50502&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Wed Apr 30 17:17:15 2008
@@ -831,22 +831,57 @@
   // abstract address of the base object.
   NodeSet Tmp;
   
-  if (IsPointerType(Base->getType())) // Base always is an LVal.
-    Visit(Base, Pred, Tmp);
-  else  
-    VisitLVal(Base, Pred, Tmp);
+  if (asLVal) {
+      
+    if (IsPointerType(Base->getType())) // Base always is an LVal.
+      Visit(Base, Pred, Tmp);
+    else  
+      VisitLVal(Base, Pred, Tmp);
+  
+    for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+      ValueState* St = GetState(*I);
+      RVal BaseV = GetRVal(St, Base);      
+      
+      RVal V = lval::FieldOffset::Make(BasicVals, GetRVal(St, Base),
+                                       M->getMemberDecl());
+      
+      MakeNode(Dst, M, *I, SetRVal(St, M, V));
+    }
+    
+    return;
+  }
+
+  // Evaluate the base.  Can be an LVal or NonLVal (depends on whether
+  //  or not isArrow() is true).
+  Visit(Base, Pred, Tmp);
   
   for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+
     ValueState* St = GetState(*I);
-    RVal BaseV = GetRVal(St, Base);      
+    RVal BaseV = GetRVal(St, Base);
     
-    RVal V = lval::FieldOffset::Make(BasicVals, GetRVal(St, Base),
-                                     M->getMemberDecl());
+    if (IsPointerType(Base->getType())) {
+    
+      assert (M->isArrow());
+      
+      RVal V = lval::FieldOffset::Make(BasicVals, GetRVal(St, Base),
+                                       M->getMemberDecl());
     
-    if (asLVal)
-      MakeNode(Dst, M, *I, SetRVal(St, M, V));
-    else
       EvalLoad(Dst, M, *I, St, V);
+    }
+    else {
+      
+      assert (!M->isArrow());
+      
+      if (BaseV.isUnknownOrUndef()) {
+        MakeNode(Dst, M, *I, SetRVal(St, M, BaseV));
+        continue;
+      }
+
+      // FIXME: Implement nonlval objects representing struct temporaries.
+      assert (isa<NonLVal>(BaseV));
+      MakeNode(Dst, M, *I, SetRVal(St, M, UnknownVal()));
+    }
   }
 }
 





More information about the cfe-commits mailing list