Skip to content

Replace PPC_FUNC_NAME with ppc::util::FuncName() implementation #460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 23, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ on:

jobs:
macos-clang-build:
runs-on: macOS-latest
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 'latest'
- name: Setup environment
run: |
brew update-reset
Expand Down Expand Up @@ -49,6 +53,10 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 'latest'
- name: Setup environment
run: |
brew update-reset
Expand Down Expand Up @@ -90,6 +98,10 @@ jobs:
runs-on: macOS-latest
steps:
- uses: actions/checkout@v4
- name: Install Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 'latest'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using latest-stable

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aobolensk done

- name: Setup environment
run: |
brew update-reset
Expand Down Expand Up @@ -152,6 +164,10 @@ jobs:
runs-on: macOS-latest
steps:
- uses: actions/checkout@v4
- name: Install Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 'latest'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, move to the separate PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aobolensk done

- name: Setup environment
run: |
brew update-reset
Expand Down
12 changes: 6 additions & 6 deletions modules/core/task/include/task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,33 +108,33 @@ class Task {
/// @brief Validates input data and task attributes before execution.
/// @return True if validation is successful.
virtual bool Validation() final {
InternalOrderTest(PPC_FUNC_NAME);
InternalOrderTest(ppc::util::FuncName());
return ValidationImpl();
}

/// @brief Performs preprocessing on the input data.
/// @return True if preprocessing is successful.
virtual bool PreProcessing() final {
InternalOrderTest(PPC_FUNC_NAME);
InternalOrderTest(ppc::util::FuncName());
if (state_of_testing_ == StateOfTesting::kFunc) {
InternalTimeTest(PPC_FUNC_NAME);
InternalTimeTest(ppc::util::FuncName());
}
return PreProcessingImpl();
}

/// @brief Executes the main logic of the task.
/// @return True if execution is successful.
virtual bool Run() final {
InternalOrderTest(PPC_FUNC_NAME);
InternalOrderTest(ppc::util::FuncName());
return RunImpl();
}

/// @brief Performs postprocessing on the output data.
/// @return True if postprocessing is successful.
virtual bool PostProcessing() final {
InternalOrderTest(PPC_FUNC_NAME);
InternalOrderTest(ppc::util::FuncName());
if (state_of_testing_ == StateOfTesting::kFunc) {
InternalTimeTest(PPC_FUNC_NAME);
InternalTimeTest(ppc::util::FuncName());
}
return PostProcessingImpl();
}
Expand Down
30 changes: 28 additions & 2 deletions modules/core/util/include/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
#include <cstdint>
#include <cstdlib>
#include <memory>
#include <source_location>
#include <string>
#include <string_view>

#include "nlohmann/json_fwd.hpp"

#define PPC_FUNC_NAME __func__

#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4459)
Expand All @@ -27,6 +26,33 @@ using NlohmannJsonTypeError = nlohmann::json::type_error;

namespace ppc::util {

/**
* @brief Obtain the simple function name (e.g. "PreProcessing" or "foo")
* from the full signature returned by std::source_location.
*
* @param loc Source location info (file, line, full signature).
* Defaults to the call site via std::source_location::current().
* @return A std::string with only the function’s unqualified name.
*
* @details
* - On GCC/Clang, function_name() returns a pretty signature
* including namespaces, templates, and parameters.
* - On MSVC, it also includes return type and calling convention.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should that be included?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aobolensk corrected

* - This routine removes any leading scope qualifiers (“::…”) and
* drops everything from the first '(' onward.
*/

inline std::string FuncName(const std::source_location& loc = std::source_location::current()) {
std::string s{loc.function_name()};
if (auto p = s.find('('); p != std::string::npos) {
s.resize(p); // drop “(…)”
}
if (auto p = s.rfind("::"); p != std::string::npos) {
s.erase(0, p + 2); // drop namespaces
}
return s;
}

enum GTestParamIndex : uint8_t { kTaskGetter, kNameTest, kTestParams };

std::string GetAbsoluteTaskPath(const std::string& id_path, const std::string& relative_path);
Expand Down
Loading