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
This commit is contained in:
Benjamin Kramer 2012-01-14 20:16:52 +00:00
Родитель 314f5544fb
Коммит 9e2822bb4a
2 изменённых файлов: 11 добавлений и 7 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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();
}