From e81de6189127845b5cec3e29b0effae5a7a7e7c6 Mon Sep 17 00:00:00 2001 From: bloodstalker Date: Sun, 10 Jun 2018 04:03:16 +0430 Subject: the codegen is working now. the generated codes will not be part of the repo for the time being. they will be generated during the build process. --- mutator_aux.cpp | 114 +++++++++++++++++--------------------------------------- 1 file changed, 34 insertions(+), 80 deletions(-) (limited to 'mutator_aux.cpp') diff --git a/mutator_aux.cpp b/mutator_aux.cpp index 665124b..a382764 100644 --- a/mutator_aux.cpp +++ b/mutator_aux.cpp @@ -36,50 +36,36 @@ using namespace clang; namespace Devi { /*a simple function that checks the sourcelocations for a macro expansion. returns the sourcelocation without macro expansion address.*/ -SourceLocation SourceLocationHasMacro [[deprecated("doesnt work")]] (SourceLocation SL, Rewriter &Rewrite, std::string Kind) -{ +#if 1 +SourceLocation SourceLocationHasMacro [[deprecated("doesnt work")]] (SourceLocation SL, Rewriter &Rewrite, std::string Kind) { /*does the sourcelocation include a macro expansion?*/ - if ( SL.isMacroID() ) - { + if ( SL.isMacroID()) { /*get the expansion range which is startloc and endloc*/ std::pair expansionRange = Rewrite.getSourceMgr().getImmediateExpansionRange(SL); - - if (Kind == "start") - { + if (Kind == "start") { return (expansionRange.first); - } - else if (Kind == "end") - { + } else if (Kind == "end") { return (expansionRange.second); - } - else - { + } else { std::cout << "the third argument of Devi::SourceLocationHasMacro is invalid." << std::endl; } - - } - else - { + } else { return (SL); } - return (SL); } +#endif SourceLocation SourceLocationHasMacro(SourceLocation __sl, Rewriter &__rewrite) { - if (__sl.isMacroID()) - { + if (__sl.isMacroID()) { return __rewrite.getSourceMgr().getSpellingLoc(__sl); - } - else - { + } else { return __sl; } } -SourceLocation getSLSpellingLoc(SourceLocation __sl, Rewriter &__rewrite) -{ +SourceLocation getSLSpellingLoc(SourceLocation __sl, Rewriter &__rewrite) { if (__sl.isMacroID()) {return __rewrite.getSourceMgr().getSpellingLoc(__sl);} else {return __sl;} } @@ -87,106 +73,74 @@ SourceLocation getSLSpellingLoc(SourceLocation __sl, Rewriter &__rewrite) /*********************************************************************************************************************/ /*********************************************************************************************************************/ /*the first argument is the option SysHeader from the mutator-lvl0 cl.*/ -bool IsTheMatchInSysHeader(bool SysHeaderFlag, const ast_matchers::MatchFinder::MatchResult &MR, SourceLocation SL) -{ +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) - { + if (SM.isInSystemHeader(SL) && !SysHeaderFlag) { return true; - } - else - { + } else { return false; } } -bool IsTheMatchInSysHeader(bool SysHeaderFlag, const SourceManager &SM, SourceLocation SL) -{ - if (SM.isInSystemHeader(SL) && !SysHeaderFlag) - { +bool IsTheMatchInSysHeader(bool SysHeaderFlag, const SourceManager &SM, SourceLocation SL) { + if (SM.isInSystemHeader(SL) && !SysHeaderFlag) { return true; - } - else - { + } else { return false; } } -bool IsTheMatchInSysHeader(bool SysHeaderFlag, bool SysHeader, SourceLocation SL) -{ - if (SysHeader && !SysHeaderFlag) - { +bool IsTheMatchInSysHeader(bool SysHeaderFlag, bool SysHeader, SourceLocation SL) { + if (SysHeader && !SysHeaderFlag) { return true; - } - else - { + } else { return false; } } bool IsTheMatchInSysHeader(bool SysHeaderFlag, bool SysHeader) { - if (SysHeader && !SysHeaderFlag) - { + if (SysHeader && !SysHeaderFlag) { return true; - } - else - { + } else { return false; } } /*********************************************************************************************************************/ /*********************************************************************************************************************/ /*********************************************************************************************************************/ -bool IsTheMatchInMainFile(bool MainFileFlag, const ast_matchers::MatchFinder::MatchResult &MR, SourceLocation SL) -{ +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) || (!SM.isInMainFile(SL) && !MainFileFlag)) - { + if (SM.isInMainFile(SL) || (!SM.isInMainFile(SL) && !MainFileFlag)) { return true; - } - else - { + } else { return false; } } -bool IsTheMatchInMainFile(bool MainFileFlag, const SourceManager &SM, SourceLocation SL) -{ - if (SM.isInMainFile(SL) || (!SM.isInMainFile(SL) && !MainFileFlag)) - { +bool IsTheMatchInMainFile(bool MainFileFlag, const SourceManager &SM, SourceLocation SL) { + if (SM.isInMainFile(SL) || (!SM.isInMainFile(SL) && !MainFileFlag)) { return true; - } - else - { + } else { return false; } } -bool IsTheMatchInMainFile(bool MainFileFlag, bool MainFile, SourceLocation SL) -{ - if (MainFile || (!MainFile && !MainFileFlag)) - { +bool IsTheMatchInMainFile(bool MainFileFlag, bool MainFile, SourceLocation SL) { + if (MainFile || (!MainFile && !MainFileFlag)) { return true; - } - else - { + } else { return false; } } -bool IsTheMatchInMainFile(bool MainFileFlag, bool MainFile) -{ - if (MainFile || (!MainFile && !MainFileFlag)) - { +bool IsTheMatchInMainFile(bool MainFileFlag, bool MainFile) { + if (MainFile || (!MainFile && !MainFileFlag)) { return true; - } - else - { + } else { return false; } } -- cgit v1.2.3