summaryrefslogtreecommitdiffstats
path: root/clang/lib/Tooling
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2013-10-29 07:47:49 +0000
committerAlp Toker <alp@nuanti.com>2013-10-29 07:47:49 +0000
commit4a9284b36a5cb12d4ea3a67da873a94ff11ebe22 (patch)
tree2e6e68baae2372be92af7e066df17f181467dae3 /clang/lib/Tooling
parentf6b936bc062e7490cfe956d58d47ba92b46e830f (diff)
downloadbcm5719-llvm-4a9284b36a5cb12d4ea3a67da873a94ff11ebe22.tar.gz
bcm5719-llvm-4a9284b36a5cb12d4ea3a67da873a94ff11ebe22.zip
Use Rewriter::overwriteChangedFiles() directly
The old code in RefactoringTool::saveRewrittenFiles() lacked atomic moves and diagnostics and had FIXME to this effect. Rubber-stamped by Manuel Klimek. llvm-svn: 193590
Diffstat (limited to 'clang/lib/Tooling')
-rw-r--r--clang/lib/Tooling/Refactoring.cpp18
1 files changed, 1 insertions, 17 deletions
diff --git a/clang/lib/Tooling/Refactoring.cpp b/clang/lib/Tooling/Refactoring.cpp
index 9e58db0f482..fa35a74c9c4 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() ? 0 : 1;
}
} // end namespace tooling
OpenPOWER on IntegriCloud