diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-01-14 19:31:39 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-01-14 19:31:39 +0000 |
| commit | 0b9c509c4ec2f53896cb8a5bbb376ec01f4a66a9 (patch) | |
| tree | 51cbff48a91c085a4edaa169a38f0b0f3753f3bc | |
| parent | 52d02f68e50352f4bd1c8b12d449a6222f5f9cee (diff) | |
| download | bcm5719-llvm-0b9c509c4ec2f53896cb8a5bbb376ec01f4a66a9.tar.gz bcm5719-llvm-0b9c509c4ec2f53896cb8a5bbb376ec01f4a66a9.zip | |
Give OverloadCandidateSet the responsibility for destroying the implicit conversion sequences so we don't get double frees when the vector reallocates.
llvm-svn: 148198
| -rw-r--r-- | clang/include/clang/Sema/Overload.h | 15 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 6 |
2 files changed, 8 insertions, 13 deletions
diff --git a/clang/include/clang/Sema/Overload.h b/clang/include/clang/Sema/Overload.h index c6d9e48f5bd..3efbddc8711 100644 --- a/clang/include/clang/Sema/Overload.h +++ b/clang/include/clang/Sema/Overload.h @@ -659,11 +659,6 @@ namespace clang { 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 @@ namespace clang { // 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 @@ namespace clang { 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 @@ namespace clang { NumInlineSequences += NumConversions; } else { // Otherwise get memory from the allocator. - C.Conversions = ConversionSequenceAllocator - .Allocate<ImplicitConversionSequence>(NumConversions); + C.Conversions = ConversionSequenceAllocator.Allocate(NumConversions); } // Construct the new objects. diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 7f1c86c2248..2706aeaf1d9 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -541,9 +541,13 @@ OverloadCandidate::DeductionFailureInfo::getSecondArg() { } 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 { |

