diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2008-12-20 06:32:12 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2008-12-20 06:32:12 +0000 |
commit | 4193eca10ce0cc8b2dae887e935a43b26f492b5b (patch) | |
tree | 33cef340f16cf56312c13fef38e99d749d76db7f /lib/Analysis/SymbolManager.cpp | |
parent | 848b34baf2094a377ad2929d0d47cdc833ecdfca (diff) |
Lazy bingding for region-store manager.
* Now Bind() methods take and return GRState* because binding could
also alter GDM.
* No variables are initialized except those declared with initial
values.
* failed C test cases are due to bugs in RemoveDeadBindings(),
which removes constraints that is still alive. This will be fixed in later
patch.
* default value of array and struct regions will be implemented in later patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61274 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/SymbolManager.cpp')
-rw-r--r-- | lib/Analysis/SymbolManager.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/Analysis/SymbolManager.cpp b/lib/Analysis/SymbolManager.cpp index 1c2814a3af..746d55c23c 100644 --- a/lib/Analysis/SymbolManager.cpp +++ b/lib/Analysis/SymbolManager.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "clang/Analysis/PathSensitive/SymbolManager.h" +#include "clang/Analysis/PathSensitive/MemRegion.h" #include "llvm/Support/raw_ostream.h" using namespace clang; @@ -21,14 +22,35 @@ void SymbolRef::print(llvm::raw_ostream& os) const { os << getNumber(); } -SymbolRef SymbolManager::getSymbol(VarDecl* D) { +SymbolRef SymbolManager::getSymbol(const MemRegion* R) { + switch (R->getKind()) { + case MemRegion::VarRegionKind: + return getSymbol(cast<VarRegion>(R)->getDecl()); + + case MemRegion::ElementRegionKind: { + const ElementRegion* ER = cast<ElementRegion>(R); + const llvm::APSInt& Idx = + cast<nonloc::ConcreteInt>(ER->getIndex()).getValue(); + return getElementSymbol(ER->getSuperRegion(), &Idx); + } + + case MemRegion::FieldRegionKind: { + const FieldRegion* FR = cast<FieldRegion>(R); + return getFieldSymbol(FR->getSuperRegion(), FR->getDecl()); + } + default: + assert(0 && "unprocessed region"); + } +} + +SymbolRef SymbolManager::getSymbol(const VarDecl* D) { assert (isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D) || D->hasGlobalStorage()); llvm::FoldingSetNodeID profile; - ParmVarDecl* PD = dyn_cast<ParmVarDecl>(D); + const ParmVarDecl* PD = dyn_cast<ParmVarDecl>(D); if (PD) SymbolDataParmVar::Profile(profile, PD); |