From 32d62545c35ca9af047883314caa6dba255cf581 Mon Sep 17 00:00:00 2001 From: Aotrix <9aotrix@protonmail.com> Date: Wed, 7 Oct 2026 19:47:35 +0200 Subject: Hmm I had to add return true; because function call was not removed --- removeFunctionCall.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'removeFunctionCall.cpp') 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, - 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(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, - 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(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))); -- cgit v1.2.3