[PATCH] D55125: [clang-tidy] Fix a false positive in misc-redundant-expression check
Alexander Kornienko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 23 05:17:42 PST 2019
alexfh added inline comments.
================
Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:136
+ case Stmt::UnaryExprOrTypeTraitExprClass:
+ if (cast<UnaryExprOrTypeTraitExpr>(Left)->isArgumentType() &&
+ cast<UnaryExprOrTypeTraitExpr>(Right)->isArgumentType())
----------------
Any reasons not to pull out the results of `cast<>()` to local variables? In this particular case this would make the code look much simpler.
================
Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:613
+static bool isSameToken(Token &T1, Token &T2, const SourceManager &SM) {
+ if (T1.getKind()!=T2.getKind())
----------------
`const Token&`
================
Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:614
+static bool isSameToken(Token &T1, Token &T2, const SourceManager &SM) {
+ if (T1.getKind()!=T2.getKind())
+ return false;
----------------
clang-format, please
================
Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:616
+ return false;
+ else if (T1.isNot(tok::raw_identifier))
+ return true;
----------------
https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return
================
Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:668-669
+ isSameToken(LTok, RTok, SM) &&
+ getCharCountUntilEndOfExpr(Lsr, LTok, SM) > 0 &&
+ getCharCountUntilEndOfExpr(Rsr, RTok, SM) > 0);
+ return !((getCharCountUntilEndOfExpr(Lsr, LTok, SM) == 0 &&
----------------
Can you just compare the location of (the end of?) the token with the end of the range?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55125/new/
https://reviews.llvm.org/D55125
More information about the cfe-commits
mailing list