aboutsummaryrefslogtreecommitdiffstats
path: root/mutator-lvl1.cpp
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2017-01-29 16:20:32 +0000
committerbloodstalker <thabogre@gmail.com>2017-01-29 16:20:32 +0000
commitd2c72081da9915c6c4734b647630978fe44b7e02 (patch)
tree38a1dcc9d7ef14767dba2448e6cbdb317e1a693e /mutator-lvl1.cpp
parentnow make install creates a temp directory to use with the auto-refac option o... (diff)
downloadmutator-d2c72081da9915c6c4734b647630978fe44b7e02.tar.gz
mutator-d2c72081da9915c6c4734b647630978fe44b7e02.zip
fixed the matcher that was causing ifconstswapper to misbehave when trying to fix nested ifs.
Diffstat (limited to 'mutator-lvl1.cpp')
-rw-r--r--mutator-lvl1.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/mutator-lvl1.cpp b/mutator-lvl1.cpp
index 19dd13d..f56aa6e 100644
--- a/mutator-lvl1.cpp
+++ b/mutator-lvl1.cpp
@@ -480,7 +480,7 @@ public:
SourceLocation SLLHS = LHS->getLocStart();
SLLHS = Devi::SourceLocationHasMacro(SLLHS, Rewrite, "start");
SourceLocation SLELHS = LHS->getLocStart();
- SLELHS = Devi::SourceLocationHasMacro(SLELHS, Rewrite, "start");
+ SLELHS = Devi::SourceLocationHasMacro(SLELHS, Rewrite, "end");
SourceRange SRLHS;
SRLHS.setBegin(SLLHS);
SRLHS.setEnd(SLELHS);
@@ -498,7 +498,7 @@ public:
SourceLocation SLRHS = RHS->getLocStart();
SLRHS = Devi::SourceLocationHasMacro(SLRHS, Rewrite, "start");
SourceLocation SLERHS = RHS->getLocEnd();
- SLERHS = Devi::SourceLocationHasMacro(SLERHS, Rewrite, "start");
+ SLERHS = Devi::SourceLocationHasMacro(SLERHS, Rewrite, "end");
SourceRange SRRHS;
SRRHS.setBegin(SLRHS);
SRRHS.setEnd(SLERHS);
@@ -506,6 +506,10 @@ public:
const std::string LHSString = Rewrite.getRewrittenText(SRLHS);
const std::string RHSString = Rewrite.getRewrittenText(SRRHS);
+#if 0
+ std::cout << "lhs:" << LHSString << " " << "rhs:" << RHSString << " " << SLLHS.printToString(*SM) << std::endl;
+#endif
+
StringRef LHSRef = StringRef(LHSString);
StringRef RHSRef = StringRef(RHSString);
@@ -549,7 +553,7 @@ public:
Matcher.addMatcher(switchStmt(hasDescendant(defaultStmt(unless(hasDescendant(compoundStmt()))).bind("mumma-hotep"))), &HandlerForSwitchDf);
- Matcher.addMatcher(ifStmt(hasDescendant(binaryOperator(anyOf(hasOperatorName("=="), hasOperatorName("="))).bind("ifconstswapbinop"))).bind("ifconstswapper"), &HandlerForIfConstSwap);
+ Matcher.addMatcher(ifStmt(has(binaryOperator(anyOf(hasOperatorName("=="), hasOperatorName("="))).bind("ifconstswapbinop"))).bind("ifconstswapper"), &HandlerForIfConstSwap);
}
void HandleTranslationUnit(ASTContext & Context) override {