From 947f7476325f87e9b366acf69f2a0a2671fa4811 Mon Sep 17 00:00:00 2001 From: Aotrix <9aotrix@protonmail.com> Date: Sun, 13 Sep 2026 22:41:34 +0200 Subject: create test function --- README.md | 2 +- main.cc | 6 +++--- remove.sh | 2 +- removeFunctionCall.cpp | 4 +--- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index be8ac7d..361521f 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -./remove.sh file.cpp -parameter "NAME_OF_FUNCTION_PARAMETER" -value +./remove.sh file.cpp -parameter "NAME_OF_FUNCTION_PARAMETER" -value diff --git a/main.cc b/main.cc index ef15e6e..9030b12 100644 --- a/main.cc +++ b/main.cc @@ -1,6 +1,6 @@ #include -bool displayHello() +bool configValue(const std::string& iKey) { bool result; std::cin >> result; @@ -16,11 +16,11 @@ bool coucouEveryone() int main() { - if (displayHello()) + if (configValue("aparam")) { coucouEveryone(); } - if (!displayHello()) + if (!configValue("")) { std::cout << "Mouhahahaha I am a villain!\n"; } diff --git a/remove.sh b/remove.sh index c2f12b9..781dc6d 100755 --- a/remove.sh +++ b/remove.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash echo "Removing calls..." -./build/remove-function-call $1 +./build/remove-function-call $1 $2 clang-tidy $1 -checks=-*,readability-simplify-boolean-expr -fix >/dev/null 2>&1 echo "Done." diff --git a/removeFunctionCall.cpp b/removeFunctionCall.cpp index 3e0d4cb..2be2d9d 100644 --- a/removeFunctionCall.cpp +++ b/removeFunctionCall.cpp @@ -127,14 +127,12 @@ int main(int argc, StandaloneToolExecutor Executor(std::move(OptionsParser.get())); - std::string ArgId = "arg"; - // auto Rule = makeRule( // callExpr(callee(functionDecl(hasName("AwesomeFunc"))), // hasArgument(0, expr(hasType(pointerType())).bind(ArgId))), // changeTo(node(ArgId), transformer::maybeDeref(ArgId))); - auto functionToRemove = functionDecl(matchesName("displayHello")); + auto functionToRemove = functionDecl(matchesName("configValue")); auto Rule = makeRule(callExpr(callee(functionToRemove)), changeTo(cat("true"))); AtomicChanges AllChanges; -- cgit v1.2.3