From 01cd46abaee65965eca85fe4987c24f7022ad71c Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 13 Aug 2015 22:33:24 +0000 Subject: [PATCH] Wdeprecated: RegionBindingsRef are copy constructed, make sure that's safe by removing the unnecessary user-declared copy assignment operator The user-defined copy assignment looks like it was working around the presence of a reference member (that probably doesn't change in the copy assignment cases present in the program). Rather than continuing this - just change the reference to a pointer and let all the special members be defined implicitly. llvm-svn: 244974 --- clang/lib/StaticAnalyzer/Core/RegionStore.cpp | 36 ++++++++----------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp index 6d41fc2146fe..417832454359 100644 --- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp +++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -149,7 +149,8 @@ typedef llvm::ImmutableMap namespace { class RegionBindingsRef : public llvm::ImmutableMapRef { - ClusterBindings::Factory &CBFactory; + ClusterBindings::Factory *CBFactory; + public: typedef llvm::ImmutableMapRef ParentTy; @@ -157,21 +158,21 @@ public: RegionBindingsRef(ClusterBindings::Factory &CBFactory, const RegionBindings::TreeTy *T, RegionBindings::TreeTy::Factory *F) - : llvm::ImmutableMapRef(T, F), - CBFactory(CBFactory) {} + : llvm::ImmutableMapRef(T, F), + CBFactory(&CBFactory) {} RegionBindingsRef(const ParentTy &P, ClusterBindings::Factory &CBFactory) - : llvm::ImmutableMapRef(P), - CBFactory(CBFactory) {} + : llvm::ImmutableMapRef(P), + CBFactory(&CBFactory) {} RegionBindingsRef add(key_type_ref K, data_type_ref D) const { - return RegionBindingsRef(static_cast(this)->add(K, D), - CBFactory); + return RegionBindingsRef(static_cast(this)->add(K, D), + *CBFactory); } RegionBindingsRef remove(key_type_ref K) const { - return RegionBindingsRef(static_cast(this)->remove(K), - CBFactory); + return RegionBindingsRef(static_cast(this)->remove(K), + *CBFactory); } RegionBindingsRef addBinding(BindingKey K, SVal V) const; @@ -179,16 +180,9 @@ public: RegionBindingsRef addBinding(const MemRegion *R, BindingKey::Kind k, SVal V) const; - RegionBindingsRef &operator=(const RegionBindingsRef &X) { - *static_cast(this) = X; - return *this; - } - const SVal *lookup(BindingKey K) const; const SVal *lookup(const MemRegion *R, BindingKey::Kind k) const; - const ClusterBindings *lookup(const MemRegion *R) const { - return static_cast(this)->lookup(R); - } + using llvm::ImmutableMapRef::lookup; RegionBindingsRef removeBinding(BindingKey K); @@ -245,10 +239,10 @@ RegionBindingsRef RegionBindingsRef::addBinding(BindingKey K, SVal V) const { const MemRegion *Base = K.getBaseRegion(); const ClusterBindings *ExistingCluster = lookup(Base); - ClusterBindings Cluster = (ExistingCluster ? *ExistingCluster - : CBFactory.getEmptyMap()); + ClusterBindings Cluster = + (ExistingCluster ? *ExistingCluster : CBFactory->getEmptyMap()); - ClusterBindings NewCluster = CBFactory.add(Cluster, K, V); + ClusterBindings NewCluster = CBFactory->add(Cluster, K, V); return add(Base, NewCluster); } @@ -277,7 +271,7 @@ RegionBindingsRef RegionBindingsRef::removeBinding(BindingKey K) { if (!Cluster) return *this; - ClusterBindings NewCluster = CBFactory.remove(*Cluster, K); + ClusterBindings NewCluster = CBFactory->remove(*Cluster, K); if (NewCluster.isEmpty()) return remove(Base); return add(Base, NewCluster);