Skip to content

Commit 0d76b37

Browse files
Change semantic of RecordContext::stealRecordChain to concatenate the chains
1 parent 1891235 commit 0d76b37

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

clang/include/clang/ExtractAPI/API.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ class RecordContext {
321321

322322
RecordContext(APIRecord::RecordKind Kind) : Kind(Kind) {}
323323

324+
/// Append \p Other children chain into ours and empty out Other's record
325+
/// chain.
324326
void stealRecordChain(RecordContext &Other);
325327

326328
APIRecord::RecordKind getKind() const { return Kind; }

clang/lib/ExtractAPI/API.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,15 @@ RecordContext *APIRecord::castToRecordContext(const APIRecord *Record) {
5555
}
5656

5757
void RecordContext::stealRecordChain(RecordContext &Other) {
58-
First = Other.First;
58+
// If we don't have an empty chain append Other's chain into ours.
59+
if (First)
60+
Last->NextInContext = Other.First;
61+
else
62+
First = Other.First;
63+
5964
Last = Other.Last;
65+
66+
// Delete Other's chain to ensure we don't accidentally traverse it.
6067
Other.First = nullptr;
6168
Other.Last = nullptr;
6269
}

0 commit comments

Comments
 (0)