diff options
| -rw-r--r-- | removeFunctionCall.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/removeFunctionCall.cpp b/removeFunctionCall.cpp index 254cfaa..40d9c91 100644 --- a/removeFunctionCall.cpp +++ b/removeFunctionCall.cpp @@ -82,14 +82,16 @@ AST_POLYMORPHIC_MATCHER_P2(hasVariableNameArgument, CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr), - unsigned, - N, clang::ast_matchers::internal::Matcher<Expr>, - InnerMatcher) + InnerMatcher, + std::string, + VariableName) { - if (N >= Node.getNumArgs()) + // TO REMOVE + return true; + if (!Node.getNumArgs()) return false; - const Expr* Arg = Node.getArg(N); + const Expr* Arg = Node.getArg(0); if (Finder->isTraversalIgnoringImplicitNodes() && isa<CXXDefaultArgExpr>(Arg)) return false; return InnerMatcher.matches(*Arg->IgnoreParenImpCasts(), Finder, Builder); @@ -100,14 +102,16 @@ AST_POLYMORPHIC_MATCHER_P2(hasExpectedValueArgument, CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr), - unsigned, - N, clang::ast_matchers::internal::Matcher<Expr>, - InnerMatcher) + InnerMatcher, + std::string, + ExpectedValue) { - if (N >= Node.getNumArgs()) + // TO REMOVE + return true; + if (Node.getNumArgs() < 2) return false; - const Expr* Arg = Node.getArg(N); + const Expr* Arg = Node.getArg(1); if (Finder->isTraversalIgnoringImplicitNodes() && isa<CXXDefaultArgExpr>(Arg)) return false; return InnerMatcher.matches(*Arg->IgnoreParenImpCasts(), Finder, Builder); @@ -184,8 +188,9 @@ int main(int argc, // for instance if there is a ternary operator somewhere... const std::string FunctionCallId{"functionCallId"}; const std::string FunctionReturnValue("true"); - auto Rule = makeRule(callExpr(hasVariableNameArgument(0, expr()), - hasExpectedValueArgument(1, expr()), callee(FunctionToRemove)) + auto Rule = makeRule(callExpr(hasVariableNameArgument(expr(), "ohThisIsTheVariableName"), + hasExpectedValueArgument(expr(), "ohTheExpectedValueIsThis"), + callee(FunctionToRemove)) .bind(FunctionCallId), transformer::changeTo(node(FunctionCallId), cat(FunctionReturnValue))); |
