SUMMARY Although std::atomic is correctly considered a "small and trivially-copyable type", passing one by value makes no sense. The only plausible use case for passing a std::atomic is passing by reference. Accordingly, it is always a false positive for clazy to warn about passing std::atomic by reference. STEPS TO REPRODUCE 1. Run clazy on a function that takes a std::atomic by const reference. OBSERVED RESULT Clazy complains that the parameter should be passed by value. EXPECTED RESULT Clazy should not complain. (Possibly it should complain about std::atomic that is *not* passed by reference.) SOFTWARE/OS VERSIONS clazy: master (75c097b118931e2d8f3a66cc12bf7045ee548e81) clang: clang-6.0.1-2.fc28 llvm: llvm-6.0.1-8.fc28
Git commit 1ac59a00dc6886ba6e1259daac8980c92230fc2a by Sergio Martins. Committed on 13/01/2019 at 21:46. Pushed by smartins into branch '1.4'. Don't suggest to pass classes with deleted copy ctor by value M +2 -1 src/TypeUtils.cpp M +12 -0 tests/function-args-by-value/main.cpp M +12 -0 tests/function-args-by-value/main.cpp_fixed.cpp.expected https://commits.kde.org/clazy/1ac59a00dc6886ba6e1259daac8980c92230fc2a
Oh, wow... I hadn't even thought about std::atomic being non-copyable. Checking for that (since following clazy's advice in such cases will break your code) is indeed a much better fix; thanks!