=?utf-8?q?Björn?= Svensson <bjorn.a.svens...@est.tech>, =?utf-8?q?Björn?= Svensson <bjorn.a.svens...@est.tech> Message-ID: In-Reply-To: <llvm.org/llvm/llvm-project/pull/149...@github.com>
================ @@ -75,16 +86,21 @@ void SignedCharMisuseCheck::registerMatchers(MatchFinder *Finder) { const auto UnSignedCharCastExpr = charCastExpression(false, IntegerType, "unsignedCastExpression"); - // Catch assignments with signed char -> integer conversion. + // Catch assignments with signed char -> integer conversion. Ignore false + // positives on C23 enums with the fixed underlying type of signed char. const auto AssignmentOperatorExpr = expr(binaryOperator(hasOperatorName("="), hasLHS(hasType(IntegerType)), - hasRHS(SignedCharCastExpr))); + hasRHS(SignedCharCastExpr)), + unless(allOf(isC23Stmt(), binaryOperator(hasLHS(hasType( + hasCanonicalType(enumType()))))))); ---------------- vbvictor wrote: > Maybe there is another way to do it? Not that I know of. You need to either create a new `Matcher` or use a `static_cast` to make `anything()` work. https://github.com/llvm/llvm-project/pull/149790 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits