aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bruiser/bruiser.cpp494
-rw-r--r--bruiser/bruiser.h53
-rw-r--r--bruiser/lua-scripts/wasmtest.lua1
-rw-r--r--m0/mutator-lvl0.cpp483
-rw-r--r--m0/mutator-lvl0.h4
-rw-r--r--m0/mutator_aux.cpp37
-rw-r--r--m0/mutator_aux.h2
-rw-r--r--m0/mutator_report.cpp11
-rw-r--r--m0/mutator_report.h4
-rwxr-xr-xm0/run.sh1
10 files changed, 293 insertions, 797 deletions
diff --git a/bruiser/bruiser.cpp b/bruiser/bruiser.cpp
index 54b632e..ae6db23 100644
--- a/bruiser/bruiser.cpp
+++ b/bruiser/bruiser.cpp
@@ -618,13 +618,11 @@ class CompilationDatabaseProcessor {
};
/**********************************************************************************************************************/
/*the implementation of the bruiser logger.*/
-bruiser::BruiserReport::BruiserReport ()
-{
+bruiser::BruiserReport::BruiserReport () {
BruiserLog.open("bruiser.log");
}
-bruiser::BruiserReport::~BruiserReport()
-{
+bruiser::BruiserReport::~BruiserReport() {
BruiserLog.close();
}
@@ -636,8 +634,7 @@ bruiser::BruiserReport::~BruiserReport()
* @return Returns true if the write was successful, false otherwise.
*/
template <typename T>
-bool bruiser::BruiserReport::PrintToLog(T __arg)
-{
+bool bruiser::BruiserReport::PrintToLog(T __arg) {
BruiserLog << __arg << "\n";
return !BruiserLog.bad();
}
@@ -646,184 +643,42 @@ bruiser::TypeInfo::TypeInfo(const clang::ast_type_traits::DynTypedNode* __dtn) :
bruiser::TypeInfo::~TypeInfo() {};
-const clang::Type* bruiser::TypeInfo::getTypeInfo(clang::ASTContext* __astc)
-{
+const clang::Type* bruiser::TypeInfo::getTypeInfo(clang::ASTContext* __astc) {
const clang::Expr* EXP = DTN->get<clang::Expr>();
-
const clang::Type* TP = EXP->getType().getTypePtr();
-
return __astc->getCanonicalType(TP);
}
/**********************************************************************************************************************/
-class AbstractMatcherHandler : public virtual MatchFinder::MatchCallback
-{
- public:
- AbstractMatcherHandler (Rewriter &Rewrite) : R(Rewrite) {}
-
- public:
- virtual void run(const MatchFinder::MatchResult &MR)
- {
-
- }
-
- private:
- Rewriter &R [[maybe_unused]];
-};
-/**********************************************************************************************************************/
-class MatcherHandlerLVL0 : public AbstractMatcherHandler
-{
- public:
- explicit MatcherHandlerLVL0 (Rewriter &Rewrite) : AbstractMatcherHandler(Rewrite) {}
-
- virtual ~MatcherHandlerLVL0() {}
-
- virtual void run(const MatchFinder::MatchResult &MR) override
- {
-
- }
-
- private:
-};
-/**********************************************************************************************************************/
-class NameFinder
-{
- public:
- NameFinder () {}
-
- class runDeclRefExprMatcher
- {
- public:
- runDeclRefExprMatcher (Rewriter &__rwrt) : LVL0Proto(__rwrt), __rwrt(__rwrt) {}
-
- virtual void runMatcher(const StringRef __sr, ASTContext &__ctx)
- {
- Matcher.addMatcher(declRefExpr(to(namedDecl(hasName(__sr.str())))).bind("declrefexpbyname"), &LVL0Proto);
- Matcher.matchAST(__ctx);
- }
-
- private:
- MatchFinder Matcher;
- MatcherHandlerLVL0 LVL0Proto;
- Rewriter __rwrt;
- StringRef __sr;
- };
-
- class runNamedDeclMatcher
- {
- public:
- runNamedDeclMatcher (Rewriter &__rwrt) : LVL0Proto(__rwrt), __rwrt(__rwrt) {}
-
- virtual void runMatcher(const StringRef __sr, ASTContext &__ctx)
- {
- Matcher.addMatcher(declRefExpr(to(namedDecl(hasName(__sr.str())))).bind("nameddeclbyname"), &LVL0Proto);
- Matcher.matchAST(__ctx);
- }
-
- private:
- MatchFinder Matcher;
- MatcherHandlerLVL0 LVL0Proto;
- Rewriter __rwrt;
- StringRef __sr;
- };
-
- private:
-};
-/**********************************************************************************************************************/
-/**********************************************************************************************************************/
-/**********************************************************************************************************************/
-class IfBreaker : public MatchFinder::MatchCallback
-{
- public:
- IfBreaker (Rewriter &Rewrite) : Rewrite(Rewrite) {}
-
- virtual void run(const MatchFinder::MatchResult &MR)
- {
- if (MR.Nodes.getNodeAs<clang::UnaryOperator>("uno") != nullptr)
- {
- const clang::UnaryOperator* UO = MR.Nodes.getNodeAs<clang::UnaryOperator>("uno");
-
- SourceLocation SL = UO->getLocStart();
- CheckSLValidity(SL);
- SL = Devi::SourceLocationHasMacro(SL, Rewrite);
-
- const Expr* EXP = UO->getSubExpr();
- const ast_type_traits::DynTypedNode DynNode = ast_type_traits::DynTypedNode::create<clang::Expr>(*EXP);
- bruiser::TypeInfo TIProto(&DynNode);
-
- const clang::Type* CTP [[maybe_unused]] = TIProto.getTypeInfo(MR.Context);
-
- NameFinder::runDeclRefExprMatcher DRENameMatcher(Rewrite);
-
- DRENameMatcher.runMatcher(StringRef(), *MR.Context);
- }
-
- if (MR.Nodes.getNodeAs<clang::BinaryOperator>("dous") != nullptr)
- {
- const clang::BinaryOperator* BO = MR.Nodes.getNodeAs<clang::BinaryOperator>("dous");
-
- SourceLocation SL = BO->getLocStart();
- CheckSLValidity(SL);
- SL = Devi::SourceLocationHasMacro(SL, Rewrite);
-
- const Expr* LHS = BO->getLHS();
- const Expr* RHS = BO->getRHS();
-
- QualType LQT = LHS->getType();
- QualType RQT = RHS->getType();
-
- const clang::Type* LTP = LQT.getTypePtr();
- const clang::Type* RTP = RQT.getTypePtr();
-
- const clang::Type* CLTP [[maybe_unused]] = MR.Context->getCanonicalType(LTP);
- const clang::Type* CRTP [[maybe_unused]] = MR.Context->getCanonicalType(RTP);
- }
- }
-
- private:
- Rewriter &Rewrite;
- MatchFinder Matcher;
-};
/**********************************************************************************************************************/
/**
* @brief Hijacks the main main and replaces it with bruiser's main.
*/
-class MainWrapper : public MatchFinder::MatchCallback
-{
+class MainWrapper : public MatchFinder::MatchCallback {
public:
MainWrapper (Rewriter &Rewrite) : Rewrite(Rewrite) {}
- virtual void run(const MatchFinder::MatchResult &MR)
- {
- if (MR.Nodes.getNodeAs<clang::FunctionDecl>("mainwrapper") != nullptr)
- {
+ virtual void run(const MatchFinder::MatchResult &MR) {
+ if (MR.Nodes.getNodeAs<clang::FunctionDecl>("mainwrapper") != nullptr) {
const FunctionDecl* FD = MR.Nodes.getNodeAs<clang::FunctionDecl>("mainwrapper");
SourceLocation SL = FD->getLocStart();
CheckSLValidity(SL);
SL = Devi::SourceLocationHasMacro(SL, Rewrite);
-
SourceLocation SLE = FD->getLocEnd();
CheckSLValidity(SLE);
SLE = Devi::SourceLocationHasMacro(SLE, Rewrite);
- if (!Devi::IsTheMatchInMainFile(MainFileOnly, MR, SL) || Devi::IsTheMatchInSysHeader(CheckSystemHeader, MR, SL))
- {
+ if (!Devi::IsTheMatchInMainFile(MainFileOnly, MR, SL) || Devi::IsTheMatchInSysHeader(CheckSystemHeader, MR, SL)) {
return void();
}
SourceRange SR(SL, SLE);
-
std::string MainSig = Rewrite.getRewrittenText(SR);
-
size_t mainbegin = MainSig.find("main");
-
StringRef __sr("sub_main");
-
Rewrite.ReplaceText(SL.getLocWithOffset(mainbegin), 4U, __sr);
-
/*@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"));
-
//BruiseRep.PrintToLog("hijacked main main.");
}
}
@@ -832,36 +687,29 @@ public:
Rewriter &Rewrite;
};
/**********************************************************************************************************************/
-class LiveListFuncs : public MatchFinder::MatchCallback
-{
+class LiveListFuncs : public MatchFinder::MatchCallback {
public:
LiveListFuncs (Rewriter &R) : R(R) {}
- virtual void run(const MatchFinder::MatchResult &MR)
- {
- if (MR.Nodes.getNodeAs<clang::FunctionDecl>("livelistfuncs") != nullptr)
- {
+ virtual void run(const MatchFinder::MatchResult &MR) {
+ if (MR.Nodes.getNodeAs<clang::FunctionDecl>("livelistfuncs") != nullptr) {
const clang::FunctionDecl* FD = MR.Nodes.getNodeAs<clang::FunctionDecl>("livelistfuncs");
SourceLocation SL = FD->getLocStart();
CheckSLValidity(SL);
SL = Devi::SourceLocationHasMacro(SL, R);
- if (!Devi::IsTheMatchInMainFile(MainFileOnly, MR, SL) || Devi::IsTheMatchInSysHeader(CheckSystemHeader, MR, SL))
- {
+ if (!Devi::IsTheMatchInMainFile(MainFileOnly, MR, SL) || Devi::IsTheMatchInSysHeader(CheckSystemHeader, MR, SL)) {
return void();
}
- if (FD->hasBody())
- {
+ if (FD->hasBody()) {
Stmt* Body = FD->getBody();
SourceLocation SLBody = Body->getLocStart();
SourceLocation SLShebang = FD->getLocStart();
PRINT_WITH_COLOR_LB(CYAN, R.getRewrittenText(clang::SourceRange(SLShebang, SLBody.getLocWithOffset(-1))).c_str());
PushToLua.push_back(R.getRewrittenText(clang::SourceRange(SLShebang, SLBody.getLocWithOffset(-1))));
- }
- else
- {
+ } else {
SourceLocation SL = FD->getLocStart();
SourceLocation SLE = FD->getLocEnd();
PRINT_WITH_COLOR_LB(CYAN, R.getRewrittenText(clang::SourceRange(SL, SLE)).c_str());
@@ -874,23 +722,19 @@ class LiveListFuncs : public MatchFinder::MatchCallback
Rewriter R;
};
/**********************************************************************************************************************/
-class LiveListVars : public MatchFinder::MatchCallback
-{
+class LiveListVars : public MatchFinder::MatchCallback {
public:
LiveListVars (Rewriter &R) : R(R) {}
- virtual void run(const MatchFinder::MatchResult &MR)
- {
- if (MR.Nodes.getNodeAs<clang::VarDecl>("livelistvars") != nullptr)
- {
+ virtual void run(const MatchFinder::MatchResult &MR) {
+ if (MR.Nodes.getNodeAs<clang::VarDecl>("livelistvars") != nullptr) {
const clang::VarDecl* VD = MR.Nodes.getNodeAs<clang::VarDecl>("livelistvars");
SourceLocation SL = VD->getLocStart();
CheckSLValidity(SL);
SL = Devi::SourceLocationHasMacro(SL, R);
- if (!Devi::IsTheMatchInMainFile(MainFileOnly, MR, SL) || Devi::IsTheMatchInSysHeader(CheckSystemHeader, MR, SL))
- {
+ if (!Devi::IsTheMatchInMainFile(MainFileOnly, MR, SL) || Devi::IsTheMatchInSysHeader(CheckSystemHeader, MR, SL)) {
return void();
}
@@ -903,15 +747,12 @@ class LiveListVars : public MatchFinder::MatchCallback
Rewriter R;
};
/**********************************************************************************************************************/
-class LiveListRecords : public MatchFinder::MatchCallback
-{
+class LiveListRecords : public MatchFinder::MatchCallback {
public:
LiveListRecords (Rewriter &R) : R(R) {}
- virtual void run(const MatchFinder::MatchResult &MR)
- {
- if (MR.Nodes.getNodeAs<clang::RecordDecl>("livelistvars") != nullptr)
- {
+ virtual void run(const MatchFinder::MatchResult &MR) {
+ if (MR.Nodes.getNodeAs<clang::RecordDecl>("livelistvars") != nullptr) {
const clang::RecordDecl* RD = MR.Nodes.getNodeAs<clang::RecordDecl>("livelistvars");
PRINT_WITH_COLOR_LB(CYAN, R.getRewrittenText(SourceRange(RD->getLocStart(), RD->getLocEnd())).c_str());
@@ -924,76 +765,27 @@ class LiveListRecords : public MatchFinder::MatchCallback
};
/**********************************************************************************************************************/
/**********************************************************************************************************************/
-/**********************************************************************************************************************/
-/**********************************************************************************************************************/
-/**********************************************************************************************************************/
-/**********************************************************************************************************************/
-/**********************************************************************************************************************/
class BruiserASTConsumer : public ASTConsumer {
-
public:
- BruiserASTConsumer(Rewriter &R) : HIfBreaker(R), HMainWrapper(R)
- {}
-
- void HandleTranslationUnit(ASTContext &Context) override
- {
- Matcher.addMatcher(ifStmt(hasDescendant(expr(anyOf(unaryOperator().bind("uno"), binaryOperator().bind("dous"))))), &HIfBreaker);
+ BruiserASTConsumer(Rewriter &R) : HMainWrapper(R) {}
+ void HandleTranslationUnit(ASTContext &Context) override {
Matcher.addMatcher(functionDecl(hasName("main")).bind("mainwrapper"), &HMainWrapper);
-
-
Matcher.matchAST(Context);
}
private:
- IfBreaker HIfBreaker;
MainWrapper HMainWrapper;
MatchFinder Matcher;
Rewriter R;
};
/**********************************************************************************************************************/
-class LiveConsumerFactory
-{
+class LiveListVarsConsumer : public ASTConsumer {
public:
- LiveConsumerFactory() {}
+ LiveListVarsConsumer(Rewriter &R) : HLLVars(R) {}
- template<typename T>
- void operator()(T __consumer)
- {
-
- }
-
-};
-/**********************************************************************************************************************/
-class LiveConsumer : public ASTConsumer
-{
- public:
- LiveConsumer(Rewriter &R) : HLLVars(R), HLLFuncs(R), HLLRecords(R)
- {}
-
- void HandleTranslationUnit(ASTContext &ctx) override
- {
- Matcher.matchAST(ctx);
- }
-
- private:
- MatchFinder Matcher;
- LiveListVars HLLVars;
- LiveListFuncs HLLFuncs;
- LiveListRecords HLLRecords;
- Rewriter R;
-};
-/**********************************************************************************************************************/
-class LiveListVarsConsumer : public ASTConsumer
-{
- public:
- LiveListVarsConsumer(Rewriter &R) : HLLVars(R)
- {}
-
- void HandleTranslationUnit(ASTContext &ctx) override
- {
+ void HandleTranslationUnit(ASTContext &ctx) override {
Matcher.addMatcher(varDecl().bind("livelistvars"), &HLLVars);
-
Matcher.matchAST(ctx);
}
@@ -1003,16 +795,12 @@ class LiveListVarsConsumer : public ASTConsumer
MatchFinder Matcher;
};
/**********************************************************************************************************************/
-class LiveListFuncsConsumer : public ASTConsumer
-{
+class LiveListFuncsConsumer : public ASTConsumer {
public:
- LiveListFuncsConsumer(Rewriter &R) : HLLFuncs(R)
- {}
+ LiveListFuncsConsumer(Rewriter &R) : HLLFuncs(R) {}
- void HandleTranslationUnit(ASTContext &ctx) override
- {
+ void HandleTranslationUnit(ASTContext &ctx) override {
Matcher.addMatcher(functionDecl().bind("livelistfuncs"), &HLLFuncs);
-
Matcher.matchAST(ctx);
}
@@ -1022,16 +810,12 @@ class LiveListFuncsConsumer : public ASTConsumer
Rewriter R;
};
/**********************************************************************************************************************/
-class LiveListClassConsumer : public ASTConsumer
-{
+class LiveListClassConsumer : public ASTConsumer {
public:
- LiveListClassConsumer(Rewriter &R) : HLLRecords(R)
- {}
+ LiveListClassConsumer(Rewriter &R) : HLLRecords(R) {}
- void HandleTranslationUnit(ASTContext &ctx) override
- {
+ void HandleTranslationUnit(ASTContext &ctx) override {
Matcher.addMatcher(recordDecl(isClass()).bind("livelistclass"), &HLLRecords);
-
Matcher.matchAST(ctx);
}
@@ -1041,16 +825,12 @@ class LiveListClassConsumer : public ASTConsumer
Rewriter R;
};
/**********************************************************************************************************************/
-class LiveListStructConsumer : public ASTConsumer
-{
+class LiveListStructConsumer : public ASTConsumer {
public:
- LiveListStructConsumer(Rewriter &R) : HLLRecords(R)
- {}
+ LiveListStructConsumer(Rewriter &R) : HLLRecords(R) {}
- void HandleTranslationUnit(ASTContext &ctx) override
- {
+ void HandleTranslationUnit(ASTContext &ctx) override {
Matcher.addMatcher(recordDecl(isStruct()).bind("liveliststruct"), &HLLRecords);
-
Matcher.matchAST(ctx);
}
@@ -1060,16 +840,12 @@ class LiveListStructConsumer : public ASTConsumer
Rewriter R;
};
/**********************************************************************************************************************/
-class LiveListUnionConsumer : public ASTConsumer
-{
+class LiveListUnionConsumer : public ASTConsumer {
public:
- LiveListUnionConsumer(Rewriter &R) : HLLRecords(R)
- {}
+ LiveListUnionConsumer(Rewriter &R) : HLLRecords(R) {}
- void HandleTranslationUnit(ASTContext &ctx) override
- {
+ void HandleTranslationUnit(ASTContext &ctx) override {
Matcher.addMatcher(recordDecl(isUnion()).bind("livelistclass"), &HLLRecords);
-
Matcher.matchAST(ctx);
}
@@ -1079,16 +855,12 @@ class LiveListUnionConsumer : public ASTConsumer
Rewriter R;
};
/**********************************************************************************************************************/
-class LiveListArrayConsumer : public ASTConsumer
-{
+class LiveListArrayConsumer : public ASTConsumer {
public:
- LiveListArrayConsumer(Rewriter &R) : HLLVars(R)
- {}
+ LiveListArrayConsumer(Rewriter &R) : HLLVars(R) {}
- void HandleTranslationUnit(ASTContext &ctx) override
- {
+ void HandleTranslationUnit(ASTContext &ctx) override {
Matcher.addMatcher(varDecl(hasType(arrayType())).bind("livelistvars"), &HLLVars);
-
Matcher.matchAST(ctx);
}
@@ -1099,28 +871,22 @@ class LiveListArrayConsumer : public ASTConsumer
};
/**********************************************************************************************************************/
/**********************************************************************************************************************/
-/**********************************************************************************************************************/
-/**********************************************************************************************************************/
-class BlankDiagConsumer : public clang::DiagnosticConsumer
-{
+class BlankDiagConsumer : public clang::DiagnosticConsumer {
public:
BlankDiagConsumer() = default;
virtual ~BlankDiagConsumer() {}
virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) override {}
};
/**********************************************************************************************************************/
-class BruiserFrontendAction : public ASTFrontendAction
-{
+class BruiserFrontendAction : public ASTFrontendAction {
public:
BruiserFrontendAction() {}
- virtual ~BruiserFrontendAction()
- {
+ virtual ~BruiserFrontendAction() {
delete BDCProto;
delete tee;
}
- void EndSourceFileAction() override
- {
+ void EndSourceFileAction() override {
std::error_code EC;
std::string OutputFilename = "./libtooling-tee";
TheRewriter.getEditBuffer(TheRewriter.getSourceMgr().getMainFileID()).write(llvm::outs());
@@ -1128,8 +894,7 @@ public:
TheRewriter.getEditBuffer(TheRewriter.getSourceMgr().getMainFileID()).write(*tee);
}
- std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef file) override
- {
+ std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef file) override {
DiagnosticsEngine &DE = CI.getPreprocessor().getDiagnostics();
DE.setClient(BDCProto, false);
TheRewriter.setSourceMgr(CI.getSourceManager(), CI.getLangOpts());
@@ -1142,19 +907,16 @@ private:
raw_ostream *tee = &llvm::outs();
};
/**********************************************************************************************************************/
-class LiveActionListVars : public ASTFrontendAction
-{
+class LiveActionListVars : public ASTFrontendAction {
public:
LiveActionListVars() = default;
- virtual ~LiveActionListVars()
- {
+ virtual ~LiveActionListVars() {
delete BDCProto;
}
void EndSourceFileAction() override {}
- std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef file) override
- {
+ std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef file) override {
DiagnosticsEngine &DE = CI.getPreprocessor().getDiagnostics();
DE.setClient(BDCProto, false);
TheRewriter.setSourceMgr(CI.getSourceManager(), CI.getLangOpts());
@@ -1166,19 +928,16 @@ class LiveActionListVars : public ASTFrontendAction
BlankDiagConsumer* BDCProto = new BlankDiagConsumer();
};
/**********************************************************************************************************************/
-class LiveActionListFuncs : public ASTFrontendAction
-{
+class LiveActionListFuncs : public ASTFrontendAction {
public:
LiveActionListFuncs() {}
- ~LiveActionListFuncs()
- {
+ ~LiveActionListFuncs() {
delete BDCProto;
}
void EndSourceFileAction() override {}
- std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef file) override
- {
+ std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef file) override {
DiagnosticsEngine &DE = CI.getPreprocessor().getDiagnostics();
DE.setClient(BDCProto, false);
TheRewriter.setSourceMgr(CI.getSourceManager(), CI.getLangOpts());
@@ -1190,19 +949,16 @@ class LiveActionListFuncs : public ASTFrontendAction
BlankDiagConsumer* BDCProto = new BlankDiagConsumer;
};
/**********************************************************************************************************************/
-class LiveActionListStructs : public ASTFrontendAction
-{
+class LiveActionListStructs : public ASTFrontendAction {
public:
LiveActionListStructs() {}
- ~LiveActionListStructs()
- {
+ ~LiveActionListStructs() {
delete BDCProto;
}
void EndSourceFileAction() override {}
- std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef file) override
- {
+ std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef file) override {
DiagnosticsEngine &DE = CI.getPreprocessor().getDiagnostics();
DE.setClient(BDCProto, false);
TheRewriter.setSourceMgr(CI.getSourceManager(), CI.getLangOpts());
@@ -1214,19 +970,16 @@ class LiveActionListStructs : public ASTFrontendAction
BlankDiagConsumer* BDCProto = new BlankDiagConsumer;
};
/**********************************************************************************************************************/
-class LiveActionListClasses : public ASTFrontendAction
-{
+class LiveActionListClasses : public ASTFrontendAction {
public:
LiveActionListClasses() {}
- ~LiveActionListClasses()
- {
+ ~LiveActionListClasses() {
delete BDCProto;
}
void EndSourceFileAction() override {}
- std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef file) override
- {
+ std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef file) override {
DiagnosticsEngine &DE = CI.getPreprocessor().getDiagnostics();
DE.setClient(BDCProto, false);
TheRewriter.setSourceMgr(CI.getSourceManager(), CI.getLangOpts());
@@ -1238,19 +991,16 @@ class LiveActionListClasses : public ASTFrontendAction
BlankDiagConsumer* BDCProto = new BlankDiagConsumer;
};
/**********************************************************************************************************************/
-class LiveActionListUnions : public ASTFrontendAction
-{
+class LiveActionListUnions : public ASTFrontendAction {
public:
LiveActionListUnions() {}
- ~LiveActionListUnions()
- {
+ ~LiveActionListUnions() {
delete BDCProto;
}
void EndSourceFileAction() override {}
- std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef file) override
- {
+ std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef file) override {
DiagnosticsEngine &DE = CI.getPreprocessor().getDiagnostics();
DE.setClient(BDCProto, false);
TheRewriter.setSourceMgr(CI.getSourceManager(), CI.getLangOpts());
@@ -1262,19 +1012,16 @@ class LiveActionListUnions : public ASTFrontendAction
BlankDiagConsumer* BDCProto = new BlankDiagConsumer;
};
/**********************************************************************************************************************/
-class LiveActionListArrays : public ASTFrontendAction
-{
+class LiveActionListArrays : public ASTFrontendAction {
public:
LiveActionListArrays() {}
- ~LiveActionListArrays()
- {
+ ~LiveActionListArrays() {
delete BDCProto;
}
void EndSourceFileAction() override {}
- std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef file) override
- {
+ std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef file) override {
DiagnosticsEngine &DE = CI.getPreprocessor().getDiagnostics();
DE.setClient(BDCProto, false);
TheRewriter.setSourceMgr(CI.getSourceManager(), CI.getLangOpts());
@@ -1288,39 +1035,31 @@ class LiveActionListArrays : public ASTFrontendAction
/**********************************************************************************************************************/
/**********************************************************************************************************************/
/*lua wrappers*/
-class LuaWrapper
-{
+class LuaWrapper {
public:
//LuaWrapper(std::unique_ptr<Executioner> _e, std::unique_ptr<XGlobals> _x) : executioner(std::move(_e)), xglobals(std::move(_x)) {}
LuaWrapper() {}
/*print out the history*/
- int BruiserLuaHistory(lua_State* __ls)
- {
+ int BruiserLuaHistory(lua_State* __ls) {
std::ifstream historyfile;
historyfile.open(SHELL_HISTORY_FILE);
std::string tempstring;
unsigned int tempint = 0;
- while(std::getline(historyfile, tempstring))
- {
+ while(std::getline(historyfile, tempstring)) {
printf(BLUE"%d ", tempint);
printf(CYAN"%s", tempstring.c_str());
printf(NORMAL"\n");
-
tempint++;
}
-
return tempint;
}
/*print the help menu*/
- int BruiserLuaHelp(lua_State* __ls)
- {
+ int BruiserLuaHelp(lua_State* __ls) {
unsigned int argcount = 0U;
-
- for (auto &iter : bruiser::CMDHelp)
- {
+ for (auto &iter : bruiser::CMDHelp) {
printf(GREEN"name: ");
printf(CYAN"%s ", iter.name.c_str());
printf(GREEN"proto: ");
@@ -1341,19 +1080,16 @@ class LuaWrapper
/*print out bruiser version*/
- int BruiserLuaVersion(lua_State* __ls)
- {
+ int BruiserLuaVersion(lua_State* __ls) {
PRINT_WITH_COLOR_LB(GREEN, "bruiser experimental version something.");
PRINT_WITH_COLOR_LB(GREEN, "project mutator");
PRINT_WITH_COLOR_LB(GREEN, "GPL v3.0");
PRINT_WITH_COLOR_LB(GREEN, "bloodstalker 2017");
-
return 1;
}
/*clear the screen*/
- int BruiserLuaClear(lua_State* __ls)
- {
+ int BruiserLuaClear(lua_State* __ls) {
linenoiseClearScreen();
return 0;
}
@@ -1985,42 +1721,34 @@ class LuaWrapper
}
/*read the m0 report*/
- int BruiserLuaM0(lua_State* __ls)
- {
- bruiser::ReadM0 M0Rep;
- tinyxml2::XMLError XMLErr;
-
- XMLErr = M0Rep.LoadXMLDoc();
- if (XMLErr != XML_SUCCESS)
- {
- std::cout << RED << "could not load m0 xml report.\n" << NORMAL;
- std::cout << RED << "tinyxml2 returned " << XMLErr << NORMAL;
- return XMLErr;
- }
+ int BruiserLuaM0(lua_State* __ls) {
+ bruiser::ReadM0 M0Rep;
+ tinyxml2::XMLError XMLErr;
- XMLErr = M0Rep.ReadFirstElement();
- if (XMLErr != XML_SUCCESS)
- {
- std::cerr << RED << "could not read first element of m0 xml report.\n" << NORMAL;
- return XMLErr;
- }
+ XMLErr = M0Rep.LoadXMLDoc();
+ if (XMLErr != XML_SUCCESS) {
+ std::cout << RED << "could not load m0 xml report.\n" << NORMAL;
+ std::cout << RED << "tinyxml2 returned " << XMLErr << NORMAL;
+ return XMLErr;
+ }
- bruiser::SearchM0(M0Rep.getRootPointer());
+ XMLErr = M0Rep.ReadFirstElement();
+ if (XMLErr != XML_SUCCESS) {
+ std::cerr << RED << "could not read first element of m0 xml report.\n" << NORMAL;
+ return XMLErr;
+ }
- return 1;
+ bruiser::SearchM0(M0Rep.getRootPointer());
+ return 1;
}
- int BruiserLuaReadXMLReport(lua_State* __ls)
- {
+ int BruiserLuaReadXMLReport(lua_State* __ls) {
int numargs = lua_gettop(__ls);
std::string xml_address;
- if (numargs == 1)
- {
+ if (numargs == 1) {
xml_address = lua_tostring(__ls, 1);
- }
- else
- {
+ } else {
xml_address = bruiser::M0REP;
}
@@ -2028,8 +1756,7 @@ class LuaWrapper
tinyxml2::XMLError error;
error = MutagenRep.LoadXMLDoc();
- if (error != XML_SUCCESS)
- {
+ if (error != XML_SUCCESS) {
PRINT_WITH_COLOR_LB(RED, "could not load report.");
PRINT_WITH_COLOR(RED, "tinyxml2 returned ");
std::cout << RED << error << NORMAL;
@@ -2038,59 +1765,49 @@ class LuaWrapper
}
error = MutagenRep.ReadFirstElement();
- if (error != XML_SUCCESS)
- {
+ if (error != XML_SUCCESS) {
PRINT_WITH_COLOR_LB(RED, "could not read first element of xml report.");
lua_pushnumber(__ls, (double)error);
return 1;
}
bruiser::SearchM0(MutagenRep.getRootPointer());
-
return 1;
}
/*quit*/
- int BruiserLuaQuit(lua_State* __ls)
- {
+ int BruiserLuaQuit(lua_State* __ls) {
dostring(__ls, "os.exit()", "test");
return 0;
}
/*quit*/
- int BruiserLuaExit(lua_State* __ls)
- {
+ int BruiserLuaExit(lua_State* __ls) {
dostring(__ls, "os.exit()", "test");
return 0;
}
- int BruiserLuaRunMake(lua_State* __ls)
- {
+ int BruiserLuaRunMake(lua_State* __ls) {
unsigned int args = 0U;
- if ((args = lua_gettop(__ls)) != 1U)
- {
+ if ((args = lua_gettop(__ls)) != 1U) {
PRINT_WITH_COLOR_LB(RED, "function was not called by one argument. Run help().");
lua_pushnumber(__ls, 1);
return 1;
}
std::string makearg = lua_tostring(__ls , 1);
-
- if (ShellGlobalInstance.MAKEPATH == "")
- {
+ if (ShellGlobalInstance.MAKEPATH == "") {
PRINT_WITH_COLOR_LB(RED, "MAKEPATH is not set. set it using setmakepath or type help.");
lua_pushnumber(__ls, 1);
return 1;
}
pid_t pid = fork();
-
if (pid < 0) {
PRINT_WITH_COLOR_LB(RED, "could not fork...");
lua_pushnumber(__ls, EXIT_FAILURE);
}
-
if (pid == 0) {
std::cout << BLUE << "MAKEPATH: " << ShellGlobalInstance.MAKEPATH << NORMAL << "\n";
std::cout << BLUE << "Running: " << "make -C " << ShellGlobalInstance.MAKEPATH << " " << makearg << NORMAL << "\n";
@@ -2098,7 +1815,6 @@ class LuaWrapper
lua_pushnumber(__ls, retval);
exit(EXIT_SUCCESS);
}
-
if (pid > 0) {
int status;
pid_t returned;
@@ -2111,14 +1827,12 @@ class LuaWrapper
int BruiserLuaChangeHistorySize(lua_State* __ls) {
unsigned int args = 0U;
-
if ((args = lua_gettop(__ls)) != 1U) {
PRINT_WITH_COLOR_LB(RED, "function was not called by one argument. Run help().");
return 0;
}
unsigned int historysize = lua_tonumber(__ls, 1);
-
linenoiseHistorySetMaxLen(historysize);
ShellGlobalInstance.HISTORY_SIZE = historysize;
@@ -2143,9 +1857,7 @@ class LuaWrapper
if (iter.rfind(filename) == iter.size() - filename.size()) {
ShellCacheInstance.LastFileUsed = iter;
ShellCacheInstance.LastFileUsedShort = filename;
-
targetfile.open(iter);
-
if(targetfile.rdstate() != std::ios_base::goodbit) {
PRINT_WITH_COLOR_LB(RED, "could not open the file.");
}
@@ -2176,7 +1888,6 @@ class LuaWrapper
}
pid_t pid = fork();
-
if (pid < 0) {
/*bruiser could not spawn a child*/
PRINT_WITH_COLOR_LB(RED, "could not fork a child process(m0).");
@@ -2291,7 +2002,6 @@ class LuaWrapper
}
ShellGlobalInstance.BINPATH = lua_tostring(__ls, 1);
-
return 0;
}
@@ -2388,8 +2098,7 @@ class LuaWrapper
return 0;
}
- int BruiserLuaPWD(lua_State* __ls)
- {
+ int BruiserLuaPWD(lua_State* __ls) {
pid_t pid = fork();
if (pid < 0) {
@@ -2426,13 +2135,11 @@ class BruiserCFE {
std::ifstream libtooling_tee("../test/bruisertest/libtooling-tee");
std::string luaoutstr;
std::string dummy;
-
while(std::getline(libtooling_tee, dummy)) {
luaoutstr = luaoutstr + dummy + "\n";
}
lua_pushstring(__ls, luaoutstr.c_str());
-
return 1;
}
@@ -2473,8 +2180,7 @@ class BruiserCFE {
std::unique_ptr<ClangTool> CT;
};
/**********************************************************************************************************************/
-class RunLoop
-{
+class RunLoop {
public:
RunLoop(lua_State* __ls, LuaEngine __le) : ls(__ls), le(__le) {}
@@ -2558,7 +2264,7 @@ std::pair<ClangTool*, CompilationDatabaseProcessor*> clang_cli_args(int argc, co
}
/**********************************************************************************************************************/
/*Main*/
-int main(int argc, const char **argv) {
+int main(int argc, const char** argv) {
int argc_n = 0;
std::vector<std::string> argv_n;
std::vector<const char*> vc;
diff --git a/bruiser/bruiser.h b/bruiser/bruiser.h
index ff47919..1e54d34 100644
--- a/bruiser/bruiser.h
+++ b/bruiser/bruiser.h
@@ -301,59 +301,6 @@ class Daemonize
};
/**********************************************************************************************************************/
/*structs to hold load.py's return values*/
-/*@DEVI-at some point in the future i might revert to using libbfd or libelf.*/
-
-/*elf*/
-#define ELF_EI_MAGIC = 0x000000000000ffff;
-#define ELF_EI_CLASS = 0x00000000000f0000;
-#define ELF_EI_DATA = 0x0000000000f00000;
-#define ELF_EI_VERSION = 0x000000000f000000;
-#define ELF_EI_OSABI = 0x00000000f0000000;
-#define ELF_EI_ABIVERSION = 0x0000000f00000000;
-#define ELF_EI_PAD = 0xfffffff000000000;
-
-// @DEVI-FIXME-using uint128 here
-// fails to build on stock ubuntu 16.04
-# if 0
-struct ELFHDR_64 {
- public:
- ELFHDR_64() = default;
- ELFHDR_64(__uint128_t _ident, uint16_t _type, uint16_t _machine,
- uint32_t _version, uint64_t _entry, uint64_t _phoff, uint64_t _shoff,
- uint32_t _flags, uint16_t _ehsize, uint16_t _phentsize,
- uint16_t _phnum, uint16_t _shentsize, uint16_t _shnum, uint16_t _shstrndx) {
- e_ident = _ident; e_type = _type; e_machine = _machine; e_version = _version;
- e_entry = _entry; e_phoff = _phoff; e_shoff = _shoff; e_flags = _flags;
- e_ehsize = _ehsize; e_phentsize = _phentsize; e_phnum = _phnum;
- e_shentsize = _shentsize; e_shnum = _shnum; e_shstrndx = _shstrndx;
- }
- __uint128_t e_ident; uint16_t e_type; uint16_t e_machine; uint32_t e_version;
- uint64_t e_entry; uint64_t e_phoff; uint64_t e_shoff; uint32_t e_flags;
- uint16_t e_ehsize; uint16_t e_phentsize; uint16_t e_phnum; uint16_t e_shentsize;
- uint16_t e_shnum; uint16_t e_shstrndx;
-};
-
-// @DEVI-FIXME-using uint128 here
-struct ELFHDR_32 {
- public:
- ELFHDR_32() = default;
- ELFHDR_32(__uint128_t _ident, uint16_t _type, uint16_t _machine, uint32_t _version,
- uint32_t _entry, uint32_t _phoff, uint32_t _shoff, uint32_t _flags,
- uint16_t _ehsize, uint16_t _phentsize, uint16_t _phnum, uint16_t _shentsize,
- uint16_t _shnum, uint16_t _shstrndx) {
- e_ident = _ident; e_type = _type; e_machine = _machine; e_version = _version;
- e_entry = _entry; e_phoff = _phoff; e_shoff = _shoff; e_flags = _flags;
- e_ehsize = _ehsize; e_phentsize = _phentsize; e_phnum = _phnum;
- e_shentsize = _shentsize; e_shnum = _shnum; e_shstrndx = _shstrndx;
- }
-
- __uint128_t e_ident; uint16_t e_type; uint16_t e_machine; uint32_t e_version;
- uint32_t e_entry; uint32_t e_phoff; uint32_t e_shoff; uint32_t e_flags;
- uint16_t e_ehsize; uint16_t e_phentsize; uint16_t e_phnum; uint16_t e_shentsize;
- uint16_t e_shnum; uint16_t e_shstrndx;
-};
-#endif
-/*program header*/
struct PHDR_64 {
public:
PHDR_64() = default;
diff --git a/bruiser/lua-scripts/wasmtest.lua b/bruiser/lua-scripts/wasmtest.lua
index 8942ad2..15aa395 100644
--- a/bruiser/lua-scripts/wasmtest.lua
+++ b/bruiser/lua-scripts/wasmtest.lua
@@ -198,6 +198,7 @@ function demo4()
io.write(v:index().."\t")
io.write(tostring(v:offset()).."\t")
io.write(v:size().."\n")
+ --FIXME
--io.write(v:data().."\n")
end
end
diff --git a/m0/mutator-lvl0.cpp b/m0/mutator-lvl0.cpp
index 33cdb00..0d8f0c4 100644
--- a/m0/mutator-lvl0.cpp
+++ b/m0/mutator-lvl0.cpp
@@ -26,14 +26,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*
#include "mutator_aux.h"
#include "mutator_report.h"
/*standard headers*/
+#include <algorithm>
#include <cassert>
#include <exception>
#include <fstream>
#include <iostream>
+#include <iterator>
#include <map>
#include <regex>
#include <string>
#include <vector>
+#include <string.h>
/*Clang headers*/
#include "clang/AST/AST.h"
#include "clang/AST/ASTConsumer.h"
@@ -218,6 +221,10 @@ cl::opt<bool> MCEA("MCEA", cl::desc("MisraC switch to enable all rule checks"),
cl::opt<bool> MCDA("MCDA", cl::desc("MisraC switches to disable all rule checks"), cl::init(false), cl::cat(MutatorLVL0Cat), cl::Optional);
cl::opt<bool> SFRCPP("SFRCPP", cl::desc("Enables SaferCPlusPlus rule checks"), cl::init(true), cl::cat(MutatorLVL0Cat), cl::Optional);
cl::opt<bool> mutagen("mutagen", cl::desc("runs mutagen after running the static tests"), cl::init(false), cl::cat(MutatorLVL0Cat), cl::Optional);
+cl::opt<std::string> ACTIONFILE("file", cl::desc("path to action file"), cl::init(""), cl::cat(MutatorLVL0Cat), cl::Optional);
+cl::opt<std::string> JSONOUT("jsonout", cl::desc("path to json output report"), cl::init(""), cl::cat(MutatorLVL0Cat), cl::Optional);
+cl::opt<std::string> XMLOUT("xmlout", cl::desc("path to xml output report"), cl::init(""), cl::cat(MutatorLVL0Cat), cl::Optional);
+cl::opt<std::string> MUTAGENOUT("mutagenout", cl::desc("path to mutagen output report"), cl::init(""), cl::cat(MutatorLVL0Cat), cl::Optional);
/**********************************************************************************************************************/
class StringOptionsParser {
friend class MutatorLVL0Tests;
@@ -6818,122 +6825,78 @@ public:
bool HaveWeSeenAComment = false;
bool WhiteSpacePostSemi = false;
- for (auto &iter : NullStmtProto)
- {
-#if 0
- std::cout << iter.Line << ":" << iter.Column << ":" << iter.FileName << "\n";
-#endif
-
+ for (auto &iter : NullStmtProto) {
ShouldBeTagged = false;
HaveWeMatchedASemi = false;
HaveWeSeenAComment = false;
WhiteSpacePostSemi = false;
-
std::ifstream InputFile(iter.FileName);
-
unsigned counter = 0U;
- for (std::string line; getline(InputFile, line);)
- {
+ for (std::string line; getline(InputFile, line);) {
counter++;
- if (counter == iter.Line)
- {
- for (auto &iterchar : line)
- {
- if (iterchar == ';')
- {
- if (HaveWeMatchedASemi)
- {
+ if (counter == iter.Line) {
+ for (auto &iterchar : line) {
+ if (iterchar == ';') {
+ if (HaveWeMatchedASemi) {
ShouldBeTagged = true;
break;
}
-
HaveWeMatchedASemi = true;
continue;
}
-
- if (iterchar == ' ')
- {
- if (HaveWeMatchedASemi)
- {
+ if (iterchar == ' ') {
+ if (HaveWeMatchedASemi) {
WhiteSpacePostSemi = true;
continue;
}
-
- if (WhiteSpacePostSemi)
- {
+ if (WhiteSpacePostSemi) {
ShouldBeTagged = true;
break;
}
-
continue;
}
-
- if (iterchar == '\t')
- {
-
- if (HaveWeMatchedASemi)
- {
+ if (iterchar == '\t') {
+ if (HaveWeMatchedASemi) {
ShouldBeTagged = true;
break;
- }
- else
- {
+ } else {
continue;
}
}
-
- if (iterchar == '/')
- {
+ if (iterchar == '/') {
HaveWeSeenAComment = true;
-
- if (HaveWeMatchedASemi)
- {
- if (WhiteSpacePostSemi)
- {
+ if (HaveWeMatchedASemi) {
+ if (WhiteSpacePostSemi) {
break;
- }
- else
- {
+ } else {
ShouldBeTagged = true;
break;
}
- }
- else
- {
+ } else {
ShouldBeTagged = true;
break;
}
-
break;
}
-
ShouldBeTagged = true;
break;
}
}
- if (ShouldBeTagged)
- {
- if (Devi::IsTheMatchInSysHeader(CheckSystemHeader, iter.IsInSysHeader))
- {
+ if (ShouldBeTagged) {
+ if (Devi::IsTheMatchInSysHeader(CheckSystemHeader, iter.IsInSysHeader)) {
/*intentionally left blank*/
- }
- else
- {
- if (Devi::IsTheMatchInMainFile(MainFileOnly, iter.IsInMainFile))
- {
+ } else {
+ if (Devi::IsTheMatchInMainFile(MainFileOnly, iter.IsInMainFile)) {
std::cout << "14.3" << ":" << "Illegal NullStmt form:" << iter.FileName << ":" << iter.Line << ":" << iter.Column << ":" << "\n";
-
XMLDocOut.XMLAddNode(iter.Line, iter.Column, iter.FileName, "14.3", "Illegal NullStmt form:");
JSONDocOUT.JSONAddElement(iter.Line, iter.Column, iter.FileName, "14.3", "Illegal NullStmt form:");
}
}
-
break;
}
}
-
InputFile.close();
}
}
@@ -7046,7 +7009,6 @@ public: onEndOfAllTUs() {}
/*tag 5.7*/
std::cout << "5.7:" << "Identifier re-used:";
std::cout << iter.SLString << ":" << iter.Name << ":" << yaiter.SLString << "\n";
-
XMLDocOut.XMLAddNode(iter.Line, iter.Column, iter.FileName, "5.7", "Identifier re-used:");
JSONDocOUT.JSONAddElement(iter.Line, iter.Column, iter.FileName, "5.7", "Identifier re-used:");
@@ -7055,7 +7017,6 @@ public: onEndOfAllTUs() {}
/*tag 5.3*/
std::cout << "5.3:" << "Typedef identifier is not unique:";
std::cout << iter.SLString << ":" << iter.Name << ":" << yaiter.SLString << "\n";
-
XMLDocOut.XMLAddNode(iter.Line, iter.Column, iter.FileName, "5.3", "Typedef identifier is not unique:");
JSONDocOUT.JSONAddElement(iter.Line, iter.Column, iter.FileName, "5.3", "Typedef identifier is not unique:");
}
@@ -7065,7 +7026,6 @@ public: onEndOfAllTUs() {}
/*tag 5.4*/
std::cout << "5.4:" << "Tag identifier is not unique:";
std::cout << iter.SLString << ":" << iter.Name << ":" << yaiter.SLString << "\n";
-
XMLDocOut.XMLAddNode(iter.Line, iter.Column, iter.FileName, "5.4", "Tag identifier is not unique:");
JSONDocOUT.JSONAddElement(iter.Line, iter.Column, iter.FileName, "5.4", "Tag identifier is not unique:");
}
@@ -7075,7 +7035,6 @@ public: onEndOfAllTUs() {}
/*tag 5.6*/
std::cout << "5.6:" << "The Identifier is re-used in another namespace:";
std::cout << iter.SLString << ":" << iter.Name << ":" << yaiter.SLString << "\n";
-
XMLDocOut.XMLAddNode(iter.Line, iter.Column, iter.FileName, "5.6", "The Identifier is re-used in another namespace:");
JSONDocOUT.JSONAddElement(iter.Line, iter.Column, iter.FileName, "5.6", "The Identifier is re-used in another namespace:");
}
@@ -7085,7 +7044,6 @@ public: onEndOfAllTUs() {}
/*tag 5.6*/
std::cout << "5.6:" << "The Identifier is re-used in another namespace:";
std::cout << iter.SLString << ":" << iter.Name << ":" << yaiter.SLString << "\n";
-
XMLDocOut.XMLAddNode(iter.Line, iter.Column, iter.FileName, "5.6", "The Identifier is re-used in another namespace:");
JSONDocOUT.JSONAddElement(iter.Line, iter.Column, iter.FileName, "5.6", "The Identifier is re-used in another namespace:");
}
@@ -7096,7 +7054,6 @@ public: onEndOfAllTUs() {}
/*tag 5.6*/
std::cout << "5.6:" << "The Identifier is re-used in another namespace:";
std::cout << iter.SLString << ":" << iter.Name << ":" << yaiter.SLString << "\n";
-
XMLDocOut.XMLAddNode(iter.Line, iter.Column, iter.FileName, "5.6", "The Identifier is re-used in another namespace:");
JSONDocOUT.JSONAddElement(iter.Line, iter.Column, iter.FileName, "5.6", "The Identifier is re-used in another namespace:");
}
@@ -7106,7 +7063,6 @@ public: onEndOfAllTUs() {}
/*tag 5.2*/
std::cout << "5.2:" << "This identifier is being hidden by an identifier of the same name in file scope:";
std::cout << iter.SLString << ":" << iter.Name << ":" << yaiter.SLString << "\n";
-
XMLDocOut.XMLAddNode(iter.Line, iter.Column, iter.FileName, "5.2", "This identifier is being hidden by an identifier of the same name in file scope:");
JSONDocOUT.JSONAddElement(iter.Line, iter.Column, iter.FileName, "5.2", "This identifier is being hidden by an identifier of the same name in file scope:");
}
@@ -7116,7 +7072,6 @@ public: onEndOfAllTUs() {}
/*tag 5.5*/
std::cout << "5.5:" << "Identifier with static storage duration is re-used:";
std::cout << iter.SLString << ":" << iter.Name << ":" << yaiter.SLString << "\n";
-
XMLDocOut.XMLAddNode(iter.Line, iter.Column, iter.FileName, "5.5", "Identifier with static storage duration is re-used:");
JSONDocOUT.JSONAddElement(iter.Line, iter.Column, iter.FileName, "5.5", "Identifier with static storage duration is re-used:");
}
@@ -7130,7 +7085,6 @@ private:
};
/**********************************************************************************************************************/
class MyASTConsumer : public ASTConsumer {
-
public:
MyASTConsumer(Rewriter &R) : HandlerForCmpless(R), HandlerWhileCmpless(R), HandlerElseCmpless(R), HandlerIfCmpless(R), \
HandlerForIfElse(R), HandlerForSwitchBrkLess(R), HandlerForSwitchDftLEss(R), HandlerForMCSwitch151(R), HandlerForMCSwitch155(R), \
@@ -7152,254 +7106,203 @@ public:
#if defined(_MUT0_EN_MATCHERS)
Matcher.addMatcher(forStmt(unless(hasDescendant(compoundStmt()))).bind("mcfor"), &HandlerForCmpless);
-
Matcher.addMatcher(whileStmt(unless(hasDescendant(compoundStmt()))).bind("mcwhile"), &HandlerWhileCmpless);
-
Matcher.addMatcher(ifStmt(allOf(hasElse(unless(ifStmt())), hasElse(unless(compoundStmt())))).bind("mcelse"), &HandlerElseCmpless);
-
Matcher.addMatcher(ifStmt(unless(hasDescendant(compoundStmt()))).bind("mcif"), &HandlerIfCmpless);
-
Matcher.addMatcher(ifStmt(allOf(hasElse(ifStmt()), unless(hasAncestor(ifStmt())), unless(hasDescendant(ifStmt(hasElse(unless(ifStmt()))))))).bind("mcifelse"), &HandlerForIfElse);
-
Matcher.addMatcher(switchStmt(hasDescendant(compoundStmt(hasDescendant(switchCase(unless(hasDescendant(breakStmt()))))))).bind("mcswitchbrk"), &HandlerForSwitchBrkLess);
-
Matcher.addMatcher(switchStmt(unless(hasDescendant(defaultStmt()))).bind("mcswitchdft"), &HandlerForSwitchDftLEss);
- if (umRuleList.at("15.1"))
- {
+ if (umRuleList.at("15.1")) {
Matcher.addMatcher(switchStmt(forEachDescendant(caseStmt(hasAncestor(compoundStmt().bind("mccmp151"))).bind("mccase151"))), &HandlerForMCSwitch151);
}
- if (umRuleList.at("15.5"))
- {
+ if (umRuleList.at("15.5")) {
Matcher.addMatcher(switchStmt(unless(hasDescendant(caseStmt()))).bind("mcswitch155"), &HandlerForMCSwitch155);
}
- if (umRuleList.at("16.1"))
- {
+ if (umRuleList.at("16.1")) {
Matcher.addMatcher(functionDecl().bind("mcfunction161"), &HandlerForMCFunction161);
}
- if (umRuleList.at("16.2"))
- {
+ if (umRuleList.at("16.2")) {
Matcher.addMatcher(functionDecl(forEachDescendant(callExpr().bind("mc162callexpr"))).bind("mc162funcdec"), &HandlerForFunction162);
}
- if (umRuleList.at("16.4"))
- {
+ if (umRuleList.at("16.4")) {
Matcher.addMatcher(functionDecl().bind("mcfunc164"), &HandlerForFunction164);
}
- if (umRuleList.at("16.6"))
- {
+ if (umRuleList.at("16.6")) {
Matcher.addMatcher(callExpr().bind("mcfunc166"), &HandlerForFunction166);
}
- if (umRuleList.at("16.8"))
- {
+ if (umRuleList.at("16.8")) {
Matcher.addMatcher(functionDecl(forEachDescendant(returnStmt().bind("mcfunc168"))), &HandlerForFunction168);
}
- if (umRuleList.at("16.9"))
- {
+ if (umRuleList.at("16.9")) {
Matcher.addMatcher(implicitCastExpr(unless(hasAncestor(callExpr()))).bind("mcfunc169"), &HandlerForFunction169);
}
- if (umRuleList.at("17.1"))
- {
+ if (umRuleList.at("17.1")) {
Matcher.addMatcher(varDecl().bind("mcpa171"), &HandlerForPA171);
}
- if (umRuleList.at("18.4"))
- {
+ if (umRuleList.at("18.4")) {
Matcher.addMatcher(recordDecl(isUnion()).bind("mcsu184"), &HandlerForSU184);
}
- if (umRuleList.at("6.4") || umRuleList.at("6.5"))
- {
+ if (umRuleList.at("6.4") || umRuleList.at("6.5")) {
Matcher.addMatcher(fieldDecl(isBitField()).bind("mctype6465"), &HandlerForType6465);
}
- if (umRuleList.at("8.1"))
- {
+ if (umRuleList.at("8.1")) {
Matcher.addMatcher(functionDecl().bind("mcdcdf81"), &HandlerForDCDF81);
}
- if (umRuleList.at("8.2"))
- {
+ if (umRuleList.at("8.2")) {
Matcher.addMatcher(varDecl().bind("mcdcdf82"), &HandlerForDCDF82);
}
- if (umRuleList.at("9.1"))
- {
+ if (umRuleList.at("9.1")) {
Matcher.addMatcher(varDecl().bind("mcinit91"), &HandlerForInit91);
}
- if (umRuleList.at("9.2"))
- {
+ if (umRuleList.at("9.2")) {
Matcher.addMatcher(initListExpr(hasAncestor(varDecl().bind("mcinit92daddy"))).bind("mcinit92"), &HandlerForInit92);
}
- if (umRuleList.at("9.3"))
- {
+ if (umRuleList.at("9.3")) {
Matcher.addMatcher(enumConstantDecl(anyOf(allOf(hasDescendant(integerLiteral().bind("mcinit93kiddy")), \
hasAncestor(enumDecl().bind("mcinit93daddy"))), hasAncestor(enumDecl().bind("mcinit93daddy")))).bind("mcinit93"), &HandlerForInit93);
}
- if (umRuleList.at("12.3"))
- {
+ if (umRuleList.at("12.3")) {
Matcher.addMatcher(unaryExprOrTypeTraitExpr(hasDescendant(expr().bind("mcexpr123kiddy"))).bind("mcexpr123"), &HandlerForExpr123);
}
- if (umRuleList.at("12.4"))
- {
+ if (umRuleList.at("12.4")) {
Matcher.addMatcher(binaryOperator(allOf(eachOf(hasOperatorName("||"), hasOperatorName("&&")), hasRHS(expr().bind("mcexpr124")))), &HandlerForExpr124);
}
- if (umRuleList.at("12.5"))
- {
+ if (umRuleList.at("12.5")) {
Matcher.addMatcher(binaryOperator(allOf(eachOf(hasOperatorName("||"), hasOperatorName("&&")), \
eachOf(hasRHS(allOf(expr().bind("lrhs"), unless(anyOf(implicitCastExpr() , declRefExpr(), callExpr(), floatLiteral(), integerLiteral(), stringLiteral()))))\
, hasLHS(allOf(expr().bind("lrhs"), unless(anyOf(implicitCastExpr(), declRefExpr(), callExpr(), floatLiteral(), integerLiteral(), stringLiteral())))))))\
, &HandlerForExpr125);
}
- if (umRuleList.at("12.6"))
- {
+ if (umRuleList.at("12.6")) {
Matcher.addMatcher(binaryOperator(allOf(eachOf(hasOperatorName("||"), hasOperatorName("&&")), \
eachOf(hasLHS(expr().bind("mcexpr126rl")), hasRHS(expr().bind("mcexpr126rl"))))), &HandlerForExpr126);
}
- if (umRuleList.at("12.7"))
- {
+ if (umRuleList.at("12.7")) {
Matcher.addMatcher(binaryOperator(allOf(eachOf(hasOperatorName("<<"), hasOperatorName(">>"), hasOperatorName("~"), hasOperatorName("<<="), \
hasOperatorName(">>="), hasOperatorName("&"), hasOperatorName("&="), hasOperatorName("^"), hasOperatorName("^=")\
, hasOperatorName("|"), hasOperatorName("|=")), eachOf(hasLHS(expr().bind("mcexpr127rl")), hasRHS(expr().bind("mcexpr127rl"))))), &HandlerForExpr127);
}
- if (umRuleList.at("12.8"))
- {
+ if (umRuleList.at("12.8")) {
Matcher.addMatcher(binaryOperator(allOf(eachOf(hasOperatorName(">>"), hasOperatorName(">>="), hasOperatorName("<<="), hasOperatorName("<<")), \
hasLHS(expr().bind("mcexpr128lhs")) , hasRHS(expr().bind("mcexpr128rhs")))), &HandlerForExpr128);
}
- if (umRuleList.at("12.9"))
- {
+ if (umRuleList.at("12.9")) {
Matcher.addMatcher(unaryOperator(allOf(hasOperatorName("-"), hasUnaryOperand(expr().bind("mcexpr129")))), &HandlerForExpr129);
}
- if (umRuleList.at("12.10"))
- {
+ if (umRuleList.at("12.10")) {
Matcher.addMatcher(binaryOperator(allOf(hasOperatorName(","), hasLHS(expr().bind("mcexpr1210")))), &HandlerForExpr1210);
}
- if (umRuleList.at("12.13"))
- {
+ if (umRuleList.at("12.13")) {
Matcher.addMatcher(unaryOperator(allOf(eachOf(hasOperatorName("++"), hasOperatorName("--"))\
, anyOf(hasAncestor(binaryOperator()), hasDescendant(binaryOperator())))).bind("mcexpr1213"), &HandlerForExpr1213);
}
- if (umRuleList.at("13.1"))
- {
+ if (umRuleList.at("13.1")) {
Matcher.addMatcher(binaryOperator(allOf(hasOperatorName("="), eachOf(hasLHS(expr().bind("cse131rlhs")), hasRHS(expr().bind("cse131rlhs"))))), &HandlerForCSE131);
}
- if (umRuleList.at("13.2"))
- {
+ if (umRuleList.at("13.2")) {
Matcher.addMatcher(ifStmt(hasCondition(expr(unless(hasDescendant(binaryOperator(anyOf(hasOperatorName("<")\
, hasOperatorName(">"), hasOperatorName("=="), hasOperatorName("<="), hasOperatorName(">=")))))).bind("mccse132"))), &HandlerForCSE132);
}
- if (umRuleList.at("13.3"))
- {
+ if (umRuleList.at("13.3")) {
Matcher.addMatcher(binaryOperator(allOf(anyOf(hasOperatorName("<"), hasOperatorName(">"), hasOperatorName("<="), hasOperatorName(">="), hasOperatorName("==")), \
eachOf(hasLHS(expr().bind("mccse1332rl")), hasRHS(expr().bind("mccse1332rl"))))).bind("mccse1332daddy"), &HandlerForCSE1332);
}
- if (umRuleList.at("13.4"))
- {
+ if (umRuleList.at("13.4")) {
Matcher.addMatcher(forStmt().bind("mccse134"), &HandlerForCSE134);
}
- if (umRuleList.at("13.6"))
- {
+ if (umRuleList.at("13.6")) {
Matcher.addMatcher(forStmt(forEachDescendant(stmt(eachOf(unaryOperator(allOf(anyOf(hasOperatorName("++"), hasOperatorName("--")), hasUnaryOperand(declRefExpr().bind("mccse136kiddo")))), \
binaryOperator(allOf(hasOperatorName("="), hasLHS(declRefExpr().bind("mccse136kiddo")))))))).bind("mccse136daddy"), &HandlerForCSE136);
}
- if (umRuleList.at("14.4"))
- {
+ if (umRuleList.at("14.4")) {
Matcher.addMatcher(gotoStmt().bind("mccf144"), &HandlerForCF144);
}
- if (umRuleList.at("14.5"))
- {
+ if (umRuleList.at("14.5")) {
Matcher.addMatcher(continueStmt().bind("mccf145"), &HandlerForCF145);
}
- if (umRuleList.at("14.6"))
- {
+ if (umRuleList.at("14.6")) {
Matcher.addMatcher(breakStmt(hasAncestor(stmt(anyOf(forStmt().bind("mccffofo"), doStmt().bind("mccfdodo"), whileStmt().bind("mccfwuwu"))))), &HandlerForCF146);
}
- if (umRuleList.at("14.7"))
- {
+ if (umRuleList.at("14.7")) {
Matcher.addMatcher(returnStmt(hasAncestor(functionDecl().bind("mccf147"))), &HandlerForCF147);
}
- if (umRuleList.at("14.8"))
- {
+ if (umRuleList.at("14.8")) {
Matcher.addMatcher(forStmt(unless(has(compoundStmt()))).bind("mccf148for"), &HandlerForCF148);
}
- if (umRuleList.at("14.8"))
- {
+ if (umRuleList.at("14.8")) {
Matcher.addMatcher(whileStmt(unless(has(compoundStmt()))).bind("mccf148while"), &HandlerForCF148);
}
- if (umRuleList.at("14.8"))
- {
+ if (umRuleList.at("14.8")) {
Matcher.addMatcher(doStmt(unless(has(compoundStmt()))).bind("mccf148do"), &HandlerForCF148);
}
- if (umRuleList.at("14.8"))
- {
+ if (umRuleList.at("14.8")) {
Matcher.addMatcher(switchStmt(unless(has(compoundStmt()))).bind("mccf148switch"), &HandlerForCF148);
}
- if (umRuleList.at("15.4"))
- {
+ if (umRuleList.at("15.4")) {
Matcher.addMatcher(switchStmt(hasCondition(expr().bind("mcswitch154"))).bind("mcswitch154daddy"), &HandlerForSwitch154);
}
- if (umRuleList.at("11.1"))
- {
+ if (umRuleList.at("11.1")) {
Matcher.addMatcher(implicitCastExpr().bind("mcptc111"), &HandlerForPTC111);
}
- if (umRuleList.at("13.7"))
- {
+ if (umRuleList.at("13.7")) {
Matcher.addMatcher(expr().bind("mccse137"), &HandlerForCSE137);
}
- if (umRuleList.at("8.10"))
- {
+ if (umRuleList.at("8.10")) {
Matcher.addMatcher(callExpr(hasAncestor(functionDecl().bind("mcdcdf810daddy"))).bind("mcdcdf810"), &HandlerForDCDF810);
}
- if (umRuleList.at("16.5"))
- {
+ if (umRuleList.at("16.5")) {
Matcher.addMatcher(functionDecl(allOf(returns(anything()), unless(returns(asString("void"))), hasBody(compoundStmt()) \
, unless(hasDescendant(returnStmt())))).bind("mcfunction165"), &HandlerForFunction165);
}
- if (umRuleList.at("16.5"))
- {
+ if (umRuleList.at("16.5")) {
Matcher.addMatcher(functionDecl(allOf(parameterCountIs(0), hasBody(compoundStmt()))).bind("mcfunction1652"), &HandlerForFunction1652);
}
- if (umRuleList.at("17.1"))
- {
+ if (umRuleList.at("17.1")) {
Matcher.addMatcher(declRefExpr(allOf(to(varDecl().bind("loco")), unless(hasParent(castExpr(hasCastKind(clang::CK_ArrayToPointerDecay)))), \
hasAncestor(stmt(eachOf(binaryOperator(hasOperatorName("+")).bind("bino"), \
binaryOperator(hasOperatorName("-")).bind("bino"), unaryOperator(hasOperatorName("++")).bind("uno"), \
@@ -7410,48 +7313,42 @@ public:
}
/*start of 17.3 matchers*/
- if (umRuleList.at("17.2") || umRuleList.at("17.3"))
- {
+ if (umRuleList.at("17.2") || umRuleList.at("17.3")) {
Matcher.addMatcher(binaryOperator(allOf(hasOperatorName("<="), hasRHS(expr(anyOf(hasDescendant(declRefExpr(hasType(pointerType())).bind("mcpointer1723rhs")), \
has(declRefExpr(hasType(pointerType())).bind("mcpointer1723rhs"))))), \
hasLHS(expr(anyOf(hasDescendant(declRefExpr(hasType(pointerType())).bind("mcpointer1723lhs")), \
has(declRefExpr(hasType(pointerType())).bind("mcpointer1723lhs"))))))).bind("mcpointer1723daddy"), &HandlerForPointer1723);
}
- if (umRuleList.at("17.2") || umRuleList.at("17.3"))
- {
+ if (umRuleList.at("17.2") || umRuleList.at("17.3")) {
Matcher.addMatcher(binaryOperator(allOf(hasOperatorName("<"), hasRHS(expr(anyOf(hasDescendant(declRefExpr(hasType(pointerType())).bind("mcpointer1723rhs")), \
has(declRefExpr(hasType(pointerType())).bind("mcpointer1723rhs"))))), \
hasLHS(expr(anyOf(hasDescendant(declRefExpr(hasType(pointerType())).bind("mcpointer1723lhs")), \
has(declRefExpr(hasType(pointerType())).bind("mcpointer1723lhs"))))))).bind("mcpointer1723daddy"), &HandlerForPointer1723);
}
- if (umRuleList.at("17.2") || umRuleList.at("17.3"))
- {
+ if (umRuleList.at("17.2") || umRuleList.at("17.3")) {
Matcher.addMatcher(binaryOperator(allOf(hasOperatorName(">="), hasRHS(expr(anyOf(hasDescendant(declRefExpr(hasType(pointerType())).bind("mcpointer1723rhs")), \
has(declRefExpr(hasType(pointerType())).bind("mcpointer1723rhs"))))), \
hasLHS(expr(anyOf(hasDescendant(declRefExpr(hasType(pointerType())).bind("mcpointer1723lhs")), \
has(declRefExpr(hasType(pointerType())).bind("mcpointer1723lhs"))))))).bind("mcpointer1723daddy"), &HandlerForPointer1723);
}
- if (umRuleList.at("17.2") || umRuleList.at("17.3"))
- {
+ if (umRuleList.at("17.2") || umRuleList.at("17.3")) {
Matcher.addMatcher(binaryOperator(allOf(hasOperatorName(">"), hasRHS(expr(anyOf(hasDescendant(declRefExpr(hasType(pointerType())).bind("mcpointer1723rhs")), \
has(declRefExpr(hasType(pointerType())).bind("mcpointer1723rhs"))))), \
hasLHS(expr(anyOf(hasDescendant(declRefExpr(hasType(pointerType())).bind("mcpointer1723lhs")), \
has(declRefExpr(hasType(pointerType())).bind("mcpointer1723lhs"))))))).bind("mcpointer1723daddy"), &HandlerForPointer1723);
}
- if (umRuleList.at("17.2") || umRuleList.at("17.3"))
- {
+ if (umRuleList.at("17.2") || umRuleList.at("17.3")) {
Matcher.addMatcher(binaryOperator(allOf(hasOperatorName("-"), hasRHS(expr(anyOf(hasDescendant(declRefExpr(hasType(pointerType())).bind("mcpointer1723rhs")), \
has(declRefExpr(hasType(pointerType())).bind("mcpointer1723rhs"))))), \
hasLHS(expr(anyOf(hasDescendant(declRefExpr(hasType(pointerType())).bind("mcpointer1723lhs")), \
has(declRefExpr(hasType(pointerType())).bind("mcpointer1723lhs"))))))).bind("mcpointer1723daddy"), &HandlerForPointer1723);
}
- if (umRuleList.at("17.2") || umRuleList.at("17.3"))
- {
+ if (umRuleList.at("17.2") || umRuleList.at("17.3")) {
Matcher.addMatcher(binaryOperator(allOf(hasOperatorName("-="), hasRHS(expr(anyOf(hasDescendant(declRefExpr(hasType(pointerType())).bind("mcpointer1723rhs")), \
has(declRefExpr(hasType(pointerType())).bind("mcpointer1723rhs"))))), \
hasLHS(expr(anyOf(hasDescendant(declRefExpr(hasType(pointerType())).bind("mcpointer1723lhs")), \
@@ -7460,13 +7357,11 @@ public:
/*end of 17.3 matchers*/
/*start of 17.4 matchers*/
- if (umRuleList.at("17.4"))
- {
+ if (umRuleList.at("17.4")) {
Matcher.addMatcher(castExpr(allOf(hasCastKind(CK_ArrayToPointerDecay), unless(hasParent(arraySubscriptExpr())))).bind("mcpointer174"), &HandlerForPointer174);
}
- if (umRuleList.at("17.4"))
- {
+ if (umRuleList.at("17.4")) {
Matcher.addMatcher(declRefExpr(allOf(hasAncestor(expr(anyOf(binaryOperator(hasOperatorName("-=")), \
unaryOperator(hasOperatorName("++")), unaryOperator(hasOperatorName("--")), \
binaryOperator(hasOperatorName("+")), binaryOperator(hasOperatorName("+=")), \
@@ -7474,196 +7369,144 @@ public:
}
/*end of 17.4 matchers*/
- if (umRuleList.at("17.5"))
- {
+ if (umRuleList.at("17.5")) {
Matcher.addMatcher(varDecl(hasType(pointerType())).bind("mcpointer175"), &HandlerForPointer175);
}
- if (umRuleList.at("17.5"))
- {
+ if (umRuleList.at("17.5")) {
Matcher.addMatcher(fieldDecl().bind("mcpointer175field"), &HandlerForPointer175);
}
- if (umRuleList.at("6.1"))
- {
+ if (umRuleList.at("6.1")) {
Matcher.addMatcher(declRefExpr(allOf(to(varDecl().bind("mctypes6origin")), \
hasAncestor(binaryOperator(allOf(hasRHS(expr().bind("mctypes6rhs")), \
hasOperatorName("="))).bind("mctypes6dous")), hasType(isAnyCharacter()))), &HandlerForTypes61);
}
- if (umRuleList.at("18.1"))
- {
+ if (umRuleList.at("18.1")) {
Matcher.addMatcher(varDecl(hasType(incompleteArrayType())).bind("mcsu181arr"), &HandlerForSU181);
}
- if (umRuleList.at("18.1"))
- {
+ if (umRuleList.at("18.1")) {
Matcher.addMatcher(recordDecl(isStruct()).bind("mcsu181struct"), &HandlerForSU184);
}
Matcher.addMatcher(cStyleCastExpr().bind("mcptc11cstyle"), &HandlerForMCPTCCSTYLE);
- if (umRuleList.at("10.1"))
- {
+ if (umRuleList.at("10.1")) {
Matcher.addMatcher(implicitCastExpr(has(expr(anyOf(binaryOperator().bind("atcdous"), unaryOperator().bind("atcuno"), \
parenExpr().bind("atcparens"), implicitCastExpr().bind("atckidice"), \
cStyleCastExpr().bind("atccstyle"))))).bind("atcdaddy"), &HandlerForATC101);
}
- if (umRuleList.at("5.1"))
- {
+ if (umRuleList.at("5.1")) {
Matcher.addMatcher(namedDecl().bind("ident5nameddecl"), &HandlerForIdent51);
}
- if (umRuleList.at("8.7"))
- {
+ if (umRuleList.at("8.7")) {
Matcher.addMatcher(declRefExpr(allOf(hasAncestor(functionDecl().bind("mcdcdf87daddy")), \
to(varDecl(unless(hasAncestor(functionDecl()))).bind("mcdcdf87origin")))).bind("mcdcdfobj"), &HandlerForDCDF87);
}
/*@DEVI-these two matcheres are breaking our 3.9 backwards compatibility.*/
-#if 1
- if (umRuleList.at("8.8"))
- {
+ if (umRuleList.at("8.8")) {
Matcher.addMatcher(functionDecl(hasExternalFormalLinkage()).bind("mcdcdf88function"), &HandlerForDCDF88);
}
- if (umRuleList.at("8.8"))
- {
+ if (umRuleList.at("8.8")) {
Matcher.addMatcher(varDecl(hasExternalFormalLinkage()).bind("mcdcdf88var"), &HandlerForDCDF88);
}
-#endif
- if (umRuleList.at("2.3"))
- {
+ if (umRuleList.at("2.3")) {
Matcher.addMatcher(expr().bind("mclangx23"), &HandlerForLangX23);
}
- if (umRuleList.at("16.7"))
- {
+ if (umRuleList.at("16.7")) {
Matcher.addMatcher(parmVarDecl(unless(allOf(hasAncestor(functionDecl(hasDescendant(binaryOperator(allOf(hasOperatorName("="), \
hasLHS(hasDescendant(declRefExpr(allOf(hasAncestor(unaryOperator(hasOperatorName("*"))), \
to(parmVarDecl(hasType(pointerType())).bind("zulu"))))))))))), equalsBoundNode("zulu")))).bind("mcfunction167"), &HandlerForFunction167);
}
- if (umRuleList.at("14.3"))
- {
+ if (umRuleList.at("14.3")) {
Matcher.addMatcher(nullStmt().bind("mccf143nullstmt"), &HandlerForCF143);
}
- if (umRuleList.at("12.12"))
- {
+ if (umRuleList.at("12.12")) {
Matcher.addMatcher(recordDecl(allOf(has(fieldDecl(hasType(realFloatingPointType()))), isUnion())).bind("mcexpr1212"), &HandlerForExpr1212);
}
- if (umRuleList.at("12.11"))
- {
+ if (umRuleList.at("12.11")) {
Matcher.addMatcher(expr(hasDescendant(expr(anyOf(unaryOperator(hasOperatorName("--"), hasOperatorName("++")).bind("mcexpr1211uno"), \
binaryOperator(anyOf(hasOperatorName("*"), hasOperatorName("/"), \
hasOperatorName("-"), hasOperatorName("+"))).bind("mcexpr1211dous"))))).bind("mcexpr1211"), &HandlerForExpr1211);
}
- if (umRuleList.at("10.5"))
- {
+ if (umRuleList.at("10.5")) {
Matcher.addMatcher(binaryOperator(allOf(hasLHS(expr(hasType(isInteger())).bind("mcatc105lhs")), hasOperatorName("<<"))).bind("mcatc105"), &HandlerForAtc105);
}
- if (umRuleList.at("10.5"))
- {
+ if (umRuleList.at("10.5")) {
Matcher.addMatcher(unaryOperator(allOf(hasOperatorName("~") , hasUnaryOperand(expr(hasType(isInteger())).bind("mcatc105lhs")))).bind("mcatc105uno"), &HandlerForAtc105);
}
- if (umRuleList.at("13.5"))
- {
+ if (umRuleList.at("13.5")) {
Matcher.addMatcher(forStmt().bind("mccse135"), &HandlerForCSE135);
}
- if (umRuleList.at("6.1") || umRuleList.at("6.2"))
- {
+ if (umRuleList.at("6.1") || umRuleList.at("6.2")) {
Matcher.addMatcher(binaryOperator(allOf(hasRHS(expr(has(expr(anyOf(integerLiteral().bind("mc612intlit"), \
characterLiteral().bind("mc612charlit")))))), hasLHS(expr(hasType(isAnyCharacter())).bind("mc612exp")), \
hasOperatorName("="))), &HandlerForTypes612);
}
/*@DEVI-start of 7.1 matchers.*/
- if (umRuleList.at("7.1"))
- {
+ if (umRuleList.at("7.1")) {
Matcher.addMatcher(stringLiteral().bind("mcconst71string"), &HandlerForConst71);
}
- if (umRuleList.at("7.1"))
- {
+ if (umRuleList.at("7.1")) {
Matcher.addMatcher(characterLiteral().bind("mcconst71char"), &HandlerForConst71);
}
- if (umRuleList.at("7.1"))
- {
+ if (umRuleList.at("7.1")) {
Matcher.addMatcher(integerLiteral().bind("mcconst71int"), &HandlerForConst71);
}
/*end of 7.1*/
/*@DEVI-matchers for 5.x*/
/*@DEVI-typedefs always have file scope.*/
- if (umRuleList.at("5.1") || umRuleList.at("5.2"), umRuleList.at("5.3") || umRuleList.at("5.4") || umRuleList.at("5.5") || umRuleList.at("5.6") || umRuleList.at("5.7"))
- {
+ if (umRuleList.at("5.1") || umRuleList.at("5.2"), umRuleList.at("5.3") || umRuleList.at("5.4") || umRuleList.at("5.5") || umRuleList.at("5.6") || umRuleList.at("5.7")) {
Matcher.addMatcher(typedefDecl().bind("ident5typedef"), &HandlerForIdent5X);
}
-#if 0
- Matcher.addMatcher(typedefDecl(unless(hasAncestor(functionDecl()))).bind("ident5typedef"), &HandlerForIdent5X);
-
- Matcher.addMatcher(typedefDecl(hasAncestor(functionDecl().bind("id5funcscope"))).bind("ident5typedef"), &HandlerForIdent5X);
-#endif
-
-
- if (umRuleList.at("5.1") || umRuleList.at("5.2"), umRuleList.at("5.3") || umRuleList.at("5.4") || umRuleList.at("5.5") || umRuleList.at("5.6") || umRuleList.at("5.7"))
- {
+ if (umRuleList.at("5.1") || umRuleList.at("5.2"), umRuleList.at("5.3") || umRuleList.at("5.4") || umRuleList.at("5.5") || umRuleList.at("5.6") || umRuleList.at("5.7")) {
Matcher.addMatcher(recordDecl(unless(hasAncestor(functionDecl()))).bind("ident5record"), &HandlerForIdent5X);
-
Matcher.addMatcher(recordDecl(hasAncestor(functionDecl().bind("id5funcscope"))).bind("ident5record"), &HandlerForIdent5X);
-
Matcher.addMatcher(fieldDecl(unless(hasAncestor(functionDecl()))).bind("ident5field"), &HandlerForIdent5X);
-
Matcher.addMatcher(fieldDecl(hasAncestor(functionDecl().bind("id5funcscope"))).bind("ident5field"), &HandlerForIdent5X);
-
Matcher.addMatcher(parmVarDecl(hasAncestor(functionDecl().bind("id5funcscope"))).bind("ident5parmvar"), &HandlerForIdent5X);
-
Matcher.addMatcher(functionDecl().bind("ident5func"), &HandlerForIdent5X);
-
Matcher.addMatcher(varDecl(unless(hasAncestor(functionDecl()))).bind("ident5var"), &HandlerForIdent5X);
-
Matcher.addMatcher(varDecl(hasAncestor(functionDecl().bind("id5funcscope"))).bind("ident5var"), &HandlerForIdent5X);
-
Matcher.addMatcher(enumDecl(unless(hasAncestor(functionDecl()))).bind("ident5enum") , &HandlerForIdent5X);
-
Matcher.addMatcher(enumDecl(hasAncestor(functionDecl().bind("id5funcscope"))).bind("ident5enum"), &HandlerForIdent5X);
-
/*@DEVI-labels always have function scope.*/
Matcher.addMatcher(labelDecl(hasAncestor(functionDecl().bind("id5funcscope"))).bind("ident5label"), &HandlerForIdent5X);
-
Matcher.addMatcher(enumConstantDecl(unless(hasAncestor(functionDecl()))).bind("ident5enumconst"), &HandlerForIdent5X);
-
Matcher.addMatcher(enumConstantDecl(hasAncestor(functionDecl().bind("id5funcscope"))).bind("ident5enumconst"), &HandlerForIdent5X);
}
/*end of matchers for 5.x*/
/*start of SaferCPP matchers*/
Matcher.addMatcher(varDecl(hasType(arrayType())).bind("sfcpparrdecl"), &HandlerForSFCPPARR01);
-
Matcher.addMatcher(fieldDecl(hasType(arrayType())).bind("sfcpparrfield"), &HandlerForSFCPPARR01);
-
Matcher.addMatcher(implicitCastExpr(hasCastKind(CK_ArrayToPointerDecay)).bind("sfcpparrcastexpr"), &HandlerForSFCPPARR01);
-
Matcher.addMatcher(cStyleCastExpr(hasCastKind(CK_ArrayToPointerDecay)).bind("sfcpparrcastexpr"), &HandlerForSFCPPARR01);
-
Matcher.addMatcher(declRefExpr(hasAncestor(binaryOperator(allOf(hasLHS(declRefExpr().bind("sfcpparrdeep")), hasRHS(hasDescendant(implicitCastExpr(hasCastKind(CK_ArrayToPointerDecay))))\
, hasOperatorName("="))))), &HandlerForSFCPPARR02);
-
Matcher.addMatcher(varDecl(hasType(pointerType())).bind("sfcpppntr01"), &HandlerForSFCPPPNTR01);
-
Matcher.addMatcher(declRefExpr(hasType(pointerType())).bind("sfcpppntr02"), &HandlerForSFCPPPNTR02);
/*end of SaferCPP matchers*/
-
#endif
}
@@ -7748,132 +7591,85 @@ private:
MatchFinder Matcher;
};
/**********************************************************************************************************************/
-class Mutator0DiagnosticConsumer : public clang::DiagnosticConsumer
-{
+class Mutator0DiagnosticConsumer : public clang::DiagnosticConsumer {
public:
-
virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) override
{
DiagnosticConsumer::HandleDiagnostic(DiagLevel, Info);
-
SourceLocation SL = Info.getLocation();
CheckSLValidity(SL);
-
SourceManager &SM = Info.getSourceManager();
- if (Devi::IsTheMatchInSysHeader(CheckSystemHeader, SM, SL))
- {
- return void();
- }
-
- if (!Devi::IsTheMatchInMainFile(MainFileOnly, SM, SL))
- {
- return void();
- }
+ if (Devi::IsTheMatchInSysHeader(CheckSystemHeader, SM, SL)) return void();
+ if (!Devi::IsTheMatchInMainFile(MainFileOnly, SM, SL)) return void();
SL = SM.getSpellingLoc(SL);
unsigned SpellingLine = SM.getSpellingLineNumber(SL);
unsigned SpellingColumn = SM.getSpellingColumnNumber(SL);
std::string FileName = SM.getFilename(SL).str();
-
SmallString<100> DiagBuffer;
-
Info.FormatDiagnostic(DiagBuffer);
-#if 0
- std::cout << "ClangDiag:" << DiagBuffer.str().str() << ":" << SL.printToString(SM) << ":" << Info.getID() << ":" << "\n";
-#endif
-
XMLDocOut.XMLAddNode(SpellingLine, SpellingColumn, FileName, "ClangDiag", DiagBuffer.str().str());
JSONDocOUT.JSONAddElement(SpellingLine, SpellingColumn, FileName, "ClangDiag", DiagBuffer.str().str());
- if (Info.getID() == 872U)
- {
+ if (Info.getID() == 872U) {
std::cout << "2.2:" << "Illegal comment format(/*...*/) used:" << SL.printToString(SM) << ":" << "\n";
-
XMLDocOut.XMLAddNode(SpellingLine, SpellingColumn, FileName, "2.2", "Illegal comment format(/*...*/) used:");
JSONDocOUT.JSONAddElement(SpellingLine, SpellingColumn, FileName, "2.2", "Illegal comment format(/*...*/) used:");
}
- if (Info.getID() == 974U)
- {
+ if (Info.getID() == 974U) {
std::cout << "2.3:" << "Use of the character sequence /* inside a comment is illegal:" << SL.printToString(SM) << ":" << "\n";
-
XMLDocOut.XMLAddNode(SpellingLine, SpellingColumn, FileName, "2.3", "Use of the character sequence /* inside a comment is illegal:");
JSONDocOUT.JSONAddElement(SpellingLine, SpellingColumn, FileName, "2.3", "Use of the character sequence /* inside a comment is illegal:");
}
- if (Info.getID() == 938U)
- {
+ if (Info.getID() == 938U) {
std::cout << "4.2:" << "Use of trigraphs is illegal:" << SL.printToString(SM) << ":" << "\n";
-
XMLDocOut.XMLAddNode(SpellingLine, SpellingColumn, FileName, "4.2", "Use of trigraphs is illegal:");
JSONDocOUT.JSONAddElement(SpellingLine, SpellingColumn, FileName, "4.2", "Use of trigraphs is illegal:");
}
- if (Info.getID() == 4578U)
- {
+ if (Info.getID() == 4578U) {
std::cout << "9.2:" << "Brace initialization has either not been correctly used or not used at all:" << SL.printToString(SM) << ":" << "\n";
-
XMLDocOut.XMLAddNode(SpellingLine, SpellingColumn, FileName, "9.2", "Brace initialization has either not been correctly used or not used at all:");
JSONDocOUT.JSONAddElement(SpellingLine, SpellingColumn, FileName, "9.2", "Brace initialization has either not been correctly used or not used at all:");
}
- if (Info.getID() == 4872U)
- {
+ if (Info.getID() == 4872U) {
std::cout << "14.2:" << "Expression result is unused:" << SL.printToString(SM) << ":" << "\n";
-
XMLDocOut.XMLAddNode(SpellingLine, SpellingColumn, FileName, "14.2", "Expression result is unused:");
JSONDocOUT.JSONAddElement(SpellingLine, SpellingColumn, FileName, "14.2", "Expression result is unused:");
}
- if (Info.getID() == 966U)
- {
+ if (Info.getID() == 966U) {
std::cout << "19.14:" << "\"defined\" has undefined behaviour:" << SL.printToString(SM) << ":" << "\n";
-
XMLDocOut.XMLAddNode(SpellingLine, SpellingColumn, FileName, "19.14", "\"defined\" has undefined behaviour:");
JSONDocOUT.JSONAddElement(SpellingLine, SpellingColumn, FileName, "19.14", "\"defined\" has undefined behaviour:");
}
- if (Info.getID() == 895U)
- {
+ if (Info.getID() == 895U) {
std::cout << "20.1:" << "Redefining built-in macro:" << SL.printToString(SM) << ":" << "\n";
-
XMLDocOut.XMLAddNode(SpellingLine, SpellingColumn, FileName, "20.1", "Redefining built-in macro:");
JSONDocOUT.JSONAddElement(SpellingLine, SpellingColumn, FileName, "20.1", "Redefining built-in macro:");
}
-
}
private:
-
};
/**********************************************************************************************************************/
-class MyFrontendAction : public ASTFrontendAction
-{
+class MyFrontendAction : public ASTFrontendAction {
public:
MyFrontendAction() {}
+ void EndSourceFileAction() override {}
- void EndSourceFileAction() override
- {
-
- }
-
- std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef file) override
- {
-#if 1
+ std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef file) override {
CI.getPreprocessor().addPPCallbacks(llvm::make_unique<PPInclusion>(&CI.getSourceManager()));
-#endif
-
DiagnosticsEngine &DiagEngine = CI.getPreprocessor().getDiagnostics();
-
-#if 1
Mutator0DiagnosticConsumer* M0DiagConsumer = new Mutator0DiagnosticConsumer;
-
DiagEngine.setClient(M0DiagConsumer, true);
-#endif
-
TheRewriter.setSourceMgr(CI.getSourceManager(), CI.getLangOpts());
return llvm::make_unique<MyASTConsumer>(TheRewriter);
}
@@ -7883,8 +7679,24 @@ private:
};
/**********************************************************************************************************************/
/*Main*/
-int main(int argc, const char **argv)
+int main(int argc, const char** argv)
{
+#if 0
+ std::string action_file_path;
+ for (int i = 0; i < argc; ++i) {
+ if (strcmp(argv[i], "--file") == 0) {
+ if (i < argc - 2) {
+ action_file_path = argv[i];
+ } else {
+ std::cout << "error:bad argument for option --file\n";
+ }
+ }
+ }
+ std::vector<const char*> vc;
+ std::vector<std::string> vs = Devi::action_file_parser(argc, argv, action_file_path);
+ std::transform(vs.begin(), vs.end(), std::back_inserter(vc), [](const std::string &s){return s.c_str();});
+#endif
+ //CommonOptionsParser op(argc, &vc[0], MutatorLVL0Cat);
CommonOptionsParser op(argc, argv, MutatorLVL0Cat);
CompilationDatabase &CDB [[maybe_unused]] = op.getCompilations();
@@ -7892,28 +7704,21 @@ int main(int argc, const char **argv)
std::vector<std::vector<std::string>> ExecCL;
#if defined(_MUT0_TEST)
- for (auto &iter : ComCom)
- {
+ for (auto &iter : ComCom) {
ExecCL.push_back(iter.CommandLine);
}
- for (auto &iter : ExecCL)
- {
- for (auto &yaiter : iter)
- {
+ for (auto &iter : ExecCL) {
+ for (auto &yaiter : iter) {
std::cout << "comcom: " << yaiter << "\n";
}
-
std::cout << "\n";
}
#endif
const std::vector<std::string> &SourcePathList = op.getSourcePathList();
-
ClangTool Tool(op.getCompilations(), op.getSourcePathList());
-
StringOptionsParser SOPProto;
-
SOPProto.MC2Parser();
#if defined(_MUT0_TEST)
@@ -7921,18 +7726,16 @@ int main(int argc, const char **argv)
#endif
#if defined(_MUT0_TEST)
- if (SOPProto.MC2Parser())
- {
+ if (SOPProto.MC2Parser()) {
typedef std::multimap<std::string, std::string>::iterator Iter;
- for (Iter iter = MC1EquivalencyMap.begin(), iterE = MC1EquivalencyMap.end(); iter != iterE; ++iter)
- {
+ for (Iter iter = MC1EquivalencyMap.begin(), iterE = MC1EquivalencyMap.end(); iter != iterE; ++iter) {
std::cout << "Key: " << iter->first << " " << "Value: " << iter->second << "\n";
}
}
#endif
XMLDocOut.XMLCreateReport();
- JSONDocOUT.JSONCreateReport();
+ JSONDocOUT.JSONCreateReport(JSONOUT);
IsThereJunkPreInclusion ITJPIInstance;
ITJPIInstance.Check(SourcePathList);
int RunResult = 0;
@@ -7950,10 +7753,10 @@ int main(int argc, const char **argv)
CheckForNullStatements CheckForNull;
CheckForNull.Check();
onEndOfAllTUs::run();
- XMLDocOut.SaveReport();
+ XMLDocOut.SaveReport(XMLOUT);
JSONDocOUT.CloseReport();
ME.DumpAll();
- ME.XMLReportAncestry();
+ ME.XMLReportAncestry(MUTAGENOUT);
return RunResult;
} //end of main
diff --git a/m0/mutator-lvl0.h b/m0/mutator-lvl0.h
index c1e452a..5881228 100644
--- a/m0/mutator-lvl0.h
+++ b/m0/mutator-lvl0.h
@@ -521,13 +521,13 @@ class MutagenExtraction
}
}
- void XMLReportAncestry(void)
+ void XMLReportAncestry(std::string savepath)
{
mutagenAncestryReport MAR(MutantStrainsAncestry, WeakPoints);
MAR.CreateReport();
MAR.AddNode();
MAR.AddNodeWeakPoint();
- MAR.SaveReport("m0.xml");
+ MAR.SaveReport(savepath.c_str());
}
private:
diff --git a/m0/mutator_aux.cpp b/m0/mutator_aux.cpp
index 83211f5..f6b2675 100644
--- a/m0/mutator_aux.cpp
+++ b/m0/mutator_aux.cpp
@@ -20,10 +20,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*
/*********************************************************************************************************************/
/*inclusion directives*/
#include "mutator_aux.h"
+#include <algorithm>
#include <string>
#include <cassert>
#include <iostream>
#include <fstream>
+#include <iterator>
#include "clang/AST/AST.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Basic/SourceManager.h"
@@ -144,6 +146,41 @@ bool IsTheMatchInMainFile(bool MainFileFlag, bool MainFile) {
}
}
/*********************************************************************************************************************/
+std::vector<std::string> action_file_parser (int argc, const char** argv, std::string file_path) {
+ int i = 1;
+ std::vector<std::string> vs;
+ std::ifstream action_file(file_path);
+ for (std::string line; getline(action_file, line);) {
+ size_t pos = line.find(":");
+ if (line[0] == '#') {
+ i++;
+ continue;
+ }
+ if (pos == std::string::npos) {
+ if (line[0] != '#') {
+ if (strcmp(line.c_str(), "") != 0)std::cout << "m0 action file parser:error:malformed line at " << i << ".\n";//FIXME-RED
+ //return 1;
+ } else {
+ i++;
+ continue;
+ }
+ }
+ std::string content = line.substr(pos + 1, std::string::npos);
+ std::string option = line.substr(0, pos);
+ if (option == "action_name") {}
+ else if (option == "exec_opts") {vs.push_back(content);}
+ else if (option == "in_files") {vs.push_back(content);}
+ else if (option == "libtooling_options") {vs.push_back(content);}
+ else if (option == "out_files") {vs.push_back(content);}
+ else if (option == "log_files") {}
+ else if (option == "print_pretty") {}
+ else if (option == "end_action") {}
+ else {/*std::cout << "m0 action file parser:error:bad option at line "<< i <<"\n"*/;}//FIXME-RED
+ i++;
+ }
+ return vs;
+}
+/*********************************************************************************************************************/
/*End of namespace Devi*/
}
/*********************************************************************************************************************/
diff --git a/m0/mutator_aux.h b/m0/mutator_aux.h
index 9f22a5a..0067335 100644
--- a/m0/mutator_aux.h
+++ b/m0/mutator_aux.h
@@ -58,6 +58,8 @@ bool IsTheMatchInMainFile(bool MainFileFlag, const SourceManager &SM, SourceLoca
bool IsTheMatchInMainFile(bool MainFileFlag, bool MainFile, SourceLocation SL);
bool IsTheMatchInMainFile(bool MainFileFlag, bool MainFile);
/*********************************************************************************************************************/
+std::vector<std::string> action_file_parser (int argc, const char** argv, std::string file_path);
+/*********************************************************************************************************************/
/*end of namespace Devi*/
}
#endif
diff --git a/m0/mutator_report.cpp b/m0/mutator_report.cpp
index 1e0459f..3b6a2d3 100644
--- a/m0/mutator_report.cpp
+++ b/m0/mutator_report.cpp
@@ -69,8 +69,7 @@ namespace Devi {
/************************************************end of XMLReportBase*************************************************/
/*********************************************************************************************************************/
/******************************************************XMLReport******************************************************/
-XMLReport::XMLReport()
-{
+ XMLReport::XMLReport() {
RootPointer = XMLReportDoc.NewElement("mutator:Report");
RootPointer->SetAttribute("xmlns:mutator", "http://www.w3.org/2001/XMLSchema");
}
@@ -176,7 +175,7 @@ bool XMLReport::isReportEmpty(void)
return false;
}
-void XMLReport::SaveReport(void)
+void XMLReport::SaveReport(std::string savepath)
{
if(this->isReportEmpty())
{
@@ -185,7 +184,7 @@ void XMLReport::SaveReport(void)
XMLReportDoc.InsertEndChild(RootPointer);
- XMLError XMLErrorResult = XMLReportDoc.SaveFile("./misrareport.xml");
+ XMLError XMLErrorResult = XMLReportDoc.SaveFile(savepath.c_str());
if (XMLErrorResult != XML_SUCCESS)
{
@@ -197,9 +196,9 @@ void XMLReport::SaveReport(void)
/*****************************************************JSONReport******************************************************/
JSONReport::JSONReport() {}
-void JSONReport::JSONCreateReport(void)
+void JSONReport::JSONCreateReport(std::string outpath)
{
- JSONRepFile.open("./test/misrareport.json", std::ios::out);
+ JSONRepFile.open(outpath, std::ios::out);
}
void JSONReport::JSONAddElement(ASTContext* ASTC, SourceLocation SL, std::string MisraRule, std::string Description)
diff --git a/m0/mutator_report.h b/m0/mutator_report.h
index 0be06f6..730b7ec 100644
--- a/m0/mutator_report.h
+++ b/m0/mutator_report.h
@@ -80,7 +80,7 @@ namespace Devi {
bool isReportEmpty(void);
- void SaveReport(void);
+ void SaveReport(std::string savepath);
private:
XMLDocument XMLReportDoc;
@@ -92,7 +92,7 @@ namespace Devi {
public:
JSONReport();
- void JSONCreateReport(void);
+ void JSONCreateReport(std::string outpath);
void JSONAddElement(ASTContext* ASTC, SourceLocation SL, std::string MisraRule, std::string Description);
/*overload for checks that announce the result in onendoftranslation unit.*/
void JSONAddElement(FullSourceLoc FSL, SourceLocation SL, std::string MisraRule, std::string Description);
diff --git a/m0/run.sh b/m0/run.sh
new file mode 100755
index 0000000..9f6b635
--- /dev/null
+++ b/m0/run.sh
@@ -0,0 +1 @@
+./mutator-lvl0 --jsonout ./report.json --xmlout ./report.xml --mutagenout ./mutagen.xml -MCEA -MCD="5.1 5.2 5.3 5.4 5.5 5.6 5.7" -SysHeader=false -MainOnly=true -MCV=C2 -mutagen ../test/testFuncs1.c ../test/testFuncs2.c ../test/testFuncs3.c ../test/testFuncs3.h ../test/testFuncs2.h ../test/testFuncs1.h -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/7/include -Wall > ./misra-log