Skip to content

Commit

Permalink
[NFC] Replace bool <= bool comparison (llvm#102948)
Browse files Browse the repository at this point in the history
Static analyser tool cppcheck flags ordered comparison with `bool`s.
Replace with equivalent logical operators to prevent this.

Closes llvm#102912
  • Loading branch information
MitalAshok authored Aug 22, 2024
1 parent 9402bb0 commit ec5e585
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions clang/lib/Sema/SemaOverload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ec5e585

Please sign in to comment.