citrun

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

commit 176db5bc269d1a0803c38c8b0f253cab1b5b86c7
parent 1cb5919f28ba2338740a6ac011be2f24eaaae792
Author: Kyle Milz <kyle@0x30.net>
Date:   Thu, 12 Jan 2017 23:26:55 -0700

inst: use better class declaration style

Diffstat:
Minst_action.h | 34+++++++++++++++++-----------------
Minst_frontend.h | 18+++++++++---------
Minst_visitor.h | 30+++++++++++++++---------------
3 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/inst_action.h b/inst_action.h @@ -7,7 +7,16 @@ // For each source file provided to the tool, a new FrontendAction is created. -class InstrumentAction : public clang::ASTFrontendAction { +class InstrumentAction : public clang::ASTFrontendAction +{ + void write_modified_src(clang::FileID const &); + + clang::Rewriter m_TheRewriter; + RewriteASTConsumer *m_InstrumentASTConsumer; + InstrumentLogger& m_log; + bool m_is_citruninst; + std::string m_compiler_file_name; + public: InstrumentAction(InstrumentLogger &log, bool citruninst, std::string const &filename) : @@ -18,21 +27,18 @@ public: void EndSourceFileAction() override; std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance &, clang::StringRef) override; - -private: - void write_modified_src(clang::FileID const &); - - clang::Rewriter m_TheRewriter; - RewriteASTConsumer *m_InstrumentASTConsumer; - InstrumentLogger& m_log; - bool m_is_citruninst; - std::string m_compiler_file_name; }; // // Needed because we pass custom stuff down into the ASTFrontendAction // -class InstrumentActionFactory : public clang::tooling::FrontendActionFactory { +class InstrumentActionFactory : public clang::tooling::FrontendActionFactory +{ + InstrumentLogger& m_log; + bool m_is_citruninst; + std::vector<std::string> m_source_files; + int m_i; + public: InstrumentActionFactory(InstrumentLogger &log, bool citruninst, std::vector<std::string> const &src_files) : m_log(log), @@ -44,10 +50,4 @@ public: clang::ASTFrontendAction *create() { return new InstrumentAction(m_log, m_is_citruninst, m_source_files[m_i++]); } - -private: - InstrumentLogger& m_log; - bool m_is_citruninst; - std::vector<std::string> m_source_files; - int m_i; }; diff --git a/inst_frontend.h b/inst_frontend.h @@ -4,15 +4,8 @@ #include <map> #include <string> -class InstFrontend { -public: - InstFrontend(int, char *argv[], bool); - - void process_cmdline(); - void instrument(); - void compile_instrumented(); - -private: +class InstFrontend +{ void log_identity(); void clean_PATH(); void save_if_srcfile(char *); @@ -29,4 +22,11 @@ private: std::chrono::high_resolution_clock::time_point m_start_time; std::vector<std::string> m_source_files; std::map<std::string, std::string> m_temp_file_map; + +public: + InstFrontend(int, char *argv[], bool); + + void process_cmdline(); + void instrument(); + void compile_instrumented(); }; diff --git a/inst_visitor.h b/inst_visitor.h @@ -18,9 +18,20 @@ enum counters { NCOUNTERS }; -class RewriteASTVisitor : public clang::RecursiveASTVisitor<RewriteASTVisitor> { +class RewriteASTVisitor : public clang::RecursiveASTVisitor<RewriteASTVisitor> +{ + bool modify_stmt(clang::Stmt *, int &); + clang::SourceLocation real_loc_end(clang::Stmt *); + + clang::Rewriter &m_TheRewriter; + clang::SourceManager &m_SM; + clang::LangOptions m_lopt; + public: explicit RewriteASTVisitor(clang::Rewriter &R) : + m_TheRewriter(R), + m_SM(R.getSourceMgr()), + m_lopt(R.getLangOpts()), m_counters(), m_counter_descr({ "Function definitions", @@ -34,10 +45,7 @@ public: "Total statements", "Binary operators", "Errors rewriting source code" - }), - m_TheRewriter(R), - m_SM(R.getSourceMgr()), - m_lopt(R.getLangOpts()) + }) {} virtual bool TraverseStmt(clang::Stmt *); @@ -58,18 +66,12 @@ public: std::array<int, NCOUNTERS> m_counters; std::array<std::string, NCOUNTERS> m_counter_descr; - -private: - bool modify_stmt(clang::Stmt *, int &); - clang::SourceLocation real_loc_end(clang::Stmt *); - - clang::Rewriter &m_TheRewriter; - clang::SourceManager &m_SM; - clang::LangOptions m_lopt; }; class RewriteASTConsumer : public clang::ASTConsumer { + RewriteASTVisitor Visitor; + public: explicit RewriteASTConsumer(clang::Rewriter &R) : Visitor(R) {} @@ -85,6 +87,4 @@ public: } RewriteASTVisitor& get_visitor() { return Visitor; }; -private: - RewriteASTVisitor Visitor; };