Clear ImplicitConversionSequence the obvious way which turns out to be less fragile.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148200 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Sema/Overload.h b/include/clang/Sema/Overload.h
index 3efbddc..24adce8 100644
--- a/include/clang/Sema/Overload.h
+++ b/include/clang/Sema/Overload.h
@@ -691,8 +691,7 @@
 
     // Allocator for OverloadCandidate::Conversions. We store the first few
     // elements inline to avoid allocation for small sets.
-    llvm::SpecificBumpPtrAllocator<ImplicitConversionSequence>
-      ConversionSequenceAllocator;
+    llvm::BumpPtrAllocator ConversionSequenceAllocator;
 
     SourceLocation Loc;
 
@@ -704,6 +703,11 @@
     
   public:
     OverloadCandidateSet(SourceLocation Loc) : Loc(Loc), NumInlineSequences(0){}
+    ~OverloadCandidateSet() {
+      for (iterator i = begin(), e = end(); i != e; ++i)
+        for (unsigned ii = 0, ie = i->NumConversions; ii != ie; ++ii)
+          i->Conversions[ii].~ImplicitConversionSequence();
+    }
 
     SourceLocation getLocation() const { return Loc; }
 
@@ -738,7 +742,8 @@
         NumInlineSequences += NumConversions;
       } else {
         // Otherwise get memory from the allocator.
-        C.Conversions = ConversionSequenceAllocator.Allocate(NumConversions);
+        C.Conversions = ConversionSequenceAllocator
+                          .Allocate<ImplicitConversionSequence>(NumConversions);
       }
 
       // Construct the new objects.
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 2706aea..5044f1c 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -541,11 +541,10 @@
 }
 
 void OverloadCandidateSet::clear() {
-  for (unsigned i = 0, e = NumInlineSequences; i != e; ++i)
-    reinterpret_cast<ImplicitConversionSequence*>(InlineSpace)[i]
-                                                 .~ImplicitConversionSequence();
+  for (iterator i = begin(), e = end(); i != e; ++i)
+    for (unsigned ii = 0, ie = i->NumConversions; ii != ie; ++ii)
+      i->Conversions[ii].~ImplicitConversionSequence();
   NumInlineSequences = 0;
-  ConversionSequenceAllocator.DestroyAll();
   Candidates.clear();
   Functions.clear();
 }