diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-01-14 20:16:52 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-01-14 20:16:52 +0000 |
commit | 9e2822bb4ada53a3cebd9a3f793fef8d700c5c9a (patch) | |
tree | 82ffc92dcbdc203b3e3ad269a592a0b41166cb68 | |
parent | 314f5544fbdcfb1082df070f730fe8acbdb85180 (diff) |
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
-rw-r--r-- | include/clang/Sema/Overload.h | 11 | ||||
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 7 |
2 files changed, 11 insertions, 7 deletions
diff --git a/include/clang/Sema/Overload.h b/include/clang/Sema/Overload.h index 3efbddc871..24adce8f35 100644 --- a/include/clang/Sema/Overload.h +++ b/include/clang/Sema/Overload.h @@ -691,8 +691,7 @@ namespace clang { // 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 @@ namespace clang { 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 @@ namespace clang { 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 2706aeaf1d..5044f1c1df 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -541,11 +541,10 @@ OverloadCandidate::DeductionFailureInfo::getSecondArg() { } 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(); } |