=?utf-8?q?Björn?= Svensson <[email protected]>,
=?utf-8?q?Björn?= Svensson <[email protected]>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/[email protected]>
================
@@ -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
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits