[cfe-commits] r57893 - in /cfe/trunk: include/clang/Analysis/PathSensitive/Environment.h include/clang/Analysis/PathSensitive/GRState.h include/clang/Analysis/PathSensitive/GRTransferFuncs.h include/clang/Analysis/PathSensitive/MemRegion.h include/clang/Analysis/PathSensitive/RValues.h include/clang/Analysis/PathSensitive/SVals.h include/clang/Analysis/PathSensitive/Store.h lib/Analysis/BasicValueFactory.cpp lib/Analysis/RValues.cpp lib/Analysis/SVals.cpp

Zhongxing Xu xuzhongxing at gmail.com
Mon Oct 20 22:41:03 PDT 2008


Author: zhongxingxu
Date: Tue Oct 21 00:41:03 2008
New Revision: 57893

URL: http://llvm.org/viewvc/llvm-project?rev=57893&view=rev
Log:
Rename:
  RValues.h/cpp => SVals.h/cpp

Added:
    cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h
      - copied, changed from r57885, cfe/trunk/include/clang/Analysis/PathSensitive/RValues.h
    cfe/trunk/lib/Analysis/SVals.cpp
      - copied unchanged from r57885, cfe/trunk/lib/Analysis/RValues.cpp
Removed:
    cfe/trunk/include/clang/Analysis/PathSensitive/RValues.h
    cfe/trunk/lib/Analysis/RValues.cpp
Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/Environment.h
    cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h
    cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
    cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h
    cfe/trunk/include/clang/Analysis/PathSensitive/Store.h
    cfe/trunk/lib/Analysis/BasicValueFactory.cpp

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/Environment.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/Environment.h?rev=57893&r1=57892&r2=57893&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/Environment.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/Environment.h Tue Oct 21 00:41:03 2008
@@ -20,7 +20,7 @@
 
 #include "llvm/ADT/ImmutableMap.h"
 #include "llvm/ADT/SmallVector.h"
-#include "clang/Analysis/PathSensitive/RValues.h"
+#include "clang/Analysis/PathSensitive/SVals.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/ADT/FoldingSet.h"
 

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h?rev=57893&r1=57892&r2=57893&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h Tue Oct 21 00:41:03 2008
@@ -20,7 +20,7 @@
 #include "clang/Analysis/PathSensitive/Store.h"
 #include "clang/Analysis/PathSensitive/ConstraintManager.h"
 #include "clang/Analysis/PathSensitive/MemRegion.h"
-#include "clang/Analysis/PathSensitive/RValues.h"
+#include "clang/Analysis/PathSensitive/SVals.h"
 #include "clang/Analysis/PathSensitive/GRCoreEngine.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/Decl.h"

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h?rev=57893&r1=57892&r2=57893&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRTransferFuncs.h Tue Oct 21 00:41:03 2008
@@ -15,7 +15,7 @@
 #ifndef LLVM_CLANG_ANALYSIS_GRTF
 #define LLVM_CLANG_ANALYSIS_GRTF
 
-#include "clang/Analysis/PathSensitive/RValues.h"
+#include "clang/Analysis/PathSensitive/SVals.h"
 #include "clang/Analysis/PathSensitive/GRCoreEngine.h"
 #include "clang/Analysis/PathSensitive/GRState.h"
 #include <vector>

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h?rev=57893&r1=57892&r2=57893&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h Tue Oct 21 00:41:03 2008
@@ -19,7 +19,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/Analysis/PathSensitive/SymbolManager.h"
-#include "clang/Analysis/PathSensitive/RValues.h"
+#include "clang/Analysis/PathSensitive/SVals.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/Support/Allocator.h"

