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 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 254 of file ReorderFieldsAction.cpp.
References addReplacement().
|
static |
Replaces one range of source code by another and adds a prefix.
Definition at line 241 of file ReorderFieldsAction.cpp.
References addReplacement().
|
static |
Replaces a range of source code by the specified text.
Definition at line 231 of file ReorderFieldsAction.cpp.
Referenced by addReplacement(), reorderFieldsInConstructor(), reorderFieldsInDefinition(), and reorderFieldsInInitListExpr().
|
static |
Definition at line 83 of file ReorderFieldsAction.cpp.
References Decl.
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 Results.
|
static |
Find all member fields used in the given init-list initializer expr that belong to the same record.
Definition at line 271 of file ReorderFieldsAction.cpp.
References Results.
Referenced by reorderFieldsInConstructor().
|
static |
Returns the end of the trailing comments after Loc
.
Definition at line 314 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 477 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 333 of file ReorderFieldsAction.cpp.
References Field, getEndOfTrailingComment(), getStartOfLeadingComment(), and Range.
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 291 of file ReorderFieldsAction.cpp.
References Column, Line, and Loc.
Referenced by getFullFieldSourceRange().
|
static |
Replacement for broken InitListExpr::isExplicit function.
FIXME: Remove when InitListExpr::isExplicit is fixed.
Definition at line 458 of file ReorderFieldsAction.cpp.
Referenced by getExplicitILE(), and reorderFieldsInInitListExpr().
|
static |
Definition at line 112 of file ReorderFieldsAction.cpp.
References containsPreprocessorDirectives(), Decl, 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 401 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 364 of file ReorderFieldsAction.cpp.
References addReplacement(), clang::reorder_fields::ReorderedStruct::Definition, Field, 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 508 of file ReorderFieldsAction.cpp.
References addReplacement(), getExplicitILE(), isImplicitILE(), clang::reorder_fields::ReorderedStruct::NewFieldsOrder, and reportError().
|
static |
Definition at line 495 of file ReorderFieldsAction.cpp.
References Loc.
Referenced by reorderFieldsInInitListExpr().