Comments (8)
Note that on modern versions of clang std::forward/move now get translated to intrinsics which shouldn’t have the same template instantiation overhead.
from libunifex.
I'd be happy to do a first pass at this and report back. One of my side hobbies it tinkering with clang-tidy and have some experience with the checks that verify correct uses of move
, forward
, and universal references.
from libunifex.
Ok, these two checks are of interest (both of which would appear in the next LLVM release version 17).
Both help identify all cases where functions do not use std::move(rvalue_ref_param)
or static_cast<T&&>(universal_ref_param)
(or std::forward<T&&>(universal_ref_param)
if you end up preferring that coding style). E.g.,
/home/ccotter/git/libunifex/include/unifex/async_mutex.hpp:119:46: warning: rvalue reference parameter 's' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
119 | tag_invoke(tag_t<connect>, lock_sender &&s, Receiver &&r) noexcept {
| ^
/home/ccotter/git/libunifex/include/unifex/async_mutex.hpp:119:60: warning: forwarding reference parameter 'r' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
119 | tag_invoke(tag_t<connect>, lock_sender &&s, Receiver &&r) noexcept {
Both checks are expecting code to always use the "named cast" using move
or forward
. The checks won't emit any kind of fixits though. Below are the counts of each diagnostic for all header includes:
36 [cppcoreguidelines-rvalue-reference-param-not-moved]
635 [cppcoreguidelines-missing-std-forward]
If you'd like, I can do a first pass to fix the parameters that use C-cast instead of std::move()
.
from libunifex.
Do you know anything about running
clang-tidy
as a linter
Unfortunately I'm not familiar with GitHub CI specifically. Googling around shows there's https://github.com/marketplace/actions/clang-tidy-review. What's needed generally to run clang-tidy
is a build capable of producing a compile_comands.json (which cmake can do at configure time), and a .clang-tidy
config file listing the checks to enable (and per-check options in some cases). Let me see if I can play with this on a personal project and see if it's easy to setup.
from libunifex.
Oh, and that clang-tidy-review
… thingy looks pretty useful! @janondrusek has done a lot more than I have to maintain our GitHub CI so I think you two might be best suited to discuss whether and how to add clang-tidy-review
to the mix.
from libunifex.
Those look awesome, @ccotter. A first pass would be most welcome.
Do you know anything about running clang-tidy
as a linter as part of GitHub CI because I imagine that would help us stay clean.
from libunifex.
Just to confirm, should I also look at migrating static_cast
or C style forwarding casts to std::forward
? I ended up writing a clang-tidy tool to do behavior preserving conversion (and it'll can optionally try to replace moves, although that transform is not possible to be behavior preserving in all cases). That said, we should still review all cases in case the intent of (T&&)t
on a forwarding reference should not even be using a forwarding reference at all.
from libunifex.
should I also look at migrating
static_cast
or C style forwarding casts tostd::forward
?
Yes, please! We're having a discussion on #552 about what to do when forwarding not-really-forwarding-references, which I think makes this issue nuanced, but, for clear cases of moves and forwards, I think we should standardize on std::move
and std::forward
so if you're interested in doing the clean-up, I'm quite happy to review and merge.
from libunifex.
Related Issues (20)
- blocking_kind customization does not compile HOT 1
- let_value decay-copies its final result HOT 4
- Using any_object with any_scheduler
- Fix errors when syncing master back to third-party HOT 1
- How to distinguish between cancellation from stop_when and ouside?
- Improve and rename `type_erased_stream` -> `any_stream_of`
- build libunifex failed with g++ 13.1.0
- `task` resumes after being cancelled causing UB HOT 6
- request_stop() return value is invalid
- (Is there already) support for async stream HOT 7
- How to properly use gtest dependency for building libunifex?
- Compile error with MSVC in default settings HOT 3
- Compile failed In Default Setting HOT 3
- Is there something equivalent to thread-local storage, but for coroutines? HOT 1
- /builddir/build/BUILD/libunifex-0.4.0/include/unifex/v2/async_scope.hpp:76:52: error: ‘MEM[(const struct scope_reference *)&optFuture].scope_’ may be used uninitialized [-Werror=maybe-uninitialized]
- Add documentation for unstoppable
- Document that senders run by at_coroutine_exist must succeed
- error_types is often an invalid type for dematerialize sender HOT 1
- When will the kernel side io_uring passthrough for reading or writing NVMe SSD devices be available?
- When will the kernel side io_uring passthrough for reading or writing NVMe SSD devices be available?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libunifex.