r298493 - [Serialization] Serialize DependentSizedExtVectorType
Alex Lorenz via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 22 03:04:49 PDT 2017
Author: arphaman
Date: Wed Mar 22 05:04:48 2017
New Revision: 298493
URL: http://llvm.org/viewvc/llvm-project?rev=298493&view=rev
Log:
[Serialization] Serialize DependentSizedExtVectorType
rdar://30659700
Differential Revision: https://reviews.llvm.org/D31134
Added:
cfe/trunk/test/PCH/cxx-dependent-sized-ext-vector.cpp
Modified:
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=298493&r1=298492&r2=298493&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Wed Mar 22 05:04:48 2017
@@ -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
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=298493&r1=298492&r2=298493&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Mar 22 05:04:48 2017
@@ -6073,6 +6073,17 @@ QualType ASTReader::readTypeRecord(unsig
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!");
}
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=298493&r1=298492&r2=298493&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Wed Mar 22 05:04:48 2017
@@ -426,8 +426,10 @@ ASTTypeWriter::VisitDependentSizedArrayT
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
Added: cfe/trunk/test/PCH/cxx-dependent-sized-ext-vector.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx-dependent-sized-ext-vector.cpp?rev=298493&view=auto
==============================================================================
--- cfe/trunk/test/PCH/cxx-dependent-sized-ext-vector.cpp (added)
+++ cfe/trunk/test/PCH/cxx-dependent-sized-ext-vector.cpp Wed Mar 22 05:04:48 2017
@@ -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 at -5 {{zero vector size}}
+ vec<float, 0> b; // expected-note {{in instantiation of template type alias 'vec' requested here}}
+}
+
+#endif
More information about the cfe-commits
mailing list