aboutsummaryrefslogtreecommitdiffstats
path: root/m0
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--m0/makefile187
-rw-r--r--m0/mutator-lvl0.cpp (renamed from mutator-lvl0.cpp)0
-rw-r--r--m0/mutator-lvl0.h (renamed from mutator-lvl0.h)0
-rw-r--r--m0/mutator-lvl1.cpp (renamed from mutator-lvl1.cpp)0
-rw-r--r--m0/mutator-lvl2.cpp (renamed from mutator-lvl2.cpp)0
-rw-r--r--m0/mutator_aux.cpp (renamed from mutator_aux.cpp)11
-rw-r--r--m0/mutator_aux.h (renamed from mutator_aux.h)10
-rw-r--r--m0/mutator_report.cpp (renamed from mutator_report.cpp)4
-rw-r--r--m0/mutator_report.h (renamed from mutator_report.h)2
9 files changed, 195 insertions, 19 deletions
diff --git a/m0/makefile b/m0/makefile
new file mode 100644
index 0000000..f1f9cb2
--- /dev/null
+++ b/m0/makefile
@@ -0,0 +1,187 @@
+TARGET=mutator-lvl0
+SHELL=bash
+SHELL?=bash
+CC=clang
+CC?=clang
+CFLAGS=-fpic -std=c11
+CXX=clang++
+CXX?=clang++
+CXX_FLAGS=-fpic
+CXX_EXTRA?=
+CTAGS_I_PATH?=./
+LD_FLAGS=
+EXTRA_LD_FLAGS?=
+ADD_SANITIZERS_CC= -g -fsanitize=address -fno-omit-frame-pointer
+ADD_SANITIZERS_LD= -g -fsanitize=address
+MEM_SANITIZERS_CC= -g -fsanitize=memory -fno-omit-frame-pointer
+MEM_SANITIZERS_LD= -g -fsanitize=memory
+UB_SANITIZERS_CC= -g -fsanitize=undefined -fno-omit-frame-pointer
+UB_SANITIZERS_LD= -g -fsanitize=undefined
+COV_CXX= -fprofile-instr-generate -fcoverage-mapping
+COV_LD= -fprofile-instr-generate
+# BUILD_MODES are=RELEASE(default), DEBUG,ADDSAN,MEMSAN,UBSAN
+BUILD_MODE?=RELEASE
+OBJ_LIST:=$(patsubst %.cpp, %.o, $(wildcard *.cpp))
+ASM_LIST:=$(patsubst %.cpp, %.dis, $(wildcard *.cpp))
+
+LLVM_CONF?=llvm-config
+LLVM_CXX_FLAGS=$(shell $(LLVM_CONF) --cxxflags)
+LLVM_CXX_FLAGS+=-I$(shell $(LLVM_CONF) --src-root)/tools/clang/include\
+ -I$(shell $(LLVM_CONF) --obj-root)/tools/clang/include\
+ -stdlib=libstdc++ -std=c++17 -fexceptions
+LLVM_LD_FLAGS=-Wl,--start-group -lclangAST -lclangAnalysis -lclangBasic\
+ -lclangDriver -lclangEdit -lclangFrontend -lclangFrontendTool\
+ -lclangLex -lclangParse -lclangSema -lclangEdit -lclangASTMatchers\
+ -lclangRewrite -lclangRewriteFrontend -lclangStaticAnalyzerFrontend\
+ -lclangStaticAnalyzerCheckers -lclangStaticAnalyzerCore\
+ -lclangSerialization -lclangToolingCore -lclangTooling -lstdc++\
+ -lLLVMRuntimeDyld -lm -Wl,--end-group
+LLVM_LD_FLAGS+=$(shell $(LLVM_CONF) --ldflags --libs --system-libs)
+
+CXX_FLAGS+=$(LLVM_CXX_FLAGS)
+LD_FLAGS+=$(LLVM_LD_FLAGS)
+
+MAKEFLAGS+=--warn-undefined-variables
+ifeq ($(BUILD_MODE), ADDSAN)
+ifeq ($(CXX), g++)
+$(error This build mode is only useable with clang++.)
+endif
+CXX_EXTRA+=$(ADD_SANITIZERS_CC)
+EXTRA_LD_FLAGS+=$(ADD_SANITIZERS_LD)
+endif
+
+ifeq ($(BUILD_MODE), MEMSAN)
+ifeq ($(CXX), g++)
+$(error This build mode is only useable with clang++.)
+endif
+CXX_EXTRA+=$(MEM_SANITIZERS_CC)
+EXTRA_LD_FLAGS+=$(MEM_SANITIZERS_LD)
+endif
+
+ifeq ($(BUILD_MODE), UBSAN)
+ifeq ($(CXX), g++)
+$(error This build mode is only useable with clang++.)
+endif
+CXX_EXTRA+=$(UB_SANITIZERS_CC)
+EXTRA_LD_FLAGS+=$(UB_SANITIZERS_LD)
+endif
+
+SRCS:=$(wildcard *.cpp)
+CXX_FLAGS+=$(CXX_EXTRA)
+LD_FLAGS+=$(EXTRA_LD_FLAGS)
+
+.DEFAULT:all
+
+.PHONY:all clean help ASM SO TAGS
+
+all:$(TARGET)
+
+everything:$(TARGET) A ASM SO $(TARGET)-dbg TAGS $(TARGET)-cov
+
+depend:.depend
+
+.depend:$(SRCS)
+ rm -rf .depend
+ $(CXX) -MM $(CXX_FLAGS) $^ > ./.depend
+ echo $(patsubst %.o:, %.odbg:, $(shell $(CXX) -MM $(CXX_FLAGS) $^)) | sed -r 's/[A-Za-z0-9\_\-]+\.odbg/\n&/g' >> ./.depend
+ echo $(patsubst %.o:, %.ocov:, $(shell $(CXX) -MM $(CXX_FLAGS) $^)) | sed -r 's/[A-Za-z0-9\_\-]+\.ocov/\n&/g' >> ./.depend
+
+-include ./.depend
+
+../json/json.o:../json/json.hpp
+ $(MAKE) -C ../json json.o
+
+../json/json.odbg:../json/json.hpp
+ $(MAKE) -C ../json json.odbg
+
+../json/json.ocov:../json/json.hpp
+ $(MAKE) -C ../json json.ocov
+
+../tinyxml2/tinyxml2.o:../tinyxml2/tinyxml2.cpp
+ $(MAKE) -C ../tinyxml2 tinyxml2.o
+
+../tinyxml2/tinyxml2.odbg:../tinyxml2/tinyxml2.cpp
+ $(MAKE) -C ../tinyxml2 tinyxml2.odbg
+
+../tinyxml2/tinyxml2.ocov:../tinyxml2/tinyxml2.cpp
+ $(MAKE) -C ../tinyxml2 tinyxml2.ocov
+
+./keccak-tiny/.o:./keccak-tiny/.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+.cpp.o:
+ $(CXX) $(CXX_FLAGS) -c $< -o $@
+
+%.odbg:%.cpp
+ $(CXX) $(CXX_FLAGS) -g -c $< -o $@
+
+%.ocov:%.cpp
+ $(CXX) $(CXX_FLAGS) $(COV_CXX) -c $< -o $@
+
+$(TARGET): $(TARGET).o ../tinyxml2/tinyxml2.o ./mutator_aux.o ./mutator_report.o ../json/json.o
+ $(CXX) $^ $(LD_FLAGS) -o $@
+
+$(TARGET)-static: $(TARGET).o ../tinyxml2/tinyxml2.o ./mutator_aux.o ./mutator_report.o ../json/json.o
+ $(CXX) $^ $(LD_FLAGS) -static -o $@
+
+$(TARGET)-dbg: $(TARGET).odbg ../tinyxml2/tinyxml2.odbg ./mutator_aux.odbg ./mutator_report.odbg ../json/json.odbg
+ $(CXX) $^ $(LD_FLAGS) -g -o $@
+
+$(TARGET)-cov: $(TARGET).ocov ../tinyxml2/tinyxml2.ocov ./mutator_aux.ocov ./mutator_report.ocov ../json/json.ocov
+ $(CXX) $^ $(LD_FLAGS) $(COV_LD) -o $@
+
+cov:
+ @llvm-profdata merge -sparse ./default.profraw -o ./default.profdata
+ @llvm-cov show $(TARGET)-cov -instr-profile=default.profdata
+
+covrep:
+ @llvm-profdata merge -sparse ./default.profraw -o ./default.profdata
+ @llvm-cov report $(TARGET)-cov -instr-profile=default.profdata
+
+ASM:$(ASM_LIST)
+
+SO:$(TARGET).so
+
+A:$(TARGET).a
+
+TAGS:tags
+
+tags:$(SRCS)
+ $(shell $(CXX) -c $(shell $(LLVM_CONF) --cxxflags) -I$(shell $(LLVM_CONF) --src-root)/tools/clang/include -I$(shell $(LLVM_CONF) --obj-root)/tools/clang/include -I $(CTAGS_I_PATH) -M $(SRCS)|\
+ sed -e 's/[\\ ]/\n/g'|sed -e '/^$$/d' -e '/\.o:[ \t]*$$/d'|\
+ ctags -L - --c++-kinds=+p --fields=+iaS --extra=+q)
+
+%.dis: %.o
+ objdump -r -d -M intel -S $< > $@
+
+$(TARGET).so: $(TARGET).o ../tinyxml2/tinyxml2.o ./mutator_aux.o ./mutator_report.o ../json/json.o
+ $(CXX) $^ $(LD_FLAGS) -shared -o $@
+
+$(TARGET).a: $(TARGET).o ../tinyxml2/tinyxml2.o ./mutator_aux.o ./mutator_report.o ../json/json.o
+ ar rcs $(TARGET).a $(TARGET).o
+
+clean:
+ rm -f *.o *.dis *.odbg *.ocov *~ $(TARGET) $(TARGET).so $(TARGET)-static $(TARGET)-dbg $(TARGET).a $(TARGET)-cov ./keccak-tiny/*.o
+
+deepclean:
+ rm -f *.o *.dis *.odbg *.ocov *~ $(TARGET) $(TARGET).so tags $(TARGET)-static $(TARGET)-dbg $(TARGET).a $(TARGET)-cov FILE*.cpp FILE*.hpp ./keccak-tiny/*.o
+ rm .depend
+ $(MAKE) -C ../tinyxml2 clean
+ $(MAKE) -C ../json clean
+
+help:
+ @echo "--all is the default target, runs $(TARGET) target"
+ @echo "--everything will build everything"
+ @echo "--SO will generate the so"
+ @echo "--ASM will generate assembly files"
+ @echo "--TAGS will generate tags file"
+ @echo "--$(TARGET) builds the dynamically-linked executable"
+ @echo "--$(TARGET)-dbg will generate the debug build. BUILD_MODE should be set to DEBUG to work"
+ @echo "--$(TARGET)-static will statically link the executable to the libraries"
+ @echo "--$(TARGET)-cov is the coverage build"
+ @echo "--cov will print the line coverage report"
+ @echo "--covrep will print the coverage report"
+ @echo "--A will build the static library"
+ @echo "--TAGS will build the tags file"
+ @echo "--clean"
+ @echo "--deepclean will clean almost everything"
diff --git a/mutator-lvl0.cpp b/m0/mutator-lvl0.cpp
index 53b3ac5..53b3ac5 100644
--- a/mutator-lvl0.cpp
+++ b/m0/mutator-lvl0.cpp
diff --git a/mutator-lvl0.h b/m0/mutator-lvl0.h
index c1e452a..c1e452a 100644
--- a/mutator-lvl0.h
+++ b/m0/mutator-lvl0.h
diff --git a/mutator-lvl1.cpp b/m0/mutator-lvl1.cpp
index c6082f9..c6082f9 100644
--- a/mutator-lvl1.cpp
+++ b/m0/mutator-lvl1.cpp
diff --git a/mutator-lvl2.cpp b/m0/mutator-lvl2.cpp
index c585734..c585734 100644
--- a/mutator-lvl2.cpp
+++ b/m0/mutator-lvl2.cpp
diff --git a/mutator_aux.cpp b/m0/mutator_aux.cpp
index a382764..83211f5 100644
--- a/mutator_aux.cpp
+++ b/m0/mutator_aux.cpp
@@ -28,8 +28,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Rewrite/Core/Rewriter.h"
-#include "tinyxml2/tinyxml2.h"
-#include "json/json.hpp"
+#include "../tinyxml2/tinyxml2.h"
+#include "../json/json.hpp"
/*********************************************************************************************************************/
using namespace clang;
/*********************************************************************************************************************/
@@ -56,8 +56,7 @@ SourceLocation SourceLocationHasMacro [[deprecated("doesnt work")]] (SourceLocat
}
#endif
-SourceLocation SourceLocationHasMacro(SourceLocation __sl, Rewriter &__rewrite)
-{
+SourceLocation SourceLocationHasMacro(SourceLocation __sl, Rewriter &__rewrite) {
if (__sl.isMacroID()) {
return __rewrite.getSourceMgr().getSpellingLoc(__sl);
} else {
@@ -66,8 +65,8 @@ SourceLocation SourceLocationHasMacro(SourceLocation __sl, Rewriter &__rewrite)
}
SourceLocation getSLSpellingLoc(SourceLocation __sl, Rewriter &__rewrite) {
- if (__sl.isMacroID()) {return __rewrite.getSourceMgr().getSpellingLoc(__sl);}
- else {return __sl;}
+ if (__sl.isMacroID()) return __rewrite.getSourceMgr().getSpellingLoc(__sl);
+ else return __sl;
}
/*********************************************************************************************************************/
/*********************************************************************************************************************/
diff --git a/mutator_aux.h b/m0/mutator_aux.h
index 3670df8..9f22a5a 100644
--- a/mutator_aux.h
+++ b/m0/mutator_aux.h
@@ -41,31 +41,21 @@ using namespace clang;
/*********************************************************************************************************************/
namespace Devi {
enum class NodeKind {NoValue, VarDecl, FieldDecl, RecordDecl, LabelDecl, FunctionDecl, TypedefDecl, ParmVarDecl, EnumDecl, EnumConstDecl};
-
enum class Scope {NoValue, TU, Block};
-
enum class FunctionDeclKind {NoValue, Definition, Declaration};
/*********************************************************************************************************************/
SourceLocation SourceLocationHasMacro(SourceLocation SL, Rewriter &Rewrite, std::string Kind);
-
SourceLocation SourceLocationHasMacro(SourceLocation __sl, Rewriter &__rewrite);
-
SourceLocation getSLSpellingLoc(SourceLocation __sl, Rewriter &__rewrite);
/*********************************************************************************************************************/
bool IsTheMatchInSysHeader(bool SysHeaderFlag, const ast_matchers::MatchFinder::MatchResult &MR, SourceLocation SL);
-
bool IsTheMatchInSysHeader(bool SysHeaderFlag, const SourceManager &SM, SourceLocation SL);
-
bool IsTheMatchInSysHeader(bool SysHeaderFlag, bool SysHeader, SourceLocation SL);
-
bool IsTheMatchInSysHeader(bool SysHeaderFlag, bool SysHeader);
/*********************************************************************************************************************/
bool IsTheMatchInMainFile(bool MainFileFlag, const ast_matchers::MatchFinder::MatchResult &MR, SourceLocation SL);
-
bool IsTheMatchInMainFile(bool MainFileFlag, const SourceManager &SM, SourceLocation SL);
-
bool IsTheMatchInMainFile(bool MainFileFlag, bool MainFile, SourceLocation SL);
-
bool IsTheMatchInMainFile(bool MainFileFlag, bool MainFile);
/*********************************************************************************************************************/
/*end of namespace Devi*/
diff --git a/mutator_report.cpp b/m0/mutator_report.cpp
index 51fd342..1e0459f 100644
--- a/mutator_report.cpp
+++ b/m0/mutator_report.cpp
@@ -28,8 +28,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Rewrite/Core/Rewriter.h"
-#include "tinyxml2/tinyxml2.h"
-#include "json/json.hpp"
+#include "../tinyxml2/tinyxml2.h"
+#include "../json/json.hpp"
/*********************************************************************************************************************/
using namespace clang;
using namespace tinyxml2;
diff --git a/mutator_report.h b/m0/mutator_report.h
index ad3b843..0be06f6 100644
--- a/mutator_report.h
+++ b/m0/mutator_report.h
@@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Rewrite/Core/Rewriter.h"
-#include "tinyxml2/tinyxml2.h"
+#include "../tinyxml2/tinyxml2.h"
/*********************************************************************************************************************/
using namespace clang;
using namespace tinyxml2;