| 450 | } |
| 451 | |
| 452 | void UTModify::applyReplacements( |
| 453 | const std::string &OrgFilePath, const std::string &OutFilePath, |
| 454 | const clang::tooling::Replacements &Replacements, |
| 455 | const std::string &Signature) const { |
| 456 | auto ID = SManager->getOrCreateFileID(FManager->getFile(OrgFilePath).get(), |
| 457 | clang::SrcMgr::C_User); |
| 458 | clang::Rewriter Rewrite(*SManager, clang::LangOptions()); |
| 459 | clang::tooling::applyAllReplacements(Replacements, Rewrite); |
| 460 | std::error_code EC; |
| 461 | llvm::raw_fd_ostream OutFile(OutFilePath, EC, llvm::sys::fs::F_None); |
| 462 | Rewrite.InsertTextBefore(SManager->getLocForStartOfFile(ID), Signature); |
| 463 | Rewrite.getEditBuffer(ID).write(OutFile); |
| 464 | } |
| 465 | |
| 466 | }; // end of namespace ftg |