-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[clang] Classify vector types in __builtin_classify_type #73299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) ChangesFull diff: https://github.com/llvm/llvm-project/pull/73299.diff 5 Files Affected:
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7e2c990d03e7f27..362ce410356719b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -225,8 +225,8 @@ Non-comprehensive list of changes in this release
determined at runtime.
* The ``__datasizeof`` keyword has been added. It is similar to ``sizeof``
except that it returns the size of a type ignoring tail padding.
-* ``__builtin_classify_type()`` now classifies ``_BitInt`` values as the return value ``18``,
- to match GCC 14's behavior.
+* ``__builtin_classify_type()`` now classifies ``_BitInt`` values as the return value ``18``
+ and vector types as return value ``19``, to match GCC 14's behavior.
New Compiler Flags
------------------
diff --git a/clang/lib/AST/ExprConstShared.h b/clang/lib/AST/ExprConstShared.h
index 53ec9c6c7a3ef2e..a97eac85abc69e9 100644
--- a/clang/lib/AST/ExprConstShared.h
+++ b/clang/lib/AST/ExprConstShared.h
@@ -49,7 +49,8 @@ enum class GCCTypeClass {
// literals.
// Lang = 16,
// OpaqueType = 17,
- BitInt = 18
+ BitInt = 18,
+ Vector = 19
};
GCCTypeClass EvaluateBuiltinClassifyType(QualType T,
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 3a41e9718bb5875..16697e5f076a8f8 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -11615,16 +11615,18 @@ GCCTypeClass EvaluateBuiltinClassifyType(QualType T,
return EvaluateBuiltinClassifyType(
CanTy->castAs<AtomicType>()->getValueType(), LangOpts);
- case Type::BlockPointer:
case Type::Vector:
case Type::ExtVector:
+ return GCCTypeClass::Vector;
+
+ case Type::BlockPointer:
case Type::ConstantMatrix:
case Type::ObjCObject:
case Type::ObjCInterface:
case Type::ObjCObjectPointer:
case Type::Pipe:
- // GCC classifies vectors as None. We follow its lead and classify all
- // other types that don't fit into the regular classification the same way.
+ // Classify all other types that don't fit into the regular
+ // classification the same way.
return GCCTypeClass::None;
case Type::BitInt:
diff --git a/clang/test/Sema/builtin-classify-type.c b/clang/test/Sema/builtin-classify-type.c
index 50f517fcbc852a2..21b212faeedcd81 100644
--- a/clang/test/Sema/builtin-classify-type.c
+++ b/clang/test/Sema/builtin-classify-type.c
@@ -13,7 +13,7 @@ enum gcc_type_class {
record_type_class, union_type_class,
array_type_class, string_type_class,
lang_type_class, opaque_type_class,
- bitint_type_class
+ bitint_type_class, vector_type_class
};
void foo(void) {
@@ -67,8 +67,8 @@ void foo(void) {
int a11[__builtin_classify_type(arr) == pointer_type_class ? 1 : -1];
int a12[__builtin_classify_type("abc") == pointer_type_class ? 1 : -1];
int a13[__builtin_classify_type(block) == no_type_class ? 1 : -1];
- int a14[__builtin_classify_type(vec) == no_type_class ? 1 : -1];
- int a15[__builtin_classify_type(evec) == no_type_class ? 1 : -1];
+ int a14[__builtin_classify_type(vec) == vector_type_class ? 1 : -1];
+ int a15[__builtin_classify_type(evec) == vector_type_class ? 1 : -1];
int a16[__builtin_classify_type(atomic_i) == integer_type_class ? 1 : -1];
int a17[__builtin_classify_type(atomic_d) == real_type_class ? 1 : -1];
int a18[__builtin_classify_type(complex_i) == complex_type_class ? 1 : -1];
diff --git a/clang/test/SemaCXX/builtin-classify-type.cpp b/clang/test/SemaCXX/builtin-classify-type.cpp
index 651dc8b24bf9483..6bae9cd6b1dc0dd 100644
--- a/clang/test/SemaCXX/builtin-classify-type.cpp
+++ b/clang/test/SemaCXX/builtin-classify-type.cpp
@@ -13,7 +13,7 @@ enum gcc_type_class {
record_type_class, union_type_class,
array_type_class, string_type_class,
lang_type_class, opaque_type_class,
- bitint_type_class
+ bitint_type_class, vector_type_class
};
class cl {
@@ -62,8 +62,8 @@ void foo() {
int a14[__builtin_classify_type(arr) == pointer_type_class ? 1 : -1];
int a15[__builtin_classify_type("abc") == pointer_type_class ? 1 : -1];
int a16[__builtin_classify_type(block) == no_type_class ? 1 : -1];
- int a17[__builtin_classify_type(vec) == no_type_class ? 1 : -1];
- int a18[__builtin_classify_type(evec) == no_type_class ? 1 : -1];
+ int a17[__builtin_classify_type(vec) == vector_type_class ? 1 : -1];
+ int a18[__builtin_classify_type(evec) == vector_type_class ? 1 : -1];
int a19[__builtin_classify_type(atomic_i) == integer_type_class ? 1 : -1];
int a20[__builtin_classify_type(atomic_d) == real_type_class ? 1 : -1];
int a21[__builtin_classify_type(complex_i) == complex_type_class ? 1 : -1];
|
cor3ntin
approved these changes
Nov 24, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang
Clang issues not falling into any other category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.