Skip to content

Demangler: remove a wrong assert #7767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions include/swift/Basic/Demangler.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class NodeFactory {

/// Allocates an object of type T or an array of objects of type T.
template<typename T> T *Allocate(size_t NumObjects = 1) {
static_assert(alignof(T) <= alignof(Slab *), "alignment not supported");
size_t ObjectSize = NumObjects * sizeof(T);
CurPtr = align(CurPtr, alignof(T));
#ifdef NODE_FACTORY_DEBUGGING
Expand All @@ -100,7 +99,7 @@ class NodeFactory {
if (CurPtr + ObjectSize > End) {
// No. We have to malloc a new slab.
// We doulbe the slab size for each allocated slab.
SlabSize = std::max(SlabSize * 2, ObjectSize);
SlabSize = std::max(SlabSize * 2, ObjectSize + alignof(T));
size_t AllocSize = sizeof(Slab) + SlabSize;
Slab *newSlab = (Slab *)malloc(AllocSize);

Expand All @@ -109,15 +108,14 @@ class NodeFactory {
CurrentSlab = newSlab;

// Initialize the pointers to the new slab.
CurPtr = (char *)(newSlab + 1);
assert(align(CurPtr, alignof(T)) == CurPtr);
End = CurPtr + SlabSize;
CurPtr = align((char *)(newSlab + 1), alignof(T));
End = (char *)newSlab + AllocSize;
assert(CurPtr + ObjectSize <= End);
#ifdef NODE_FACTORY_DEBUGGING
std::cerr << " ** new slab " << newSlab << ", allocsize = "
<< AllocSize << ", CurPtr = " << (void *)CurPtr
<< ", End = " << (void *)End << "\n";
#endif
assert(End == (char *)newSlab + AllocSize);
}
T *AllocatedObj = (T *)CurPtr;
CurPtr += ObjectSize;
Expand Down