[cfe-commits] r148198 - in /cfe/trunk: include/clang/Sema/Overload.h lib/Sema/SemaOverload.cpp

Benjamin Kramer benny.kra at googlemail.com
Sat Jan 14 11:31:39 PST 2012


Author: d0k
Date: Sat Jan 14 13:31:39 2012
New Revision: 148198

URL: http://llvm.org/viewvc/llvm-project?rev=148198&view=rev
Log:
Give OverloadCandidateSet the responsibility for destroying the implicit conversion sequences so we don't get double frees when the vector reallocates.

Modified:
    cfe/trunk/include/clang/Sema/Overload.h
    cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/include/clang/Sema/Overload.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=148198&r1=148197&r2=148198&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Sat Jan 14 13:31:39 2012
@@ -659,11 +659,6 @@
       StandardConversionSequence FinalConversion;
     };
 
-    ~OverloadCandidate() {
-      for (unsigned i = 0, e = NumConversions; i != e; ++i)
-        Conversions[i].~ImplicitConversionSequence();
-    }
-
     /// hasAmbiguousConversion - Returns whether this overload
     /// candidate requires an ambiguous conversion or not.
     bool hasAmbiguousConversion() const {
@@ -696,7 +691,8 @@
 
     // Allocator for OverloadCandidate::Conversions. We store the first few
     // elements inline to avoid allocation for small sets.
-    llvm::BumpPtrAllocator ConversionSequenceAllocator;
+    llvm::SpecificBumpPtrAllocator<ImplicitConversionSequence>
+      ConversionSequenceAllocator;
 
     SourceLocation Loc;
 
@@ -708,10 +704,6 @@
     
   public:
     OverloadCandidateSet(SourceLocation Loc) : Loc(Loc), NumInlineSequences(0){}
-    ~OverloadCandidateSet() {
-      // Destroy OverloadCandidates before the allocator is destroyed.
-      Candidates.clear();
-    }
 
     SourceLocation getLocation() const { return Loc; }
 
@@ -746,8 +738,7 @@
         NumInlineSequences += NumConversions;
       } else {
         // Otherwise get memory from the allocator.
-        C.Conversions = ConversionSequenceAllocator
-                          .Allocate<ImplicitConversionSequence>(NumConversions);
+        C.Conversions = ConversionSequenceAllocator.Allocate(NumConversions);
       }
 
       // Construct the new objects.

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=148198&r1=148197&r2=148198&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Sat Jan 14 13:31:39 2012
@@ -541,9 +541,13 @@
 }
 
 void OverloadCandidateSet::clear() {
+  for (unsigned i = 0, e = NumInlineSequences; i != e; ++i)
+    reinterpret_cast<ImplicitConversionSequence*>(InlineSpace)[i]
+                                                 .~ImplicitConversionSequence();
+  NumInlineSequences = 0;
+  ConversionSequenceAllocator.DestroyAll();
   Candidates.clear();
   Functions.clear();
-  NumInlineSequences = 0;
 }
 
 namespace {





More information about the cfe-commits mailing list