summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-02-28 01:28:18 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-02-28 01:28:18 +0000
commit4b45f6628edfde2a5c14376a7ffc3cc88502073a (patch)
treefea13b34d2a07e2b65e5903bf9f016a8d9d1d124 /clang/lib/StaticAnalyzer
parent6d6801c5c7e9b6d96e7e53acf198a667f207c3cb (diff)
downloadbcm5719-llvm-4b45f6628edfde2a5c14376a7ffc3cc88502073a.tar.gz
bcm5719-llvm-4b45f6628edfde2a5c14376a7ffc3cc88502073a.zip
[analyzer] Introduce SVal::getAsVarDecl().
llvm-svn: 126627
Diffstat (limited to 'clang/lib/StaticAnalyzer')
-rw-r--r--clang/lib/StaticAnalyzer/Core/SVals.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/SVals.cpp b/clang/lib/StaticAnalyzer/Core/SVals.cpp
index 4614e349dec..76ad94e40d8 100644
--- a/clang/lib/StaticAnalyzer/Core/SVals.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SVals.cpp
@@ -60,6 +60,16 @@ const FunctionDecl *SVal::getAsFunctionDecl() const {
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
/// wraps a symbol, return that SymbolRef. Otherwise return 0.
// FIXME: should we consider SymbolRef wrapped in CodeTextRegion?
OpenPOWER on IntegriCloud