[PATCH] D58609: [clang-tidy] bugprone-string-integer-assignment: Reduce false positives.
Alexander Kornienko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 25 06:50:47 PST 2019
alexfh added inline comments.
================
Comment at: clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp:45
+ const auto* RHS = BinOp->getRHS()->IgnoreParenImpCasts();
+ // <expr> & <mask>, mask is a compile time constant.
+ Expr::EvalResult RHSVal;
----------------
What about `<mask> & <expr>`?
================
Comment at: clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp:52
+ // <char literal> + (<expr> % <mod>), where <base> is a char literal.
+ BinOp->dump();
+ llvm::errs() << "A " << isa<CharacterLiteral>(LHS) << " " << (BinOp->getOpcode() == BO_Add)<< "\n";
----------------
Please remove the debug output.
================
Comment at: clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp:54
+ llvm::errs() << "A " << isa<CharacterLiteral>(LHS) << " " << (BinOp->getOpcode() == BO_Add)<< "\n";
+ if (isa<CharacterLiteral>(LHS) && BinOp->getOpcode() == BO_Add) {
+ const auto* RHSOp = dyn_cast<BinaryOperator>(RHS);
----------------
What about `(x % 26) + 'a'`?
Repository:
rCTE Clang Tools Extra
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58609/new/
https://reviews.llvm.org/D58609
More information about the cfe-commits
mailing list