Skip to content

Commit 6c80c6e

Browse files
committed
Add compiler-agnostic function name helper
1 parent 81c3284 commit 6c80c6e

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

modules/core/task/include/task.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,33 +109,33 @@ class Task {
109109
/// @brief Validates input data and task attributes before execution.
110110
/// @return True if validation is successful.
111111
virtual bool Validation() final {
112-
InternalOrderTest(__builtin_FUNCTION());
112+
InternalOrderTest(PPC_FUNC_NAME);
113113
return ValidationImpl();
114114
}
115115

116116
/// @brief Performs preprocessing on the input data.
117117
/// @return True if preprocessing is successful.
118118
virtual bool PreProcessing() final {
119-
InternalOrderTest(__builtin_FUNCTION());
119+
InternalOrderTest(PPC_FUNC_NAME);
120120
if (state_of_testing_ == StateOfTesting::kFunc) {
121-
InternalTimeTest(__builtin_FUNCTION());
121+
InternalTimeTest(PPC_FUNC_NAME);
122122
}
123123
return PreProcessingImpl();
124124
}
125125

126126
/// @brief Executes the main logic of the task.
127127
/// @return True if execution is successful.
128128
virtual bool Run() final {
129-
InternalOrderTest(__builtin_FUNCTION());
129+
InternalOrderTest(PPC_FUNC_NAME);
130130
return RunImpl();
131131
}
132132

133133
/// @brief Performs postprocessing on the output data.
134134
/// @return True if postprocessing is successful.
135135
virtual bool PostProcessing() final {
136-
InternalOrderTest(__builtin_FUNCTION());
136+
InternalOrderTest(PPC_FUNC_NAME);
137137
if (state_of_testing_ == StateOfTesting::kFunc) {
138-
InternalTimeTest(__builtin_FUNCTION());
138+
InternalTimeTest(PPC_FUNC_NAME);
139139
}
140140
return PostProcessingImpl();
141141
}

modules/core/util/include/util.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ using NlohmannJsonTypeError = nlohmann::json::type_error; // NOLINT(misc-includ
3030
#define INSTANTIATE_TEST_SUITE_P_NOLINT(n, t, g) INSTANTIATE_TEST_SUITE_P(n, t, g) // NOLINT
3131
// INSTANTIATE_TEST_SUITE_P | n, t, g, ng == name, test_case_name, generator, name_generator
3232

33+
#if defined(__clang__) || defined(__GNUC__)
34+
#define PPC_FUNC_NAME __PRETTY_FUNCTION__
35+
#else
36+
#define PPC_FUNC_NAME __func__
37+
#endif
38+
3339
namespace ppc::util {
3440

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

0 commit comments

Comments
 (0)