]> granicus.if.org Git - clang/commitdiff
[Serialization] Serialize DependentSizedExtVectorType
authorAlex Lorenz <arphaman@gmail.com>
Wed, 22 Mar 2017 10:04:48 +0000 (10:04 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Wed, 22 Mar 2017 10:04:48 +0000 (10:04 +0000)
rdar://30659700

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@298493 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Serialization/ASTBitCodes.h
lib/Serialization/ASTReader.cpp
lib/Serialization/ASTWriter.cpp
test/PCH/cxx-dependent-sized-ext-vector.cpp [new file with mode: 0644]

index de8e2a8183e3e92af09e6f0dbb75b2ac71a4ff45..eec88404f4002a93e98ca03b06cbc4b001e8de14 100644 (file)
@@ -927,7 +927,9 @@ namespace clang {
       /// \brief An ObjCTypeParamType record.
       TYPE_OBJC_TYPE_PARAM       = 44,
       /// \brief A DeducedTemplateSpecializationType record.
-      TYPE_DEDUCED_TEMPLATE_SPECIALIZATION = 45
+      TYPE_DEDUCED_TEMPLATE_SPECIALIZATION = 45,
+      /// \brief A DependentSizedExtVectorType record.
+      TYPE_DEPENDENT_SIZED_EXT_VECTOR = 46
     };
 
     /// \brief The type IDs for special types constructed by semantic
index c6b21aadbdd63192bcb79b2483281999c4919710..9f50e0541d505b84b72b960179d03e42a82be5c7 100644 (file)
@@ -6073,6 +6073,17 @@ QualType ASTReader::readTypeRecord(unsigned Index) {
     return Context.getPipeType(ElementType, ReadOnly);
   }
 
+  case TYPE_DEPENDENT_SIZED_EXT_VECTOR: {
+    unsigned Idx = 0;
+
+    // DependentSizedExtVectorType
+    QualType ElementType = readType(*Loc.F, Record, Idx);
+    Expr *SizeExpr = ReadExpr(*Loc.F);
+    SourceLocation AttrLoc = ReadSourceLocation(*Loc.F, Record, Idx);
+
+    return Context.getDependentSizedExtVectorType(ElementType, SizeExpr,
+                                                  AttrLoc);
+  }
   }
   llvm_unreachable("Invalid TypeCode!");
 }
index 524bc2dae730e908aa53612b07707f398253e093..e4474a84179c27c2694bb719d4cf886773fa521f 100644 (file)
@@ -426,8 +426,10 @@ ASTTypeWriter::VisitDependentSizedArrayType(const DependentSizedArrayType *T) {
 void
 ASTTypeWriter::VisitDependentSizedExtVectorType(
                                         const DependentSizedExtVectorType *T) {
-  // FIXME: Serialize this type (C++ only)
-  llvm_unreachable("Cannot serialize dependent sized extended vector types");
+  Record.AddTypeRef(T->getElementType());
+  Record.AddStmt(T->getSizeExpr());
+  Record.AddSourceLocation(T->getAttributeLoc());
+  Code = TYPE_DEPENDENT_SIZED_EXT_VECTOR;
 }
 
 void
diff --git a/test/PCH/cxx-dependent-sized-ext-vector.cpp b/test/PCH/cxx-dependent-sized-ext-vector.cpp
new file mode 100644 (file)
index 0000000..29c06f7
--- /dev/null
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++11 -emit-pch %s -o %t
+// RUN: %clang_cc1 -std=c++11 -include-pch %t -verify %s
+
+#ifndef HEADER_INCLUDED
+
+#define HEADER_INCLUDED
+
+template<typename T, int N>
+using vec = T __attribute__((ext_vector_type(N)));
+
+#else
+
+void test() {
+  vec<float, 2> a;  // expected-error@-5 {{zero vector size}}
+  vec<float, 0> b; // expected-note {{in instantiation of template type alias 'vec' requested here}}
+}
+
+#endif