diff options
| author | Alp Toker <alp@nuanti.com> | 2013-10-29 08:32:41 +0000 |
|---|---|---|
| committer | Alp Toker <alp@nuanti.com> | 2013-10-29 08:32:41 +0000 |
| commit | a23d26607ed2ea7738e43d137c92e71aa6e0125d (patch) | |
| tree | 70830eb1697ad7be20bbe3dd4d79ab8060d0531b | |
| parent | d29ddf67138718126b2c363ee294dcd242308eb0 (diff) | |
| download | bcm5719-llvm-a23d26607ed2ea7738e43d137c92e71aa6e0125d.tar.gz bcm5719-llvm-a23d26607ed2ea7738e43d137c92e71aa6e0125d.zip | |
Use Rewriter::overwriteChangedFiles() directly
This replaces the custom code in RefactoringTool::saveRewrittenFiles() which
lacked atomic file saving and error diagnostics, resolving an old FIXME from
r157331.
Landing this time with the proper return code, plus a very unhelpful comment
cleared up.
Rubber-stamped by Manuel Klimek.
llvm-svn: 193594
| -rw-r--r-- | clang/include/clang/Rewrite/Core/Rewriter.h | 2 | ||||
| -rw-r--r-- | clang/lib/Tooling/Refactoring.cpp | 18 |
2 files changed, 2 insertions, 18 deletions
diff --git a/clang/include/clang/Rewrite/Core/Rewriter.h b/clang/include/clang/Rewrite/Core/Rewriter.h index 1c147f3c29c..f791d5528c8 100644 --- a/clang/include/clang/Rewrite/Core/Rewriter.h +++ b/clang/include/clang/Rewrite/Core/Rewriter.h @@ -284,7 +284,7 @@ public: /// overwriteChangedFiles - Save all changed files to disk. /// - /// Returns whether not all changes were saved successfully. + /// Returns true if any files were not saved successfully. /// Outputs diagnostics via the source manager's diagnostic engine /// in case of an error. bool overwriteChangedFiles(); diff --git a/clang/lib/Tooling/Refactoring.cpp b/clang/lib/Tooling/Refactoring.cpp index 9e58db0f482..e165c12e000 100644 --- a/clang/lib/Tooling/Refactoring.cpp +++ b/clang/lib/Tooling/Refactoring.cpp @@ -301,23 +301,7 @@ bool RefactoringTool::applyAllReplacements(Rewriter &Rewrite) { } int RefactoringTool::saveRewrittenFiles(Rewriter &Rewrite) { - for (Rewriter::buffer_iterator I = Rewrite.buffer_begin(), - E = Rewrite.buffer_end(); - I != E; ++I) { - // FIXME: This code is copied from the FixItRewriter.cpp - I think it should - // go into directly into Rewriter (there we also have the Diagnostics to - // handle the error cases better). - const FileEntry *Entry = - Rewrite.getSourceMgr().getFileEntryForID(I->first); - std::string ErrorInfo; - llvm::raw_fd_ostream FileStream(Entry->getName(), ErrorInfo, - llvm::sys::fs::F_Binary); - if (!ErrorInfo.empty()) - return 1; - I->second.write(FileStream); - FileStream.flush(); - } - return 0; + return Rewrite.overwriteChangedFiles() ? 1 : 0; } } // end namespace tooling |

