]> granicus.if.org Git - clang/commitdiff
Add a QualType to ConjuredSymbol to represent the type and size of the symbol.
authorTed Kremenek <kremenek@apple.com>
Wed, 1 Oct 2008 00:21:14 +0000 (00:21 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 1 Oct 2008 00:21:14 +0000 (00:21 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56894 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathSensitive/SymbolManager.h
lib/Analysis/CFRefCount.cpp
lib/Analysis/GRExprEngine.cpp
lib/Analysis/SymbolManager.cpp

index d0473c6a8eeb196a092821f998b0d7dae334f96c..0f6476100c492ca8a7625b4c4c454013785b2d80 100644 (file)
@@ -167,25 +167,29 @@ public:
   
 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 @@ public:
   
   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;
   
index adbeff991586000eff972ae6ff22378be19f5b45..733cad18acf28b5fd7c7c35fbe23c1a64d928b52 100644 (file)
@@ -1515,7 +1515,9 @@ void CFRefCount::EvalSummary(ExplodedNodeSet<GRState>& Dst,
 
         // 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())
index 40c2b6507b9de0b8eaf81f84ab0d05b012cbe68c..41bf98933efdbf64a2548ec4fa1974d814500ada 100644 (file)
@@ -1702,10 +1702,12 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred,
             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;   
             
index beb4379f99a44eb4a95555f6126a1b646ec6df57..24d2ed725309e8986090d023774cfb3aefcbe8c5 100644 (file)
@@ -73,10 +73,10 @@ SymbolID SymbolManager::getContentsOfSymbol(SymbolID sym) {
   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 @@ SymbolID SymbolManager::getConjuredSymbol(Expr* E, unsigned Count) {
     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 @@ QualType SymbolData::getType(const SymbolManager& SymMgr) const {
     }
       
     case ConjuredKind:
-      return cast<SymbolConjured>(this)->getExpr()->getType();
+      return cast<SymbolConjured>(this)->getType();
   }
 }