diff options
-rw-r--r-- | bruiser/ORCmutation.h | 5 | ||||
-rwxr-xr-x | extra-tools/precommitTests.sh | 30 | ||||
-rw-r--r-- | mutator-lvl0.cpp | 22 | ||||
-rw-r--r-- | mutator-lvl0.h | 2 | ||||
-rw-r--r-- | mutator-lvl2.cpp | 11 | ||||
-rw-r--r-- | samples/action_file.mutator | 5 | ||||
-rw-r--r-- | test/bruisertest/test.cpp | 4 |
7 files changed, 51 insertions, 28 deletions
diff --git a/bruiser/ORCmutation.h b/bruiser/ORCmutation.h index 0a67c80..288ea21 100644 --- a/bruiser/ORCmutation.h +++ b/bruiser/ORCmutation.h @@ -23,7 +23,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.* /*inclusion guard*/ #ifndef ORC_MUTATION_H #define ORC_MUTATION_H -#if __clang_major__ >= 5 +//#if __clang_major__ >= 5 +#if 0 /**********************************************************************************************************************/ /*included modules*/ /*project headers*/ @@ -151,7 +152,7 @@ class MutatorJIT class runMainOnJit { -#if 0 +#if 1 std::unique_ptr<llvm::Module> M = buildModule(); MutatorJIT jit; Handle H = jit.addModule(*M); diff --git a/extra-tools/precommitTests.sh b/extra-tools/precommitTests.sh index 640aa2e..924731b 100755 --- a/extra-tools/precommitTests.sh +++ b/extra-tools/precommitTests.sh @@ -57,8 +57,8 @@ fi printf "${Lblue}running mutator-lvl0 on the tdd sources...\n${NC}" | tee -a ./test/precommit.rep -printf "${Orange}./mutator-lvl0 -SysHeader=false -MainOnly=true ./test/testFuncs1.c ./test/testFuncs2.c ./test/testFuncs3.c -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.3.1/include -Wall > ./test/misra-log\n${NC}" | tee -a ./test/precommit.rep -"./mutator-lvl0" -SysHeader=false -MainOnly=true ./test/testFuncs1.c ./test/testFuncs2.c ./test/testFuncs3.c -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.3.1/include -Wall > ./test/misra-log +printf "${Orange}./mutator-lvl0 -SysHeader=false -MainOnly=true ./test/testFuncs1.c ./test/testFuncs2.c ./test/testFuncs3.c -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.4.1/include -Wall > ./test/misra-log\n${NC}" | tee -a ./test/precommit.rep +"./mutator-lvl0" -SysHeader=false -MainOnly=true ./test/testFuncs1.c ./test/testFuncs2.c ./test/testFuncs3.c -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.4.1/include -Wall > ./test/misra-log if [[ $? == 0 ]]; then printf "${Green}mutator-lvl0 smoke test on the tdds passed.\n${NC}" | tee -a ./test/precommit.rep @@ -85,8 +85,8 @@ else fi printf "${Lblue}running smoke tests on mutator-lvl0...\n${NC}" | tee -a ./test/precommit.rep -printf "${Orange}./mutator-lvl0 -SysHeader=false -MainOnly=true ./test/testFuncs3.h -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.3.1/include -Wall > ./test/misra-log\n${NC}" | tee -a ./test/precommit.rep -"./mutator-lvl0" -SysHeader=false -MainOnly=true ./test/testFuncs3.h -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.3.1/include -Wall > ./test/misra-log +printf "${Orange}./mutator-lvl0 -SysHeader=false -MainOnly=true ./test/testFuncs3.h -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.4.1/include -Wall > ./test/misra-log\n${NC}" | tee -a ./test/precommit.rep +"./mutator-lvl0" -SysHeader=false -MainOnly=true ./test/testFuncs3.h -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.4.1/include -Wall > ./test/misra-log if [[ $? == 0 ]]; then printf "${Green}mutator-lvl0 C++11 smoke test passed...\n${NC}" | tee -a ./test/precommit.rep @@ -119,7 +119,7 @@ fi printf "${Lblue}running cpp smoke tests on mutator-lvl0...\n${NC}" | tee -a ./test/precommit.rep printf "${Orange}./mutator-lvl0 ./test/m0-cpp-smoke/m0-cpp-smoke.cpp\n${NC}" | tee -a ./test/precommit.rep -"./mutator-lvl0" -./test/m0-cpp-smoke/m0-cpp-smoke.cpp +"./mutator-lvl0" ./test/m0-cpp-smoke/m0-cpp-smoke.cpp -- if [[ $? == 0 ]]; then printf "${Green}mutator-lvl0 C++11 cpp std headers smoke test passed...\n${NC}" | tee -a ./test/precommit.rep @@ -149,8 +149,8 @@ else fi printf "${Lblue}running mutator-lvl0 on the tdd sources...\n${NC}" | tee -a ./test/precommit.rep -printf "${Orange}./mutator-lvl0 -SysHeader=false -MainOnly=true ./test/testFuncs1.c ./test/testFuncs2.c ./test/testFuncs3.c -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.3.1/include -Wall > ./test/misra-log\n${NC}" | tee -a ./test/precommit.rep -"./mutator-lvl0" -SysHeader=false -MainOnly=true ./test/testFuncs1.c ./test/testFuncs2.c ./test/testFuncs3.c -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.3.1/include -Wall > ./test/misra-log +printf "${Orange}./mutator-lvl0 -SysHeader=false -MainOnly=true ./test/testFuncs1.c ./test/testFuncs2.c ./test/testFuncs3.c -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.4.1/include -Wall > ./test/misra-log\n${NC}" | tee -a ./test/precommit.rep +"./mutator-lvl0" -SysHeader=false -MainOnly=true ./test/testFuncs1.c ./test/testFuncs2.c ./test/testFuncs3.c -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.4.1/include -Wall > ./test/misra-log if [[ $? == 0 ]]; then printf "${Green}mutator-lvl0 smoke test on the tdds passed.\n${NC}" | tee -a ./test/precommit.rep @@ -177,8 +177,8 @@ else fi printf "${Lblue}running smoke tests on mutator-lvl0...\n${NC}" | tee -a ./test/precommit.rep -printf "${Orange}./mutator-lvl0 -SysHeader=false -MainOnly=true ./test/testFuncs3.h -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.3.1/include -Wall > ./test/misra-log\n${NC}" | tee -a ./test/precommit.rep -"./mutator-lvl0" -SysHeader=false -MainOnly=true ./test/testFuncs3.h -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.3.1/include -Wall > ./test/misra-log +printf "${Orange}./mutator-lvl0 -SysHeader=false -MainOnly=true ./test/testFuncs3.h -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.4.1/include -Wall > ./test/misra-log\n${NC}" | tee -a ./test/precommit.rep +"./mutator-lvl0" -SysHeader=false -MainOnly=true ./test/testFuncs3.h -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.4.1/include -Wall > ./test/misra-log if [[ $? == 0 ]]; then printf "${Green}mutator-lvl0 C++1z smoke test passed...\n${NC}" | tee -a ./test/precommit.rep @@ -211,7 +211,7 @@ fi printf "${Lblue}running cpp smoke tests on mutator-lvl0...\n${NC}" | tee -a ./test/precommit.rep printf "${Orange}./mutator-lvl0 ./test/m0-cpp-smoke/m0-cpp-smoke.cpp\n${NC}" | tee -a ./test/precommit.rep -"./mutator-lvl0" -./test/m0-cpp-smoke/m0-cpp-smoke.cpp +"./mutator-lvl0" ./test/m0-cpp-smoke/m0-cpp-smoke.cpp -- if [[ $? == 0 ]]; then printf "${Green}mutator-lvl0 C++1z cpp std headers smoke test passed...\n${NC}" | tee -a ./test/precommit.rep @@ -234,8 +234,8 @@ else fi printf "${Lblue}running mutator-lvl0 on the tdd sources...\n${NC}" | tee -a ./test/precommit.rep -printf "${Orange}./mutator-lvl0 -SysHeader=false -MainOnly=true ./test/testFuncs1.c ./test/testFuncs2.c ./test/testFuncs3.c -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.3.1/include -Wall > ./test/misra-log\n${NC}" | tee -a ./test/precommit.rep -"./mutator-lvl0" -SysHeader=false -MainOnly=true ./test/testFuncs1.c ./test/testFuncs2.c ./test/testFuncs3.c -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.3.1/include -Wall > ./test/misra-log +printf "${Orange}./mutator-lvl0 -SysHeader=false -MainOnly=true ./test/testFuncs1.c ./test/testFuncs2.c ./test/testFuncs3.c -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.4.1/include -Wall > ./test/misra-log\n${NC}" | tee -a ./test/precommit.rep +"./mutator-lvl0" -SysHeader=false -MainOnly=true ./test/testFuncs1.c ./test/testFuncs2.c ./test/testFuncs3.c -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.4.1/include -Wall > ./test/misra-log if [[ $? == 0 ]]; then printf "${Green}mutator-lvl0 smoke test on the tdds passed.\n${NC}" | tee -a ./test/precommit.rep @@ -262,8 +262,8 @@ else fi printf "${Lblue}running smoke tests on mutator-lvl0...\n${NC}" | tee -a ./test/precommit.rep -printf "${Orange}./mutator-lvl0 -SysHeader=false -MainOnly=true ./test/testFuncs3.h -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.3.1/include -Wall > ./test/misra-log\n${NC}" | tee -a ./test/precommit.rep -"./mutator-lvl0" -SysHeader=false -MainOnly=true ./test/testFuncs3.h -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.3.1/include -Wall > ./test/misra-log +printf "${Orange}./mutator-lvl0 -SysHeader=false -MainOnly=true ./test/testFuncs3.h -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.4.1/include -Wall > ./test/misra-log\n${NC}" | tee -a ./test/precommit.rep +"./mutator-lvl0" -SysHeader=false -MainOnly=true ./test/testFuncs3.h -- -std=c90 -I/lib/gcc/x86_64-redhat-linux/6.4.1/include -Wall > ./test/misra-log if [[ $? == 0 ]]; then printf "${Green}mutator-lvl0 C++14 smoke test passed...\n${NC}" | tee -a ./test/precommit.rep @@ -296,7 +296,7 @@ fi printf "${Lblue}running cpp smoke tests on mutator-lvl0...\n${NC}" | tee -a ./test/precommit.rep printf "${Orange}./mutator-lvl0 ./test/m0-cpp-smoke/m0-cpp-smoke.cpp\n${NC}" | tee -a ./test/precommit.rep -"./mutator-lvl0" -./test/m0-cpp-smoke/m0-cpp-smoke.cpp +"./mutator-lvl0" ./test/m0-cpp-smoke/m0-cpp-smoke.cpp -- if [[ $? == 0 ]]; then printf "${Green}mutator-lvl0 C++14 cpp std headers smoke test passed...\n${NC}" | tee -a ./test/precommit.rep diff --git a/mutator-lvl0.cpp b/mutator-lvl0.cpp index 8121030..783cb65 100644 --- a/mutator-lvl0.cpp +++ b/mutator-lvl0.cpp @@ -683,9 +683,12 @@ public: ASTContext *const ASTC = MR.Context; ASTContext::DynTypedNodeList NodeList = ASTC->getParents(*CS); + + ast_type_traits::DynTypedNode ParentNode; /*@DEVI-assumptions:nothing has more than one parent in C.*/ - ast_type_traits::DynTypedNode ParentNode = NodeList[0]; + if (!NodeList.empty()) ParentNode = NodeList[0]; + else return void(); ast_type_traits::ASTNodeKind ParentNodeKind = ParentNode.getNodeKind(); @@ -3488,9 +3491,11 @@ public: if (TP->isIntegerType()) { ASTContext::DynTypedNodeList NodeList = ASTC->getParents(*EXP); - + + ast_type_traits::DynTypedNode ParentNode; /*assumptions:nothing has more than one parent in C.*/ - ast_type_traits::DynTypedNode ParentNode = NodeList[0]; + if (!NodeList.empty()) ParentNode = NodeList[0]; + else return void(); ast_type_traits::ASTNodeKind ParentNodeKind = ParentNode.getNodeKind(); @@ -5341,12 +5346,15 @@ public: { /*@DEVI-assumes there is only one parent for every node which is true only for C, not Cpp*/ ASTContext::DynTypedNodeList NodeList = ASTC->getParents(DynOpNode); - - const ast_type_traits::DynTypedNode &ParentNode = NodeList[0U]; + ast_type_traits::DynTypedNode ParentNode; + if (!NodeList.empty()) ParentNode = NodeList[0U]; + else return void(); ASTContext::DynTypedNodeList AncestorNodeList = ASTC->getParents(ParentNode); - const ast_type_traits::DynTypedNode AncestorNode = AncestorNodeList[0U]; + ast_type_traits::DynTypedNode AncestorNode; + if (!AncestorNodeList.empty()) AncestorNode = AncestorNodeList[0U]; + else return void(); ast_type_traits::ASTNodeKind ParentNodeKind = ParentNode.getNodeKind(); ast_type_traits::ASTNodeKind AncestorNodeKind = AncestorNode.getNodeKind(); @@ -8506,7 +8514,9 @@ public: 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()); diff --git a/mutator-lvl0.h b/mutator-lvl0.h index f4a7635..28c126c 100644 --- a/mutator-lvl0.h +++ b/mutator-lvl0.h @@ -460,6 +460,7 @@ class MutagenExtraction void ExtractAncestry(clang::ast_type_traits::DynTypedNode __dtn, clang::ASTContext &__astx) { clang::ASTContext::DynTypedNodeList DNL = __astx.getParents(__dtn); + if (DNL.empty()) return void(); /*FIXME-a LastStrain. obviously well end up losing some parents in cpp if we're just picking up the * first parent from the list.*/ @@ -470,6 +471,7 @@ class MutagenExtraction while (DTN.getNodeKind().asStringRef().str() != "FunctionDecl") { DNL = __astx.getParents(DTN); + if (DNL.empty()) return void(); DTN = DNL[0]; LastStrain.push_back(DTN.getNodeKind().asStringRef().str()); } diff --git a/mutator-lvl2.cpp b/mutator-lvl2.cpp index 6ba03f7..5bb0020 100644 --- a/mutator-lvl2.cpp +++ b/mutator-lvl2.cpp @@ -106,9 +106,15 @@ private: Rewriter &Rewrite; }; /**********************************************************************************************************************/ +class BlankDiagConsumer : public clang::DiagnosticConsumer +{ + public: + BlankDiagConsumer() = default; + virtual ~BlankDiagConsumer() {} + virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) override {} +}; /**********************************************************************************************************************/ class MyASTConsumer : public ASTConsumer { - public: MyASTConsumer(Rewriter &R) : HandlerForIfElse(R) { Matcher.addMatcher(ifStmt(allOf(hasElse(ifStmt()), unless(hasAncestor(ifStmt())), unless(hasDescendant(ifStmt(hasElse(unless(ifStmt()))))))).bind("mrifelse"), &HandlerForIfElse); @@ -131,11 +137,14 @@ public: } 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()); return llvm::make_unique<MyASTConsumer>(TheRewriter); } private: + BlankDiagConsumer* BDCProto = new BlankDiagConsumer; Rewriter TheRewriter; }; /**********************************************************************************************************************/ diff --git a/samples/action_file.mutator b/samples/action_file.mutator index 5ed1f08..fcee97d 100644 --- a/samples/action_file.mutator +++ b/samples/action_file.mutator @@ -2,9 +2,10 @@ action_name:my_action1 executable_name:mutator-lvl0 #these are the options specific to the executable exec_opts:-MCEA -MCD="5.1 5.2 5.3 5.4 5.5 5.6 5.7" -SysHeader=false -MainOnly=true -MCV=C2 -mutagen -in_files:./test/testFuncs1.c ./test/testFuncs2.c ./test/testFuncs3.c +in_files:./test/testFuncs1.c ./test/testFuncs2.c ./test/testFuncs3.c ./test/testFuncs3.h ./test/testFuncs2.h ./test/testFuncs1.h +#in_files:./test/testFuncs1.c ./test/testFuncs2.c ./test/testFuncs3.c #clang options -libtooling_options:-std=c90 -I/lib/gcc/x86_64-redhat-linux/6.3.1/include -Wall +libtooling_options:-std=c90 -I/lib/gcc/x86_64-redhat-linux/6.4.1/include -Wall #the output file out_files:./test/misra-log #the log file diff --git a/test/bruisertest/test.cpp b/test/bruisertest/test.cpp index 680ce56..2e39dd9 100644 --- a/test/bruisertest/test.cpp +++ b/test/bruisertest/test.cpp @@ -1,5 +1,5 @@ -#if 1 +#if 0 #include <fstream> #include <iostream> #endif @@ -22,7 +22,7 @@ namespace devi int main(int argc, const char **argv) { -#if 1 +#if 0 std::ofstream myfile; myfile.open("./touch"); myfile << "line one.\n"; |