Skip to content

Commit 55d27a7

Browse files
committed
Fix build error with gcc in swift demangling code
Fixes: third_party/swift/include/swift/Demangling/Demangler.h:228:11: error: declaration of ‘swift::Demangle::NodeFactory::Slab* swift::Demangle::NodeFactory::Checkpoint::Slab’ changes meaning of ‘Slab’ [-fpermissive] 228 | Slab *Slab; | ^~~~ third_party/swift/include/swift/Demangling/Demangler.h:47:10: note: ‘Slab’ declared here as ‘struct swift::Demangle::NodeFactory::Slab’ 47 | struct Slab { | ^~~~ No intended behavior change.
1 parent a894dd2 commit 55d27a7

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

Diff for: include/swift/Demangling/Demangler.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ class NodeFactory {
4444
/// The end of the current slab.
4545
char *End = nullptr;
4646

47-
struct Slab {
47+
struct AllocatedSlab {
4848
// The previously allocated slab.
49-
Slab *Previous;
49+
AllocatedSlab *Previous;
5050
// Tail allocated memory starts here.
5151
};
5252

5353
/// The head of the single-linked slab list.
54-
Slab *CurrentSlab = nullptr;
54+
AllocatedSlab *CurrentSlab = nullptr;
5555

5656
/// The size of the previously allocated slab. This may NOT be the size of
5757
/// CurrentSlab, in the case where a checkpoint has been popped.
@@ -66,7 +66,7 @@ class NodeFactory {
6666
& ~((uintptr_t)Alignment - 1));
6767
}
6868

69-
static void freeSlabs(Slab *slab);
69+
static void freeSlabs(AllocatedSlab *slab);
7070

7171
/// If not null, the NodeFactory from which this factory borrowed free memory.
7272
NodeFactory *BorrowedFrom = nullptr;
@@ -149,8 +149,8 @@ class NodeFactory {
149149
// No. We have to malloc a new slab.
150150
// We double the slab size for each allocated slab.
151151
SlabSize = std::max(SlabSize * 2, ObjectSize + alignof(T));
152-
size_t AllocSize = sizeof(Slab) + SlabSize;
153-
Slab *newSlab = (Slab *)malloc(AllocSize);
152+
size_t AllocSize = sizeof(AllocatedSlab) + SlabSize;
153+
AllocatedSlab *newSlab = (AllocatedSlab *)malloc(AllocSize);
154154

155155
// Insert the new slab in the single-linked list of slabs.
156156
newSlab->Previous = CurrentSlab;
@@ -225,7 +225,7 @@ class NodeFactory {
225225
/// A checkpoint which captures the allocator's state at any given time. A
226226
/// checkpoint can be popped to free all allocations made since it was made.
227227
struct Checkpoint {
228-
Slab *Slab;
228+
AllocatedSlab *Slab;
229229
char *CurPtr;
230230
char *End;
231231
};

Diff for: lib/Demangling/Demangler.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,9 @@ Node* Node::findByKind(Node::Kind kind, int maxDepth) {
481481
// NodeFactory member functions //
482482
//////////////////////////////////
483483

484-
void NodeFactory::freeSlabs(Slab *slab) {
484+
void NodeFactory::freeSlabs(AllocatedSlab *slab) {
485485
while (slab) {
486-
Slab *prev = slab->Previous;
486+
AllocatedSlab *prev = slab->Previous;
487487
free(slab);
488488
slab = prev;
489489
}
@@ -543,7 +543,7 @@ void NodeFactory::popCheckpoint(NodeFactory::Checkpoint checkpoint) {
543543
// checkpoint's slab is less than 1/16th of the current slab's space. We
544544
// won't repeatedly allocate and deallocate the current slab. The size
545545
// doubles each time so we'll quickly pass the threshold.
546-
Slab *savedSlab = nullptr;
546+
AllocatedSlab *savedSlab = nullptr;
547547
if (CurrentSlab) {
548548
size_t checkpointSlabFreeSpace = checkpoint.End - checkpoint.CurPtr;
549549
size_t currentSlabSize = End - (char *)(CurrentSlab + 1);

0 commit comments

Comments
 (0)