[PATCH] D55125: [clang-tidy] Fix a false positive in misc-redundant-expression check
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 10 08:58:17 PDT 2019
aaron.ballman added inline comments.
================
Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:621
+static bool isSameToken(const Token &T1, const Token &T2,
+ const SourceManager &SM) {
----------------
`isSameRawIdentifierToken()` so that the name isn't too generic.
================
Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:629-630
+ return false;
+ return strncmp(SM.getCharacterData(T1.getLocation()),
+ SM.getCharacterData(T2.getLocation()), T1.getLength()) == 0;
+}
----------------
I would feel more comfortable if this were written:
```
return StringRef(SM.getCharacterData(T1.getLocation()), T1.getLength()) == StringRef(SM.getCharacterData(T2.getLocation()), T2.getLength());
```
================
Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:674
+ return !(
+ (isTokAtEndOfExpr(Lsr, LTok, SM) && isTokAtEndOfExpr(Rsr, RTok, SM)) &&
+ isSameToken(LTok, RTok, SM));
----------------
You can drop a set of parens here as they don't change the order of evaluation.
================
Comment at: test/clang-tidy/misc-redundant-expression.cpp:152
+
// Overloaded operators that compare two instances of a struct.
----------------
Spurious newline.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55125/new/
https://reviews.llvm.org/D55125
More information about the cfe-commits
mailing list