aboutsummaryrefslogtreecommitdiffstats
path: root/mutator-lvl0.cpp
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2017-04-03 01:28:15 +0000
committerbloodstalker <thabogre@gmail.com>2017-04-03 01:28:15 +0000
commita0f838df37cd23c3188bcdac471053a4438d2170 (patch)
tree5d701ee1b0bdadb89745e95b160816b7a2c30342 /mutator-lvl0.cpp
parentadded a blue-print for SaferCPP's tagging of all native pointers (diff)
downloadmutator-a0f838df37cd23c3188bcdac471053a4438d2170.tar.gz
mutator-a0f838df37cd23c3188bcdac471053a4438d2170.zip
added pointer declrefexpr tagging for safercpp
Diffstat (limited to '')
-rw-r--r--mutator-lvl0.cpp47
1 files changed, 45 insertions, 2 deletions
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<clang::DeclRefExpr>("sfcpppntr02") != nullptr)
+ {
+ const DeclRefExpr* DRE = MR.Nodes.getNodeAs<clang::DeclRefExpr>("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;
};
/**********************************************************************************************************************/