njames93 created this revision. njames93 added reviewers: rsmith, aaron.ballman. njames93 requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Swapping the order of Init and MemberOrEllipsisLocation removes 8 bytes (20%) of padding on 64bit builds. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D97191 Files: clang/include/clang/AST/DeclCXX.h clang/lib/AST/DeclCXX.cpp Index: clang/lib/AST/DeclCXX.cpp =================================================================== --- clang/lib/AST/DeclCXX.cpp +++ clang/lib/AST/DeclCXX.cpp @@ -2506,16 +2506,15 @@ SourceLocation L, Expr *Init, SourceLocation R, SourceLocation EllipsisLoc) - : Initializee(TInfo), MemberOrEllipsisLocation(EllipsisLoc), Init(Init), + : Initializee(TInfo), Init(Init), MemberOrEllipsisLocation(EllipsisLoc), LParenLoc(L), RParenLoc(R), IsDelegating(false), IsVirtual(IsVirtual), IsWritten(false), SourceOrder(0) {} -CXXCtorInitializer::CXXCtorInitializer(ASTContext &Context, - FieldDecl *Member, +CXXCtorInitializer::CXXCtorInitializer(ASTContext &Context, FieldDecl *Member, SourceLocation MemberLoc, SourceLocation L, Expr *Init, SourceLocation R) - : Initializee(Member), MemberOrEllipsisLocation(MemberLoc), Init(Init), + : Initializee(Member), Init(Init), MemberOrEllipsisLocation(MemberLoc), LParenLoc(L), RParenLoc(R), IsDelegating(false), IsVirtual(false), IsWritten(false), SourceOrder(0) {} @@ -2524,7 +2523,7 @@ SourceLocation MemberLoc, SourceLocation L, Expr *Init, SourceLocation R) - : Initializee(Member), MemberOrEllipsisLocation(MemberLoc), Init(Init), + : Initializee(Member), Init(Init), MemberOrEllipsisLocation(MemberLoc), LParenLoc(L), RParenLoc(R), IsDelegating(false), IsVirtual(false), IsWritten(false), SourceOrder(0) {} Index: clang/include/clang/AST/DeclCXX.h =================================================================== --- clang/include/clang/AST/DeclCXX.h +++ clang/include/clang/AST/DeclCXX.h @@ -2166,6 +2166,10 @@ llvm::PointerUnion<TypeSourceInfo *, FieldDecl *, IndirectFieldDecl *> Initializee; + /// The argument used to initialize the base or member, which may + /// end up constructing an object (when multiple arguments are involved). + Stmt *Init; + /// The source location for the field name or, for a base initializer /// pack expansion, the location of the ellipsis. /// @@ -2174,10 +2178,6 @@ /// Initializee points to the CXXConstructorDecl (to allow loop detection). SourceLocation MemberOrEllipsisLocation; - /// The argument used to initialize the base or member, which may - /// end up constructing an object (when multiple arguments are involved). - Stmt *Init; - /// Location of the left paren of the ctor-initializer. SourceLocation LParenLoc;
Index: clang/lib/AST/DeclCXX.cpp =================================================================== --- clang/lib/AST/DeclCXX.cpp +++ clang/lib/AST/DeclCXX.cpp @@ -2506,16 +2506,15 @@ SourceLocation L, Expr *Init, SourceLocation R, SourceLocation EllipsisLoc) - : Initializee(TInfo), MemberOrEllipsisLocation(EllipsisLoc), Init(Init), + : Initializee(TInfo), Init(Init), MemberOrEllipsisLocation(EllipsisLoc), LParenLoc(L), RParenLoc(R), IsDelegating(false), IsVirtual(IsVirtual), IsWritten(false), SourceOrder(0) {} -CXXCtorInitializer::CXXCtorInitializer(ASTContext &Context, - FieldDecl *Member, +CXXCtorInitializer::CXXCtorInitializer(ASTContext &Context, FieldDecl *Member, SourceLocation MemberLoc, SourceLocation L, Expr *Init, SourceLocation R) - : Initializee(Member), MemberOrEllipsisLocation(MemberLoc), Init(Init), + : Initializee(Member), Init(Init), MemberOrEllipsisLocation(MemberLoc), LParenLoc(L), RParenLoc(R), IsDelegating(false), IsVirtual(false), IsWritten(false), SourceOrder(0) {} @@ -2524,7 +2523,7 @@ SourceLocation MemberLoc, SourceLocation L, Expr *Init, SourceLocation R) - : Initializee(Member), MemberOrEllipsisLocation(MemberLoc), Init(Init), + : Initializee(Member), Init(Init), MemberOrEllipsisLocation(MemberLoc), LParenLoc(L), RParenLoc(R), IsDelegating(false), IsVirtual(false), IsWritten(false), SourceOrder(0) {} Index: clang/include/clang/AST/DeclCXX.h =================================================================== --- clang/include/clang/AST/DeclCXX.h +++ clang/include/clang/AST/DeclCXX.h @@ -2166,6 +2166,10 @@ llvm::PointerUnion<TypeSourceInfo *, FieldDecl *, IndirectFieldDecl *> Initializee; + /// The argument used to initialize the base or member, which may + /// end up constructing an object (when multiple arguments are involved). + Stmt *Init; + /// The source location for the field name or, for a base initializer /// pack expansion, the location of the ellipsis. /// @@ -2174,10 +2178,6 @@ /// Initializee points to the CXXConstructorDecl (to allow loop detection). SourceLocation MemberOrEllipsisLocation; - /// The argument used to initialize the base or member, which may - /// end up constructing an object (when multiple arguments are involved). - Stmt *Init; - /// Location of the left paren of the ctor-initializer. SourceLocation LParenLoc;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits