[cfe-commits] r56894 - in /cfe/trunk: include/clang/Analysis/PathSensitive/SymbolManager.h lib/Analysis/CFRefCount.cpp lib/Analysis/GRExprEngine.cpp lib/Analysis/SymbolManager.cpp

Ted Kremenek kremenek at apple.com
Tue Sep 30 17:21:14 PDT 2008


Author: kremenek
Date: Tue Sep 30 19:21:14 2008
New Revision: 56894

URL: http://llvm.org/viewvc/llvm-project?rev=56894&view=rev
Log:
Add a QualType to ConjuredSymbol to represent the type and size of the symbol.

Use this updated interface when invalidating arguments passed by reference; the type of symbol is of the object passed by reference, not the reference itself.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h
    cfe/trunk/lib/Analysis/CFRefCount.cpp
    cfe/trunk/lib/Analysis/GRExprEngine.cpp
    cfe/trunk/lib/Analysis/SymbolManager.cpp

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h?rev=56894&r1=56893&r2=56894&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h Tue Sep 30 19:21:14 2008
@@ -167,25 +167,29 @@
   
 class SymbolConjured : public SymbolData {
   Expr* E;
+  QualType T;
   unsigned Count;
 
 public:
-  SymbolConjured(SymbolID Sym, Expr* exp, unsigned count)
-    : SymbolData(ConjuredKind, Sym), E(exp), Count(count) {}
+  SymbolConjured(SymbolID Sym, Expr* exp, QualType t, unsigned count)
+    : SymbolData(ConjuredKind, Sym), E(exp), T(t), Count(count) {}
   
   Expr* getExpr() const { return E; }
   unsigned getCount() const { return Count; }  
   
+  QualType getType() const { return T; }
+  
   static void Profile(llvm::FoldingSetNodeID& profile,
-                      Expr* E, unsigned Count) {
+                      Expr* E, QualType T, unsigned Count) {
     
     profile.AddInteger((unsigned) ConjuredKind);
     profile.AddPointer(E);
+    profile.Add(T);
     profile.AddInteger(Count);
   }
   
   virtual void Profile(llvm::FoldingSetNodeID& profile) {
-    Profile(profile, E, Count);
+    Profile(profile, E, T, Count);
   }
   
   // Implement isa<T> support.
@@ -243,7 +247,10 @@
   
   SymbolID getSymbol(VarDecl* D);
   SymbolID getContentsOfSymbol(SymbolID sym);
-  SymbolID getConjuredSymbol(Expr* E, unsigned VisitCount);
+  SymbolID getConjuredSymbol(Expr* E, QualType T, unsigned VisitCount);
+  SymbolID getConjuredSymbol(Expr* E, unsigned VisitCount) {
+    return getConjuredSymbol(E, E->getType(), VisitCount);
+  }
   
   const SymbolData& getSymbolData(SymbolID ID) const;
   

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

==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Tue Sep 30 19:21:14 2008
@@ -1515,7 +1515,9 @@
 
         // Set the value of the variable to be a conjured symbol.
         unsigned Count = Builder.getCurrentBlockCount();
-        SymbolID NewSym = Eng.getSymbolManager().getConjuredSymbol(*I, Count);
+        SymbolID NewSym =
+          Eng.getSymbolManager().getConjuredSymbol(*I, DV->getDecl()->getType(),
+                                                   Count);
 
         state = state.SetRVal(*DV,
                               LVal::IsLValType(DV->getDecl()->getType())

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

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Tue Sep 30 19:21:14 2008
@@ -1702,10 +1702,12 @@
             break;
             
           case UnaryOperator::Not:
+            // FIXME: Do we need to handle promotions?
             St = SetRVal(St, U, EvalComplement(cast<NonLVal>(V)));
             break;            
             
           case UnaryOperator::Minus:
+            // FIXME: Do we need to handle promotions?
             St = SetRVal(St, U, EvalMinus(U, cast<NonLVal>(V)));
             break;   
             

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

==============================================================================
--- cfe/trunk/lib/Analysis/SymbolManager.cpp (original)
+++ cfe/trunk/lib/Analysis/SymbolManager.cpp Tue Sep 30 19:21:14 2008
@@ -73,10 +73,10 @@
   return SymbolCounter++;
 }
   
-SymbolID SymbolManager::getConjuredSymbol(Expr* E, unsigned Count) {
+SymbolID SymbolManager::getConjuredSymbol(Expr* E, QualType T, unsigned Count) {
   
   llvm::FoldingSetNodeID profile;
-  SymbolConjured::Profile(profile, E, Count);
+  SymbolConjured::Profile(profile, E, T, Count);
   void* InsertPos;
   
   SymbolData* SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
@@ -85,7 +85,7 @@
     return SD->getSymbol();
   
   SD = (SymbolData*) BPAlloc.Allocate<SymbolConjured>();
-  new (SD) SymbolConjured(SymbolCounter, E, Count);
+  new (SD) SymbolConjured(SymbolCounter, E, T, Count);
   
   DataSet.InsertNode(SD, InsertPos);  
   DataMap[SymbolCounter] = SD;
@@ -118,7 +118,7 @@
     }
       
     case ConjuredKind:
-      return cast<SymbolConjured>(this)->getExpr()->getType();
+      return cast<SymbolConjured>(this)->getType();
   }
 }
 





More information about the cfe-commits mailing list