From a31d81df13ebf96f83122f9d186aad99d41c8be6 Mon Sep 17 00:00:00 2001 From: bloodstalker Date: Sat, 3 Dec 2016 20:47:48 +0330 Subject: added 8.5-has a problem with headers being pasted. sees things double --- mutator-lvl0.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/mutator-lvl0.cpp b/mutator-lvl0.cpp index 57289de..4253913 100644 --- a/mutator-lvl0.cpp +++ b/mutator-lvl0.cpp @@ -41,6 +41,7 @@ Devi::XMLReport XMLDocOut; std::vector MacroDefSourceLocation; std::vector MacroUndefSourceLocation; std::vector MacroNameString; +std::vector IncludeFileArr; static llvm::cl::OptionCategory MatcherSampleCategory("Matcher Sample"); /**********************************************************************************************************************/ @@ -742,6 +743,30 @@ public: FullSourceLoc FSL = ASTC->getFullLoc(SL); FullSourceLoc FSLE = ASTC->getFullLoc(SLE); + /*start of 8.5*/ + bool FunctionDeclaredInsideHeader = false; + + if (FD->isThisDeclarationADefinition()) + { + for (unsigned x = 0; x < IncludeFileArr.size(); ++x) + { + if (SM.getFilename(SL).str() == IncludeFileArr[x]) + { + FunctionDeclaredInsideHeader = true; + } + } + } + + if (FunctionDeclaredInsideHeader) + { + std::cout << "8.5 : " << "Function definition inside a header file : " << std::endl; + std::cout << SL.printToString(*MR.SourceManager) << "\n" << std::endl; + + XMLDocOut.XMLAddNode(MR.Context, SL, "8.5", "Function definition inside a header file : "); + } + /*end of 8.5*/ + + /*start of checks for 19.5*/ /*has false positives.*/ if (FD->isThisDeclarationADefinition()) @@ -894,6 +919,33 @@ public: const clang::Type* TP = QT.getTypePtr(); + ASTContext *const ASTC = MR.Context; + + SourceManager &SM = ASTC->getSourceManager(); + + /*start of 8.5*/ + bool VarDeclaredInsideHeader = false; + + if (VD->isThisDeclarationADefinition(*ASTC) && !(!VD->isLocalVarDecl() && VD->isLocalVarDeclOrParm())) + { + for (unsigned x = 0; x < IncludeFileArr.size(); ++x) + { + if (SM.getFilename(SL).str() == IncludeFileArr[x]) + { + VarDeclaredInsideHeader = true; + } + } + } + + if (VarDeclaredInsideHeader) + { + std::cout << "8.5 : " << "Variable definition inside a header file : " << std::endl; + std::cout << SL.printToString(*MR.SourceManager) << "\n" << std::endl; + + XMLDocOut.XMLAddNode(MR.Context, SL, "8.5", "Variable definition inside a header file : "); + } + /*end of 8.5*/ + /*start of 8.12*/ if (!VD->hasInit()) { @@ -2403,6 +2455,22 @@ public: XMLDocOut.XMLAddNode(SM, HashLoc, "19.2", "illegal characters in inclusion directive : "); } + + bool IsNewIncludeFile = true; + + for (unsigned x = 0; x < IncludeFileArr.size(); ++x) + { + if (FileName.str() == IncludeFileArr[x]) + { + IsNewIncludeFile = false; + break; + } + } + + if (IsNewIncludeFile) + { + IncludeFileArr.push_back(SearchPath.str() + "/" + FileName.str()); + } } size_t whateverSlashPos = FileName.find("\\", 0); -- cgit v1.2.3