citrun

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

commit b057b9bf2dcce97639f24af3c20612a52c8d51bc
parent 94bfdee51ea0f2fd2d13c43f2c4fb5dd3df36c16
Author: Kyle Milz <kyle@0x30.net>
Date:   Fri, 12 Aug 2016 00:29:08 -0600

src: remove namespace std from inst_action

Diffstat:
Msrc/inst_action.cc | 59+++++++++++++++++++++++++++++------------------------------
Msrc/inst_action.h | 3++-
2 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/src/inst_action.cc b/src/inst_action.cc @@ -13,18 +13,17 @@ // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // +#include "inst_action.h" +#include "runtime_h.h" + #include <clang/Frontend/CompilerInstance.h> #include <err.h> #include <fstream> #include <sstream> #include <string> -#include "inst_action.h" -#include "runtime_h.h" - -using namespace std; -unique_ptr<clang::ASTConsumer> +std::unique_ptr<clang::ASTConsumer> InstrumentAction::CreateASTConsumer(clang::CompilerInstance &CI, clang::StringRef file) { // llvm::errs() << "** Creating AST consumer for: " << file << "\n"; @@ -33,13 +32,13 @@ InstrumentAction::CreateASTConsumer(clang::CompilerInstance &CI, clang::StringRe // Hang onto a reference to this so we can read from it later m_InstrumentASTConsumer = new RewriteASTConsumer(m_TheRewriter); - return unique_ptr<clang::ASTConsumer>(m_InstrumentASTConsumer); + return std::unique_ptr<clang::ASTConsumer>(m_InstrumentASTConsumer); } void InstrumentAction::write_modified_src(clang::FileID const &fid) { - string out_file(getCurrentFile()); + std::string out_file(getCurrentFile()); if (m_is_citruninst) { out_file += ".citrun"; @@ -47,7 +46,7 @@ InstrumentAction::write_modified_src(clang::FileID const &fid) << out_file << "'.\n"; } - error_code ec; + std::error_code ec; llvm::raw_fd_ostream output(out_file, ec, llvm::sys::fs::F_None); if (ec.value()) { *m_log << m_pfx << "Error writing modified source: " @@ -71,7 +70,7 @@ InstrumentAction::EndSourceFileAction() clang::SourceLocation end = sm.getLocForEndOfFile(main_fid); unsigned int num_lines = sm.getPresumedLineNumber(end); - string const file_name = getCurrentFile(); + std::string const file_name = getCurrentFile(); // // Write instrumentation preamble. Includes: @@ -79,27 +78,27 @@ InstrumentAction::EndSourceFileAction() // - per tu citrun_node // - static constructor for runtime initialization // - ostringstream preamble; - preamble << "#ifdef __cplusplus" << endl - << "extern \"C\" {" << endl - << "#endif" << endl; - preamble << runtime_h << endl; - preamble << "static uint64_t _citrun_lines[" << num_lines << "];" << endl; - preamble << "static struct citrun_node _citrun_node = {" << endl - << " _citrun_lines," << endl - << " " << num_lines << "," << endl - << " \"" << m_compiler_file_name << "\"," << endl - << " \"" << file_name << "\"," << endl; - preamble << "};" << endl; - preamble << "__attribute__((constructor))" << endl - << "static void citrun_constructor() {" << endl - << " citrun_node_add(citrun_major, citrun_minor, &_citrun_node);" << endl - << "}" << endl; - preamble << "#ifdef __cplusplus" << endl - << "}" << endl - << "#endif" << endl; - - string header = preamble.str(); + std::ostringstream preamble; + preamble << "#ifdef __cplusplus\n" + << "extern \"C\" {\n" + << "#endif\n"; + preamble << runtime_h << "\n"; + preamble << "static uint64_t _citrun_lines[" << num_lines << "];\n"; + preamble << "static struct citrun_node _citrun_node = {\n" + << " _citrun_lines,\n" + << " " << num_lines << ",\n" + << " \"" << m_compiler_file_name << "\",\n" + << " \"" << file_name << "\",\n"; + preamble << "};\n"; + preamble << "__attribute__((constructor))\n" + << "static void citrun_constructor() {\n" + << " citrun_node_add(citrun_major, citrun_minor, &_citrun_node);\n" + << "}\n"; + preamble << "#ifdef __cplusplus\n" + << "}\n" + << "#endif\n"; + + std::string header = preamble.str(); unsigned header_sz = count(header.begin(), header.end(), '\n'); if (!m_is_citruninst && m_TheRewriter.InsertTextAfter(start, header)) { diff --git a/src/inst_action.h b/src/inst_action.h @@ -1,9 +1,10 @@ +#include "inst_visitor.h" + #include <clang/AST/ASTConsumer.h> #include <clang/Frontend/FrontendActions.h> #include <clang/Rewrite/Core/Rewriter.h> #include <clang/Tooling/Tooling.h> -#include "inst_visitor.h" class RewriteASTConsumer : public clang::ASTConsumer { public: