Skip to content

Commit 3295d37

Browse files
authored
[clang] Remove __is_layout_compatible from revertible type traits list (#100572)
`__is_layout_compatible` was added in Clang 19 (#81506), and at that time it wasn't entirely clear whether it should be a revertible type trait or not. We decided to follow the example of other type traits. Since then #95969 happened, and now we know that we don't want new revertible type traits. This patch removes `__is_layout_compatible` from revertible type traits list, and leaves a comment what revertible type traits are, and that new type traits should not be added there. The intention is to also cherry-pick this to 19 branch.
1 parent d8b672d commit 3295d37

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

clang/lib/Parse/ParseExpr.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,9 @@ class CastExpressionIdValidator final : public CorrectionCandidateCallback {
763763
bool Parser::isRevertibleTypeTrait(const IdentifierInfo *II,
764764
tok::TokenKind *Kind) {
765765
if (RevertibleTypeTraits.empty()) {
766+
// Revertible type trait is a feature for backwards compatibility with older
767+
// standard libraries that declare their own structs with the same name as
768+
// the builtins listed below. New builtins should NOT be added to this list.
766769
#define RTT_JOIN(X, Y) X##Y
767770
#define REVERTIBLE_TYPE_TRAIT(Name) \
768771
RevertibleTypeTraits[PP.getIdentifierInfo(#Name)] = RTT_JOIN(tok::kw_, Name)
@@ -790,7 +793,6 @@ bool Parser::isRevertibleTypeTrait(const IdentifierInfo *II,
790793
REVERTIBLE_TYPE_TRAIT(__is_fundamental);
791794
REVERTIBLE_TYPE_TRAIT(__is_integral);
792795
REVERTIBLE_TYPE_TRAIT(__is_interface_class);
793-
REVERTIBLE_TYPE_TRAIT(__is_layout_compatible);
794796
REVERTIBLE_TYPE_TRAIT(__is_literal);
795797
REVERTIBLE_TYPE_TRAIT(__is_lvalue_expr);
796798
REVERTIBLE_TYPE_TRAIT(__is_lvalue_reference);

0 commit comments

Comments
 (0)