]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/clang/include/clang/AST/TypeProperties.td
Merge ^/vendor/lvm-project/master up to its last change (upstream commit
[FreeBSD/FreeBSD.git] / contrib / llvm-project / clang / include / clang / AST / TypeProperties.td
1 //==--- TypeProperties.td - Type property definitions ---------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 include "clang/AST/PropertiesBase.td"
10 include "clang/Basic/TypeNodes.td"
11
12 let Class = ComplexType in {
13   def : Property<"elementType", QualType> {
14     let Read = [{ node->getElementType() }];    
15   }
16
17   def : Creator<[{ return ctx.getComplexType(elementType); }]>;
18 }
19
20 let Class = PointerType in {
21   def : Property<"pointeeType", QualType> {
22     let Read = [{ node->getPointeeType() }];
23   }
24
25   def : Creator<[{ return ctx.getPointerType(pointeeType); }]>;
26 }
27
28 let Class = AdjustedType in {
29   def : Property<"originalType", QualType> {
30     let Read = [{ node->getOriginalType() }];
31   }
32   def : Property<"adjustedType", QualType> {
33     let Read = [{ node->getAdjustedType() }];
34   }
35
36   def : Creator<[{ return ctx.getAdjustedType(originalType, adjustedType); }]>;
37 }
38
39 let Class = DecayedType in {
40   def : Override {
41     // We don't need to serialize the adjusted type because we can always
42     // derive it by decaying the original type.
43     let IgnoredProperties = [ "adjustedType" ];
44   }
45
46   def : Creator<[{ return ctx.getAdjustedParameterType(originalType); }]>;
47 }
48
49 let Class = BlockPointerType in {
50   def : Property<"pointeeType", QualType> {
51     let Read = [{ node->getPointeeType() }];
52   }
53
54   def : Creator<[{ return ctx.getBlockPointerType(pointeeType); }]>;
55 }
56
57 let Class = ReferenceType in {
58   def : Property<"pointeeTypeAsWritten", QualType> {
59     let Read = [{ node->getPointeeTypeAsWritten() }];
60   }
61 }
62
63 let Class = LValueReferenceType in {
64   def : Property<"isSpelledAsLValue", Bool> {
65     let Read = [{ node->isSpelledAsLValue() }];
66   }
67
68   def : Creator<[{
69     return ctx.getLValueReferenceType(pointeeTypeAsWritten,
70                                       isSpelledAsLValue);
71   }]>;
72 }
73
74 let Class = RValueReferenceType in {
75   def : Creator<[{
76     return ctx.getRValueReferenceType(pointeeTypeAsWritten);
77   }]>;
78 }
79
80 let Class = MemberPointerType in {
81   def : Property<"pointeeType", QualType> {
82     let Read = [{ node->getPointeeType() }];
83   }
84   def : Property<"baseType", QualType> {
85     let Read = [{ QualType(node->getClass(), 0) }];
86   }
87
88   def : Creator<[{
89     return ctx.getMemberPointerType(pointeeType, baseType.getTypePtr());
90   }]>;
91 }
92
93 let Class = ArrayType in {
94   def : Property<"elementType", QualType> {
95     let Read = [{ node->getElementType() }];
96   }
97   def : Property<"sizeModifier", ArraySizeModifier> {
98     let Read = [{ node->getSizeModifier() }];
99   }
100   def : Property<"indexQualifiers", Qualifiers> {
101     let Read = [{ Qualifiers::fromCVRMask(node->getIndexTypeCVRQualifiers()) }];
102   }
103 }
104
105 let Class = ConstantArrayType in {
106   def : Property<"sizeValue", APInt> {
107     let Read = [{ node->getSize() }];
108   }
109   def : Property<"size", ExprRef> {
110     let Read = [{ node->getSizeExpr() }];
111   }
112
113   def : Creator<[{
114     return ctx.getConstantArrayType(elementType, sizeValue, size,
115                                     sizeModifier,
116                                     indexQualifiers.getCVRQualifiers());
117   }]>;
118 }
119
120 let Class = IncompleteArrayType in {
121   def : Creator<[{
122     return ctx.getIncompleteArrayType(elementType, sizeModifier,
123                                       indexQualifiers.getCVRQualifiers());
124   }]>;
125 }
126
127 let Class = VariableArrayType in {
128   def : Property<"leftBracketLoc", SourceLocation> {
129     let Read = [{ node->getLBracketLoc() }];
130   }
131   def : Property<"rightBracketLoc", SourceLocation> {
132     let Read = [{ node->getRBracketLoc() }];
133   }
134   def : Property<"size", ExprRef> {
135     let Read = [{ node->getSizeExpr() }];
136   }
137
138   def : Creator<[{
139     return ctx.getVariableArrayType(elementType, size, sizeModifier,
140                                     indexQualifiers.getCVRQualifiers(),
141                                     SourceRange(leftBracketLoc,
142                                                 rightBracketLoc));
143   }]>;
144 }
145
146 let Class = DependentSizedArrayType in {
147   def : Property<"size", ExprRef> {
148     let Read = [{ node->getSizeExpr() }];
149   }
150   def : Property<"leftBracketLoc", SourceLocation> {
151     let Read = [{ node->getLBracketLoc() }];
152   }
153   def : Property<"rightBracketLoc", SourceLocation> {
154     let Read = [{ node->getRBracketLoc() }];
155   }
156
157   def : Creator<[{
158     return ctx.getDependentSizedArrayType(elementType, size, sizeModifier,
159                                           indexQualifiers.getCVRQualifiers(),
160                                           SourceRange(leftBracketLoc,
161                                                       rightBracketLoc));
162   }]>;
163 }
164
165 let Class = VectorType in {
166   def : Property<"elementType", QualType> {
167     let Read = [{ node->getElementType() }];
168   }
169   def : Property<"numElements", UInt32> {
170     let Read = [{ node->getNumElements() }];
171   }
172   def : Property<"vectorKind", VectorKind> {
173     let Read = [{ node->getVectorKind() }];
174   }
175
176   def : Creator<[{
177     return ctx.getVectorType(elementType, numElements, vectorKind);
178   }]>;
179 }
180
181 let Class = DependentVectorType in {
182   def : Property<"elementType", QualType> {
183     let Read = [{ node->getElementType() }];
184   }
185   def : Property<"size", ExprRef> {
186     let Read = [{ node->getSizeExpr() }];
187   }
188   def : Property<"attributeLoc", SourceLocation> {
189     let Read = [{ node->getAttributeLoc() }];
190   }
191   def : Property<"vectorKind", VectorKind> {
192     let Read = [{ node->getVectorKind() }];
193   }
194
195   def : Creator<[{
196     return ctx.getDependentVectorType(elementType, size, attributeLoc,
197                                       vectorKind);
198   }]>;
199 }
200
201 let Class = ExtVectorType in {
202   def : Override {
203     let IgnoredProperties = [ "vectorKind" ];
204   }
205
206   def : Creator<[{
207     return ctx.getExtVectorType(elementType, numElements);
208   }]>;
209 }
210
211 let Class = DependentSizedExtVectorType in {
212   def : Property<"elementType", QualType> {
213     let Read = [{ node->getElementType() }];
214   }
215   def : Property<"size", ExprRef> {
216     let Read = [{ node->getSizeExpr() }];
217   }
218   def : Property<"attributeLoc", SourceLocation> {
219     let Read = [{ node->getAttributeLoc() }];
220   }
221
222   def : Creator<[{
223     return ctx.getDependentSizedExtVectorType(elementType, size, attributeLoc);
224   }]>;
225 }
226
227 let Class = FunctionType in {
228   def : Property<"returnType", QualType> {
229     let Read = [{ node->getReturnType() }];
230   }
231   def : Property<"noReturn", Bool> {
232     let Read = [{ node->getExtInfo().getNoReturn() }];
233   }
234   def : Property<"hasRegParm", Bool> {
235     let Read = [{ node->getExtInfo().getHasRegParm() }];
236   }
237   def : Property<"regParm", UInt32> {
238     let Read = [{ node->getExtInfo().getRegParm() }];
239   }
240   def : Property<"callingConvention", CallingConv> {
241     let Read = [{ node->getExtInfo().getCC() }];
242   }
243   def : Property<"producesResult", Bool> {
244     let Read = [{ node->getExtInfo().getProducesResult() }];
245   }
246   def : Property<"noCallerSavedRegs", Bool> {
247     let Read = [{ node->getExtInfo().getNoCallerSavedRegs() }];
248   }
249   def : Property<"noCfCheck", Bool> {
250     let Read = [{ node->getExtInfo().getNoCfCheck() }];
251   }
252 }
253
254 let Class = FunctionNoProtoType in {
255   def : Creator<[{
256     auto extInfo = FunctionType::ExtInfo(noReturn, hasRegParm, regParm,
257                                          callingConvention, producesResult,
258                                          noCallerSavedRegs, noCfCheck);
259     return ctx.getFunctionNoProtoType(returnType, extInfo);
260   }]>;
261 }
262
263 let Class = FunctionProtoType in {
264   def : Property<"variadic", Bool> {
265     let Read = [{ node->isVariadic() }];
266   }
267   def : Property<"trailingReturn", Bool> {
268     let Read = [{ node->hasTrailingReturn() }];
269   }
270   def : Property<"methodQualifiers", Qualifiers> {
271     let Read = [{ node->getMethodQuals() }];
272   }
273   def : Property<"refQualifier", RefQualifierKind> {
274     let Read = [{ node->getRefQualifier() }];
275   }
276   def : Property<"exceptionSpecifier", ExceptionSpecInfo> {
277     let Read = [{ node->getExceptionSpecInfo() }];
278   }
279   def : Property<"parameters", Array<QualType>> {
280     let Read = [{ node->getParamTypes() }];
281   }
282   def : Property<"extParameterInfo", Array<ExtParameterInfo>> {
283     let Read = [{ node->hasExtParameterInfos()
284                     ? node->getExtParameterInfos()
285                     : llvm::ArrayRef<FunctionProtoType::ExtParameterInfo>() }];
286   }
287
288   def : Creator<[{
289     auto extInfo = FunctionType::ExtInfo(noReturn, hasRegParm, regParm,
290                                          callingConvention, producesResult,
291                                          noCallerSavedRegs, noCfCheck);
292     FunctionProtoType::ExtProtoInfo epi;
293     epi.ExtInfo = extInfo;
294     epi.Variadic = variadic;
295     epi.HasTrailingReturn = trailingReturn;
296     epi.TypeQuals = methodQualifiers;
297     epi.RefQualifier = refQualifier;
298     epi.ExceptionSpec = exceptionSpecifier;
299     epi.ExtParameterInfos =
300       extParameterInfo.empty() ? nullptr : extParameterInfo.data();
301     return ctx.getFunctionType(returnType, parameters, epi);
302   }]>;
303 }
304
305 let Class = AtomicType in {
306   def : Property<"valueType", QualType> {
307     let Read = [{ node->getValueType() }];
308   }
309
310   def : Creator<[{
311     return ctx.getAtomicType(valueType);
312   }]>;
313 }
314
315 let Class = UnresolvedUsingType in {
316   def : Property<"declaration", DeclRef> {
317     let Read = [{ node->getDecl() }];
318   }
319
320   def : Creator<[{
321     return ctx.getTypeDeclType(cast<UnresolvedUsingTypenameDecl>(declaration));
322   }]>;
323 }
324
325 let Class = TypedefType in {
326   def : Property<"declaration", DeclRef> {
327     let Read = [{ node->getDecl() }];
328   }
329   def : Property<"canonicalType", Optional<QualType>> {
330     let Read = [{ makeOptionalFromNullable(node->getCanonicalTypeInternal()) }];
331   }
332
333   def : Creator<[{
334     QualType finalCanonicalType =
335       canonicalType ? ctx.getCanonicalType(*canonicalType)
336                     : QualType();
337     return ctx.getTypedefType(cast<TypedefNameDecl>(declaration),
338                               finalCanonicalType);
339   }]>;
340 }
341
342 let Class = TypeOfExprType in {
343   def : Property<"expression", ExprRef> {
344     let Read = [{ node->getUnderlyingExpr() }];
345   }
346
347   def : Creator<[{
348     return ctx.getTypeOfExprType(expression);
349   }]>;
350 }
351
352 let Class = TypeOfType in {
353   def : Property<"underlyingType", QualType> {
354     let Read = [{ node->getUnderlyingType() }];
355   }
356
357   def : Creator<[{
358     return ctx.getTypeOfType(underlyingType);
359   }]>;
360 }
361
362 let Class = DecltypeType in {
363   def : Property<"underlyingType", QualType> {
364     let Read = [{ node->getUnderlyingType() }];
365   }
366   def : Property<"expression", ExprRef> {
367     let Read = [{ node->getUnderlyingExpr() }];
368   }
369
370   def : Creator<[{
371     return ctx.getDecltypeType(expression, underlyingType);
372   }]>;
373 }
374
375 let Class = UnaryTransformType in {
376   def : Property<"baseType", QualType> {
377     let Read = [{ node->getBaseType() }];
378   }
379   def : Property<"underlyingType", QualType> {
380     let Read = [{ node->getUnderlyingType() }];
381   }
382   def : Property<"transform", UnaryTypeTransformKind> {
383     let Read = [{ node->getUTTKind() }];
384   }
385
386   def : Creator<[{
387     return ctx.getUnaryTransformType(baseType, underlyingType, transform);
388   }]>;
389 }
390
391 let Class = AutoType in {
392   def : Property<"deducedType", Optional<QualType>> {
393     let Read = [{ makeOptionalFromNullable(node->getDeducedType()) }];
394   }
395   def : Property<"keyword", AutoTypeKeyword> {
396     let Read = [{ node->getKeyword() }];
397   }
398   // FIXME: better enumerated value
399   // Only really required when the deduced type is null
400   def : Property<"dependence", UInt32> {
401     let Read = [{ !node->getDeducedType().isNull() ? 0 :
402                   node->containsUnexpandedParameterPack() ? 2 :
403                   node->isDependentType() ? 1 : 0 }];
404   }
405
406   def : Creator<[{
407     return ctx.getAutoType(makeNullableFromOptional(deducedType), keyword,
408                            /*isDependentWithoutDeducedType*/ dependence > 0,
409                            /*isPackWithoutDeducedType*/ dependence > 1);
410   }]>;
411 }
412
413 let Class = DeducedTemplateSpecializationType in {
414   def : Property<"templateName", Optional<TemplateName>> {
415     let Read = [{ makeOptionalFromNullable(node->getTemplateName()) }];
416   }
417   def : Property<"deducedType", QualType> {
418     let Read = [{ node->getDeducedType() }];
419   }
420   // Only really required when the deduced type is null
421   def : Property<"dependent", Bool> {
422     let Read = [{ !node->getDeducedType().isNull()
423                     ? false : node->isDependentType() }];
424   }
425
426   def : Creator<[{
427     return ctx.getDeducedTemplateSpecializationType(
428                                      makeNullableFromOptional(templateName),
429                                      deducedType, dependent);
430   }]>;
431 }
432
433 let Class = TagType in {
434   def : Property<"dependent", Bool> {
435     let Read = [{ node->isDependentType() }];
436   }
437   def : Property<"declaration", DeclRef> {
438     // Serializing a reference to the canonical declaration is apparently
439     // necessary to make module-merging work.
440     let Read = [{ node->getDecl()->getCanonicalDecl() }];
441   }
442 }
443
444 let Class = EnumType in {
445   def : Creator<[{
446     QualType result = ctx.getEnumType(cast<EnumDecl>(declaration));
447     const_cast<Type*>(result.getTypePtr())->setDependent(dependent);
448     return result;
449   }]>;
450 }
451
452 let Class = RecordType in {
453   def : Creator<[{
454     auto record = cast<RecordDecl>(declaration);
455     QualType result = ctx.getRecordType(record);
456     const_cast<Type*>(result.getTypePtr())->setDependent(dependent);
457     return result;
458   }]>;
459 }
460
461 let Class = ElaboratedType in {
462   def : Property<"keyword", ElaboratedTypeKeyword> {
463     let Read = [{ node->getKeyword() }];
464   }
465   def : Property<"qualifier", NestedNameSpecifier> {
466     let Read = [{ node->getQualifier() }];
467   }
468   def : Property<"namedType", QualType> {
469     let Read = [{ node->getNamedType() }];
470   }
471   def : Property<"ownedTag", Optional<TagDeclRef>> {
472     let Read = [{ makeOptionalFromPointer(
473                     const_cast<const TagDecl *>(node->getOwnedTagDecl())) }];
474   }
475
476   def : Creator<[{
477     return ctx.getElaboratedType(keyword, qualifier, namedType,
478                                  makePointerFromOptional(ownedTag));
479   }]>;
480 }
481
482 let Class = InjectedClassNameType in {
483   def : Property<"declaration", DeclRef> {
484     // FIXME: drilling down to the canonical declaration is what the
485     // existing serialization code was doing, but it's not clear why.
486     let Read = [{ node->getDecl()->getCanonicalDecl() }];
487   }
488   def : Property<"injectedSpecializationType", QualType> {
489     let Read = [{ node->getInjectedSpecializationType() }];
490   }
491
492   def : Creator<[{
493     // FIXME: ASTContext::getInjectedClassNameType is not currently suitable
494     // for AST reading, too much interdependencies.
495     const Type *T = nullptr;
496     auto typeDecl = cast<CXXRecordDecl>(declaration);
497     for (auto *DI = typeDecl; DI; DI = DI->getPreviousDecl()) {
498       if (const Type *existing = DI->getTypeForDecl()) {
499         T = existing;
500         break;
501       }
502     }
503     if (!T) {
504       T = new (ctx, TypeAlignment)
505             InjectedClassNameType(typeDecl, injectedSpecializationType);
506       for (auto *DI = typeDecl; DI; DI = DI->getPreviousDecl())
507         DI->setTypeForDecl(T);
508     }
509     return QualType(T, 0);
510   }]>;
511 }
512
513 let Class = ParenType in {
514   def : Property<"innerType", QualType> {
515     let Read = [{ node->getInnerType() }];
516   }
517
518   def : Creator<[{
519     return ctx.getParenType(innerType);
520   }]>;  
521 }
522
523 let Class = MacroQualifiedType in {
524   def : Property<"underlyingType", QualType> {
525     let Read = [{ node->getUnderlyingType() }];
526   }
527   def : Property<"macroIdentifier", Identifier> {
528     let Read = [{ node->getMacroIdentifier() }];
529   }
530
531   def : Creator<[{
532     return ctx.getMacroQualifiedType(underlyingType, macroIdentifier);
533   }]>;
534 }
535
536 let Class = AttributedType in {
537   def : Property<"modifiedType", QualType> {
538     let Read = [{ node->getModifiedType() }];
539   }
540   def : Property<"equivalentType", QualType> {
541     let Read = [{ node->getEquivalentType() }];
542   }
543   def : Property<"attribute", AttrKind> {
544     let Read = [{ node->getAttrKind() }];
545   }
546
547   def : Creator<[{
548     return ctx.getAttributedType(attribute, modifiedType, equivalentType);
549   }]>;
550 }
551
552 let Class = DependentAddressSpaceType in {
553   def : Property<"pointeeType", QualType> {
554     let Read = [{ node->getPointeeType() }];
555   }
556   def : Property<"addressSpace", ExprRef> {
557     let Read = [{ node->getAddrSpaceExpr() }];
558   }
559   def : Property<"attributeLoc", SourceLocation> {
560     let Read = [{ node->getAttributeLoc() }];
561   }
562
563   def : Creator<[{
564     return ctx.getDependentAddressSpaceType(pointeeType, addressSpace,
565                                             attributeLoc);
566   }]>;
567 }
568
569 let Class = TemplateSpecializationType in {
570   def : Property<"dependent", Bool> {
571     let Read = [{ node->isDependentType() }];
572   }
573   def : Property<"templateName", TemplateName> {
574     let Read = [{ node->getTemplateName() }];
575   }
576   def : Property<"templateArguments", Array<TemplateArgument>> {
577     let Read = [{ node->template_arguments() }];
578   }
579   def : Property<"underlyingType", Optional<QualType>> {
580     let Read = [{
581       node->isTypeAlias()
582         ? llvm::Optional<QualType>(node->getAliasedType())
583         : node->isCanonicalUnqualified()
584             ? llvm::None
585             : llvm::Optional<QualType>(node->getCanonicalTypeInternal())
586     }];
587   }
588
589   def : Creator<[{
590     QualType result;
591     if (!underlyingType.hasValue()) {
592       result = ctx.getCanonicalTemplateSpecializationType(templateName,
593                                                           templateArguments);
594     } else {
595       result = ctx.getTemplateSpecializationType(templateName,
596                                                  templateArguments,
597                                                  *underlyingType);
598     }
599     const_cast<Type*>(result.getTypePtr())->setDependent(dependent);
600     return result;
601   }]>;
602 }
603
604 let Class = DependentTemplateSpecializationType in {
605   def : Property<"keyword", ElaboratedTypeKeyword> {
606     let Read = [{ node->getKeyword() }];
607   }
608   def : Property<"qualifier", NestedNameSpecifier> {
609     let Read = [{ node->getQualifier() }];
610   }
611   def : Property<"name", Identifier> {
612     let Read = [{ node->getIdentifier() }];
613   }
614   def : Property<"templateArguments", Array<TemplateArgument>> {
615     let Read = [{ node->template_arguments() }];
616   }
617
618   def : Creator<[{
619     return ctx.getDependentTemplateSpecializationType(keyword, qualifier,
620                                                       name, templateArguments);
621   }]>;
622 }
623
624 let Class = TemplateTypeParmType in {
625   def : Property<"depth", UInt32> {
626     let Read = [{ node->getDepth() }];
627   }
628   def : Property<"index", UInt32> {
629     let Read = [{ node->getIndex() }];
630   }
631   def : Property<"isParameterPack", Bool> {
632     let Read = [{ node->isParameterPack() }];
633   }
634   def : Property<"declaration", Optional<TemplateTypeParmDeclRef>> {
635     let Read = [{ makeOptionalFromPointer(
636                     const_cast<const TemplateTypeParmDecl*>(node->getDecl())) }];
637   }
638
639   def : Creator<[{
640     return ctx.getTemplateTypeParmType(depth, index, isParameterPack,
641                                        makePointerFromOptional(declaration));
642   }]>;
643 }
644
645 let Class = SubstTemplateTypeParmType in {
646   def : Property<"replacedParameter", QualType> {
647     let Read = [{ QualType(node->getReplacedParameter(), 0) }];
648   }
649   def : Property<"replacementType", QualType> {
650     let Read = [{ node->getReplacementType() }];
651   }
652
653   def : Creator<[{
654     // The call to getCanonicalType here existed in ASTReader.cpp, too.
655     return ctx.getSubstTemplateTypeParmType(
656         cast<TemplateTypeParmType>(replacedParameter),
657         ctx.getCanonicalType(replacementType));
658   }]>;
659 }
660
661 let Class = PackExpansionType in {
662   def : Property<"pattern", QualType> {
663     let Read = [{ node->getPattern() }];
664   }
665   def : Property<"numExpansions", Optional<UInt32>> {
666     let Read = [{ node->getNumExpansions() }];
667   }
668
669   def : Creator<[{
670     return ctx.getPackExpansionType(pattern, numExpansions);
671   }]>;
672 }
673
674 let Class = SubstTemplateTypeParmPackType in {
675   def : Property<"replacedParameter", QualType> {
676     let Read = [{ QualType(node->getReplacedParameter(), 0) }];
677   }
678   def : Property<"replacementPack", TemplateArgument> {
679     let Read = [{ node->getArgumentPack() }];
680   }
681
682   def : Creator<[{
683     return ctx.getSubstTemplateTypeParmPackType(
684                          cast<TemplateTypeParmType>(replacedParameter),
685                         replacementPack);
686   }]>;
687 }
688
689 let Class = BuiltinType in {
690   def : Property<"kind", BuiltinTypeKind> {
691     let Read = [{ node->getKind() }];
692   }
693
694   def : Creator<[{
695       switch (kind) {
696 #define IMAGE_TYPE(IMGTYPE, ID, SINGLETON_ID, ACCESS, SUFFIX) \
697       case BuiltinType::ID: return ctx.SINGLETON_ID;
698 #include "clang/Basic/OpenCLImageTypes.def"
699
700 #define EXT_OPAQUE_TYPE(EXTTYPE, ID, EXT) \
701       case BuiltinType::ID: return ctx.ID##Ty;
702 #include "clang/Basic/OpenCLExtensionTypes.def"
703
704 #define SVE_TYPE(NAME, ID, SINGLETON_ID) \
705       case BuiltinType::ID: return ctx.SINGLETON_ID;
706 #include "clang/Basic/AArch64SVEACLETypes.def"
707
708 #define BUILTIN_TYPE(ID, SINGLETON_ID) \
709       case BuiltinType::ID: return ctx.SINGLETON_ID;
710 #include "clang/AST/BuiltinTypes.def"
711       }
712       llvm_unreachable("unreachable builtin case");
713   }]>;
714 }
715
716 let Class = DependentNameType in {
717   def : Property<"keyword", ElaboratedTypeKeyword> {
718     let Read = [{ node->getKeyword() }];
719   }
720   def : Property<"qualifier", NestedNameSpecifier> {
721     let Read = [{ node->getQualifier() }];
722   }
723   def : Property<"name", Identifier> {
724     let Read = [{ node->getIdentifier() }];
725   }
726   def : Property<"underlyingType", Optional<QualType>> {
727     let Read = [{
728       node->isCanonicalUnqualified()
729         ? llvm::None
730         : llvm::Optional<QualType>(node->getCanonicalTypeInternal())
731     }];
732   }
733
734   def : Creator<[{
735     QualType canon = (underlyingType
736                         ? ctx.getCanonicalType(*underlyingType)
737                         : QualType());
738     return ctx.getDependentNameType(keyword, qualifier, name, canon);
739   }]>;
740 }
741
742 let Class = ObjCObjectType in {
743   def : Property<"baseType", QualType> {
744     let Read = [{ node->getBaseType() }];
745   }
746   def : Property<"typeArgsAsWritten", Array<QualType>> {
747     let Read = [{ node->getTypeArgsAsWritten() }];
748   }
749   def : Property<"qualifiers", Array<ObjCProtocolDeclRef>> {
750     let Read = [{ node->getProtocols() }];
751   }
752   def : Property<"isKindOfTypeAsWritten", Bool> {
753     let Read = [{ node->isKindOfTypeAsWritten() }];
754   }
755
756   def : Creator<[{
757     return ctx.getObjCObjectType(baseType, typeArgsAsWritten, qualifiers,
758                                  isKindOfTypeAsWritten);
759   }]>;
760 }
761
762 let Class = ObjCInterfaceType in {
763   // We don't actually want any of the properties of the superclass.
764   def : Override {
765     let IgnoredProperties = [ "baseType", "typeArgsAsWritten",
766                               "qualifiers", "isKindOfTypeAsWritten" ];
767   }
768
769   def : Property<"declaration", DeclRef> {
770     // FIXME: drilling down to the canonical declaration is what the
771     // existing serialization code was doing, but it's not clear why.
772     let Read = [{ node->getDecl()->getCanonicalDecl() }];
773   }
774
775   def : Creator<[{
776     return ctx.getObjCInterfaceType(
777              cast<ObjCInterfaceDecl>(declaration->getCanonicalDecl()));
778   }]>;
779 }
780
781 let Class = ObjCTypeParamType in {
782   def : Property<"declaration", ObjCTypeParamDeclRef> {
783     let Read = [{ node->getDecl() }];
784   }  
785   def : Property<"qualifiers", Array<ObjCProtocolDeclRef>> {
786     let Read = [{ node->getProtocols() }];
787   }
788
789   def : Creator<[{
790     return ctx.getObjCTypeParamType(declaration, qualifiers);
791   }]>;
792 }
793
794 let Class = ObjCObjectPointerType in {
795   def : Property<"pointeeType", QualType> {
796     let Read = [{ node->getPointeeType() }];
797   }
798
799   def : Creator<[{
800     return ctx.getObjCObjectPointerType(pointeeType);
801   }]>;
802 }
803
804 let Class = PipeType in {
805   def : Property<"elementType", QualType> {
806     let Read = [{ node->getElementType() }];
807   }
808   def : Property<"isReadOnly", Bool> {
809     let Read = [{ node->isReadOnly() }];
810   }
811
812   def : Creator<[{
813     return ctx.getPipeType(elementType, isReadOnly);
814   }]>;
815 }