[PATCH] D98104: Update __is_unsigned builtin to match the Standard.
Arthur O'Dwyer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 5 22:47:57 PST 2021
Quuxplusone added a comment.
🎉
================
Comment at: clang/lib/Sema/SemaExprCXX.cpp:4837
+ // Enum types should always return false (same as UTT_IsSigned).
+ return !T->isEnumeralType() && T->isUnsignedIntegerType();
----------------
FWIW, I'd lose the parenthetical comment, and I'd write the conditions as respectively
return T->isUnsignedIntegerType() && !T->isEnumeralType();
return T->isFloatingType() || (T->isSignedIntegerType() && !T->isEnumeralType());
both because "T not being an enum type" is expected to be usually true, and because I think `(!x && y)` runs the risk of being misread as `!(x && y)`, whereas `(x && !y)` is easy on the brain.
================
Comment at: clang/test/SemaCXX/type-traits.cpp:1472
+ int t27[F(__is_unsigned(Enum))];
+ int t28[F(__is_unsigned(UnsignedEnum))];
}
----------------
I think you should check `F(__is_unsigned(SignedEnum))` here, too, just for the record.
And `F(__is_signed(UnsignedEnum))` in the other place.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98104/new/
https://reviews.llvm.org/D98104
More information about the cfe-commits
mailing list