summaryrefslogtreecommitdiff
path: root/removeFunctionCall.cpp
diff options
context:
space:
mode:
authorAotrix <[email protected]>2026-10-07 19:47:35 +0200
committerAotrix <[email protected]>2026-10-07 19:47:35 +0200
commit32d62545c35ca9af047883314caa6dba255cf581 (patch)
tree5af5520f1359cb65353b5a617799ee76b440b61d /removeFunctionCall.cpp
parent5b39c848257662ae4a8f890bf4171e36ccf77bb6 (diff)
Hmm I had to add return true; because function call was not removed
Diffstat (limited to 'removeFunctionCall.cpp')
-rw-r--r--removeFunctionCall.cpp29
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)));