================ @@ -189,7 +203,54 @@ void UseStartsEndsWithCheck::check(const MatchFinder::MatchResult &Result) { if (ComparisonExpr->getBeginLoc().isMacroID()) return; - const bool Neg = ComparisonExpr->getOpcode() == BO_NE; + bool Neg; + if (const auto *BO = llvm::dyn_cast<BinaryOperator>(ComparisonExpr)) { + Neg = BO->getOpcode() == BO_NE; + } else { + assert(llvm::isa<CXXOperatorCallExpr>(ComparisonExpr)); + Neg = llvm::cast<CXXOperatorCallExpr>(ComparisonExpr)->getOperator() == + OO_ExclaimEqual; + } ---------------- nicovank wrote:
A possible risk of errors here is `RewrittenBinaryOperator` for C++20 and above: sometimes (always?) CXXOperatorCallExpr nodes `operator!=` are rewritten into `not operator==`. I'm not sure if this is something to worry about here, will have to read on it again. https://github.com/llvm/llvm-project/pull/116033 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits