aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-01-14 19:31:39 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-01-14 19:31:39 +0000
commit314f5544fbdcfb1082df070f730fe8acbdb85180 (patch)
treea501baf40bf6a888b0251fbfd84fc5ddae18241c
parent47b1d96bde79633d4aeded1cde2c5f870a58af24 (diff)
Give OverloadCandidateSet the responsibility for destroying the implicit conversion sequences so we don't get double frees when the vector reallocates.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148198 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Sema/Overload.h15
-rw-r--r--lib/Sema/SemaOverload.cpp6
2 files changed, 8 insertions, 13 deletions
diff --git a/include/clang/Sema/Overload.h b/include/clang/Sema/Overload.h
index c6d9e48f5b..3efbddc871 100644
--- a/include/clang/Sema/Overload.h
+++ b/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/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 7f1c86c224..2706aeaf1d 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/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 {