Skip to content

Commit 18bcbc0

Browse files
committed
Add reorder method for RecordDecl
1 parent 5749304 commit 18bcbc0

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

clang/include/clang/AST/Decl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3814,6 +3814,8 @@ class RecordDecl : public TagDecl {
38143814
/// nullptr is returned if no named data member exists.
38153815
const FieldDecl *findFirstNamedDataMember() const;
38163816

3817+
void reorderFields(ArrayRef<Decl *> Decls) const;
3818+
38173819
private:
38183820
/// Deserialize just the fields.
38193821
void LoadFieldsFromExternalStorage() const;

clang/lib/AST/Decl.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4148,6 +4148,14 @@ RecordDecl::field_iterator RecordDecl::field_begin() const {
41484148
return field_iterator(decl_iterator(FirstDecl));
41494149
}
41504150

4151+
void RecordDecl::reorderFields(ArrayRef<Decl *> Decls) const {
4152+
Decl *NewFirst, *NewLast;
4153+
std::tie(NewFirst, NewLast) =
4154+
BuildDeclChain(Decls, false);
4155+
FirstDecl = NewFirst;
4156+
LastDecl = NewLast;
4157+
}
4158+
41514159
/// completeDefinition - Notes that the definition of this type is now
41524160
/// complete.
41534161
void RecordDecl::completeDefinition() {

0 commit comments

Comments
 (0)