Catching trivial objects by value is not dangerous but may be inefficient if they are too large. This patch adds an option WarnOnLargeObject to the checker to also warn if such an object is caught by value. An object is considered as "large" if its size is greater than MaxSize which is another option. Default value is the machine word of the architecture (size of the type size_t).
Details
Details
- Reviewers
alexfh aaron.ballman lebedev.ri - Commits
- rZORG6b643d79328a: [clang-tidy] New option for misc-throw-by-value-catch-by-reference
rG6b643d79328a: [clang-tidy] New option for misc-throw-by-value-catch-by-reference
rCTE361225: [clang-tidy] New option for misc-throw-by-value-catch-by-reference
rG5f3deb9bb5a7: [clang-tidy] New option for misc-throw-by-value-catch-by-reference
rL361225: [clang-tidy] New option for misc-throw-by-value-catch-by-reference
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst | ||
---|---|---|
35–46 ↗ | (On Diff #199245) | I think it might be worth adding a note on the fallback to sizeof(size_t) if MaxSize is not set or manually set to std::numeric_limits<uint64_t>::max() by the user. |
clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp | ||
---|---|---|
25 ↗ | (On Diff #199245) | Missing a full stop at the end of the comment. |
docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst | ||
37–40 ↗ | (On Diff #199245) | large trivial object -> large, trivial object |
docs/ReleaseNotes.rst | ||
---|---|---|
182–184 ↗ | (On Diff #199245) | for check :doc:..<..> check (repeated 'check' word) |
Comment Actions
Looks good
clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h | ||
---|---|---|
45 ↗ | (On Diff #200266) | because |