[cfe-commits] r148200 - in /cfe/trunk: include/clang/Sema/Overload.h lib/Sema/SemaOverload.cpp
Benjamin Kramer
benny.kra at googlemail.com
Sat Jan 14 12:16:53 PST 2012
Author: d0k
Date: Sat Jan 14 14:16:52 2012
New Revision: 148200
URL: http://llvm.org/viewvc/llvm-project?rev=148200&view=rev
Log:
Clear ImplicitConversionSequence the obvious way which turns out to be less fragile.
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=148200&r1=148199&r2=148200&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Sat Jan 14 14:16:52 2012
@@ -691,8 +691,7 @@
// 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 @@
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 @@
NumInlineSequences += NumConversions;
} else {
// Otherwise get memory from the allocator.
- C.Conversions = ConversionSequenceAllocator.Allocate(NumConversions);
+ C.Conversions = ConversionSequenceAllocator
+ .Allocate<ImplicitConversionSequence>(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=148200&r1=148199&r2=148200&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Sat Jan 14 14:16:52 2012
@@ -541,11 +541,10 @@
}
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();
}
More information about the cfe-commits
mailing list