diff options
Diffstat (limited to 'tools/clang-refactor/ClangRefactor.cpp')
-rw-r--r-- | tools/clang-refactor/ClangRefactor.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/tools/clang-refactor/ClangRefactor.cpp b/tools/clang-refactor/ClangRefactor.cpp index ed9bf5ed28..523c3a6220 100644 --- a/tools/clang-refactor/ClangRefactor.cpp +++ b/tools/clang-refactor/ClangRefactor.cpp @@ -40,6 +40,11 @@ static cl::OptionCategory CommonRefactorOptions("Refactoring options"); static cl::opt<bool> Verbose("v", cl::desc("Use verbose output"), cl::cat(cl::GeneralCategory), cl::sub(*cl::AllSubCommands)); + +static cl::opt<bool> Inplace("i", cl::desc("Inplace edit <file>s"), + cl::cat(cl::GeneralCategory), + cl::sub(*cl::AllSubCommands)); + } // end namespace opts namespace { @@ -436,13 +441,18 @@ public: return true; } - std::error_code EC; - llvm::raw_fd_ostream OS(File, EC, llvm::sys::fs::F_Text); - if (EC) { - llvm::errs() << EC.message() << "\n"; - return true; + if (opts::Inplace) { + std::error_code EC; + llvm::raw_fd_ostream OS(File, EC, llvm::sys::fs::F_Text); + if (EC) { + llvm::errs() << EC.message() << "\n"; + return true; + } + OS << *Result; + continue; } - OS << *Result; + + llvm::outs() << *Result; } return false; } |