[cfe-commits] r145274 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h lib/StaticAnalyzer/Core/SValBuilder.cpp

Anna Zaks ganna at apple.com
Mon Nov 28 12:43:37 PST 2011


Author: zaks
Date: Mon Nov 28 14:43:37 2011
New Revision: 145274

URL: http://llvm.org/viewvc/llvm-project?rev=145274&view=rev
Log:
[analyzer] Minor cleanup of SValBuilder: Comments + code reuse.

Modified:
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
    cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h?rev=145274&r1=145273&r2=145274&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h Mon Nov 28 14:43:37 2011
@@ -140,12 +140,18 @@
     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,

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp?rev=145274&r1=145273&r2=145274&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp Mon Nov 28 14:43:37 2011
@@ -90,23 +90,13 @@
                                                        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();
 





More information about the cfe-commits mailing list