From: Anna Zaks Date: Mon, 28 Nov 2011 20:43:37 +0000 (+0000) Subject: [analyzer] Minor cleanup of SValBuilder: Comments + code reuse. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=426a16d4e5efe7efefe76c405207fb170cabad9f;p=clang [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 --- 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();