Removed: cfe/trunk/include/clang/Analysis/PathSensitive/RValues.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/RValues.h?rev=57892&view=auto

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/RValues.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/RValues.h (removed)
@@ -1,432 +0,0 @@
-//== SValues.h - Abstract Values for Static Analysis ---------*- C++ -*--==//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-//  This file defines SVal, Loc, and NonLoc, classes that represent
-//  abstract r-values for use with path-sensitive value tracking.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_ANALYSIS_RVALUE_H
-#define LLVM_CLANG_ANALYSIS_RVALUE_H
-
-#include "clang/Analysis/PathSensitive/BasicValueFactory.h"
-#include "llvm/Support/Casting.h"
-  
-//==------------------------------------------------------------------------==//
-//  Base SVal types.
-//==------------------------------------------------------------------------==//
-
-namespace clang {
-  
-class MemRegion;
-class GRStateManager;
-  
-class SVal {
-public:
-  enum BaseKind { UndefinedKind, UnknownKind, LocKind, NonLocKind };
-  enum { BaseBits = 2, BaseMask = 0x3 };
-  
-protected:
-  void* Data;
-  unsigned Kind;
-  
-protected:
-  SVal(const void* d, bool isLoc, unsigned ValKind)
-  : Data(const_cast<void*>(d)),
-    Kind((isLoc ? LocKind : NonLocKind) | (ValKind << BaseBits)) {}
-  
-  explicit SVal(BaseKind k, void* D = NULL)
-    : Data(D), Kind(k) {}
-  
-public:
-  ~SVal() {};
-  
-  /// BufferTy - A temporary buffer to hold a set of SVals.
-  typedef llvm::SmallVector<SVal,5> BufferTy;
-  
-  inline unsigned getRawKind() const { return Kind; }
-  inline BaseKind getBaseKind() const { return (BaseKind) (Kind & BaseMask); }
-  inline unsigned getSubKind() const { return (Kind & ~BaseMask) >> BaseBits; }
-  
-  inline void Profile(llvm::FoldingSetNodeID& ID) const {
-    ID.AddInteger((unsigned) getRawKind());
-    ID.AddPointer(reinterpret_cast<void*>(Data));
-  }
-  
-  inline bool operator==(const SVal& R) const {
-    return getRawKind() == R.getRawKind() && Data == R.Data;
-  }
-  
-  
-  inline bool operator!=(const SVal& R) const {
-    return !(*this == R);
-  }
-  
-  static SVal GetSymbolValue(SymbolManager& SymMgr, VarDecl *D);
-  
-  inline bool isUnknown() const {
-    return getRawKind() == UnknownKind;
-  }
-
-  inline bool isUndef() const {
-    return getRawKind() == UndefinedKind;
-  }
-
-  inline bool isUnknownOrUndef() const {
-    return getRawKind() <= UnknownKind;
-  }
-  
-  inline bool isValid() const {
-    return getRawKind() > UnknownKind;
-  }
-  
-  bool isZeroConstant() const;
-  
-  void print(std::ostream& OS) const;
-  void printStdErr() const;
-  
-  typedef const SymbolID* symbol_iterator;
-  symbol_iterator symbol_begin() const;
-  symbol_iterator symbol_end() const;  
-  
-  // Implement isa<T> support.
-  static inline bool classof(const SVal*) { return true; }
-};
-
-class UnknownVal : public SVal {
-public:
-  UnknownVal() : SVal(UnknownKind) {}
-  
-  static inline bool classof(const SVal* V) {
-    return V->getBaseKind() == UnknownKind;
-  }  
-};
-
-class UndefinedVal : public SVal {
-public:
-  UndefinedVal() : SVal(UndefinedKind) {}
-  UndefinedVal(void* D) : SVal(UndefinedKind, D) {}
-  
-  static inline bool classof(const SVal* V) {
-    return V->getBaseKind() == UndefinedKind;
-  }
-  
-  void* getData() const { return Data; }  
-};
-
-class NonLoc : public SVal {
-protected:
-  NonLoc(unsigned SubKind, const void* d) : SVal(d, false, SubKind) {}
-  
-public:
-  void print(std::ostream& Out) const;
-  
-  // Utility methods to create NonLocs.
-  static NonLoc MakeVal(BasicValueFactory& BasicVals, uint64_t X, QualType T);
-  
-  static NonLoc MakeVal(BasicValueFactory& BasicVals, IntegerLiteral* I);
-    
-  static NonLoc MakeIntTruthVal(BasicValueFactory& BasicVals, bool b);
-    
-  // Implement isa<T> support.
-  static inline bool classof(const SVal* V) {
-    return V->getBaseKind() == NonLocKind;
-  }
-};
-
-class Loc : public SVal {
-protected:
-  Loc(unsigned SubKind, const void* D)
-    : SVal(const_cast<void*>(D), true, SubKind) {}
-  
-  // Equality operators.
-  NonLoc EQ(BasicValueFactory& BasicVals, const Loc& R) const;
-  NonLoc NE(BasicValueFactory& BasicVals, const Loc& R) const;
-  
-public:
-  void print(std::ostream& Out) const;
-    
-  static Loc MakeVal(AddrLabelExpr* E);
-  
-  static Loc MakeVal(StringLiteral* S);
-  
-  // Implement isa<T> support.
-  static inline bool classof(const SVal* V) {
-    return V->getBaseKind() == LocKind;
-  }
-  
-  static inline bool IsLocType(QualType T) {
-    return T->isPointerType() || T->isObjCQualifiedIdType() 
-      || T->isBlockPointerType();
-  }
-};
-  
-//==------------------------------------------------------------------------==//
-//  Subclasses of NonLoc.
-//==------------------------------------------------------------------------==//
-
-namespace nonloc {
-  
-enum Kind { ConcreteIntKind, SymbolValKind, SymIntConstraintValKind,
-            LocAsIntegerKind };
-
-class SymbolVal : public NonLoc {
-public:
-  SymbolVal(unsigned SymID)
-    : NonLoc(SymbolValKind, reinterpret_cast<void*>((uintptr_t) SymID)) {}
-  
-  SymbolID getSymbol() const {
-    return (SymbolID) reinterpret_cast<uintptr_t>(Data);
-  }
-  
-  static inline bool classof(const SVal* V) {
-    return V->getBaseKind() == NonLocKind && 
-           V->getSubKind() == SymbolValKind;
-  }
-  
-  static inline bool classof(const NonLoc* V) {
-    return V->getSubKind() == SymbolValKind;
-  }
-};
-
-class SymIntConstraintVal : public NonLoc {    
-public:
-  SymIntConstraintVal(const SymIntConstraint& C)
-    : NonLoc(SymIntConstraintValKind, reinterpret_cast<const void*>(&C)) {}
-
-  const SymIntConstraint& getConstraint() const {
-    return *reinterpret_cast<SymIntConstraint*>(Data);
-  }
-  
-  static inline bool classof(const SVal* V) {
-    return V->getBaseKind() == NonLocKind &&
-           V->getSubKind() == SymIntConstraintValKind;
-  }
-  
-  static inline bool classof(const NonLoc* V) {
-    return V->getSubKind() == SymIntConstraintValKind;
-  }
-};
-
-class ConcreteInt : public NonLoc {
-public:
-  ConcreteInt(const llvm::APSInt& V) : NonLoc(ConcreteIntKind, &V) {}
-  
-  const llvm::APSInt& getValue() const {
-    return *static_cast<llvm::APSInt*>(Data);
-  }
-  
-  // Transfer functions for binary/unary operations on ConcreteInts.
-  SVal EvalBinOp(BasicValueFactory& BasicVals, BinaryOperator::Opcode Op,
-                 const ConcreteInt& R) const;
-  
-  ConcreteInt EvalComplement(BasicValueFactory& BasicVals) const;
-  
-  ConcreteInt EvalMinus(BasicValueFactory& BasicVals, UnaryOperator* U) const;
-  
-  // Implement isa<T> support.
-  static inline bool classof(const SVal* V) {
-    return V->getBaseKind() == NonLocKind &&
-           V->getSubKind() == ConcreteIntKind;
-  }
-  
-  static inline bool classof(const NonLoc* V) {
-    return V->getSubKind() == ConcreteIntKind;
-  }
-};
-  
-class LocAsInteger : public NonLoc {
-  LocAsInteger(const std::pair<SVal, uintptr_t>& data) :
-    NonLoc(LocAsIntegerKind, &data) {
-      assert (isa<Loc>(data.first));
-    }
-  
-public:
-    
-  Loc getLoc() const {
-    return cast<Loc>(((std::pair<SVal, uintptr_t>*) Data)->first);
-  }
-  
-  const Loc& getPersistentLoc() const {
-    const SVal& V = ((std::pair<SVal, uintptr_t>*) Data)->first;
-    return cast<Loc>(V);
-  }    
-  
-  unsigned getNumBits() const {
-    return ((std::pair<SVal, unsigned>*) Data)->second;
-  }
-  
-  // Implement isa<T> support.
-  static inline bool classof(const SVal* V) {
-    return V->getBaseKind() == NonLocKind &&
-           V->getSubKind() == LocAsIntegerKind;
-  }
-  
-  static inline bool classof(const NonLoc* V) {
-    return V->getSubKind() == LocAsIntegerKind;
-  }
-  
-  static inline LocAsInteger Make(BasicValueFactory& Vals, Loc V,
-                                   unsigned Bits) {    
-    return LocAsInteger(Vals.getPersistentSValWithData(V, Bits));
-  }
-};
-  
-} // end namespace clang::nonloc
-
-//==------------------------------------------------------------------------==//
-//  Subclasses of Loc.
-//==------------------------------------------------------------------------==//
-
-namespace loc {
-  
-enum Kind { SymbolValKind, GotoLabelKind, MemRegionKind, FuncValKind,
-            ConcreteIntKind, StringLiteralValKind };
-
-class SymbolVal : public Loc {
-public:
-  SymbolVal(unsigned SymID)
-  : Loc(SymbolValKind, reinterpret_cast<void*>((uintptr_t) SymID)) {}
-  
-  SymbolID getSymbol() const {
-    return (SymbolID) reinterpret_cast<uintptr_t>(Data);
-  }
-  
-  static inline bool classof(const SVal* V) {
-    return V->getBaseKind() == LocKind &&
-           V->getSubKind() == SymbolValKind;
-  }
-  
-  static inline bool classof(const Loc* V) {
-    return V->getSubKind() == SymbolValKind;
-  }
-};
-
-class GotoLabel : public Loc {
-public:
-  GotoLabel(LabelStmt* Label) : Loc(GotoLabelKind, Label) {}
-  
-  LabelStmt* getLabel() const {
-    return static_cast<LabelStmt*>(Data);
-  }
-  
-  static inline bool classof(const SVal* V) {
-    return V->getBaseKind() == LocKind &&
-           V->getSubKind() == GotoLabelKind;
-  }
-  
-  static inline bool classof(const Loc* V) {
-    return V->getSubKind() == GotoLabelKind;
-  } 
-};
-  
-
-class MemRegionVal : public Loc {
-public:
-  MemRegionVal(const MemRegion* r) : Loc(MemRegionKind, r) {}
-
-  const MemRegion* getRegion() const {
-    return static_cast<MemRegion*>(Data);
-  }
-  
-  template <typename REGION>
-  const REGION* getRegionAs() const {
-    return llvm::dyn_cast<REGION>(getRegion());
-  }  
-  
-  inline bool operator==(const MemRegionVal& R) const {
-    return getRegion() == R.getRegion();
-  }
-  
-  inline bool operator!=(const MemRegionVal& R) const {
-    return getRegion() != R.getRegion();
-  }
-  
-  // Implement isa<T> support.
-  static inline bool classof(const SVal* V) {
-    return V->getBaseKind() == LocKind &&
-           V->getSubKind() == MemRegionKind;
-  }
-  
-  static inline bool classof(const Loc* V) {
-    return V->getSubKind() == MemRegionKind;
-  }    
-};
-
-class FuncVal : public Loc {
-public:
-  FuncVal(const FunctionDecl* fd) : Loc(FuncValKind, fd) {}
-  
-  FunctionDecl* getDecl() const {
-    return static_cast<FunctionDecl*>(Data);
-  }
-  
-  inline bool operator==(const FuncVal& R) const {
-    return getDecl() == R.getDecl();
-  }
-  
-  inline bool operator!=(const FuncVal& R) const {
-    return getDecl() != R.getDecl();
-  }
-  
-  // Implement isa<T> support.
-  static inline bool classof(const SVal* V) {
-    return V->getBaseKind() == LocKind &&
-           V->getSubKind() == FuncValKind;
-  }
-  
-  static inline bool classof(const Loc* V) {
-    return V->getSubKind() == FuncValKind;
-  }
-};
-
-class ConcreteInt : public Loc {
-public:
-  ConcreteInt(const llvm::APSInt& V) : Loc(ConcreteIntKind, &V) {}
-  
-  const llvm::APSInt& getValue() const {
-    return *static_cast<llvm::APSInt*>(Data);
-  }
-
-  // Transfer functions for binary/unary operations on ConcreteInts.
-  SVal EvalBinOp(BasicValueFactory& BasicVals, BinaryOperator::Opcode Op,
-                 const ConcreteInt& R) const;
-      
-  // Implement isa<T> support.
-  static inline bool classof(const SVal* V) {
-    return V->getBaseKind() == LocKind &&
-           V->getSubKind() == ConcreteIntKind;
-  }
-  
-  static inline bool classof(const Loc* V) {
-    return V->getSubKind() == ConcreteIntKind;
-  }
-};
-  
-class StringLiteralVal : public Loc {
-public:
-  StringLiteralVal(StringLiteral* L) : Loc(StringLiteralValKind, L) {}
-  
-  StringLiteral* getLiteral() const { return (StringLiteral*) Data; }
-  
-  // Implement isa<T> support.
-  static inline bool classof(const SVal* V) {
-    return V->getBaseKind() == LocKind &&
-           V->getSubKind() == StringLiteralValKind;
-  }
-  
-  static inline bool classof(const Loc* V) {
-    return V->getSubKind() == StringLiteralValKind;
-  }
-};  
-  
-} // end clang::loc namespace
-} // end clang namespace  
-
-#endif

