]> granicus.if.org Git - clang/commitdiff
Use Rewriter::overwriteChangedFiles() directly
authorAlp Toker <alp@nuanti.com>
Tue, 29 Oct 2013 07:47:49 +0000 (07:47 +0000)
committerAlp Toker <alp@nuanti.com>
Tue, 29 Oct 2013 07:47:49 +0000 (07:47 +0000)
The old code in RefactoringTool::saveRewrittenFiles() lacked
atomic moves and diagnostics and had FIXME to this effect.

Rubber-stamped by Manuel Klimek.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193590 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Tooling/Refactoring.cpp

index 9e58db0f482443c6a01ad42a8506e87110bf7c8f..fa35a74c9c4844bc64d6f9fe7fc051d1ec0f352b 100644 (file)
@@ -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