10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_MOVE_CLANGMOVE_H 11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_MOVE_CLANGMOVE_H 14 #include "clang/ASTMatchers/ASTMatchFinder.h" 15 #include "clang/Frontend/FrontendAction.h" 16 #include "clang/Tooling/Core/Replacement.h" 17 #include "clang/Tooling/Tooling.h" 18 #include "llvm/ADT/SmallPtrSet.h" 19 #include "llvm/ADT/StringMap.h" 20 #include "llvm/ADT/StringRef.h" 37 DeclarationList.emplace_back(DeclarationName, Type, Templated);
54 return DeclarationList;
58 std::vector<Declaration> DeclarationList;
65 SmallVector<std::string, 4>
Names;
76 bool OldDependOnNew =
false;
79 bool NewDependOnOld =
false;
122 void registerMatchers(ast_matchers::MatchFinder *Finder);
124 void run(
const ast_matchers::MatchFinder::MatchResult &
Result)
override;
126 void onEndOfTranslationUnit()
override;
139 void addIncludes(llvm::StringRef IncludeHeader,
bool IsAngled,
140 llvm::StringRef SearchPath, llvm::StringRef
FileName,
141 clang::CharSourceRange IncludeFilenameRange,
142 const SourceManager &SM);
149 void addRemovedDecl(
const NamedDecl *Decl);
152 return UnremovedDeclsInOldHeader;
158 std::string makeAbsolutePath(StringRef
Path);
160 void removeDeclsInOldFiles();
161 void moveDeclsToNewFiles();
162 void moveAll(SourceManager& SM, StringRef OldFile, StringRef NewFile);
165 std::vector<std::unique_ptr<ast_matchers::MatchFinder::MatchCallback>>
171 std::vector<const NamedDecl *> MovedDecls;
173 std::vector<const NamedDecl *> RemovedDecls;
175 std::vector<std::string> HeaderIncludes;
177 std::vector<std::string> CCIncludes;
181 std::vector<const NamedDecl *> HelperDeclarations;
183 llvm::SmallPtrSet<const NamedDecl*, 8> UnremovedDeclsInOldHeader;
187 clang::CharSourceRange OldHeaderIncludeRangeInCC;
191 clang::CharSourceRange OldHeaderIncludeRangeInHeader;
194 llvm::StringMap<FileID> FilePathToFileID;
207 : MoveTool(Context, Reporter) {
208 MoveTool.registerMatchers(&MatchFinder);
213 std::unique_ptr<clang::ASTConsumer>
214 CreateASTConsumer(clang::CompilerInstance &Compiler,
215 llvm::StringRef InFile)
override;
218 ast_matchers::MatchFinder MatchFinder;
226 : Context(Context), Reporter(Reporter) {}
228 clang::FrontendAction *
create()
override {
241 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_MOVE_CLANGMOVE_H void reportDeclaration(llvm::StringRef DeclarationName, llvm::StringRef Type, bool Templated)
std::string OriginalRunningDirectory
clang::FrontendAction * create() override
SmallVector< std::string, 4 > Names
std::vector< HeaderHandle > Path
std::string FallbackStyle
Declaration(llvm::StringRef QName, llvm::StringRef Kind, bool Templated)
ClangMoveAction(ClangMoveContext *const Context, DeclarationReporter *const Reporter)
bool IsAngled
true if this was an include with angle brackets
std::string QualifiedName
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
const std::vector< Declaration > getDeclarationList() const
ClangMoveActionFactory(ClangMoveContext *const Context, DeclarationReporter *const Reporter=nullptr)
~DeclarationReporter()=default
std::map< std::string, tooling::Replacements > & FileToReplacements
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
DeclarationReporter()=default
friend bool operator==(const Declaration &LHS, const Declaration &RHS)