I'm writing C++ code in CLion 2021.3, which uses clang-tidy checks.
In my code, I have a lightweight reference class; let's say it looks like this:
struct resource_t {
uint8_t kind;
int id;
}
Now, when I pass a resource_t
object around, I want to pass it by value. There is no reason I would need to employ references to it, or move it, or what-not. However, clang-tidy doesn't like this. So it complains about my functions with take resource_t's by values, and about my passing them by-value to these functions. It always suggests to me to make the parameters const resource_t&
's, and in some cases to consider passing std::move(my_resource)
if that's the only use of my_resource
in the function.
Now, these warnings are fine for "heavy" classes - but not for this one. Is there any way - with CLion or for clang-tidy generally - to get clang-tidy to tell apart the "heavy" from the "lightweight" case? Or perhaps to whitelist some specific types?