From 7442d6faa2719e4e7d33a7021c406c5a4facd74d Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 16 Apr 2017 16:02:28 +0000 Subject: Vendor import of clang trunk r300422: https://llvm.org/svn/llvm-project/cfe/trunk@300422 --- lib/Tooling/Refactoring.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'lib/Tooling/Refactoring.cpp') diff --git a/lib/Tooling/Refactoring.cpp b/lib/Tooling/Refactoring.cpp index 308c1ac48b281..db34c952d7945 100644 --- a/lib/Tooling/Refactoring.cpp +++ b/lib/Tooling/Refactoring.cpp @@ -28,7 +28,7 @@ namespace tooling { RefactoringTool::RefactoringTool( const CompilationDatabase &Compilations, ArrayRef SourcePaths, std::shared_ptr PCHContainerOps) - : ClangTool(Compilations, SourcePaths, PCHContainerOps) {} + : ClangTool(Compilations, SourcePaths, std::move(PCHContainerOps)) {} std::map &RefactoringTool::getReplacements() { return FileToReplaces; @@ -68,8 +68,8 @@ int RefactoringTool::saveRewrittenFiles(Rewriter &Rewrite) { } bool formatAndApplyAllReplacements( - const std::map &FileToReplaces, Rewriter &Rewrite, - StringRef Style) { + const std::map &FileToReplaces, + Rewriter &Rewrite, StringRef Style) { SourceManager &SM = Rewrite.getSourceMgr(); FileManager &Files = SM.getFileManager(); @@ -83,9 +83,14 @@ bool formatAndApplyAllReplacements( FileID ID = SM.getOrCreateFileID(Entry, SrcMgr::C_User); StringRef Code = SM.getBufferData(ID); - format::FormatStyle CurStyle = format::getStyle(Style, FilePath, "LLVM"); + 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); + format::formatReplacements(Code, CurReplaces, *CurStyle); if (!NewReplacements) { llvm::errs() << llvm::toString(NewReplacements.takeError()) << "\n"; return false; -- cgit v1.2.3