Skip to content
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

Add missing std::forward calls #8049

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft

Add missing std::forward calls #8049

wants to merge 9 commits into from

Conversation

steven-johnson
Copy link
Contributor

Found by enabling cppcoreguidelines-missing-std-forward (https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/missing-std-forward.html) -- that specific check isn't ready to be enabled for other reasons (it changes the behavior of other checks in ways that are painful) but doing this cleanup seems modestly worthwhile.

Found by enabling cppcoreguidelines-missing-std-forward (https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/missing-std-forward.html) -- that specific check isn't ready to be enabled for other reasons (it changes the behavior of other checks in ways that are painful) but doing this cleanup seems modestly worthwhile.
@@ -930,17 +930,17 @@ std::ostream &operator<<(std::ostream &s, const BinOp<Mod, A, B> &op) {
}
Copy link
Member

Choose a reason for hiding this comment

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

IIUC std::forward is supposed to be strictly better. However, this whole file is very sensitive to what the compiler decides needs an address and stack location and what doesn't, so this change is not a no-brainer. I need to check what the stack frame looks like for some of the simplify visitors before and after this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't consider this change really essential... basically just wanted to grind through the new checks while waiting on some buildbots. This can wait for a lazy day. (Or be merged piecewise.)

@@ -2338,7 +2334,7 @@ class Buffer {
typename... Args,
typename = decltype(std::declval<Fn>()(std::declval<Args>()...))>
HALIDE_ALWAYS_INLINE static void for_each_element_variadic(int, int, const for_each_element_task_dim *, Fn &&f, Args... args) {
f(args...);
std::forward<Fn>(f)(args...);
Copy link
Member

Choose a reason for hiding this comment

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

This one's a bit weird. What does it mean to std::forward the this parameter of operator()?

Base automatically changed from srj/clang-fmt-tidy to main January 27, 2024 00:33
@zvookin
Copy link
Member

zvookin commented Feb 7, 2024

Are you up for moving the small style fixes into another PR? It should be trivial to land and makes this one smaller. Optionally, update the description to explain the other changes.

@steven-johnson
Copy link
Contributor Author

Are you up for moving the small style fixes into another PR? It should be trivial to land and makes this one smaller. Optionally, update the description to explain the other changes.

Yeah, looks like this has a lot of cruft in it that I didn't expect. Converting to draft for now.

@steven-johnson steven-johnson marked this pull request as draft February 7, 2024 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants