Skip to content

Commit ec5e585

Browse files
authored
[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
1 parent 9402bb0 commit ec5e585

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clang/lib/Sema/SemaOverload.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ NarrowingKind StandardConversionSequence::getNarrowingKind(
509509
constexpr auto CanRepresentAll = [](bool FromSigned, unsigned FromWidth,
510510
bool ToSigned, unsigned ToWidth) {
511511
return (FromWidth < ToWidth + (FromSigned == ToSigned)) &&
512-
(FromSigned <= ToSigned);
512+
!(FromSigned && !ToSigned);
513513
};
514514

515515
if (CanRepresentAll(FromSigned, FromWidth, ToSigned, ToWidth))
@@ -542,7 +542,7 @@ NarrowingKind StandardConversionSequence::getNarrowingKind(
542542
// If the bit-field width was dependent, it might end up being small
543543
// enough to fit in the target type (unless the target type is unsigned
544544
// and the source type is signed, in which case it will never fit)
545-
if (DependentBitField && (FromSigned <= ToSigned))
545+
if (DependentBitField && !(FromSigned && !ToSigned))
546546
return NK_Dependent_Narrowing;
547547

548548
// Otherwise, such a conversion is always narrowing

0 commit comments

Comments
 (0)