From a0f838df37cd23c3188bcdac471053a4438d2170 Mon Sep 17 00:00:00 2001 From: bloodstalker Date: Mon, 3 Apr 2017 05:58:15 +0430 Subject: added pointer declrefexpr tagging for safercpp --- mutator-lvl0.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'mutator-lvl0.cpp') diff --git a/mutator-lvl0.cpp b/mutator-lvl0.cpp index 26b85a3..42f0946 100644 --- a/mutator-lvl0.cpp +++ b/mutator-lvl0.cpp @@ -6025,7 +6025,7 @@ class SFCPPARR02 : public MatchFinder::MatchCallback }; /**********************************************************************************************************************/ /** - * @brief The callback for the Safercpp pointer matchers. + * @brief The callback for the Safercpp pointer matchers. Matches the dedlarations. */ class SFCPPPNTR01 : public MatchFinder::MatchCallback { @@ -6052,6 +6052,45 @@ class SFCPPPNTR01 : public MatchFinder::MatchCallback return void(); } + std::cout << "SaferCPP02" << ":" << "Native pointer declared:" << SL.printToString(*MR.SourceManager) << ":" << std::endl; + + XMLDocOut.XMLAddNode(MR.Context, SL, "SaferCPP02", "Native pointer declared:"); + JSONDocOUT.JSONAddElement(MR.Context, SL, "SaferCPP02", "Native pointer declared:"); + } + } + + private: + Rewriter &Rewrite; +}; +/**********************************************************************************************************************/ +/** + * @brief The callback for the Safercpp pointer matchers. Matches the DeclRefExprs. + */ +class SFCPPPNTR02 : public MatchFinder::MatchCallback +{ + public: + SFCPPPNTR02 (Rewriter &Rewrite) : Rewrite(Rewrite) {} + + virtual void run(const MatchFinder::MatchResult &MR) + { + if (MR.Nodes.getNodeAs("sfcpppntr02") != nullptr) + { + const DeclRefExpr* DRE = MR.Nodes.getNodeAs("sfcpppntr02"); + + SourceLocation SL = DRE->getLocStart(); + CheckSLValidity(SL); + SL = Devi::SourceLocationHasMacro(SL, Rewrite, "start"); + + if (Devi::IsTheMatchInSysHeader(CheckSystemHeader, MR, SL)) + { + return void(); + } + + if (!Devi::IsTheMatchInMainFile(MainFileOnly, MR, SL)) + { + return void(); + } + std::cout << "SaferCPP02" << ":" << "Native pointer used:" << SL.printToString(*MR.SourceManager) << ":" << std::endl; XMLDocOut.XMLAddNode(MR.Context, SL, "SaferCPP02", "Native pointer used:"); @@ -6070,6 +6109,7 @@ class SFCPPPNTR01 : public MatchFinder::MatchCallback /**********************************************************************************************************************/ /**********************************************************************************************************************/ /**********************************************************************************************************************/ +/**********************************************************************************************************************/ /*the sourcelocation used in the overload of XMLAddNode that takes sourcemanager as input parameter uses the spelling location so the client does not need to check the sourcelocation for macros expansions.*/ class PPInclusion : public PPCallbacks @@ -7558,7 +7598,7 @@ public: HandlerForMCPTCCSTYLE(R), HandlerForATC101(R), HandlerForIdent51(R), HandlerForDCDF87(R), HandlerForDCDF88(R), HandlerForLangX23(R), \ HandlerForFunction167(R), HandlerForCF143(R), HandlerForExpr1212(R), HandlerForExpr1211(R), HandlerForAtc105(R), HandlerForCSE135(R), \ HandlerForTypes612(R), HandlerForConst71(R), HandlerForIdent5X(R), HandlerForSFCPPARR01(R), HandlerForSFCPPARR02(R), \ - HandlerForSFCPPPNTR01(R) { + HandlerForSFCPPPNTR01(R), HandlerForSFCPPPNTR02(R) { /*@DEVI-disables all matchers*/ #if defined(_MUT0_DIS_MATCHERS) @@ -7828,6 +7868,8 @@ public: , hasOperatorName("="))))), &HandlerForSFCPPARR02); Matcher.addMatcher(varDecl(hasType(pointerType())).bind("sfcpppntr01"), &HandlerForSFCPPPNTR01); + + Matcher.addMatcher(declRefExpr(hasType(pointerType())).bind("sfcpppntr02"), &HandlerForSFCPPPNTR02); #endif } @@ -7908,6 +7950,7 @@ private: SFCPPARR01 HandlerForSFCPPARR01; SFCPPARR02 HandlerForSFCPPARR02; SFCPPPNTR01 HandlerForSFCPPPNTR01; + SFCPPPNTR02 HandlerForSFCPPPNTR02; MatchFinder Matcher; }; /**********************************************************************************************************************/ -- cgit v1.2.3