From 8642eb69bebc218f887dec5a9ae810445e8f9929 Mon Sep 17 00:00:00 2001 From: bloodstalker Date: Sat, 31 Dec 2016 20:36:37 +0330 Subject: added some helper functions to support the new mutator-lvl0 cl options --- mutator_aux.cpp | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/mutator_aux.cpp b/mutator_aux.cpp index 0d74e68..a27878a 100644 --- a/mutator_aux.cpp +++ b/mutator_aux.cpp @@ -8,6 +8,7 @@ #include #include #include "clang/AST/AST.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/Basic/SourceManager.h" #include "clang/Rewrite/Core/Rewriter.h" #include "tinyxml2/tinyxml2.h" @@ -50,6 +51,91 @@ SourceLocation SourceLocationHasMacro (SourceLocation SL, Rewriter &Rewrite, std return (SL); } +/*********************************************************************************************************************/ +/*********************************************************************************************************************/ +/*********************************************************************************************************************/ +/*the first argument is the option SysHeader from the mutator-lvl0 cl.*/ +bool IsTheMatchInSysHeader(bool SysHeaderFlag, const ast_matchers::MatchFinder::MatchResult &MR, SourceLocation SL) +{ + ASTContext *const ASTC = MR.Context; + const SourceManager &SM = ASTC->getSourceManager(); + + if (SM.isInSystemHeader(SL) && !SysHeaderFlag) + { + return true; + } + else + { + return false; + } +} + +bool IsTheMatchInSysHeader(bool SysHeaderFlag, const SourceManager &SM, SourceLocation SL) +{ + if (SM.isInSystemHeader(SL) && !SysHeaderFlag) + { + return true; + } + else + { + return false; + } +} + +bool IsTheMatchInSysHeader(bool SysHeaderFlag, bool SysHeader, SourceLocation SL) +{ + if (SysHeader && !SysHeaderFlag) + { + return true; + } + else + { + return false; + } +} +/*********************************************************************************************************************/ +/*********************************************************************************************************************/ +/*********************************************************************************************************************/ +bool IsTheMatchInMainFile(bool MainFileFlag, const ast_matchers::MatchFinder::MatchResult &MR, SourceLocation SL) +{ + ASTContext *const ASTC = MR.Context; + const SourceManager &SM = ASTC->getSourceManager(); + + if (SM.isInMainFile(SL) && !MainFileFlag) + { + return true; + } + else + { + return false; + } +} + +bool IsTheMatchInMainFile(bool MainFileFlag, const SourceManager &SM, SourceLocation SL) +{ + if (SM.isInMainFile(SL) && !MainFileFlag) + { + return true; + } + else + { + return false; + } +} + +bool IsTheMatchInMainFile(bool MainFileFlag, bool MainFile, SourceLocation SL) +{ + if (MainFile && !MainFileFlag) + { + return true; + } + else + { + return false; + } +} +/*********************************************************************************************************************/ +/*********************************************************************************************************************/ /******************************************************XMLReport******************************************************/ XMLReport::XMLReport() { @@ -134,7 +220,7 @@ void XMLReport::SaveReport(void) } } /***************************************************End of XMLReport**************************************************/ - +/*********************************************************************************************************************/ /*****************************************************JSONReport******************************************************/ JSONReport::JSONReport() {} @@ -213,7 +299,10 @@ void JSONReport::CloseReport(void) { JSONRepFile.close(); } +/*********************************************************************************************************************/ /****************************************************End Of JSONReport************************************************/ +/*********************************************************************************************************************/ +/*End of namespace Devi*/ } /*********************************************************************************************************************/ /*last line intentionally left blank.*/ -- cgit v1.2.3