[PATCH] D107900: Add a new clang-tidy check for trivially copyable types passed by const reference

Julien Marrec via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 11 08:10:21 PDT 2021


jmarrec added inline comments.


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/misc-pod-const-ref-to-value.rst:21
+
+   If set to `true`, this check will limit itself to the `builtinType()` types. Default is `false`.
----------------
Quuxplusone wrote:
> D107873 is related.
> 
> I'd like to see some tests/discussion around large types, e.g.
> ```
> struct Widget { int a[1000]; };
> void f(const Widget&);
> ```
> (I think D107873 at least makes a conscious attempt to get the "would it be passed in registers?" check right.)
> 
> I'd like to see some tests/discussion around generic code, e.g.
> ```
> template<class T>
> struct Max {
>     static T max(const T& a, const T& b);
> };
> int x = Max<int>::max(1, 2);  // passes `int` by const reference, but this is fine
> ```
Should I close this one in favor of https://reviews.llvm.org/D107873?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107900/new/

https://reviews.llvm.org/D107900



More information about the cfe-commits mailing list