From b64793999546ed8adebaeebd9d8345d18db8927d Mon Sep 17 00:00:00 2001 From: patrick Date: Mon, 3 Aug 2020 15:06:44 +0000 Subject: Remove LLVM 8.0.1 files. --- gnu/llvm/tools/clang/lib/Tooling/Refactoring.cpp | 104 ----------------------- 1 file changed, 104 deletions(-) delete mode 100644 gnu/llvm/tools/clang/lib/Tooling/Refactoring.cpp (limited to 'gnu/llvm/tools/clang/lib/Tooling/Refactoring.cpp') diff --git a/gnu/llvm/tools/clang/lib/Tooling/Refactoring.cpp b/gnu/llvm/tools/clang/lib/Tooling/Refactoring.cpp deleted file mode 100644 index db34c952d79..00000000000 --- a/gnu/llvm/tools/clang/lib/Tooling/Refactoring.cpp +++ /dev/null @@ -1,104 +0,0 @@ -//===--- Refactoring.cpp - Framework for clang refactoring tools ----------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Implements tools to support refactorings. -// -//===----------------------------------------------------------------------===// - -#include "clang/Tooling/Refactoring.h" -#include "clang/Basic/DiagnosticOptions.h" -#include "clang/Basic/FileManager.h" -#include "clang/Basic/SourceManager.h" -#include "clang/Format/Format.h" -#include "clang/Frontend/TextDiagnosticPrinter.h" -#include "clang/Lex/Lexer.h" -#include "clang/Rewrite/Core/Rewriter.h" -#include "llvm/Support/Path.h" -#include "llvm/Support/raw_os_ostream.h" - -namespace clang { -namespace tooling { - -RefactoringTool::RefactoringTool( - const CompilationDatabase &Compilations, ArrayRef SourcePaths, - std::shared_ptr PCHContainerOps) - : ClangTool(Compilations, SourcePaths, std::move(PCHContainerOps)) {} - -std::map &RefactoringTool::getReplacements() { - return FileToReplaces; -} - -int RefactoringTool::runAndSave(FrontendActionFactory *ActionFactory) { - if (int Result = run(ActionFactory)) { - return Result; - } - - LangOptions DefaultLangOptions; - IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions(); - TextDiagnosticPrinter DiagnosticPrinter(llvm::errs(), &*DiagOpts); - DiagnosticsEngine Diagnostics( - IntrusiveRefCntPtr(new DiagnosticIDs()), - &*DiagOpts, &DiagnosticPrinter, false); - SourceManager Sources(Diagnostics, getFiles()); - Rewriter Rewrite(Sources, DefaultLangOptions); - - if (!applyAllReplacements(Rewrite)) { - llvm::errs() << "Skipped some replacements.\n"; - } - - return saveRewrittenFiles(Rewrite); -} - -bool RefactoringTool::applyAllReplacements(Rewriter &Rewrite) { - bool Result = true; - for (const auto &Entry : groupReplacementsByFile( - Rewrite.getSourceMgr().getFileManager(), FileToReplaces)) - Result = tooling::applyAllReplacements(Entry.second, Rewrite) && Result; - return Result; -} - -int RefactoringTool::saveRewrittenFiles(Rewriter &Rewrite) { - return Rewrite.overwriteChangedFiles() ? 1 : 0; -} - -bool formatAndApplyAllReplacements( - const std::map &FileToReplaces, - Rewriter &Rewrite, StringRef Style) { - SourceManager &SM = Rewrite.getSourceMgr(); - FileManager &Files = SM.getFileManager(); - - bool Result = true; - for (const auto &FileAndReplaces : groupReplacementsByFile( - Rewrite.getSourceMgr().getFileManager(), FileToReplaces)) { - const std::string &FilePath = FileAndReplaces.first; - auto &CurReplaces = FileAndReplaces.second; - - const FileEntry *Entry = Files.getFile(FilePath); - FileID ID = SM.getOrCreateFileID(Entry, SrcMgr::C_User); - StringRef Code = SM.getBufferData(ID); - - auto CurStyle = format::getStyle(Style, FilePath, "LLVM"); - if (!CurStyle) { - llvm::errs() << llvm::toString(CurStyle.takeError()) << "\n"; - return false; - } - - auto NewReplacements = - format::formatReplacements(Code, CurReplaces, *CurStyle); - if (!NewReplacements) { - llvm::errs() << llvm::toString(NewReplacements.takeError()) << "\n"; - return false; - } - Result = applyAllReplacements(*NewReplacements, Rewrite) && Result; - } - return Result; -} - -} // end namespace tooling -} // end namespace clang -- cgit v1.2.3-59-g8ed1b