[PATCH] D98692: [clang-tidy] Add cppcoreguidelines-comparison-operator

2021-03-20 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp updated this revision to Diff 332145. nullptr.cpp edited the summary of this revision. nullptr.cpp added a comment. - Warn on both declarations and definitions - Add check for parameter passing - Add options `CheckParamPassing` and `ExpensiveToCopySize` Repository: rG LLVM Github

[PATCH] D98692: [clang-tidy] Add cppcoreguidelines-comparison-operator

2021-03-17 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment. In D98692#2631504 , @nullptr.cpp wrote: > The relevant rule is F.16: For "in" parameters, pass cheaply-copied types by > value and others by reference to const >

[PATCH] D98692: [clang-tidy] Add cppcoreguidelines-comparison-operator

2021-03-17 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp added a comment. In D98692#2631182 , @njames93 wrote: > While we're here, I'm not sure if there is a cppcoreguideline for it, but > parameters to comparison functions should be passed by const ref usually, or > by value if they are cheap to

[PATCH] D98692: [clang-tidy] Add cppcoreguidelines-comparison-operator

2021-03-17 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment. While we're here, I'm not sure if there is a cppcoreguideline for it, but parameters to comparison functions should be passed by const ref usually, or by value if they are cheap to copy. Maybe there's precedent to extend this to flag parameters that take non const

[PATCH] D98692: [clang-tidy] Add cppcoreguidelines-comparison-operator

2021-03-17 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp updated this revision to Diff 331179. nullptr.cpp edited the summary of this revision. nullptr.cpp added a comment. Update Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D98692/new/ https://reviews.llvm.org/D98692 Files:

[PATCH] D98692: [clang-tidy] Add cppcoreguidelines-comparison-operator

2021-03-17 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp updated this revision to Diff 331170. nullptr.cpp marked 6 inline comments as done. nullptr.cpp edited the summary of this revision. nullptr.cpp added a comment. Modify according to suggestions Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION

[PATCH] D98692: [clang-tidy] Add cppcoreguidelines-comparison-operator

2021-03-16 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments. Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/ComparisonOperatorCheck.cpp:20-21 +void ComparisonOperatorCheck::registerMatchers(MatchFinder *Finder) { + Finder->addMatcher(functionDecl(hasAnyOverloadedOperatorName("==", "!=", "<", +