From: Ted Kremenek Date: Wed, 1 Oct 2008 00:21:14 +0000 (+0000) Subject: Add a QualType to ConjuredSymbol to represent the type and size of the symbol. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=60a6e0ce72a24d6247602625c631fc3dc7bfd8d4;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56894 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Analysis/PathSensitive/SymbolManager.h b/include/clang/Analysis/PathSensitive/SymbolManager.h index d0473c6a8e..0f6476100c 100644 --- a/include/clang/Analysis/PathSensitive/SymbolManager.h +++ b/include/clang/Analysis/PathSensitive/SymbolManager.h @@ -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 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; diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp index adbeff9915..733cad18ac 100644 --- a/lib/Analysis/CFRefCount.cpp +++ b/lib/Analysis/CFRefCount.cpp @@ -1515,7 +1515,9 @@ void CFRefCount::EvalSummary(ExplodedNodeSet& 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()) diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index 40c2b6507b..41bf98933e 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -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(V))); break; case UnaryOperator::Minus: + // FIXME: Do we need to handle promotions? St = SetRVal(St, U, EvalMinus(U, cast(V))); break; diff --git a/lib/Analysis/SymbolManager.cpp b/lib/Analysis/SymbolManager.cpp index beb4379f99..24d2ed7253 100644 --- a/lib/Analysis/SymbolManager.cpp +++ b/lib/Analysis/SymbolManager.cpp @@ -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(); - 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(this)->getExpr()->getType(); + return cast(this)->getType(); } }