clang-tools 22.0.0git
|
Classes | |
class | Designator |
Represents a part of a designation in a C99/C++20 designated initializer. More... | |
class | Designators |
List of designators. More... | |
struct | ReorderedStruct |
class | ReorderFieldsAction |
Functions | |
static const RecordDecl * | findDefinition (StringRef RecordName, ASTContext &Context) |
Finds the definition of a record by name. | |
static bool | declaresMultipleFieldsInStatement (const RecordDecl *Decl) |
static bool | declaresMultipleFieldsInMacro (const RecordDecl *Decl, const SourceManager &SrcMgr) |
static bool | containsPreprocessorDirectives (const RecordDecl *Decl, const SourceManager &SrcMgr, const LangOptions &LangOpts) |
static bool | isSafeToRewrite (const RecordDecl *Decl, const ASTContext &Context) |
static SmallVector< unsigned, 4 > | getNewFieldsOrder (const RecordDecl *Definition, ArrayRef< std::string > DesiredFieldsOrder) |
Calculates the new order of fields. | |
static bool | isOrderValid (const RecordDecl *RD, ArrayRef< unsigned > FieldOrder) |
static void | addReplacement (SourceRange Old, StringRef New, const ASTContext &Context, std::map< std::string, tooling::Replacements > &Replacements) |
Replaces a range of source code by the specified text. | |
static void | addReplacement (SourceRange Old, SourceRange New, StringRef Prefix, const ASTContext &Context, std::map< std::string, tooling::Replacements > &Replacements) |
Replaces one range of source code by another and adds a prefix. | |
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 SourceLocation | getStartOfLeadingComment (SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts) |
Returns the start of the leading comments before Loc. | |
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 ReorderedStruct &RS, 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, const ReorderedStruct &RS, ASTContext &Context, std::map< std::string, tooling::Replacements > &Replacements) |
Reorders initializers in a C++ struct/class constructor. | |
static bool | isImplicitILE (const InitListExpr *ILE, const ASTContext &Context) |
Replacement for broken InitListExpr::isExplicit function. | |
static const InitListExpr * | getExplicitILE (const InitListExpr *ILE, ASTContext &Context) |
Finds the semantic form of the first explicit ancestor of the given initializer list including itself. | |
static void | reportError (const Twine &Message, SourceLocation Loc, const SourceManager &SM) |
static bool | reorderFieldsInInitListExpr (const InitListExpr *InitListEx, const ReorderedStruct &RS, 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 270 of file ReorderFieldsAction.cpp.
References addReplacement().
|
static |
Replaces one range of source code by another and adds a prefix.
Definition at line 257 of file ReorderFieldsAction.cpp.
References addReplacement().
|
static |
Replaces a range of source code by the specified text.
Definition at line 247 of file ReorderFieldsAction.cpp.
Referenced by addReplacement(), addReplacement(), reorderFieldsInConstructor(), reorderFieldsInDefinition(), and reorderFieldsInInitListExpr().
|
static |
Definition at line 83 of file ReorderFieldsAction.cpp.
Referenced by isSafeToRewrite().
|
static |
Definition at line 69 of file ReorderFieldsAction.cpp.
Referenced by isSafeToRewrite().
|
static |
Definition at line 57 of file ReorderFieldsAction.cpp.
Referenced by isSafeToRewrite().
|
static |
Finds the definition of a record by name.
Definition at line 40 of file ReorderFieldsAction.cpp.
References RecordName().
|
static |
Find all member fields used in the given init-list initializer expr that belong to the same record.
Definition at line 287 of file ReorderFieldsAction.cpp.
Referenced by reorderFieldsInConstructor().
|
static |
Returns the end of the trailing comments after Loc.
Definition at line 330 of file ReorderFieldsAction.cpp.
Referenced by getFullFieldSourceRange().
|
static |
Finds the semantic form of the first explicit ancestor of the given initializer list including itself.
Definition at line 493 of file ReorderFieldsAction.cpp.
References isImplicitILE().
Referenced by reorderFieldsInInitListExpr().
|
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 349 of file ReorderFieldsAction.cpp.
References getEndOfTrailingComment(), and getStartOfLeadingComment().
Referenced by reorderFieldsInDefinition().
|
static |
Calculates the new order of fields.
Definition at line 140 of file ReorderFieldsAction.cpp.
|
static |
Returns the start of the leading comments before Loc.
Definition at line 307 of file ReorderFieldsAction.cpp.
Referenced by getFullFieldSourceRange().
|
static |
Replacement for broken InitListExpr::isExplicit function.
FIXME: Remove when InitListExpr::isExplicit is fixed.
Definition at line 474 of file ReorderFieldsAction.cpp.
Referenced by getExplicitILE().
|
static |
Definition at line 167 of file ReorderFieldsAction.cpp.
|
static |
Definition at line 112 of file ReorderFieldsAction.cpp.
References containsPreprocessorDirectives(), declaresMultipleFieldsInMacro(), and declaresMultipleFieldsInStatement().
|
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 417 of file ReorderFieldsAction.cpp.
References addReplacement(), findMembersUsedInInitExpr(), and clang::reorder_fields::ReorderedStruct::NewFieldsPositions.
|
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 380 of file ReorderFieldsAction.cpp.
References addReplacement(), clang::reorder_fields::ReorderedStruct::Definition, getFullFieldSourceRange(), and clang::reorder_fields::ReorderedStruct::NewFieldsOrder.
|
static |
Reorders initializers in the brace initialization of an aggregate.
At the moment partial initialization is not supported.
Definition at line 524 of file ReorderFieldsAction.cpp.
References addReplacement(), getExplicitILE(), clang::reorder_fields::ReorderedStruct::NewFieldsOrder, and reportError().
|
static |
Definition at line 511 of file ReorderFieldsAction.cpp.
Referenced by reorderFieldsInInitListExpr().