From 64595fad45abbaa75778609196b9223bf6f2ece3 Mon Sep 17 00:00:00 2001
From: Anna Zaks <ganna@apple.com>
Date: Thu, 17 Nov 2011 22:57:01 +0000
Subject: [PATCH] [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
---
 include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h | 2 ++
 lib/StaticAnalyzer/Core/SVals.cpp                       | 7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h b/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
index 6c9c9576ba3..be1b9cecca8 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 309b6ea4242..52e52d6d59d 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<loc::MemRegionVal>(this))
     return X->getRegion();
-- 
GitLab