Skip to content
Snippets Groups Projects
Commit 4b45f662 authored by Argyrios Kyrtzidis's avatar Argyrios Kyrtzidis
Browse files

[analyzer] Introduce SVal::getAsVarDecl().

llvm-svn: 126627
parent 6d6801c5
No related branches found
No related tags found
No related merge requests found
...@@ -125,6 +125,10 @@ public: ...@@ -125,6 +125,10 @@ public:
/// Otherwise return 0. /// Otherwise return 0.
const FunctionDecl* getAsFunctionDecl() const; const FunctionDecl* getAsFunctionDecl() const;
/// \brief If this SVal is a MemRegionVal and wraps a VarDecl,
/// return that VarDecl. Otherwise return 0.
const VarDecl* getAsVarDecl() const;
/// getAsLocSymbol - If this SVal is a location (subclasses Loc) and /// getAsLocSymbol - If this SVal is a location (subclasses Loc) and
/// wraps a symbol, return that SymbolRef. Otherwise return NULL. /// wraps a symbol, return that SymbolRef. Otherwise return NULL.
SymbolRef getAsLocSymbol() const; SymbolRef getAsLocSymbol() const;
......
...@@ -60,6 +60,16 @@ const FunctionDecl *SVal::getAsFunctionDecl() const { ...@@ -60,6 +60,16 @@ const FunctionDecl *SVal::getAsFunctionDecl() const {
return NULL; return NULL;
} }
const VarDecl* SVal::getAsVarDecl() const {
if (const loc::MemRegionVal* X = dyn_cast<loc::MemRegionVal>(this)) {
const MemRegion* R = X->getRegion();
if (const VarRegion *VR = R->getAs<VarRegion>())
return cast<VarDecl>(VR->getDecl());
}
return NULL;
}
/// getAsLocSymbol - If this SVal is a location (subclasses Loc) and /// getAsLocSymbol - If this SVal is a location (subclasses Loc) and
/// wraps a symbol, return that SymbolRef. Otherwise return 0. /// wraps a symbol, return that SymbolRef. Otherwise return 0.
// FIXME: should we consider SymbolRef wrapped in CodeTextRegion? // FIXME: should we consider SymbolRef wrapped in CodeTextRegion?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment