[cfe-commits] r130606 - in /cfe/trunk: lib/AST/Type.cpp test/SemaCXX/literal-type.cpp test/SemaCXX/type-traits.cpp
Chandler Carruth
chandlerc at gmail.com
Sat Apr 30 03:46:26 PDT 2011
Author: chandlerc
Date: Sat Apr 30 05:46:26 2011
New Revision: 130606
URL: http://llvm.org/viewvc/llvm-project?rev=130606&view=rev
Log:
Make type-traits reflect that Clang's vectors act like scalar types.
Modified:
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/test/SemaCXX/literal-type.cpp
cfe/trunk/test/SemaCXX/type-traits.cpp
Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=130606&r1=130605&r2=130606&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Sat Apr 30 05:46:26 2011
@@ -891,7 +891,8 @@
// C++0x [basic.types]p10:
// A type is a literal type if it is:
// -- a scalar type; or
- if (BaseTy->isScalarType()) return true;
+ // As an extension, Clang treats vector types as Scalar types.
+ if (BaseTy->isScalarType() || BaseTy->isVectorType()) return true;
// -- a reference type; or
if (BaseTy->isReferenceType()) return true;
// -- a class type that has all of the following properties:
@@ -936,7 +937,8 @@
if (BaseTy->isIncompleteType())
return false;
- if (BaseTy->isScalarType()) return true;
+ // As an extension, Clang treats vector types as Scalar types.
+ if (BaseTy->isScalarType() || BaseTy->isVectorType()) return true;
if (const RecordType *RT = BaseTy->getAs<RecordType>()) {
if (const CXXRecordDecl *ClassDecl =
dyn_cast<CXXRecordDecl>(RT->getDecl())) {
@@ -970,7 +972,8 @@
if (BaseTy->isIncompleteType())
return false;
- if (BaseTy->isScalarType()) return true;
+ // As an extension, Clang treats vector types as Scalar types.
+ if (BaseTy->isScalarType() || BaseTy->isVectorType()) return true;
if (const RecordType *RT = BaseTy->getAs<RecordType>()) {
if (const CXXRecordDecl *ClassDecl =
dyn_cast<CXXRecordDecl>(RT->getDecl()))
@@ -1005,7 +1008,8 @@
if (BaseTy->isIncompleteType())
return false;
- if (BaseTy->isScalarType()) return true;
+ // As an extension, Clang treats vector types as Scalar types.
+ if (BaseTy->isScalarType() || BaseTy->isVectorType()) return true;
if (const RecordType *RT = BaseTy->getAs<RecordType>()) {
if (const CXXRecordDecl *ClassDecl =
dyn_cast<CXXRecordDecl>(RT->getDecl())) {
Modified: cfe/trunk/test/SemaCXX/literal-type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/literal-type.cpp?rev=130606&r1=130605&r2=130606&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/literal-type.cpp (original)
+++ cfe/trunk/test/SemaCXX/literal-type.cpp Sat Apr 30 05:46:26 2011
@@ -8,6 +8,10 @@
static_assert(__is_literal(decltype(E1)), "fail");
typedef int IAR[10];
static_assert(__is_literal(IAR), "fail");
+typedef int Vector __attribute__((vector_size(16)));
+typedef int VectorExt __attribute__((ext_vector_type(4)));
+static_assert(__is_literal(Vector), "fail");
+static_assert(__is_literal(VectorExt), "fail");
// C++0x [basic.types]p10:
// A type is a literal type if it is:
Modified: cfe/trunk/test/SemaCXX/type-traits.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/type-traits.cpp?rev=130606&r1=130605&r2=130606&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/type-traits.cpp (original)
+++ cfe/trunk/test/SemaCXX/type-traits.cpp Sat Apr 30 05:46:26 2011
@@ -27,6 +27,9 @@
};
};
+typedef int Vector __attribute__((vector_size(16)));
+typedef int VectorExt __attribute__((ext_vector_type(4)));
+
// Not PODs
typedef const void cvoid;
struct Derives : POD {};
@@ -104,6 +107,8 @@
{ int arr[T(__is_pod(HasAssign))]; }
{ int arr[T(__is_pod(IntArNB))]; }
{ int arr[T(__is_pod(HasAnonymousUnion))]; }
+ { int arr[T(__is_pod(Vector))]; }
+ { int arr[T(__is_pod(VectorExt))]; }
{ int arr[F(__is_pod(Derives))]; }
{ int arr[F(__is_pod(DerivesAr))]; }
@@ -942,6 +947,8 @@
int t04[T(__is_standard_layout(CStruct))];
int t05[T(__is_standard_layout(CppStructStandard))];
int t06[T(__is_standard_layout(CppStructStandardAr))];
+ int t07[T(__is_standard_layout(Vector))];
+ int t08[T(__is_standard_layout(VectorExt))];
typedef CppStructNonStandardByBase CppStructNonStandardByBaseAr[4];
@@ -1447,6 +1454,8 @@
{ int arr[T(__is_trivial(HasProt))]; }
{ int arr[T(__is_trivial(DerivesHasPriv))]; }
{ int arr[T(__is_trivial(DerivesHasProt))]; }
+ { int arr[T(__is_trivial(Vector))]; }
+ { int arr[T(__is_trivial(VectorExt))]; }
{ int arr[F(__is_trivial(HasCons))]; }
{ int arr[F(__is_trivial(HasCopyAssign))]; }
More information about the cfe-commits
mailing list