From: Anna Zaks Date: Thu, 17 Nov 2011 22:57:01 +0000 (+0000) Subject: [analyzer] Add a helper method. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=64595fad45abbaa75778609196b9223bf6f2ece3;p=clang [analyzer] Add a helper method. Naming could be improved.. But we should first rename the classes in the SVal hierarchy. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144927 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h b/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h index 6c9c9576ba..be1b9cecca 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h @@ -136,6 +136,8 @@ public: /// return that expression. Otherwise return NULL. const SymExpr *getAsSymbolicExpression() const; + const SymExpr* getAsSymExpr() const; + const MemRegion *getAsRegion() const; void dumpToStream(raw_ostream &OS) const; diff --git a/lib/StaticAnalyzer/Core/SVals.cpp b/lib/StaticAnalyzer/Core/SVals.cpp index 309b6ea424..52e52d6d59 100644 --- a/lib/StaticAnalyzer/Core/SVals.cpp +++ b/lib/StaticAnalyzer/Core/SVals.cpp @@ -114,6 +114,13 @@ const SymExpr *SVal::getAsSymbolicExpression() const { return getAsSymbol(); } +const SymExpr* SVal::getAsSymExpr() const { + const SymExpr* Sym = getAsSymbol(); + if (!Sym) + Sym = getAsSymbolicExpression(); + return Sym; +} + const MemRegion *SVal::getAsRegion() const { if (const loc::MemRegionVal *X = dyn_cast(this)) return X->getRegion();