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" 35 llvm::StringRef Type) {
36 DeclarationList.emplace_back(DeclarationName, Type);
46 return DeclarationList;
50 std::vector<DeclarationPair> DeclarationList;
57 SmallVector<std::string, 4>
Names;
68 bool OldDependOnNew =
false;
71 bool NewDependOnOld =
false;
114 void registerMatchers(ast_matchers::MatchFinder *Finder);
116 void run(
const ast_matchers::MatchFinder::MatchResult &Result)
override;
118 void onEndOfTranslationUnit()
override;
131 void addIncludes(llvm::StringRef IncludeHeader,
bool IsAngled,
132 llvm::StringRef SearchPath, llvm::StringRef
FileName,
133 clang::CharSourceRange IncludeFilenameRange,
134 const SourceManager &SM);
141 void addRemovedDecl(
const NamedDecl *Decl);
144 return UnremovedDeclsInOldHeader;
150 std::string makeAbsolutePath(StringRef
Path);
152 void removeDeclsInOldFiles();
153 void moveDeclsToNewFiles();
154 void moveAll(SourceManager& SM, StringRef OldFile, StringRef NewFile);
157 std::vector<std::unique_ptr<ast_matchers::MatchFinder::MatchCallback>>
163 std::vector<const NamedDecl *> MovedDecls;
165 std::vector<const NamedDecl *> RemovedDecls;
167 std::vector<std::string> HeaderIncludes;
169 std::vector<std::string> CCIncludes;
173 std::vector<const NamedDecl *> HelperDeclarations;
175 llvm::SmallPtrSet<const NamedDecl*, 8> UnremovedDeclsInOldHeader;
179 clang::CharSourceRange OldHeaderIncludeRangeInCC;
183 clang::CharSourceRange OldHeaderIncludeRangeInHeader;
186 llvm::StringMap<FileID> FilePathToFileID;
199 : MoveTool(Context, Reporter) {
200 MoveTool.registerMatchers(&MatchFinder);
205 std::unique_ptr<clang::ASTConsumer>
206 CreateASTConsumer(clang::CompilerInstance &Compiler,
207 llvm::StringRef InFile)
override;
210 ast_matchers::MatchFinder MatchFinder;
218 : Context(Context), Reporter(Reporter) {}
220 clang::FrontendAction *
create()
override {
233 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_MOVE_CLANGMOVE_H std::pair< std::string, std::string > DeclarationPair
std::string OriginalRunningDirectory
clang::FrontendAction * create() override
const std::vector< DeclarationPair > getDeclarationList() const
void reportDeclaration(llvm::StringRef DeclarationName, llvm::StringRef Type)
SmallVector< std::string, 4 > Names
std::vector< HeaderHandle > Path
std::string FallbackStyle
ClangMoveAction(ClangMoveContext *const Context, DeclarationReporter *const Reporter)
bool IsAngled
true if this was an include with angle brackets
ClangMoveActionFactory(ClangMoveContext *const Context, DeclarationReporter *const Reporter=nullptr)
~DeclarationReporter()=default
std::map< std::string, tooling::Replacements > & FileToReplacements
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
DeclarationReporter()=default