clang-tools 22.0.0git
ReorderFieldsAction.cpp File Reference

This file contains the definition of the ReorderFieldsAction::newASTConsumer method. More...

#include "ReorderFieldsAction.h"
#include "Designator.h"
#include "clang/AST/AST.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Lex/Lexer.h"
#include "clang/Tooling/Refactoring.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/Support/ErrorHandling.h"
#include <string>

Go to the source code of this file.

Classes

struct  clang::reorder_fields::ReorderedStruct

Namespaces

namespace  clang
 ===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
namespace  clang::reorder_fields

Functions

static const RecordDecl * clang::reorder_fields::findDefinition (StringRef RecordName, ASTContext &Context)
 Finds the definition of a record by name.
static bool clang::reorder_fields::declaresMultipleFieldsInStatement (const RecordDecl *Decl)
static bool clang::reorder_fields::declaresMultipleFieldsInMacro (const RecordDecl *Decl, const SourceManager &SrcMgr)
static bool clang::reorder_fields::containsPreprocessorDirectives (const RecordDecl *Decl, const SourceManager &SrcMgr, const LangOptions &LangOpts)
static bool clang::reorder_fields::isSafeToRewrite (const RecordDecl *Decl, const ASTContext &Context)
static SmallVector< unsigned, 4 > clang::reorder_fields::getNewFieldsOrder (const RecordDecl *Definition, ArrayRef< std::string > DesiredFieldsOrder)
 Calculates the new order of fields.
static bool clang::reorder_fields::isOrderValid (const RecordDecl *RD, ArrayRef< unsigned > FieldOrder)
static void clang::reorder_fields::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 clang::reorder_fields::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 clang::reorder_fields::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 > clang::reorder_fields::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 clang::reorder_fields::getStartOfLeadingComment (SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
 Returns the start of the leading comments before Loc.
static SourceLocation clang::reorder_fields::getEndOfTrailingComment (SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
 Returns the end of the trailing comments after Loc.
static SourceRange clang::reorder_fields::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 clang::reorder_fields::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 clang::reorder_fields::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 clang::reorder_fields::isImplicitILE (const InitListExpr *ILE, const ASTContext &Context)
 Replacement for broken InitListExpr::isExplicit function.
static const InitListExpr * clang::reorder_fields::getExplicitILE (const InitListExpr *ILE, ASTContext &Context)
 Finds the semantic form of the first explicit ancestor of the given initializer list including itself.
static void clang::reorder_fields::reportError (const Twine &Message, SourceLocation Loc, const SourceManager &SM)
static bool clang::reorder_fields::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.

Detailed Description

This file contains the definition of the ReorderFieldsAction::newASTConsumer method.

Definition in file ReorderFieldsAction.cpp.