[PATCH] D58977: [clang-tidy] Add the abseil-time-comparison check
Eric Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 11 04:32:27 PDT 2019
ioeric accepted this revision.
ioeric added inline comments.
This revision is now accepted and ready to land.
================
Comment at: clang-tidy/abseil/TimeComparisonCheck.cpp:23
+ auto Matcher =
+ binaryOperator(anyOf(hasOperatorName(">"), hasOperatorName(">="),
+ hasOperatorName("=="), hasOperatorName("<="),
----------------
hwright wrote:
> ioeric wrote:
> > `DurationComparisonCheck.cpp` has a very similar matcher pattern.
> >
> > Maybe pull out a common matcher for this? E.g. `comparisonOperatorWithCallee(...)`?
> >
> My one concern about doing so is that it would move the name bindings into a separate location away from the callback consuming those bindings.
>
> Since this is only the second instance of this pattern, would it be reasonable to wait until there's a third to combine them?
> My one concern about doing so is that it would move the name bindings into a separate location away from the callback consuming those bindings.
I think the name binding can stay in the same file. `comparisonOperatorWithCallee` is a matcher for a FunctionDecl, so, on the call site, you could do `comparisonOperatorWithCallee(functionDecl(TimeConversionFunction()).bind("function_decl")).bind("binop")`.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58977/new/
https://reviews.llvm.org/D58977
More information about the cfe-commits
mailing list