Details
- Reviewers
steveire aaron.ballman njames93 alexfh
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Added content to the clang-tools-extra/docs/clang-tidy/checks/misc-pod-const-ref-to-value.rst file
clang-tools-extra/docs/clang-tidy/checks/misc-pod-const-ref-to-value.rst | ||
---|---|---|
22 | 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 |
clang-tools-extra/test/clang-tidy/checkers/misc-pod-const-ref-to-value.cpp | ||
---|---|---|
4–6 | This is now failing after I applied clang-format. int f1(const int& i) would correctly produce int f1(int i);, now it does int f1(inti);... I need to find a way to fix that. |
clang-tools-extra/docs/clang-tidy/checks/misc-pod-const-ref-to-value.rst | ||
---|---|---|
22 | Should I close this one in favor of https://reviews.llvm.org/D107873? |
Added a MaxSize option. defaults to 16. Also skip templates. like in D107873
Dealt with the f(int &i) case instead of f(int& i)
clang-tools-extra/docs/clang-tidy/checks/misc-pod-const-ref-to-value.rst | ||
---|---|---|
22 | @cjdb I guess it's uncanny that we would both decide to do it at the same time. A bit unfortunate too probably, I could have saved a few hours :) but I learned something about clang-tidy so I don't mind at all! Yours (D107873) is definitely better documented, you handle to opposite case (I only deal with const-ref -> value, not value -> const ret) and I just borrowed your implementation for MaxSize / ignoring shared_ptr As far as I can tell from a cursory look, there are a couple of things I'm doing that you aren't:
Perhaps we could discuss adding the above to your PR and consolidate over there to make a nice, feature-complete check? |
clang-tools-extra/docs/clang-tidy/checks/misc-pod-const-ref-to-value.rst | ||
---|---|---|
22 | Sounds good. |