Copied: cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h (from r57885, cfe/trunk/include/clang/Analysis/PathSensitive/RValues.h)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h?p2=cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h&p1=cfe/trunk/include/clang/Analysis/PathSensitive/RValues.h&r1=57885&r2=57893&rev=57893&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/RValues.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h Tue Oct 21 00:41:03 2008
@@ -1,4 +1,4 @@
-//== SValues.h - Abstract Values for Static Analysis ---------*- C++ -*--==//
+//== SVals.h - Abstract Values for Static Analysis ---------*- C++ -*--==//
 //
 //                     The LLVM Compiler Infrastructure
 //

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/Store.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/Store.h?rev=57893&r1=57892&r2=57893&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/Store.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/Store.h Tue Oct 21 00:41:03 2008
@@ -14,7 +14,7 @@
 #ifndef LLVM_CLANG_ANALYSIS_STORE_H
 #define LLVM_CLANG_ANALYSIS_STORE_H
 
-#include "clang/Analysis/PathSensitive/RValues.h"
+#include "clang/Analysis/PathSensitive/SVals.h"
 #include "clang/Analysis/PathSensitive/MemRegion.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallSet.h"

Modified: cfe/trunk/lib/Analysis/BasicValueFactory.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicValueFactory.cpp?rev=57893&r1=57892&r2=57893&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/BasicValueFactory.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicValueFactory.cpp Tue Oct 21 00:41:03 2008
@@ -14,7 +14,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/Analysis/PathSensitive/BasicValueFactory.h"
-#include "clang/Analysis/PathSensitive/RValues.h"
+#include "clang/Analysis/PathSensitive/SVals.h"
 
 using namespace clang;
 

