aboutsummaryrefslogtreecommitdiffstats
path: root/mutator-lvl0.cpp
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2017-03-29 10:37:14 +0000
committerbloodstalker <thabogre@gmail.com>2017-03-29 10:37:14 +0000
commit818ba5ecde1b05a169b80562df1e24a0f28ffcfe (patch)
tree2b0b6a1641f1765e5452b90954285a4a93dda16b /mutator-lvl0.cpp
parentenabled writing the changes out to the input file, some translation (diff)
downloadmutator-818ba5ecde1b05a169b80562df1e24a0f28ffcfe.tar.gz
mutator-818ba5ecde1b05a169b80562df1e24a0f28ffcfe.zip
changed the matchers for safercpparr. i still have to add a matcher that recognizes pointers pointing to an array.
Diffstat (limited to '')
-rw-r--r--mutator-lvl0.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/mutator-lvl0.cpp b/mutator-lvl0.cpp
index cacb098..17afc46 100644
--- a/mutator-lvl0.cpp
+++ b/mutator-lvl0.cpp
@@ -72,10 +72,18 @@ using namespace clang::driver;
using namespace clang::tooling;
/**********************************************************************************************************************/
/*macros and defs*/
+
+/*@DEVI-disbale debugs info printouts.*/
#define _MUT0_TEST
-#if 1
+#if 0
#undef _MUT0_TEST
#endif
+
+/*@DEVI-disbale all matchers.*/
+#define _MUT0_DIS_MATCHERS
+#if 0
+#undef _MUT0_DIS_MATCHERS
+#endif
/**********************************************************************************************************************/
/*global vars*/
Devi::XMLReport XMLDocOut;
@@ -5774,11 +5782,11 @@ class SFCPPARR01 : public MatchFinder::MatchCallback
JSONDocOUT.JSONAddElement(MR.Context, SL, "SaferCPP01", "Native CPP array declared:");
}
- if (MR.Nodes.getNodeAs<clang::ArraySubscriptExpr>("sfcpparrsubscript") != nullptr)
+ if (MR.Nodes.getNodeAs<clang::CastExpr>("sfcpparrcastexpr") != nullptr)
{
- const ArraySubscriptExpr* ASE = MR.Nodes.getNodeAs<clang::ArraySubscriptExpr>("sfcpparrsubscript");
+ const CastExpr* CS = MR.Nodes.getNodeAs<clang::CastExpr>("sfcpparrcastexpr");
- SourceLocation SL = ASE->getLocStart();
+ SourceLocation SL = CS->getLocStart();
CheckSLValidity(SL);
SL = Devi::SourceLocationHasMacro(SL, Rewrite, "start");
@@ -7299,20 +7307,16 @@ public:
HandlerForFunction167(R), HandlerForCF143(R), HandlerForExpr1212(R), HandlerForExpr1211(R), HandlerForAtc105(R), HandlerForCSE135(R), \
HandlerForTypes612(R), HandlerForConst71(R), HandlerForIdent5X(R), HandlerForSFCPPARR01(R) {
-#if 1
- /*forstmts whithout a compound statement.*/
+/*@DEVI-disables all matchers*/
+#if defined(_MUT0_DIS_MATCHERS)
Matcher.addMatcher(forStmt(unless(hasDescendant(compoundStmt()))).bind("mcfor"), &HandlerForCmpless);
- /*whilestmts without a compound statement.*/
Matcher.addMatcher(whileStmt(unless(hasDescendant(compoundStmt()))).bind("mcwhile"), &HandlerWhileCmpless);
- /*else blocks that dont have a compound statemnt.*/
Matcher.addMatcher(ifStmt(allOf(hasElse(unless(ifStmt())), hasElse(unless(compoundStmt())))).bind("mcelse"), &HandlerElseCmpless);
- /*if blocks that dont have a compound statement.*/
Matcher.addMatcher(ifStmt(unless(hasDescendant(compoundStmt()))).bind("mcif"), &HandlerIfCmpless);
- /*if-elseif statements that are missing the else block.*/
Matcher.addMatcher(ifStmt(allOf(hasElse(ifStmt()), unless(hasAncestor(ifStmt())), unless(hasDescendant(ifStmt(hasElse(unless(ifStmt()))))))).bind("mcifelse"), &HandlerForIfElse);
Matcher.addMatcher(switchStmt(hasDescendant(compoundStmt(hasDescendant(switchCase(unless(hasDescendant(breakStmt()))))))).bind("mcswitchbrk"), &HandlerForSwitchBrkLess);
@@ -7561,9 +7565,11 @@ public:
Matcher.addMatcher(enumConstantDecl(hasAncestor(functionDecl().bind("id5funcscope"))).bind("ident5enumconst"), &HandlerForIdent5X);
/*end of matchers for 5.x*/
- Matcher.addMatcher(arraySubscriptExpr().bind("sfcpparrsubscript"), &HandlerForSFCPPARR01);
-
Matcher.addMatcher(varDecl(hasType(arrayType())).bind("sfcpparrdecl"), &HandlerForSFCPPARR01);
+
+ Matcher.addMatcher(implicitCastExpr(hasCastKind(CK_ArrayToPointerDecay)).bind("sfcpparrcastexpr"), &HandlerForSFCPPARR01);
+
+ Matcher.addMatcher(cStyleCastExpr(hasCastKind(CK_ArrayToPointerDecay)).bind("sfcpparrcastexpr"), &HandlerForSFCPPARR01);
#endif
}