From bd32ac31d865e8822e4579695fee8d1084424910 Mon Sep 17 00:00:00 2001 From: bloodstalker Date: Sat, 15 Apr 2017 17:28:19 +0430 Subject: added a new class to read the xml report created by M0. --- bruiser/bruiser.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/bruiser/bruiser.cpp b/bruiser/bruiser.cpp index 439605b..1847b0d 100644 --- a/bruiser/bruiser.cpp +++ b/bruiser/bruiser.cpp @@ -50,6 +50,9 @@ using namespace clang::tooling; /*global vars*/ static llvm::cl::OptionCategory BruiserCategory("Empty"); /**********************************************************************************************************************/ +cl::opt Intrusive("intrusive", cl::desc("If set true. bruiser will mutate the source."), cl::init(true), cl::cat(BruiserCategory), cl::ZeroOrMore); +cl::opt M0XMLPath("xmlpath", cl::desc("tells bruiser where to find the XML file containing the Mutator-LVL0 report."), cl::init("./test/misrareport.xml"), cl::cat(BruiserCategory), cl::ZeroOrMore); +/**********************************************************************************************************************/ /*the implementation of the bruiser logger.*/ bruiser::BruiserReport::BruiserReport () { @@ -175,6 +178,10 @@ class IfBreaker : public MatchFinder::MatchCallback const clang::Type* CTP = TIProto.getTypeInfo(MR.Context); + NameFinder::runDeclRefExprMatcher DRENameMatcher(Rewrite); + + DRENameMatcher.runMatcher(StringRef(), *MR.Context); + } if (MR.Nodes.getNodeAs("dous") != nullptr) @@ -236,7 +243,8 @@ public: Rewrite.ReplaceText(SL.getLocWithOffset(mainbegin), 4U, __sr); - Rewrite.InsertTextAfter(SLE.getLocWithOffset(1U), StringRef("\n\nint main(int argc, const char **argv)\n{\n\tsub_main(argc, argv);\n}")); + /*@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" } @@ -248,10 +256,10 @@ public: /**********************************************************************************************************************/ /**********************************************************************************************************************/ /**********************************************************************************************************************/ -class MyASTConsumer : public ASTConsumer { +class BruiserASTConsumer : public ASTConsumer { public: - MyASTConsumer(Rewriter &R) : HIfBreaker(R), HMainWrapper(R) + BruiserASTConsumer(Rewriter &R) : HIfBreaker(R), HMainWrapper(R) {} void HandleTranslationUnit(ASTContext &Context) override @@ -270,10 +278,10 @@ private: Rewriter R; }; /**********************************************************************************************************************/ -class MyFrontendAction : public ASTFrontendAction +class BruiserFrontendAction : public ASTFrontendAction { public: - MyFrontendAction() {} + BruiserFrontendAction() {} void EndSourceFileAction() override { TheRewriter.getEditBuffer(TheRewriter.getSourceMgr().getMainFileID()).write(llvm::outs()); @@ -282,7 +290,7 @@ public: std::unique_ptr CreateASTConsumer(CompilerInstance &CI, StringRef file) override { TheRewriter.setSourceMgr(CI.getSourceManager(), CI.getLangOpts()); - return llvm::make_unique(TheRewriter); + return llvm::make_unique(TheRewriter); } private: @@ -297,7 +305,7 @@ int main(int argc, const char **argv) bruiser::BruiserReport BruiseRep; - return Tool.run(newFrontendActionFactory().get()); + return Tool.run(newFrontendActionFactory().get()); } /*last line interntionally left blank.*/ -- cgit v1.2.3