[clang] c682488 - [AST][SVE] Treat built-in SVE types as trivial

Richard Sandiford via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 27 10:40:35 PDT 2020


Author: Richard Sandiford
Date: 2020-03-27T17:34:04Z
New Revision: c6824883cc9de7e46b2417d58463f9c4e02da195

URL: https://github.com/llvm/llvm-project/commit/c6824883cc9de7e46b2417d58463f9c4e02da195
DIFF: https://github.com/llvm/llvm-project/commit/c6824883cc9de7e46b2417d58463f9c4e02da195.diff

LOG: [AST][SVE] Treat built-in SVE types as trivial

Built-in SVE types are trivial, since they're trivially copyable
and support default construction.

Differential Revision: https://reviews.llvm.org/D76692

Added: 
    

Modified: 
    clang/lib/AST/Type.cpp
    clang/test/SemaCXX/sizeless-1.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 44d3dbc806d8..99005a33e5a9 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2249,6 +2249,9 @@ bool QualType::isTrivialType(const ASTContext &Context) const {
   if ((*this)->isArrayType())
     return Context.getBaseElementType(*this).isTrivialType(Context);
 
+  if ((*this)->isSizelessBuiltinType())
+    return true;
+
   // Return false for incomplete types after skipping any incomplete array
   // types which are expressly allowed by the standard and thus our API.
   if ((*this)->isIncompleteType())

diff  --git a/clang/test/SemaCXX/sizeless-1.cpp b/clang/test/SemaCXX/sizeless-1.cpp
index 3d0f07ccc74a..a7c02343cb48 100644
--- a/clang/test/SemaCXX/sizeless-1.cpp
+++ b/clang/test/SemaCXX/sizeless-1.cpp
@@ -516,6 +516,7 @@ void cxx_only(int sel) {
   _Static_assert(!__is_literal(svint8_t), "");
   _Static_assert(__is_pod(svint8_t), "");
   _Static_assert(!__is_polymorphic(svint8_t), "");
+  _Static_assert(__is_trivial(svint8_t), "");
   _Static_assert(__is_object(svint8_t), "");
   _Static_assert(!__is_arithmetic(svint8_t), "");
   _Static_assert(!__is_floating_point(svint8_t), "");


        


More information about the cfe-commits mailing list