On Thu, Nov 20, 2008 at 2:01 AM, Ted Kremenek <[EMAIL PROTECTED]> wrote:
> Hi Zhongxing, > > Great progress! This looks fine for now, but in the future we should think > about how symbols that are specific to a given combination of > StoreManager/ConstraintManager should be factored out of the the base > implementation of StoreManager. Do you mean "..out of the base implementation of SymbolicManager"? > > > It's definitely something we should *not* worry about right now, as I think > we are still trying to factor apart the main pieces of the analysis engine > (i.e., GRTransferFuncs needs to be overhauled into probably a few big pieces > similar to StoreManager and ConstraintManager). > > Ted > > > On Nov 19, 2008, at 3:03 AM, Zhongxing Xu wrote: > > Author: zhongxingxu >> Date: Wed Nov 19 05:03:17 2008 >> New Revision: 59618 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=59618&view=rev >> Log: >> Add SymbolData for array elements and struct fields. >> >> Modified: >> cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h >> cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h >> cfe/trunk/lib/Analysis/SVals.cpp >> cfe/trunk/lib/Analysis/SymbolManager.cpp >> >> Modified: cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h?rev=59618&r1=59617&r2=59618&view=diff >> >> >> ============================================================================== >> --- cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h (original) >> +++ cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h Wed Nov 19 >> 05:03:17 2008 >> @@ -73,6 +73,10 @@ >> } >> >> static SVal GetSymbolValue(SymbolManager& SymMgr, VarDecl *D); >> + static SVal getSymbolValue(SymbolManager& SymMgr, const MemRegion* R, >> + const llvm::APSInt* Idx, QualType T); >> + static SVal getSymbolValue(SymbolManager& SymMgr, const MemRegion* R, >> + const FieldDecl* FD, QualType T); >> >> inline bool isUnknown() const { >> return getRawKind() == UnknownKind; >> >> 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=59618&r1=59617&r2=59618&view=diff >> >> >> ============================================================================== >> --- cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h >> (original) >> +++ cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h Wed Nov >> 19 05:03:17 2008 >> @@ -24,7 +24,7 @@ >> >> namespace clang { >> >> - >> +class MemRegion; >> class SymbolManager; >> >> class SymbolID { >> @@ -69,7 +69,8 @@ >> >> class SymbolData : public llvm::FoldingSetNode { >> public: >> - enum Kind { UndefKind, ParmKind, GlobalKind, ContentsOfKind, >> ConjuredKind }; >> + enum Kind { UndefKind, ParmKind, GlobalKind, ElementKind, FieldKind, >> + ContentsOfKind, ConjuredKind }; >> >> private: >> Kind K; >> @@ -141,6 +142,52 @@ >> } >> }; >> >> +class SymbolDataElement : public SymbolData { >> + const MemRegion* R; >> + const llvm::APSInt* Idx; >> + >> +public: >> + SymbolDataElement(SymbolID MySym, const MemRegion* r, const >> llvm::APSInt* idx) >> + : SymbolData(ElementKind, MySym), R(r), Idx(idx) {} >> + >> + static void Profile(llvm::FoldingSetNodeID& profile, const MemRegion* >> R, >> + const llvm::APSInt* Idx) { >> + profile.AddPointer(R); >> + profile.AddPointer(Idx); >> + } >> + >> + void Profile(llvm::FoldingSetNodeID& profile) { >> + Profile(profile, R, Idx); >> + } >> + >> + static bool classof(const SymbolData* D) { >> + return D->getKind() == ElementKind; >> + } >> +}; >> + >> +class SymbolDataField : public SymbolData { >> + const MemRegion* R; >> + const FieldDecl* D; >> + >> +public: >> + SymbolDataField(SymbolID MySym, const MemRegion* r, const FieldDecl* d) >> + : SymbolData(FieldKind, MySym), R(r), D(d) {} >> + >> + static void Profile(llvm::FoldingSetNodeID& profile, const MemRegion* >> R, >> + const FieldDecl* D) { >> + profile.AddPointer(R); >> + profile.AddPointer(D); >> + } >> + >> + void Profile(llvm::FoldingSetNodeID& profile) { >> + Profile(profile, R, D); >> + } >> + >> + static bool classof(const SymbolData* D) { >> + return D->getKind() == FieldKind; >> + } >> +}; >> + >> class SymbolDataContentsOf : public SymbolData { >> SymbolID Sym; >> >> @@ -245,6 +292,8 @@ >> ~SymbolManager(); >> >> SymbolID getSymbol(VarDecl* D); >> + SymbolID getElementSymbol(const MemRegion* R, const llvm::APSInt* Idx); >> + SymbolID getFieldSymbol(const MemRegion* R, const FieldDecl* D); >> SymbolID getContentsOfSymbol(SymbolID sym); >> SymbolID getConjuredSymbol(Stmt* E, QualType T, unsigned VisitCount); >> SymbolID getConjuredSymbol(Expr* E, unsigned VisitCount) { >> >> Modified: cfe/trunk/lib/Analysis/SVals.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/SVals.cpp?rev=59618&r1=59617&r2=59618&view=diff >> >> >> ============================================================================== >> --- cfe/trunk/lib/Analysis/SVals.cpp (original) >> +++ cfe/trunk/lib/Analysis/SVals.cpp Wed Nov 19 05:03:17 2008 >> @@ -272,6 +272,22 @@ >> return nonloc::SymbolVal(SymMgr.getSymbol(D)); >> } >> >> +SVal SVal::getSymbolValue(SymbolManager& SymMgr, const MemRegion* R, >> + const llvm::APSInt* Idx, QualType T) { >> + if (Loc::IsLocType(T)) >> + return loc::SymbolVal(SymMgr.getElementSymbol(R, Idx)); >> + else >> + return nonloc::SymbolVal(SymMgr.getElementSymbol(R, Idx)); >> +} >> + >> +SVal SVal::getSymbolValue(SymbolManager& SymMgr, const MemRegion* R, >> + const FieldDecl* FD, QualType T) { >> + if (Loc::IsLocType(T)) >> + return loc::SymbolVal(SymMgr.getFieldSymbol(R, FD)); >> + else >> + return nonloc::SymbolVal(SymMgr.getFieldSymbol(R, FD)); >> +} >> + >> nonloc::LocAsInteger nonloc::LocAsInteger::Make(BasicValueFactory& Vals, >> Loc V, >> unsigned Bits) { >> return LocAsInteger(Vals.getPersistentSValWithData(V, Bits)); >> >> Modified: cfe/trunk/lib/Analysis/SymbolManager.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/SymbolManager.cpp?rev=59618&r1=59617&r2=59618&view=diff >> >> >> ============================================================================== >> --- cfe/trunk/lib/Analysis/SymbolManager.cpp (original) >> +++ cfe/trunk/lib/Analysis/SymbolManager.cpp Wed Nov 19 05:03:17 2008 >> @@ -51,6 +51,41 @@ >> DataMap[SymbolCounter] = SD; >> return SymbolCounter++; >> } >> + >> +SymbolID SymbolManager::getElementSymbol(const MemRegion* R, >> + const llvm::APSInt* Idx){ >> + llvm::FoldingSetNodeID ID; >> + SymbolDataElement::Profile(ID, R, Idx); >> + void* InsertPos; >> + SymbolData* SD = DataSet.FindNodeOrInsertPos(ID, InsertPos); >> + >> + if (SD) >> + return SD->getSymbol(); >> + >> + SD = (SymbolData*) BPAlloc.Allocate<SymbolDataElement>(); >> + new (SD) SymbolDataElement(SymbolCounter, R, Idx); >> + >> + DataSet.InsertNode(SD, InsertPos); >> + DataMap[SymbolCounter] = SD; >> + return SymbolCounter++; >> +} >> + >> +SymbolID SymbolManager::getFieldSymbol(const MemRegion* R, const >> FieldDecl* D) { >> + llvm::FoldingSetNodeID ID; >> + SymbolDataField::Profile(ID, R, D); >> + void* InsertPos; >> + SymbolData* SD = DataSet.FindNodeOrInsertPos(ID, InsertPos); >> + >> + if (SD) >> + return SD->getSymbol(); >> + >> + SD = (SymbolData*) BPAlloc.Allocate<SymbolDataField>(); >> + new (SD) SymbolDataField(SymbolCounter, R, D); >> + >> + DataSet.InsertNode(SD, InsertPos); >> + DataMap[SymbolCounter] = SD; >> + return SymbolCounter++; >> +} >> >> SymbolID SymbolManager::getContentsOfSymbol(SymbolID sym) { >> >> >> >> _______________________________________________ >> cfe-commits mailing list >> [email protected] >> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >> > >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
