citrun

watch C/C++ source code execute
Log | Files | Refs | LICENSE

commit 9c8e9948985117fdd8ec77afd250b650ac92b6f2
parent 18d45cf3d4d55c04dcc21ccee4e8854e9d8beb47
Author: Kyle Milz <kyle@0x30.net>
Date:   Fri, 30 Dec 2016 23:19:40 -0700

src: don't append .citrun and write preamble elsewhere

Diffstat:
Msrc/inst_action.cc | 11+++++------
1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/inst_action.cc b/src/inst_action.cc @@ -40,11 +40,6 @@ InstrumentAction::write_modified_src(clang::FileID const &fid) { std::string out_file(getCurrentFile()); - if (m_is_citruninst) { - out_file += ".citrun"; - m_log << "Writing modified source to '" << out_file << "'" << std::endl; - } - std::error_code ec; llvm::raw_fd_ostream output(out_file, ec, llvm::sys::fs::F_None); if (ec.value()) { @@ -92,7 +87,11 @@ InstrumentAction::EndSourceFileAction() << "#endif\n"; clang::SourceLocation start = sm.getLocForStartOfFile(main_fid); - if (m_TheRewriter.InsertTextAfter(start, preamble.str())) { + if (m_is_citruninst) { + std::ofstream preamble_file(getCurrentFile().str() + ".preamble"); + preamble_file << preamble.str(); + preamble_file.close(); + } else if (m_TheRewriter.InsertTextAfter(start, preamble.str())) { m_log << "Failed to insert the instrumentation preabmle."; return; }