svn commit: r194755 - in vendor/clang/dist: clang.xcodeproj include/clang/Analysis/PathSensitive lib/Analysis lib/Driver lib/Frontend test/CXX/basic/basic.def.odr test/CXX/temp/temp.res/temp.dep.re...

Ed Schouten ed at FreeBSD.org
Tue Jun 23 19:32:17 UTC 2009


Author: ed
Date: Tue Jun 23 19:32:16 2009
New Revision: 194755
URL: http://svn.freebsd.org/changeset/base/194755

Log:
  Import Clang r73984.

Added:
  vendor/clang/dist/test/CXX/basic/basic.def.odr/p2-typeid.cpp
  vendor/clang/dist/test/CXX/temp/temp.res/temp.dep.res/temp.point/p1.cpp
Deleted:
  vendor/clang/dist/clang.xcodeproj/project.pbxproj
Modified:
  vendor/clang/dist/include/clang/Analysis/PathSensitive/GRState.h
  vendor/clang/dist/include/clang/Analysis/PathSensitive/MemRegion.h
  vendor/clang/dist/lib/Analysis/BugReporter.cpp
  vendor/clang/dist/lib/Analysis/CFRefCount.cpp
  vendor/clang/dist/lib/Analysis/CMakeLists.txt
  vendor/clang/dist/lib/Analysis/GRExprEngine.cpp
  vendor/clang/dist/lib/Analysis/GRState.cpp
  vendor/clang/dist/lib/Analysis/MemRegion.cpp
  vendor/clang/dist/lib/Analysis/RegionStore.cpp
  vendor/clang/dist/lib/Driver/CMakeLists.txt
  vendor/clang/dist/lib/Frontend/CMakeLists.txt

Modified: vendor/clang/dist/include/clang/Analysis/PathSensitive/GRState.h
==============================================================================
--- vendor/clang/dist/include/clang/Analysis/PathSensitive/GRState.h	Tue Jun 23 19:31:59 2009	(r194754)
+++ vendor/clang/dist/include/clang/Analysis/PathSensitive/GRState.h	Tue Jun 23 19:32:16 2009	(r194755)
@@ -530,21 +530,6 @@ public:
   
 private:
 
-  // Methods that query & manipulate the Environment.  
-  SVal GetSVal(const GRState* St, const Stmt* Ex) {
-    return St->getEnvironment().GetSVal(Ex, ValueMgr);
-  }
-  
-  SVal GetSValAsScalarOrLoc(const GRState* state, const Stmt *S) {
-    if (const Expr *Ex = dyn_cast<Expr>(S)) {
-      QualType T = Ex->getType();
-      if (Loc::IsLocType(T) || T->isIntegerType())
-        return GetSVal(state, S);
-    }
-    
-    return UnknownVal();
-  }
-
   SVal GetBlkExprSVal(const GRState* St, const Stmt* Ex) {
     return St->getEnvironment().GetBlkExprSVal(Ex, ValueMgr);
   }
@@ -589,21 +574,11 @@ public:
   // Methods that manipulate the GDM.
   const GRState* addGDM(const GRState* St, void* Key, void* Data);
   
-  // Methods that query or create regions.
-  bool hasStackStorage(const MemRegion* R) {
-    return getRegionManager().hasStackStorage(R);
-  }
-  
   // Methods that query & manipulate the Store.
 
   void iterBindings(const GRState* state, StoreManager::BindingsHandler& F) {
     StoreMgr->iterBindings(state->getStore(), F);
   }
-    
-  
-  SVal GetSVal(const GRState* state, Loc LV, QualType T = QualType()) {
-    return StoreMgr->Retrieve(state, LV, T);
-  }
   
   SVal GetSVal(const GRState* state, const MemRegion* R) {
     return StoreMgr->Retrieve(state, loc::MemRegionVal(R));
@@ -781,19 +756,25 @@ inline const llvm::APSInt *GRState::getS
 }
   
 inline SVal GRState::getSVal(const Stmt* Ex) const {
-  return Mgr->GetSVal(this, Ex);
+  return getEnvironment().GetSVal(Ex, Mgr->ValueMgr);
 }
 
 inline SVal GRState::getBlkExprSVal(const Stmt* Ex) const {  
   return Mgr->GetBlkExprSVal(this, Ex);
 }
 
