[PATCH] D55125: [clang-tidy] Fix a false positive in misc-redundant-expression check

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 12 14:25:07 PST 2018


Szelethus added inline comments.


================
Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:601
 
+static bool compareToks(Token &T1, Token &T2, const SourceManager &SM) {
+  if (T1.getLength() != T2.getLength())
----------------
Szelethus wrote:
> alexfh wrote:
> > Should this function compare token kinds first?
> I personally prefer to see boolean functions to have a name that starts with either "should", "is", "does", "has", or anything that clearly indicates that it returns with either `true` or `false`. In this case, "compare" is especially misleading, since it might as well return `-1`, `0` or `1`.
> 
> Maybe `hasSameLength`?
Sorry, upon closer inspection, `isSameToken` would be more fitting. Mind you, there already is a function somewhere for this, but due to the lack of a `Preprocessor` object, we can't use it.
https://clang.llvm.org/doxygen/RewriteMacros_8cpp.html#a0ba058873ae3930f71b19b4dee4b1cbb


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55125





More information about the cfe-commits mailing list