Skip to content

Commit a79a561

Browse files
authored
[clang] Classify vector types in __builtin_classify_type (#73299)
1 parent 3d8a910 commit a79a561

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ Non-comprehensive list of changes in this release
225225
determined at runtime.
226226
* The ``__datasizeof`` keyword has been added. It is similar to ``sizeof``
227227
except that it returns the size of a type ignoring tail padding.
228-
* ``__builtin_classify_type()`` now classifies ``_BitInt`` values as the return value ``18``,
229-
to match GCC 14's behavior.
228+
* ``__builtin_classify_type()`` now classifies ``_BitInt`` values as the return value ``18``
229+
and vector types as return value ``19``, to match GCC 14's behavior.
230230

231231
New Compiler Flags
232232
------------------

clang/lib/AST/ExprConstShared.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ enum class GCCTypeClass {
4949
// literals.
5050
// Lang = 16,
5151
// OpaqueType = 17,
52-
BitInt = 18
52+
BitInt = 18,
53+
Vector = 19
5354
};
5455

5556
GCCTypeClass EvaluateBuiltinClassifyType(QualType T,

clang/lib/AST/ExprConstant.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11615,16 +11615,18 @@ GCCTypeClass EvaluateBuiltinClassifyType(QualType T,
1161511615
return EvaluateBuiltinClassifyType(
1161611616
CanTy->castAs<AtomicType>()->getValueType(), LangOpts);
1161711617

11618-
case Type::BlockPointer:
1161911618
case Type::Vector:
1162011619
case Type::ExtVector:
11620+
return GCCTypeClass::Vector;
11621+
11622+
case Type::BlockPointer:
1162111623
case Type::ConstantMatrix:
1162211624
case Type::ObjCObject:
1162311625
case Type::ObjCInterface:
1162411626
case Type::ObjCObjectPointer:
1162511627
case Type::Pipe:
11626-
// GCC classifies vectors as None. We follow its lead and classify all
11627-
// other types that don't fit into the regular classification the same way.
11628+
// Classify all other types that don't fit into the regular
11629+
// classification the same way.
1162811630
return GCCTypeClass::None;
1162911631

1163011632
case Type::BitInt:

clang/test/Sema/builtin-classify-type.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ enum gcc_type_class {
1313
record_type_class, union_type_class,
1414
array_type_class, string_type_class,
1515
lang_type_class, opaque_type_class,
16-
bitint_type_class
16+
bitint_type_class, vector_type_class
1717
};
1818

1919
void foo(void) {
@@ -67,8 +67,8 @@ void foo(void) {
6767
int a11[__builtin_classify_type(arr) == pointer_type_class ? 1 : -1];
6868
int a12[__builtin_classify_type("abc") == pointer_type_class ? 1 : -1];
6969
int a13[__builtin_classify_type(block) == no_type_class ? 1 : -1];
70-
int a14[__builtin_classify_type(vec) == no_type_class ? 1 : -1];
71-
int a15[__builtin_classify_type(evec) == no_type_class ? 1 : -1];
70+
int a14[__builtin_classify_type(vec) == vector_type_class ? 1 : -1];
71+
int a15[__builtin_classify_type(evec) == vector_type_class ? 1 : -1];
7272
int a16[__builtin_classify_type(atomic_i) == integer_type_class ? 1 : -1];
7373
int a17[__builtin_classify_type(atomic_d) == real_type_class ? 1 : -1];
7474
int a18[__builtin_classify_type(complex_i) == complex_type_class ? 1 : -1];

clang/test/SemaCXX/builtin-classify-type.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ enum gcc_type_class {
1313
record_type_class, union_type_class,
1414
array_type_class, string_type_class,
1515
lang_type_class, opaque_type_class,
16-
bitint_type_class
16+
bitint_type_class, vector_type_class
1717
};
1818

1919
class cl {
@@ -62,8 +62,8 @@ void foo() {
6262
int a14[__builtin_classify_type(arr) == pointer_type_class ? 1 : -1];
6363
int a15[__builtin_classify_type("abc") == pointer_type_class ? 1 : -1];
6464
int a16[__builtin_classify_type(block) == no_type_class ? 1 : -1];
65-
int a17[__builtin_classify_type(vec) == no_type_class ? 1 : -1];
66-
int a18[__builtin_classify_type(evec) == no_type_class ? 1 : -1];
65+
int a17[__builtin_classify_type(vec) == vector_type_class ? 1 : -1];
66+
int a18[__builtin_classify_type(evec) == vector_type_class ? 1 : -1];
6767
int a19[__builtin_classify_type(atomic_i) == integer_type_class ? 1 : -1];
6868
int a20[__builtin_classify_type(atomic_d) == real_type_class ? 1 : -1];
6969
int a21[__builtin_classify_type(complex_i) == complex_type_class ? 1 : -1];

0 commit comments

Comments
 (0)