-
Notifications
You must be signed in to change notification settings - Fork 73
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
Changes from 5 commits
51ec3b9
686006e
94f5988
b33a506
11f586e
e00f6ad
462acd5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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' | ||
- name: Setup environment | ||
run: | | ||
brew update-reset | ||
|
@@ -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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, move to the separate PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @aobolensk done |
||
- name: Setup environment | ||
run: | | ||
brew update-reset | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
@@ -27,6 +26,33 @@ using NlohmannJsonTypeError = nlohmann::json::type_error; | |
|
||
namespace ppc::util { | ||
|
||
/** | ||
aobolensk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* @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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should that be included? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using
latest-stable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aobolensk done