r193590 - Use Rewriter::overwriteChangedFiles() directly

Alp Toker alp at nuanti.com
Tue Oct 29 00:47:50 PDT 2013


Author: alp
Date: Tue Oct 29 02:47:49 2013
New Revision: 193590

URL: http://llvm.org/viewvc/llvm-project?rev=193590&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Tooling/Refactoring.cpp

Modified: cfe/trunk/lib/Tooling/Refactoring.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring.cpp?rev=193590&r1=193589&r2=193590&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/Refactoring.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring.cpp Tue Oct 29 02:47:49 2013
@@ -301,23 +301,7 @@ bool RefactoringTool::applyAllReplacemen
 }
 
 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





More information about the cfe-commits mailing list