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 /clang/lib/Tooling/Refactoring.cpp | |
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
Diffstat (limited to 'clang/lib/Tooling/Refactoring.cpp')
-rw-r--r-- | clang/lib/Tooling/Refactoring.cpp | 18 |
1 files changed, 1 insertions, 17 deletions
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 |