Author: Mital Ashok Date: 2024-08-22T17:04:39+02:00 New Revision: ec5e58519d24010beea937fccf5fc4541db3ec21
URL: https://github.com/llvm/llvm-project/commit/ec5e58519d24010beea937fccf5fc4541db3ec21 DIFF: https://github.com/llvm/llvm-project/commit/ec5e58519d24010beea937fccf5fc4541db3ec21.diff LOG: [NFC] Replace bool <= bool comparison (#102948) Static analyser tool cppcheck flags ordered comparison with `bool`s. Replace with equivalent logical operators to prevent this. Closes #102912 Added: Modified: clang/lib/Sema/SemaOverload.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 52f640eb96b73b..1ce0fa091938d7 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -509,7 +509,7 @@ NarrowingKind StandardConversionSequence::getNarrowingKind( constexpr auto CanRepresentAll = [](bool FromSigned, unsigned FromWidth, bool ToSigned, unsigned ToWidth) { return (FromWidth < ToWidth + (FromSigned == ToSigned)) && - (FromSigned <= ToSigned); + !(FromSigned && !ToSigned); }; if (CanRepresentAll(FromSigned, FromWidth, ToSigned, ToWidth)) @@ -542,7 +542,7 @@ NarrowingKind StandardConversionSequence::getNarrowingKind( // If the bit-field width was dependent, it might end up being small // enough to fit in the target type (unless the target type is unsigned // and the source type is signed, in which case it will never fit) - if (DependentBitField && (FromSigned <= ToSigned)) + if (DependentBitField && !(FromSigned && !ToSigned)) return NK_Dependent_Narrowing; // Otherwise, such a conversion is always narrowing _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits