aboutsummaryrefslogtreecommitdiffstats
path: root/bruiser
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2017-04-15 12:58:19 +0000
committerbloodstalker <thabogre@gmail.com>2017-04-15 12:58:19 +0000
commitbd32ac31d865e8822e4579695fee8d1084424910 (patch)
tree5d4993c8c0a790ea56d963e985307755499b524d /bruiser
parentadded some more experimental stuff. right now bruiser can only hijack the main. (diff)
downloadmutator-bd32ac31d865e8822e4579695fee8d1084424910.tar.gz
mutator-bd32ac31d865e8822e4579695fee8d1084424910.zip
added a new class to read the xml report created by M0.
Diffstat (limited to 'bruiser')
-rw-r--r--bruiser/bruiser.cpp22
1 files 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<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("./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<clang::BinaryOperator>("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<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef file) override
{
TheRewriter.setSourceMgr(CI.getSourceManager(), CI.getLangOpts());
- return llvm::make_unique<MyASTConsumer>(TheRewriter);
+ return llvm::make_unique<BruiserASTConsumer>(TheRewriter);
}
private:
@@ -297,7 +305,7 @@ int main(int argc, const char **argv)
bruiser::BruiserReport BruiseRep;
- return Tool.run(newFrontendActionFactory<MyFrontendAction>().get());
+ return Tool.run(newFrontendActionFactory<BruiserFrontendAction>().get());
}
/*last line interntionally left blank.*/