diff options
author | bloodstalker <thabogre@gmail.com> | 2017-04-24 17:05:36 +0000 |
---|---|---|
committer | bloodstalker <thabogre@gmail.com> | 2017-04-24 17:05:36 +0000 |
commit | 06dc0dca3d915f6bb4cc226a4c3c8dd166ea1f24 (patch) | |
tree | a1d76456e10f0d85f932a5126537337481e4cd7c /bruiser/bruiser.cpp | |
parent | Merge branch 'master' of https://github.com/bloodstalker/mutator (diff) | |
download | mutator-06dc0dca3d915f6bb4cc226a4c3c8dd166ea1f24.tar.gz mutator-06dc0dca3d915f6bb4cc226a4c3c8dd166ea1f24.zip |
some fixes
Diffstat (limited to '')
-rw-r--r-- | bruiser/bruiser.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/bruiser/bruiser.cpp b/bruiser/bruiser.cpp index 44a2084..3df89ea 100644 --- a/bruiser/bruiser.cpp +++ b/bruiser/bruiser.cpp @@ -51,6 +51,7 @@ using namespace clang::tooling; static llvm::cl::OptionCategory BruiserCategory("Empty"); bruiser::M0_ERR m0_err; +bruiser::BruiserReport BruiseRep; /**********************************************************************************************************************/ cl::opt<bool> Intrusive("intrusive", cl::desc("If set true. bruiser will mutate the source."), cl::init(true), cl::cat(BruiserCategory), cl::ZeroOrMore); cl::opt<std::string> M0XMLPath("xmlpath", cl::desc("tells bruiser where to find the XML file containing the Mutator-LVL0 report."), cl::init(bruiser::M0REP), cl::cat(BruiserCategory), cl::ZeroOrMore); @@ -66,9 +67,17 @@ bruiser::BruiserReport::~BruiserReport() BruiserLog.close(); } -bool bruiser::BruiserReport::PrintToLog(std::string __in_arg) +template <typename T> +/** + * @brief Will print the argument in the log file. Expects to receive valid types usable for a stream. + * + * @param __arg + * + * @return Returns true if the write was successful, false otherwise. + */ +bool bruiser::BruiserReport::PrintToLog(T __arg) { - BruiserLog << __in_arg << "\n"; + BruiserLog << __arg << "\n"; return !BruiserLog.bad(); } /**********************************************************************************************************************/ @@ -105,6 +114,8 @@ class MatcherHandlerLVL0 : public AbstractMatcherHandler public: explicit MatcherHandlerLVL0 (Rewriter &Rewrite) : AbstractMatcherHandler(Rewrite) {} + virtual ~MatcherHandlerLVL0() {} + virtual void run(const MatchFinder::MatchResult &MR) override { @@ -248,7 +259,7 @@ public: /*@DEVI-obviously the best way to do this is to use the main signature already used, instead of going with a general predefined one. the current form is a temp.*/ Rewrite.InsertTextAfter(SLE.getLocWithOffset(1U), StringRef("\n\nint main(int argc, const char **argv)\n{\n\treturn sub_main(argc, argv);\n}\n")); - //ruiseRep << "changed main main's name.\n" + //BruiseRep.PrintToLog("hijacked main main."); } } @@ -305,9 +316,11 @@ int main(int argc, const char **argv) CommonOptionsParser op(argc, argv, BruiserCategory); ClangTool Tool(op.getCompilations(), op.getSourcePathList()); - bruiser::BruiserReport BruiseRep; + int RunResult = Tool.run(newFrontendActionFactory<BruiserFrontendAction>().get()); + + BruiseRep.PrintToLog(RunResult); - return Tool.run(newFrontendActionFactory<BruiserFrontendAction>().get()); + return RunResult; } /*last line interntionally left blank.*/ |