-inline SVal GRState::getSValAsScalarOrLoc(const Stmt *Ex) const {
-  return Mgr->GetSValAsScalarOrLoc(this, Ex);
+inline SVal GRState::getSValAsScalarOrLoc(const Stmt *S) const {
+  if (const Expr *Ex = dyn_cast<Expr>(S)) {
+    QualType T = Ex->getType();
+    if (Loc::IsLocType(T) || T->isIntegerType())
+      return getSVal(S);
+  }
+    
+  return UnknownVal();
 }
 
 inline SVal GRState::getSVal(Loc LV, QualType T) const {
-  return Mgr->GetSVal(this, LV, T);
+  return Mgr->StoreMgr->Retrieve(this, LV, T);
 }
 
 inline SVal GRState::getSVal(const MemRegion* R) const {

Modified: vendor/clang/dist/include/clang/Analysis/PathSensitive/MemRegion.h
==============================================================================
--- vendor/clang/dist/include/clang/Analysis/PathSensitive/MemRegion.h	Tue Jun 23 19:31:59 2009	(r194754)
+++ vendor/clang/dist/include/clang/Analysis/PathSensitive/MemRegion.h	Tue Jun 23 19:32:16 2009	(r194755)
@@ -33,7 +33,7 @@ namespace llvm { class raw_ostream; }
 namespace clang {
  
 class MemRegionManager;
-  
+class MemSpaceRegion;  
       
 /// MemRegion - The root abstract class for all memory regions.
 class MemRegion : public llvm::FoldingSetNode {
@@ -68,6 +68,14 @@ public:
   virtual MemRegionManager* getMemRegionManager() const = 0;
 
   std::string getString() const;
+  
+  const MemSpaceRegion *getMemorySpace() const;
+    
+  bool hasStackStorage() const;
+  
+  bool hasHeapStorage() const;
+  
+  bool hasHeapOrStackStorage() const;
 
   virtual void print(llvm::raw_ostream& os) const;  
   
@@ -668,10 +676,6 @@ public:
     assert(R);
     return R == globals; 
   }
-
-  bool hasStackStorage(const MemRegion* R);
-
-  bool hasHeapStorage(const MemRegion* R);
   
 private:
   MemSpaceRegion* LazyAllocate(MemSpaceRegion*& region);

Modified: vendor/clang/dist/lib/Analysis/BugReporter.cpp
==============================================================================
--- vendor/clang/dist/lib/Analysis/BugReporter.cpp	Tue Jun 23 19:31:59 2009	(r194754)
+++ vendor/clang/dist/lib/Analysis/BugReporter.cpp	Tue Jun 23 19:32:16 2009	(r194755)
@@ -380,7 +380,7 @@ public:
       return true;
     
     // Check if the previous state has this binding.    
-    SVal X = VMgr.GetSVal(PrevSt, loc::MemRegionVal(R));
+    SVal X = PrevSt->getSVal(loc::MemRegionVal(R));
     
     if (X == V) // Same binding?
       return true;

Modified: vendor/clang/dist/lib/Analysis/CFRefCount.cpp
==============================================================================
--- vendor/clang/dist/lib/Analysis/CFRefCount.cpp	Tue Jun 23 19:31:59 2009	(r194754)
+++ vendor/clang/dist/lib/Analysis/CFRefCount.cpp	Tue Jun 23 19:32:16 2009	(r194755)
@@ -3141,7 +3141,7 @@ void CFRefCount::EvalBind(GRStmtNodeBuil
     escapes = true;
   else {
     const MemRegion* R = cast<loc::MemRegionVal>(location).getRegion();
-    escapes = !B.getStateManager().hasStackStorage(R);
+    escapes = !R->hasStackStorage();
     
     if (!escapes) {
       // To test (3), generate a new state with the binding removed.  If it is

Modified: vendor/clang/dist/lib/Analysis/CMakeLists.txt
==============================================================================
--- vendor/clang/dist/lib/Analysis/CMakeLists.txt	Tue Jun 23 19:31:59 2009	(r194754)
+++ vendor/clang/dist/lib/Analysis/CMakeLists.txt	Tue Jun 23 19:32:16 2009	(r194755)
@@ -31,6 +31,7 @@ add_clang_library(clangAnalysis
   SVals.cpp
   SymbolManager.cpp
   UninitializedValues.cpp
+  ValueManager.cpp
   )
 
 add_dependencies(clangAnalysis ClangDiagnosticAnalysis)

Modified: vendor/clang/dist/lib/Analysis/GRExprEngine.cpp
==============================================================================
--- vendor/clang/dist/lib/Analysis/GRExprEngine.cpp	Tue Jun 23 19:31:59 2009	(r194754)
+++ vendor/clang/dist/lib/Analysis/GRExprEngine.cpp	Tue Jun 23 19:32:16 2009	(r194755)
@@ -2764,7 +2764,7 @@ void GRExprEngine::VisitReturnStmt(Retur
       // Determine if the value is on the stack.
       const MemRegion* R = cast<loc::MemRegionVal>(&X)->getRegion();
       
-      if (R && getStateManager().hasStackStorage(R)) {
+      if (R && R->hasStackStorage()) {
         // Create a special node representing the error.
         if (NodeTy* N = Builder->generateNode(S, GetState(*I), *I)) {
           N->markAsSink();

Modified: vendor/clang/dist/lib/Analysis/GRState.cpp
==============================================================================
--- vendor/clang/dist/lib/Analysis/GRState.cpp	Tue Jun 23 19:31:59 2009	(r194754)
+++ vendor/clang/dist/lib/Analysis/GRState.cpp	Tue Jun 23 19:32:16 2009	(r194755)
@@ -282,7 +282,7 @@ bool GRState::scanReachableSymbols(SVal 
 bool GRStateManager::isEqual(const GRState* state, Expr* Ex,
                              const llvm::APSInt& Y) {
   
-  SVal V = GetSVal(state, Ex);
+  SVal V = state->getSVal(Ex);
   
   if (loc::ConcreteInt* X = dyn_cast<loc::ConcreteInt>(&V))
     return X->getValue() == Y;

Modified: vendor/clang/dist/lib/Analysis/MemRegion.cpp
==============================================================================
--- vendor/clang/dist/lib/Analysis/MemRegion.cpp	Tue Jun 23 19:31:59 2009	(r194754)
+++ vendor/clang/dist/lib/Analysis/MemRegion.cpp	Tue Jun 23 19:32:16 2009	(r194755)
@@ -313,45 +313,40 @@ AllocaRegion* MemRegionManager::getAlloc
   return getRegion<AllocaRegion>(E, cnt);
 }
 
-bool MemRegionManager::hasStackStorage(const MemRegion* R) {
-  // Only subregions can have stack storage.
-  const SubRegion* SR = dyn_cast<SubRegion>(R);
 
-  if (!SR)
-    return false;
-
-  MemSpaceRegion* S = getStackRegion();
+const MemSpaceRegion *MemRegion::getMemorySpace() const {
+  const MemRegion *R = this;
+  const SubRegion* SR = dyn_cast<SubRegion>(this);
   
   while (SR) {
     R = SR->getSuperRegion();
-    if (R == S)
-      return true;
-    
-    SR = dyn_cast<SubRegion>(R);    
+    SR = dyn_cast<SubRegion>(R);
   }
- 
-  return false;
+  
+  return dyn_cast<MemSpaceRegion>(R);
 }
 
-bool MemRegionManager::hasHeapStorage(const MemRegion* R) {
-  // Only subregions can have stack storage.
-  const SubRegion* SR = dyn_cast<SubRegion>(R);
+bool MemRegion::hasStackStorage() const {
+  if (const MemSpaceRegion *MS = getMemorySpace())
+    return MS == getMemRegionManager()->getStackRegion();
 
-  if (!SR)
-    return false;
+  return false;
+}
 
-  MemSpaceRegion* H = getHeapRegion();
+bool MemRegion::hasHeapStorage() const {
+  if (const MemSpaceRegion *MS = getMemorySpace())
+    return MS == getMemRegionManager()->getHeapRegion();
 
-  while (SR) {
-    R = SR->getSuperRegion();
-    if (R == H)
-      return true;
+  return false;
+}
 
-    SR = dyn_cast<SubRegion>(R);
+bool MemRegion::hasHeapOrStackStorage() const {
+  if (const MemSpaceRegion *MS = getMemorySpace()) {
+    MemRegionManager *Mgr = getMemRegionManager();
+    return MS == Mgr->getHeapRegion() || MS == Mgr->getStackRegion();
   }
-
   return false;
-}
+}  
 
 //===----------------------------------------------------------------------===//
 // View handling.

Modified: vendor/clang/dist/lib/Analysis/RegionStore.cpp
==============================================================================
--- vendor/clang/dist/lib/Analysis/RegionStore.cpp	Tue Jun 23 19:31:59 2009	(r194754)
+++ vendor/clang/dist/lib/Analysis/RegionStore.cpp	Tue Jun 23 19:32:16 2009	(r194755)
@@ -939,7 +939,7 @@ SVal RegionStoreManager::Retrieve(const 
     }
   }  
 
-  if (MRMgr.hasStackStorage(R) || MRMgr.hasHeapStorage(R)) {
+  if (R->hasHeapOrStackStorage()) {
     // All stack variables are considered to have undefined values
     // upon creation.  All heap allocated blocks are considered to
     // have undefined values as well unless they are explicitly bound

Modified: vendor/clang/dist/lib/Driver/CMakeLists.txt
==============================================================================
--- vendor/clang/dist/lib/Driver/CMakeLists.txt	Tue Jun 23 19:31:59 2009	(r194754)
+++ vendor/clang/dist/lib/Driver/CMakeLists.txt	Tue Jun 23 19:32:16 2009	(r194755)
@@ -18,4 +18,4 @@ add_clang_library(clangDriver
   Types.cpp
   )
 
-add_dependencies(clangSema ClangDiagnosticDriver)
+add_dependencies(clangDriver ClangDiagnosticDriver)

Modified: vendor/clang/dist/lib/Frontend/CMakeLists.txt
==============================================================================
--- vendor/clang/dist/lib/Frontend/CMakeLists.txt	Tue Jun 23 19:31:59 2009	(r194754)
+++ vendor/clang/dist/lib/Frontend/CMakeLists.txt	Tue Jun 23 19:32:16 2009	(r194755)
@@ -36,4 +36,4 @@ add_clang_library(clangFrontend
   Warnings.cpp
   )
 
-add_dependencies(clangSema ClangDiagnosticFrontend)
+add_dependencies(clangFrontend ClangDiagnosticFrontend)

Added: vendor/clang/dist/test/CXX/basic/basic.def.odr/p2-typeid.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/clang/dist/test/CXX/basic/basic.def.odr/p2-typeid.cpp	Tue Jun 23 19:32:16 2009	(r194755)
@@ -0,0 +1,36 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+// C++ [basic.def.odr]p2:
+//   An expression is potentially evaluated unless it [...] is the
+//   operand of the typeid operator and the expression does not
+//   designate an lvalue of polymorphic class type.
+
+// FIXME: This should really include <typeinfo>, but we don't have that yet.
+namespace std {
+  class type_info;
+}
+
+struct Poly {
+  virtual ~Poly();
+};
+
+struct NonPoly { };
+
+template<typename T, typename Result = T> 
+struct X {
+  Result f(T t) { return t + t; } // expected-error{{invalid operands}}
+
+  void g(T t) {
+    (void)typeid(f(t)); // expected-note{{here}}
+  }
+};
+
+void test(X<Poly> xp, X<Poly, Poly&> xpr, X<NonPoly> xnp, X<NonPoly, NonPoly&> xnpr) {
+  // These are okay (although GCC and EDG get them wrong).
+  xp.g(Poly());
+  xnp.g(NonPoly());
+  xnpr.g(NonPoly());
+
+  // Triggers an error (as it should);
+  xpr.g(Poly());
+}

Added: vendor/clang/dist/test/CXX/temp/temp.res/temp.dep.res/temp.point/p1.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/clang/dist/test/CXX/temp/temp.res/temp.dep.res/temp.point/p1.cpp	Tue Jun 23 19:32:16 2009	(r194755)
@@ -0,0 +1,32 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+// XFAIL
+
+// Note: we fail this test because we perform template instantiation
+// at the end of the translation unit, so argument-dependent lookup
+// finds functions that occur after the point of instantiation. Note
+// that GCC fails this test; EDG passes the test in strict mode, but
+// not in relaxed mode.
+namespace N {
+  struct A { };
+  struct B : public A { };
+
+  int& f0(A&);
+}
+
+template<typename T, typename Result>
+struct X0 {
+  void test_f0(T t) {
+    Result r = f0(t);
+  };
+};
+
+void test_f0() {
+  X0<N::A, int&> xA;
+  xA.test_f0(N::A());
+  X0<N::B, int&> xB;
+  xB.test_f0(N::B());
+}
+
+namespace N {
+  char& f0(B&);
+}


More information about the svn-src-all mailing list