[PATCH] D12970: SmallVector fix. Some tests still failing. Not sure thisis right approach for fixing circular dependency that givesuse-after-dtor bug.

Naomi Musgrave via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 18 10:04:42 PDT 2015


nmusgrave created this revision.
nmusgrave added a reviewer: eugenis.
nmusgrave added a subscriber: llvm-commits.

http://reviews.llvm.org/D12970

Files:
  include/llvm/ADT/SmallVector.h

Index: include/llvm/ADT/SmallVector.h
===================================================================
--- include/llvm/ADT/SmallVector.h
+++ include/llvm/ADT/SmallVector.h
@@ -365,16 +365,6 @@
   }
 
 public:
-  ~SmallVectorImpl() {
-    // Destroy the constructed elements in the vector.
-    this->destroy_range(this->begin(), this->end());
-
-    // If this wasn't grown from the inline copy, deallocate the old space.
-    if (!this->isSmall())
-      free(this->begin());
-  }
-
-
   void clear() {
     this->destroy_range(this->begin(), this->end());
     this->EndX = this->BeginX;
@@ -926,9 +916,19 @@
     this->assign(IL);
     return *this;
   }
+
+  ~SmallVector() {
+    if (this->isSmall()) {
+      // Destroy the constructed elements in the vector.
+      this->destroy_range(this->begin(), this->end());
+    } else {
+      // If this wasn't grown from the inline copy, deallocate the old space.
+      free(this->begin());
+    }
+  }
 };
 
-template<typename T, unsigned N>
+template <typename T, unsigned N>
 static inline size_t capacity_in_bytes(const SmallVector<T, N> &X) {
   return X.capacity_in_bytes();
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12970.35098.patch
Type: text/x-patch
Size: 1140 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150918/813786e3/attachment.bin>


More information about the llvm-commits mailing list