aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2017-04-02 23:46:39 +0000
committerbloodstalker <thabogre@gmail.com>2017-04-02 23:46:39 +0000
commit694154c79d6517e2ddd4ffe60ece2c7fb445b80f (patch)
treed1caa6e6ce35741a6eea020d684021e04c58232f
parentfixed the temp workarounds for 12.11,10.1 and 10.2. they are proper now. (diff)
downloadmutator-694154c79d6517e2ddd4ffe60ece2c7fb445b80f.tar.gz
mutator-694154c79d6517e2ddd4ffe60ece2c7fb445b80f.zip
added a blue-print for SaferCPP's tagging of all native pointers
-rw-r--r--mutator-lvl0.cpp44
1 files changed, 43 insertions, 1 deletions
diff --git a/mutator-lvl0.cpp b/mutator-lvl0.cpp
index 26b9673..26b85a3 100644
--- a/mutator-lvl0.cpp
+++ b/mutator-lvl0.cpp
@@ -6024,6 +6024,44 @@ class SFCPPARR02 : public MatchFinder::MatchCallback
SFCPPARR02SUB SubHandler;
};
/**********************************************************************************************************************/
+/**
+ * @brief The callback for the Safercpp pointer matchers.
+ */
+class SFCPPPNTR01 : public MatchFinder::MatchCallback
+{
+ public:
+ SFCPPPNTR01 (Rewriter &Rewrite) : Rewrite(Rewrite) {}
+
+ virtual void run(const MatchFinder::MatchResult &MR)
+ {
+ if (MR.Nodes.getNodeAs<clang::VarDecl>("sfcpppntr01") != nullptr)
+ {
+ const VarDecl* VD = MR.Nodes.getNodeAs<clang::VarDecl>("sfcpppntr01");
+
+ SourceLocation SL = VD->clang::Decl::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:");
+ JSONDocOUT.JSONAddElement(MR.Context, SL, "SaferCPP02", "Native pointer used:");
+ }
+ }
+
+ private:
+ Rewriter &Rewrite;
+};
/**********************************************************************************************************************/
/**********************************************************************************************************************/
/**********************************************************************************************************************/
@@ -7519,7 +7557,8 @@ public:
HandlerForPointer1723(R), HandlerForPointer174(R), HandlerForPointer175(R), HandlerForTypes61(R), HandlerForSU181(R), \
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) {
+ HandlerForTypes612(R), HandlerForConst71(R), HandlerForIdent5X(R), HandlerForSFCPPARR01(R), HandlerForSFCPPARR02(R), \
+ HandlerForSFCPPPNTR01(R) {
/*@DEVI-disables all matchers*/
#if defined(_MUT0_DIS_MATCHERS)
@@ -7787,6 +7826,8 @@ public:
Matcher.addMatcher(declRefExpr(hasAncestor(binaryOperator(allOf(hasLHS(declRefExpr().bind("sfcpparrdeep")), hasRHS(hasDescendant(implicitCastExpr(hasCastKind(CK_ArrayToPointerDecay))))\
, hasOperatorName("="))))), &HandlerForSFCPPARR02);
+
+ Matcher.addMatcher(varDecl(hasType(pointerType())).bind("sfcpppntr01"), &HandlerForSFCPPPNTR01);
#endif
}
@@ -7866,6 +7907,7 @@ private:
MCIdent5x HandlerForIdent5X;
SFCPPARR01 HandlerForSFCPPARR01;
SFCPPARR02 HandlerForSFCPPARR02;
+ SFCPPPNTR01 HandlerForSFCPPPNTR01;
MatchFinder Matcher;
};
/**********************************************************************************************************************/