[Base] replace some instances of SourceLocation by std::source_location#1858
[Base] replace some instances of SourceLocation by std::source_location#1858tdavidcl wants to merge 2 commits into
Conversation
|
Thanks @tdavidcl for opening this PR! You can do multiple things directly here: Once the workflow completes a message will appear displaying informations related to the run. Also the PR gets automatically reviewed by gemini, you can: |
There was a problem hiding this comment.
Code Review
This pull request migrates the custom SourceLocation class to C++20's standard std::source_location across kernel calls, stack trace utilities, and test assertions. The review feedback correctly points out that std::source_location is a small, trivially copyable type and should be passed by value instead of by reference or rvalue reference to prevent unnecessary indirection and improve efficiency.
| index_t n, | ||
| Functor &&kernel_gen, | ||
| SourceLocation &&callsite = SourceLocation{}) { | ||
| std::source_location &&callsite = std::source_location::current()) { |
There was a problem hiding this comment.
In C++20, std::source_location is a small, trivially copyable object (typically consisting of a couple of pointers and integers). Passing it by rvalue reference (std::source_location&&) is an anti-pattern that prevents passing lvalue std::source_location objects and adds unnecessary indirection. It should be passed by value instead.
std::source_location callsite = std::source_location::current()) {| index_t n, | ||
| Functor &&func, | ||
| SourceLocation &&callsite = SourceLocation{}) { | ||
| std::source_location &&callsite = std::source_location::current()) { |
There was a problem hiding this comment.
In C++20, std::source_location is a small, trivially copyable object. Passing it by rvalue reference (std::source_location&&) is an anti-pattern that prevents passing lvalue std::source_location objects and adds unnecessary indirection. It should be passed by value instead.
std::source_location callsite = std::source_location::current()) {| u32 n, | ||
| Functor &&func, | ||
| SourceLocation &&callsite = SourceLocation{}) { | ||
| std::source_location &&callsite = std::source_location::current()) { |
There was a problem hiding this comment.
In C++20, std::source_location is a small, trivially copyable object. Passing it by rvalue reference (std::source_location&&) is an anti-pattern that prevents passing lvalue std::source_location objects and adds unnecessary indirection. It should be passed by value instead.
std::source_location callsite = std::source_location::current()) {| u64 n, | ||
| Functor &&func, | ||
| SourceLocation &&callsite = SourceLocation{}) { | ||
| std::source_location &&callsite = std::source_location::current()) { |
There was a problem hiding this comment.
In C++20, std::source_location is a small, trivially copyable object. Passing it by rvalue reference (std::source_location&&) is an anti-pattern that prevents passing lvalue std::source_location objects and adds unnecessary indirection. It should be passed by value instead.
std::source_location callsite = std::source_location::current()) {| u32 n, | ||
| Functor &&kernel_gen, | ||
| SourceLocation &&callsite = SourceLocation{}) { | ||
| std::source_location &&callsite = std::source_location::current()) { |
There was a problem hiding this comment.
In C++20, std::source_location is a small, trivially copyable object. Passing it by rvalue reference (std::source_location&&) is an anti-pattern that prevents passing lvalue std::source_location objects and adds unnecessary indirection. It should be passed by value instead.
std::source_location callsite = std::source_location::current()) {| u64 n, | ||
| Functor &&kernel_gen, | ||
| SourceLocation &&callsite = SourceLocation{}) { | ||
| std::source_location &&callsite = std::source_location::current()) { |
There was a problem hiding this comment.
In C++20, std::source_location is a small, trivially copyable object. Passing it by rvalue reference (std::source_location&&) is an anti-pattern that prevents passing lvalue std::source_location objects and adds unnecessary indirection. It should be passed by value instead.
std::source_location callsite = std::source_location::current()) {| inline CallStackEntry(const std::source_location &loc) { | ||
| // Push the source location to the call stack | ||
| call_stack.emplace(SourceLocation{loc}); | ||
| } |
There was a problem hiding this comment.
In C++20, std::source_location is a small, trivially copyable object. Passing it by const std::source_location& is less efficient than passing by value because it introduces pointer indirection. It should be passed by value instead.
| inline CallStackEntry(const std::source_location &loc) { | |
| // Push the source location to the call stack | |
| call_stack.emplace(SourceLocation{loc}); | |
| } | |
| inline CallStackEntry(std::source_location loc) { | |
| // Push the source location to the call stack | |
| call_stack.emplace(SourceLocation{loc}); | |
| } |
| inline BasicStackEntry( | ||
| const std::source_location &callsite, | ||
| bool do_timer = true, | ||
| std::source_location &&loc = std::source_location::current()) | ||
| : BasicStackEntry(SourceLocation{callsite}, do_timer, SourceLocation{loc}) {} |
There was a problem hiding this comment.
In C++20, std::source_location is a small, trivially copyable object. Passing it by reference (const std::source_location& or std::source_location&&) is less efficient and can prevent passing lvalue objects. It should be passed by value instead.
| inline BasicStackEntry( | |
| const std::source_location &callsite, | |
| bool do_timer = true, | |
| std::source_location &&loc = std::source_location::current()) | |
| : BasicStackEntry(SourceLocation{callsite}, do_timer, SourceLocation{loc}) {} | |
| inline BasicStackEntry( | |
| std::source_location callsite, | |
| bool do_timer = true, | |
| std::source_location loc = std::source_location::current()) | |
| : BasicStackEntry(SourceLocation{callsite}, do_timer, SourceLocation{loc}) {} |
Workflow reportworkflow report corresponding to commit 5f4016a Light CI is enabled. This will only run the basic tests and not the full tests. Pre-commit check reportPre-commit check: ✅ Test pipeline can run. Doxygen diff with
|
No description provided.