summaryrefslogtreecommitdiff
path: root/removeFunctionCall.cpp
diff options
context:
space:
mode:
authorAotrix <[email protected]>2026-10-07 22:33:10 +0200
committerAotrix <[email protected]>2026-10-07 22:33:20 +0200
commitbe2826ed7596c7f82347af4f3908e8dce7558a6d (patch)
treef207fb5d53b9263434e40d8e9bfc3ac68e5d0599 /removeFunctionCall.cpp
parent32d62545c35ca9af047883314caa6dba255cf581 (diff)
Perform function name check at the beginning
Diffstat (limited to 'removeFunctionCall.cpp')
-rw-r--r--removeFunctionCall.cpp28
1 files changed, 12 insertions, 16 deletions
diff --git a/removeFunctionCall.cpp b/removeFunctionCall.cpp
index 40d9c91..16bd6a9 100644
--- a/removeFunctionCall.cpp
+++ b/removeFunctionCall.cpp
@@ -82,13 +82,13 @@ AST_POLYMORPHIC_MATCHER_P2(hasVariableNameArgument,
CXXConstructExpr,
CXXUnresolvedConstructExpr,
ObjCMessageExpr),
- clang::ast_matchers::internal::Matcher<Expr>,
- InnerMatcher,
std::string,
- VariableName)
+ VariableName,
+ clang::ast_matchers::internal::Matcher<Expr>,
+ InnerMatcher)
{
- // TO REMOVE
- return true;
+ if (!VariableName.empty())
+ std::cout << VariableName << " ; " << Node.getNumArgs() << '\n';
if (!Node.getNumArgs())
return false;
const Expr* Arg = Node.getArg(0);
@@ -102,13 +102,11 @@ AST_POLYMORPHIC_MATCHER_P2(hasExpectedValueArgument,
CXXConstructExpr,
CXXUnresolvedConstructExpr,
ObjCMessageExpr),
- clang::ast_matchers::internal::Matcher<Expr>,
- InnerMatcher,
std::string,
- ExpectedValue)
+ ExpectedValue,
+ clang::ast_matchers::internal::Matcher<Expr>,
+ InnerMatcher)
{
- // TO REMOVE
- return true;
if (Node.getNumArgs() < 2)
return false;
const Expr* Arg = Node.getArg(1);
@@ -186,13 +184,11 @@ int main(int argc,
auto FunctionToRemove = functionDecl(matchesName("configValue"));
// FIXME: do not clean a function call if it used by strictly more than one parameter
// for instance if there is a ternary operator somewhere...
- const std::string FunctionCallId{"functionCallId"};
const std::string FunctionReturnValue("true");
- auto Rule = makeRule(callExpr(hasVariableNameArgument(expr(), "ohThisIsTheVariableName"),
- hasExpectedValueArgument(expr(), "ohTheExpectedValueIsThis"),
- callee(FunctionToRemove))
- .bind(FunctionCallId),
- transformer::changeTo(node(FunctionCallId), cat(FunctionReturnValue)));
+ auto Rule = makeRule(callExpr(callee(FunctionToRemove),
+ hasVariableNameArgument("ohThisIsTheVariableName", expr()),
+ hasExpectedValueArgument("ohTheExpectedValueIsThis", expr())),
+ transformer::changeTo(cat(FunctionReturnValue)));
AtomicChanges AllChanges;