From 426a16d4e5efe7efefe76c405207fb170cabad9f Mon Sep 17 00:00:00 2001 From: Anna Zaks Date: Mon, 28 Nov 2011 20:43:37 +0000 Subject: [PATCH] [analyzer] Minor cleanup of SValBuilder: Comments + code reuse. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145274 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../StaticAnalyzer/Core/PathSensitive/SValBuilder.h | 10 ++++++++-- lib/StaticAnalyzer/Core/SValBuilder.cpp | 12 +----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h b/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h index 9266588163..b7b2345503 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h @@ -140,12 +140,18 @@ public: return SymMgr.getConjuredSymbol(expr, visitCount, symbolTag); } - /// makeZeroVal - Construct an SVal representing '0' for the specified type. + /// Construct an SVal representing '0' for the specified type. DefinedOrUnknownSVal makeZeroVal(QualType type); - /// getRegionValueSymbolVal - make a unique symbol for value of region. + /// Make a unique symbol for value of region. DefinedOrUnknownSVal getRegionValueSymbolVal(const TypedValueRegion *region); + /// \brief Create a new symbol with a unique 'name'. + /// + /// We resort to conjured symbols when we cannot construct a derived symbol. + /// The advantage of symbols derived/built from other symbols is that we + /// preserve the relation between related(or even equivalent) expressions, so + /// conjured symbols should be used sparingly. DefinedOrUnknownSVal getConjuredSymbolVal(const void *symbolTag, const Expr *expr, unsigned count); DefinedOrUnknownSVal getConjuredSymbolVal(const void *symbolTag, diff --git a/lib/StaticAnalyzer/Core/SValBuilder.cpp b/lib/StaticAnalyzer/Core/SValBuilder.cpp index 778a0bf97d..331f5934b5 100644 --- a/lib/StaticAnalyzer/Core/SValBuilder.cpp +++ b/lib/StaticAnalyzer/Core/SValBuilder.cpp @@ -90,23 +90,13 @@ DefinedOrUnknownSVal SValBuilder::getConjuredSymbolVal(const void *symbolTag, const Expr *expr, unsigned count) { QualType T = expr->getType(); - - if (!SymbolManager::canSymbolicate(T)) - return UnknownVal(); - - SymbolRef sym = SymMgr.getConjuredSymbol(expr, count, symbolTag); - - if (Loc::isLocType(T)) - return loc::MemRegionVal(MemMgr.getSymbolicRegion(sym)); - - return nonloc::SymbolVal(sym); + return getConjuredSymbolVal(symbolTag, expr, T, count); } DefinedOrUnknownSVal SValBuilder::getConjuredSymbolVal(const void *symbolTag, const Expr *expr, QualType type, unsigned count) { - if (!SymbolManager::canSymbolicate(type)) return UnknownVal(); -- 2.50.1