aboutsummaryrefslogtreecommitdiffstats
path: root/bruiser
diff options
context:
space:
mode:
Diffstat (limited to 'bruiser')
-rw-r--r--bruiser/bruiser.cpp94
-rw-r--r--bruiser/bruiser.h35
-rw-r--r--bruiser/makefile29
3 files changed, 158 insertions, 0 deletions
diff --git a/bruiser/bruiser.cpp b/bruiser/bruiser.cpp
new file mode 100644
index 0000000..a7df7ca
--- /dev/null
+++ b/bruiser/bruiser.cpp
@@ -0,0 +1,94 @@
+
+/***************************************************Project Mutator****************************************************/
+//-*-c++-*-
+/*first line intentionally left blank.*/
+/*the source code for the mutator code breaker.*/
+/*Copyright (C) 2017 Farzad Sadeghi
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*/
+/**********************************************************************************************************************/
+/*included modules*/
+/*project headers*/
+#include "bruiser.h"
+#include "../mutator_aux.h"
+/*standard headers*/
+#include <string>
+#include <iostream>
+#include <cassert>
+/*LLVM headers*/
+#include "clang/AST/AST.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/Tooling.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/IR/Function.h"
+/**********************************************************************************************************************/
+/*used namespaces*/
+using namespace llvm;
+using namespace clang;
+using namespace clang::ast_matchers;
+using namespace clang::driver;
+using namespace clang::tooling;
+/**********************************************************************************************************************/
+/*global vars*/
+
+static llvm::cl::OptionCategory BruiserCategory("Empty");
+/**********************************************************************************************************************/
+/**********************************************************************************************************************/
+/**********************************************************************************************************************/
+class MyASTConsumer : public ASTConsumer {
+
+public:
+ MyASTConsumer(Rewriter &R) {}
+
+ void HandleTranslationUnit(ASTContext &Context) override {
+ Matcher.matchAST(Context);
+ }
+
+private:
+ MatchFinder Matcher;
+};
+/**********************************************************************************************************************/
+class MyFrontendAction : public ASTFrontendAction {
+public:
+ MyFrontendAction() {}
+ void EndSourceFileAction() override {
+ TheRewriter.getEditBuffer(TheRewriter.getSourceMgr().getMainFileID()).write(llvm::outs());
+ }
+
+ std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef file) override {
+ TheRewriter.setSourceMgr(CI.getSourceManager(), CI.getLangOpts());
+ return llvm::make_unique<MyASTConsumer>(TheRewriter);
+ }
+
+private:
+ Rewriter TheRewriter;
+};
+/**********************************************************************************************************************/
+/*Main*/
+int main(int argc, const char **argv) {
+ CommonOptionsParser op(argc, argv, BruiserCategory);
+ ClangTool Tool(op.getCompilations(), op.getSourcePathList());
+
+ return Tool.run(newFrontendActionFactory<MyFrontendAction>().get());
+}
+/*last line interntionally left blank.*/
+
diff --git a/bruiser/bruiser.h b/bruiser/bruiser.h
new file mode 100644
index 0000000..cf22e5e
--- /dev/null
+++ b/bruiser/bruiser.h
@@ -0,0 +1,35 @@
+
+/***************************************************Project Mutator****************************************************/
+//-*-c++-*-
+/*first line intentionally left blank.*/
+/*the header for mutator's code breaker.*/
+/*Copyright (C) 2017 Farzad Sadeghi
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*/
+/*code structure inspired by Eli Bendersky's tutorial on Rewriters.*/
+/**********************************************************************************************************************/
+/*inclusion guard*/
+#ifndef BRUISER_H
+#define BRUISER_H
+/**********************************************************************************************************************/
+/*included modules*/
+/*project headers*/
+/*standard library headers*/
+/**********************************************************************************************************************/
+/*externals*/
+/**********************************************************************************************************************/
+#endif
+/*last line intentionally left balnk.*/
+
diff --git a/bruiser/makefile b/bruiser/makefile
new file mode 100644
index 0000000..561da73
--- /dev/null
+++ b/bruiser/makefile
@@ -0,0 +1,29 @@
+
+######################################INCLUDES#################################
+include ../macros.mk
+
+#######################################VARS####################################
+CXX_FLAGS+=
+BRUISER=bruiser
+
+######################################RULES####################################
+.DEFAULT: all
+
+.PHONY: all clean help $(BRUISER)
+
+all: $(BRUISER)
+
+.cpp.o:
+ $(CXX) $(CXX_FLAGS) -c $< -o $@
+
+$(BRUISER): $(BRUISER).o ../mutator_aux.o
+ $(CXX) $^ $(LD_FLAGS) -o $@
+
+clean:
+ rm -f *.o *~ $(BRUISER)
+
+help:
+ @echo 'There is help.'
+ @echo 'All is the defualt target.'
+ @echo 'Clean runs clean.'
+ @echo 'For a more complete and detaild list of BUILD_MODE and other things look at the main makefiles help under project root.'