clang-tools 20.0.0git
|
Classes | |
class | ReorderFieldsAction |
Functions | |
static const RecordDecl * | findDefinition (StringRef RecordName, ASTContext &Context) |
Finds the definition of a record by name. | |
static SmallVector< unsigned, 4 > | getNewFieldsOrder (const RecordDecl *Definition, ArrayRef< std::string > DesiredFieldsOrder) |
Calculates the new order of fields. | |
static void | addReplacement (SourceRange Old, SourceRange New, const ASTContext &Context, std::map< std::string, tooling::Replacements > &Replacements) |
Replaces one range of source code by another. | |
static SmallSetVector< FieldDecl *, 1 > | findMembersUsedInInitExpr (const CXXCtorInitializer *Initializer, ASTContext &Context) |
Find all member fields used in the given init-list initializer expr that belong to the same record. | |
static std::optional< Token > | getTokenAfter (SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts) |
Returns the next token after Loc (including comment tokens). | |
static SourceLocation | getEndOfTrailingComment (SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts) |
Returns the end of the trailing comments after Loc . | |
static SourceRange | getFullFieldSourceRange (const FieldDecl &Field, const ASTContext &Context) |
Returns the full source range for the field declaration up to (including) the trailing semicolumn, including potential macro invocations, e.g. | |
static bool | reorderFieldsInDefinition (const RecordDecl *Definition, ArrayRef< unsigned > NewFieldsOrder, const ASTContext &Context, std::map< std::string, tooling::Replacements > &Replacements) |
Reorders fields in the definition of a struct/class. | |
static void | reorderFieldsInConstructor (const CXXConstructorDecl *CtorDecl, ArrayRef< unsigned > NewFieldsOrder, ASTContext &Context, std::map< std::string, tooling::Replacements > &Replacements) |
Reorders initializers in a C++ struct/class constructor. | |
static bool | reorderFieldsInInitListExpr (const InitListExpr *InitListEx, ArrayRef< unsigned > NewFieldsOrder, const ASTContext &Context, std::map< std::string, tooling::Replacements > &Replacements) |
Reorders initializers in the brace initialization of an aggregate. | |
|
static |
Replaces one range of source code by another.
Definition at line 86 of file ReorderFieldsAction.cpp.
Referenced by reorderFieldsInConstructor(), reorderFieldsInDefinition(), and reorderFieldsInInitListExpr().
|
static |
Finds the definition of a record by name.
Definition at line 36 of file ReorderFieldsAction.cpp.
References Results.
|
static |
Find all member fields used in the given init-list initializer expr that belong to the same record.
Definition at line 102 of file ReorderFieldsAction.cpp.
References Results.
Referenced by reorderFieldsInConstructor().
|
static |
Returns the end of the trailing comments after Loc
.
Definition at line 151 of file ReorderFieldsAction.cpp.
References Column, getTokenAfter(), and Loc.
Referenced by getFullFieldSourceRange().
|
static |
Returns the full source range for the field declaration up to (including) the trailing semicolumn, including potential macro invocations, e.g.
int a GUARDED_BY(mu);
. If there is a trailing comment, include it.
Definition at line 169 of file ReorderFieldsAction.cpp.
References Field, getEndOfTrailingComment(), and Range.
Referenced by reorderFieldsInDefinition().
|
static |
Calculates the new order of fields.
Definition at line 57 of file ReorderFieldsAction.cpp.
|
static |
Returns the next token after Loc
(including comment tokens).
Definition at line 122 of file ReorderFieldsAction.cpp.
References Loc.
Referenced by getEndOfTrailingComment().
|
static |
Reorders initializers in a C++ struct/class constructor.
A constructor can have initializers for an arbitrary subset of the class's fields. Thus, we need to ensure that we reorder just the initializers that are present.
Definition at line 236 of file ReorderFieldsAction.cpp.
References addReplacement(), findMembersUsedInInitExpr(), and ID.
|
static |
Reorders fields in the definition of a struct/class.
At the moment reordering of fields with different accesses (public/protected/private) is not supported.
Definition at line 199 of file ReorderFieldsAction.cpp.
References addReplacement(), Field, and getFullFieldSourceRange().
|
static |
Reorders initializers in the brace initialization of an aggregate.
At the moment partial initialization is not supported.
Definition at line 299 of file ReorderFieldsAction.cpp.
References addReplacement().