Removed: cfe/trunk/lib/Analysis/RValues.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RValues.cpp?rev=57892&view=auto

==============================================================================
--- cfe/trunk/lib/Analysis/RValues.cpp (original)
+++ cfe/trunk/lib/Analysis/RValues.cpp (removed)
@@ -1,399 +0,0 @@
-//= RValues.cpp - Abstract RValues for Path-Sens. Value Tracking -*- C++ -*-==//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-//  This file defines SVal, Loc, and NonLoc, classes that represent
-//  abstract r-values for use with path-sensitive value tracking.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/Analysis/PathSensitive/GRState.h"
-#include "clang/Basic/IdentifierTable.h"
-#include "llvm/Support/Streams.h"
-
-using namespace clang;
-using llvm::dyn_cast;
-using llvm::cast;
-using llvm::APSInt;
-
-//===----------------------------------------------------------------------===//
-// Symbol Iteration.
-//===----------------------------------------------------------------------===//
-
-SVal::symbol_iterator SVal::symbol_begin() const {
-  
-  // FIXME: This is a rat's nest.  Cleanup.
-
-  if (isa<loc::SymbolVal>(this))
-    return (symbol_iterator) (&Data);
-  else if (isa<nonloc::SymbolVal>(this))
-    return (symbol_iterator) (&Data);
-  else if (isa<nonloc::SymIntConstraintVal>(this)) {
-    const SymIntConstraint& C =
-      cast<nonloc::SymIntConstraintVal>(this)->getConstraint();
-    
-    return (symbol_iterator) &C.getSymbol();
-  }
-  else if (isa<nonloc::LocAsInteger>(this)) {
-    const nonloc::LocAsInteger& V = cast<nonloc::LocAsInteger>(*this);
-    return V.getPersistentLoc().symbol_begin();
-  }
-  
-  // FIXME: We need to iterate over the symbols of regions.
-
-  return NULL;
-}
-
-SVal::symbol_iterator SVal::symbol_end() const {
-  symbol_iterator X = symbol_begin();
-  return X ? X+1 : NULL;
-}
-
-//===----------------------------------------------------------------------===//
-// Useful predicates.
-//===----------------------------------------------------------------------===//
-
-bool SVal::isZeroConstant() const {
-  if (isa<loc::ConcreteInt>(*this))
-    return cast<loc::ConcreteInt>(*this).getValue() == 0;
-  else if (isa<nonloc::ConcreteInt>(*this))
-    return cast<nonloc::ConcreteInt>(*this).getValue() == 0;
-  else
-    return false;
-}
-
-
-//===----------------------------------------------------------------------===//
-// Transfer function dispatch for Non-Locs.
-//===----------------------------------------------------------------------===//
-
-SVal nonloc::ConcreteInt::EvalBinOp(BasicValueFactory& BasicVals,
-                                     BinaryOperator::Opcode Op,
-                                     const nonloc::ConcreteInt& R) const {
-  
-  const llvm::APSInt* X =
-    BasicVals.EvaluateAPSInt(Op, getValue(), R.getValue());
-  
-  if (X)
-    return nonloc::ConcreteInt(*X);
-  else
-    return UndefinedVal();
-}
-
-  // Bitwise-Complement.
-
-nonloc::ConcreteInt
-nonloc::ConcreteInt::EvalComplement(BasicValueFactory& BasicVals) const {
-  return BasicVals.getValue(~getValue()); 
-}
-
-  // Unary Minus.
-
-nonloc::ConcreteInt
-nonloc::ConcreteInt::EvalMinus(BasicValueFactory& BasicVals, UnaryOperator* U) const {
-  assert (U->getType() == U->getSubExpr()->getType());  
-  assert (U->getType()->isIntegerType());  
-  return BasicVals.getValue(-getValue()); 
-}
-
-//===----------------------------------------------------------------------===//
-// Transfer function dispatch for Locs.
-//===----------------------------------------------------------------------===//
-
-SVal
-loc::ConcreteInt::EvalBinOp(BasicValueFactory& BasicVals, BinaryOperator::Opcode Op,
-                             const loc::ConcreteInt& R) const {
-  
-  assert (Op == BinaryOperator::Add || Op == BinaryOperator::Sub ||
-          (Op >= BinaryOperator::LT && Op <= BinaryOperator::NE));
-  
-  const llvm::APSInt* X = BasicVals.EvaluateAPSInt(Op, getValue(), R.getValue());
-  
-  if (X)
-    return loc::ConcreteInt(*X);
-  else
-    return UndefinedVal();
-}
-
-NonLoc Loc::EQ(BasicValueFactory& BasicVals, const Loc& R) const {
-  
-  switch (getSubKind()) {
-    default:
-      assert(false && "EQ not implemented for this Loc.");
-      break;
-      
-    case loc::ConcreteIntKind:
-      if (isa<loc::ConcreteInt>(R)) {
-        bool b = cast<loc::ConcreteInt>(this)->getValue() ==
-                 cast<loc::ConcreteInt>(R).getValue();
-        
-        return NonLoc::MakeIntTruthVal(BasicVals, b);
-      }
-      else if (isa<loc::SymbolVal>(R)) {
-        
-        const SymIntConstraint& C =
-          BasicVals.getConstraint(cast<loc::SymbolVal>(R).getSymbol(),
-                               BinaryOperator::EQ,
-                               cast<loc::ConcreteInt>(this)->getValue());
-        
-        return nonloc::SymIntConstraintVal(C);        
-      }
-      
-      break;
-      
-      case loc::SymbolValKind: {
-        if (isa<loc::ConcreteInt>(R)) {
-          
-          const SymIntConstraint& C =
-            BasicVals.getConstraint(cast<loc::SymbolVal>(this)->getSymbol(),
-                                 BinaryOperator::EQ,
-                                 cast<loc::ConcreteInt>(R).getValue());
-          
-          return nonloc::SymIntConstraintVal(C);
-        }
-        
-        assert (!isa<loc::SymbolVal>(R) && "FIXME: Implement unification.");
-        
-        break;
-      }
-      
-      case loc::MemRegionKind:
-      if (isa<loc::MemRegionVal>(R)) {        
-        bool b = cast<loc::MemRegionVal>(*this) == cast<loc::MemRegionVal>(R);
-        return NonLoc::MakeIntTruthVal(BasicVals, b);
-      }
-      
-      break;
-  }
-  
-  return NonLoc::MakeIntTruthVal(BasicVals, false);
-}
-
-NonLoc Loc::NE(BasicValueFactory& BasicVals, const Loc& R) const {
-  switch (getSubKind()) {
-    default:
-      assert(false && "NE not implemented for this Loc.");
-      break;
-      
-    case loc::ConcreteIntKind:
-      if (isa<loc::ConcreteInt>(R)) {
-        bool b = cast<loc::ConcreteInt>(this)->getValue() !=
-                 cast<loc::ConcreteInt>(R).getValue();
-        
-        return NonLoc::MakeIntTruthVal(BasicVals, b);
-      }
-      else if (isa<loc::SymbolVal>(R)) {
-        
-        const SymIntConstraint& C =
-        BasicVals.getConstraint(cast<loc::SymbolVal>(R).getSymbol(),
-                             BinaryOperator::NE,
-                             cast<loc::ConcreteInt>(this)->getValue());
-        
-        return nonloc::SymIntConstraintVal(C);        
-      }
-      
-      break;
-      
-      case loc::SymbolValKind: {
-        if (isa<loc::ConcreteInt>(R)) {
-          
-          const SymIntConstraint& C =
-          BasicVals.getConstraint(cast<loc::SymbolVal>(this)->getSymbol(),
-                               BinaryOperator::NE,
-                               cast<loc::ConcreteInt>(R).getValue());
-          
-          return nonloc::SymIntConstraintVal(C);
-        }
-        
-        assert (!isa<loc::SymbolVal>(R) && "FIXME: Implement sym !=.");
-        
-        break;
-      }
-      
-      case loc::MemRegionKind:
-        if (isa<loc::MemRegionVal>(R)) {        
-          bool b = cast<loc::MemRegionVal>(*this)==cast<loc::MemRegionVal>(R);
-          return NonLoc::MakeIntTruthVal(BasicVals, b);
-        }
-      
-        break;
-  }
-  
-  return NonLoc::MakeIntTruthVal(BasicVals, true);
-}
-
-//===----------------------------------------------------------------------===//
-// Utility methods for constructing Non-Locs.
-//===----------------------------------------------------------------------===//
-
-NonLoc NonLoc::MakeVal(BasicValueFactory& BasicVals, uint64_t X, QualType T) {  
-  return nonloc::ConcreteInt(BasicVals.getValue(X, T));
-}
-
-NonLoc NonLoc::MakeVal(BasicValueFactory& BasicVals, IntegerLiteral* I) {
-
-  return nonloc::ConcreteInt(BasicVals.getValue(APSInt(I->getValue(),
-                              I->getType()->isUnsignedIntegerType())));
-}
-
-NonLoc NonLoc::MakeIntTruthVal(BasicValueFactory& BasicVals, bool b) {
-  return nonloc::ConcreteInt(BasicVals.getTruthValue(b));
-}
-
-SVal SVal::GetSymbolValue(SymbolManager& SymMgr, VarDecl* D) {
-
-  QualType T = D->getType();
-  
-  if (Loc::IsLocType(T))
-    return loc::SymbolVal(SymMgr.getSymbol(D));
-  
-  return nonloc::SymbolVal(SymMgr.getSymbol(D));
-}
-
-//===----------------------------------------------------------------------===//
-// Utility methods for constructing Locs.
-//===----------------------------------------------------------------------===//
-
-Loc Loc::MakeVal(AddrLabelExpr* E) { return loc::GotoLabel(E->getLabel()); }
-
-Loc Loc::MakeVal(StringLiteral* S) {
-  return loc::StringLiteralVal(S);
-}
-
-//===----------------------------------------------------------------------===//
-// Pretty-Printing.
-//===----------------------------------------------------------------------===//
-
-void SVal::printStdErr() const { print(*llvm::cerr.stream()); }
-
-void SVal::print(std::ostream& Out) const {
-
-  switch (getBaseKind()) {
-      
-    case UnknownKind:
-      Out << "Invalid"; break;
-      
-    case NonLocKind:
-      cast<NonLoc>(this)->print(Out); break;
-      
-    case LocKind:
-      cast<Loc>(this)->print(Out); break;
-      
-    case UndefinedKind:
-      Out << "Undefined"; break;
-      
-    default:
-      assert (false && "Invalid SVal.");
-  }
-}
-
-static void printOpcode(std::ostream& Out, BinaryOperator::Opcode Op) {
-  
-  switch (Op) {      
-    case BinaryOperator::Mul: Out << '*'  ; break;
-    case BinaryOperator::Div: Out << '/'  ; break;
-    case BinaryOperator::Rem: Out << '%'  ; break;
-    case BinaryOperator::Add: Out << '+'  ; break;
-    case BinaryOperator::Sub: Out << '-'  ; break;
-    case BinaryOperator::Shl: Out << "<<" ; break;
-    case BinaryOperator::Shr: Out << ">>" ; break;
-    case BinaryOperator::LT:  Out << "<"  ; break;
-    case BinaryOperator::GT:  Out << '>'  ; break;
-    case BinaryOperator::LE:  Out << "<=" ; break;
-    case BinaryOperator::GE:  Out << ">=" ; break;    
-    case BinaryOperator::EQ:  Out << "==" ; break;
-    case BinaryOperator::NE:  Out << "!=" ; break;
-    case BinaryOperator::And: Out << '&'  ; break;
-    case BinaryOperator::Xor: Out << '^'  ; break;
-    case BinaryOperator::Or:  Out << '|'  ; break;
-      
-    default: assert(false && "Not yet implemented.");
-  }        
-}
-
-void NonLoc::print(std::ostream& Out) const {
-
-  switch (getSubKind()) {  
-
-    case nonloc::ConcreteIntKind:
-      Out << cast<nonloc::ConcreteInt>(this)->getValue().getZExtValue();
-
-      if (cast<nonloc::ConcreteInt>(this)->getValue().isUnsigned())
-        Out << 'U';
-      
-      break;
-      
-    case nonloc::SymbolValKind:
-      Out << '$' << cast<nonloc::SymbolVal>(this)->getSymbol();
-      break;
-     
-    case nonloc::SymIntConstraintValKind: {
-      const nonloc::SymIntConstraintVal& C = 
-        *cast<nonloc::SymIntConstraintVal>(this);
-      
-      Out << '$' << C.getConstraint().getSymbol() << ' ';
-      printOpcode(Out, C.getConstraint().getOpcode());
-      Out << ' ' << C.getConstraint().getInt().getZExtValue();
-      
-      if (C.getConstraint().getInt().isUnsigned())
-        Out << 'U';
-      
-      break;
-    }
-    
-    case nonloc::LocAsIntegerKind: {
-      const nonloc::LocAsInteger& C = *cast<nonloc::LocAsInteger>(this);
-      C.getLoc().print(Out);
-      Out << " [as " << C.getNumBits() << " bit integer]";
-      break;
-    }
-      
-    default:
-      assert (false && "Pretty-printed not implemented for this NonLoc.");
-      break;
-  }
-}
-
-void Loc::print(std::ostream& Out) const {
-  
-  switch (getSubKind()) {        
-
-    case loc::ConcreteIntKind:
-      Out << cast<loc::ConcreteInt>(this)->getValue().getZExtValue()
-          << " (Loc)";
-      break;
-      
-    case loc::SymbolValKind:
-      Out << '$' << cast<loc::SymbolVal>(this)->getSymbol();
-      break;
-      
-    case loc::GotoLabelKind:
-      Out << "&&"
-          << cast<loc::GotoLabel>(this)->getLabel()->getID()->getName();
-      break;
-
-    case loc::MemRegionKind:
-      Out << '&' << cast<loc::MemRegionVal>(this)->getRegion()->getString();
-      break;
-      
-    case loc::FuncValKind:
-      Out << "function " 
-          << cast<loc::FuncVal>(this)->getDecl()->getIdentifier()->getName();
-      break;
-      
-    case loc::StringLiteralValKind:
-      Out << "literal \""
-          << cast<loc::StringLiteralVal>(this)->getLiteral()->getStrData()
-          << "\"";
-      break;
-      
-    default:
-      assert (false && "Pretty-printing not implemented for this Loc.");
-      break;
-  }
-}





More information about the cfe-commits mailing list