clang  8.0.0svn
Type.cpp
Go to the documentation of this file.
1 //===- Type.cpp - Type representation and manipulation --------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements type-related functionality.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "clang/AST/Type.h"
15 #include "Linkage.h"
16 #include "clang/AST/ASTContext.h"
17 #include "clang/AST/Attr.h"
18 #include "clang/AST/CharUnits.h"
19 #include "clang/AST/Decl.h"
20 #include "clang/AST/DeclBase.h"
21 #include "clang/AST/DeclCXX.h"
22 #include "clang/AST/DeclObjC.h"
23 #include "clang/AST/DeclTemplate.h"
24 #include "clang/AST/Expr.h"
27 #include "clang/AST/TemplateBase.h"
28 #include "clang/AST/TemplateName.h"
29 #include "clang/AST/TypeVisitor.h"
33 #include "clang/Basic/LLVM.h"
35 #include "clang/Basic/Linkage.h"
36 #include "clang/Basic/Specifiers.h"
38 #include "clang/Basic/TargetInfo.h"
39 #include "clang/Basic/Visibility.h"
40 #include "llvm/ADT/APInt.h"
41 #include "llvm/ADT/APSInt.h"
42 #include "llvm/ADT/ArrayRef.h"
43 #include "llvm/ADT/FoldingSet.h"
44 #include "llvm/ADT/None.h"
45 #include "llvm/ADT/SmallVector.h"
46 #include "llvm/Support/Casting.h"
47 #include "llvm/Support/ErrorHandling.h"
48 #include "llvm/Support/MathExtras.h"
49 #include <algorithm>
50 #include <cassert>
51 #include <cstdint>
52 #include <cstring>
53 
54 using namespace clang;
55 
57  return (*this != Other) &&
58  // CVR qualifiers superset
59  (((Mask & CVRMask) | (Other.Mask & CVRMask)) == (Mask & CVRMask)) &&
60  // ObjC GC qualifiers superset
61  ((getObjCGCAttr() == Other.getObjCGCAttr()) ||
62  (hasObjCGCAttr() && !Other.hasObjCGCAttr())) &&
63  // Address space superset.
64  ((getAddressSpace() == Other.getAddressSpace()) ||
65  (hasAddressSpace()&& !Other.hasAddressSpace())) &&
66  // Lifetime qualifier superset.
67  ((getObjCLifetime() == Other.getObjCLifetime()) ||
68  (hasObjCLifetime() && !Other.hasObjCLifetime()));
69 }
70 
72  const Type* ty = getTypePtr();
73  NamedDecl *ND = nullptr;
74  if (ty->isPointerType() || ty->isReferenceType())
76  else if (ty->isRecordType())
77  ND = ty->getAs<RecordType>()->getDecl();
78  else if (ty->isEnumeralType())
79  ND = ty->getAs<EnumType>()->getDecl();
80  else if (ty->getTypeClass() == Type::Typedef)
81  ND = ty->getAs<TypedefType>()->getDecl();
82  else if (ty->isArrayType())
83  return ty->castAsArrayTypeUnsafe()->
84  getElementType().getBaseTypeIdentifier();
85 
86  if (ND)
87  return ND->getIdentifier();
88  return nullptr;
89 }
90 
92  const auto *ClassDecl = getTypePtr()->getPointeeCXXRecordDecl();
93  return ClassDecl && ClassDecl->mayBeDynamicClass();
94 }
95 
97  const auto *ClassDecl = getTypePtr()->getPointeeCXXRecordDecl();
98  return !ClassDecl || ClassDecl->mayBeNonDynamicClass();
99 }
100 
101 bool QualType::isConstant(QualType T, const ASTContext &Ctx) {
102  if (T.isConstQualified())
103  return true;
104 
105  if (const ArrayType *AT = Ctx.getAsArrayType(T))
106  return AT->getElementType().isConstant(Ctx);
107 
109 }
110 
112  QualType ElementType,
113  const llvm::APInt &NumElements) {
114  uint64_t ElementSize = Context.getTypeSizeInChars(ElementType).getQuantity();
115 
116  // Fast path the common cases so we can avoid the conservative computation
117  // below, which in common cases allocates "large" APSInt values, which are
118  // slow.
119 
120  // If the element size is a power of 2, we can directly compute the additional
121  // number of addressing bits beyond those required for the element count.
122  if (llvm::isPowerOf2_64(ElementSize)) {
123  return NumElements.getActiveBits() + llvm::Log2_64(ElementSize);
124  }
125 
126  // If both the element count and element size fit in 32-bits, we can do the
127  // computation directly in 64-bits.
128  if ((ElementSize >> 32) == 0 && NumElements.getBitWidth() <= 64 &&
129  (NumElements.getZExtValue() >> 32) == 0) {
130  uint64_t TotalSize = NumElements.getZExtValue() * ElementSize;
131  return 64 - llvm::countLeadingZeros(TotalSize);
132  }
133 
134  // Otherwise, use APSInt to handle arbitrary sized values.
135  llvm::APSInt SizeExtended(NumElements, true);
136  unsigned SizeTypeBits = Context.getTypeSize(Context.getSizeType());
137  SizeExtended = SizeExtended.extend(std::max(SizeTypeBits,
138  SizeExtended.getBitWidth()) * 2);
139 
140  llvm::APSInt TotalSize(llvm::APInt(SizeExtended.getBitWidth(), ElementSize));
141  TotalSize *= SizeExtended;
142 
143  return TotalSize.getActiveBits();
144 }
145 
147  unsigned Bits = Context.getTypeSize(Context.getSizeType());
148 
149  // Limit the number of bits in size_t so that maximal bit size fits 64 bit
150  // integer (see PR8256). We can do this as currently there is no hardware
151  // that supports full 64-bit virtual space.
152  if (Bits > 61)
153  Bits = 61;
154 
155  return Bits;
156 }
157 
158 DependentSizedArrayType::DependentSizedArrayType(const ASTContext &Context,
159  QualType et, QualType can,
160  Expr *e, ArraySizeModifier sm,
161  unsigned tq,
162  SourceRange brackets)
163  : ArrayType(DependentSizedArray, et, can, sm, tq,
165  (e && e->containsUnexpandedParameterPack()))),
166  Context(Context), SizeExpr((Stmt*) e), Brackets(brackets) {}
167 
168 void DependentSizedArrayType::Profile(llvm::FoldingSetNodeID &ID,
169  const ASTContext &Context,
170  QualType ET,
171  ArraySizeModifier SizeMod,
172  unsigned TypeQuals,
173  Expr *E) {
174  ID.AddPointer(ET.getAsOpaquePtr());
175  ID.AddInteger(SizeMod);
176  ID.AddInteger(TypeQuals);
177  E->Profile(ID, Context, true);
178 }
179 
180 DependentVectorType::DependentVectorType(
181  const ASTContext &Context, QualType ElementType, QualType CanonType,
182  Expr *SizeExpr, SourceLocation Loc, VectorType::VectorKind VecKind)
183  : Type(DependentVector, CanonType, /*Dependent=*/true,
184  /*InstantiationDependent=*/true,
185  ElementType->isVariablyModifiedType(),
186  ElementType->containsUnexpandedParameterPack() ||
187  (SizeExpr && SizeExpr->containsUnexpandedParameterPack())),
188  Context(Context), ElementType(ElementType), SizeExpr(SizeExpr), Loc(Loc) {
189  VectorTypeBits.VecKind = VecKind;
190 }
191 
192 void DependentVectorType::Profile(llvm::FoldingSetNodeID &ID,
193  const ASTContext &Context,
194  QualType ElementType, const Expr *SizeExpr,
195  VectorType::VectorKind VecKind) {
196  ID.AddPointer(ElementType.getAsOpaquePtr());
197  ID.AddInteger(VecKind);
198  SizeExpr->Profile(ID, Context, true);
199 }
200 
201 DependentSizedExtVectorType::DependentSizedExtVectorType(const
202  ASTContext &Context,
203  QualType ElementType,
204  QualType can,
205  Expr *SizeExpr,
206  SourceLocation loc)
207  : Type(DependentSizedExtVector, can, /*Dependent=*/true,
208  /*InstantiationDependent=*/true,
209  ElementType->isVariablyModifiedType(),
210  (ElementType->containsUnexpandedParameterPack() ||
211  (SizeExpr && SizeExpr->containsUnexpandedParameterPack()))),
212  Context(Context), SizeExpr(SizeExpr), ElementType(ElementType),
213  loc(loc) {}
214 
215 void
216 DependentSizedExtVectorType::Profile(llvm::FoldingSetNodeID &ID,
217  const ASTContext &Context,
218  QualType ElementType, Expr *SizeExpr) {
219  ID.AddPointer(ElementType.getAsOpaquePtr());
220  SizeExpr->Profile(ID, Context, true);
221 }
222 
223 DependentAddressSpaceType::DependentAddressSpaceType(
224  const ASTContext &Context, QualType PointeeType, QualType can,
225  Expr *AddrSpaceExpr, SourceLocation loc)
226  : Type(DependentAddressSpace, can, /*Dependent=*/true,
227  /*InstantiationDependent=*/true,
228  PointeeType->isVariablyModifiedType(),
229  (PointeeType->containsUnexpandedParameterPack() ||
230  (AddrSpaceExpr &&
231  AddrSpaceExpr->containsUnexpandedParameterPack()))),
232  Context(Context), AddrSpaceExpr(AddrSpaceExpr), PointeeType(PointeeType),
233  loc(loc) {}
234 
235 void DependentAddressSpaceType::Profile(llvm::FoldingSetNodeID &ID,
236  const ASTContext &Context,
237  QualType PointeeType,
238  Expr *AddrSpaceExpr) {
239  ID.AddPointer(PointeeType.getAsOpaquePtr());
240  AddrSpaceExpr->Profile(ID, Context, true);
241 }
242 
243 VectorType::VectorType(QualType vecType, unsigned nElements, QualType canonType,
244  VectorKind vecKind)
245  : VectorType(Vector, vecType, nElements, canonType, vecKind) {}
246 
247 VectorType::VectorType(TypeClass tc, QualType vecType, unsigned nElements,
248  QualType canonType, VectorKind vecKind)
249  : Type(tc, canonType, vecType->isDependentType(),
250  vecType->isInstantiationDependentType(),
251  vecType->isVariablyModifiedType(),
253  ElementType(vecType) {
254  VectorTypeBits.VecKind = vecKind;
255  VectorTypeBits.NumElements = nElements;
256 }
257 
258 /// getArrayElementTypeNoTypeQual - If this is an array type, return the
259 /// element type of the array, potentially with type qualifiers missing.
260 /// This method should never be used when type qualifiers are meaningful.
262  // If this is directly an array type, return it.
263  if (const auto *ATy = dyn_cast<ArrayType>(this))
264  return ATy->getElementType().getTypePtr();
265 
266  // If the canonical form of this type isn't the right kind, reject it.
267  if (!isa<ArrayType>(CanonicalType))
268  return nullptr;
269 
270  // If this is a typedef for an array type, strip the typedef off without
271  // losing all typedef information.
272  return cast<ArrayType>(getUnqualifiedDesugaredType())
274 }
275 
276 /// getDesugaredType - Return the specified type with any "sugar" removed from
277 /// the type. This takes off typedefs, typeof's etc. If the outer level of
278 /// the type is already concrete, it returns it unmodified. This is similar
279 /// to getting the canonical type, but it doesn't remove *all* typedefs. For
280 /// example, it returns "T*" as "T*", (not as "int*"), because the pointer is
281 /// concrete.
283  SplitQualType split = getSplitDesugaredType(T);
284  return Context.getQualifiedType(split.Ty, split.Quals);
285 }
286 
287 QualType QualType::getSingleStepDesugaredTypeImpl(QualType type,
288  const ASTContext &Context) {
289  SplitQualType split = type.split();
291  return Context.getQualifiedType(desugar, split.Quals);
292 }
293 
295  switch (getTypeClass()) {
296 #define ABSTRACT_TYPE(Class, Parent)
297 #define TYPE(Class, Parent) \
298  case Type::Class: { \
299  const auto *ty = cast<Class##Type>(this); \
300  if (!ty->isSugared()) return QualType(ty, 0); \
301  return ty->desugar(); \
302  }
303 #include "clang/AST/TypeNodes.def"
304  }
305  llvm_unreachable("bad type kind!");
306 }
307 
310 
311  QualType Cur = T;
312  while (true) {
313  const Type *CurTy = Qs.strip(Cur);
314  switch (CurTy->getTypeClass()) {
315 #define ABSTRACT_TYPE(Class, Parent)
316 #define TYPE(Class, Parent) \
317  case Type::Class: { \
318  const auto *Ty = cast<Class##Type>(CurTy); \
319  if (!Ty->isSugared()) \
320  return SplitQualType(Ty, Qs); \
321  Cur = Ty->desugar(); \
322  break; \
323  }
324 #include "clang/AST/TypeNodes.def"
325  }
326  }
327 }
328 
329 SplitQualType QualType::getSplitUnqualifiedTypeImpl(QualType type) {
330  SplitQualType split = type.split();
331 
332  // All the qualifiers we've seen so far.
333  Qualifiers quals = split.Quals;
334 
335  // The last type node we saw with any nodes inside it.
336  const Type *lastTypeWithQuals = split.Ty;
337 
338  while (true) {
339  QualType next;
340 
341  // Do a single-step desugar, aborting the loop if the type isn't
342  // sugared.
343  switch (split.Ty->getTypeClass()) {
344 #define ABSTRACT_TYPE(Class, Parent)
345 #define TYPE(Class, Parent) \
346  case Type::Class: { \
347  const auto *ty = cast<Class##Type>(split.Ty); \
348  if (!ty->isSugared()) goto done; \
349  next = ty->desugar(); \
350  break; \
351  }
352 #include "clang/AST/TypeNodes.def"
353  }
354 
355  // Otherwise, split the underlying type. If that yields qualifiers,
356  // update the information.
357  split = next.split();
358  if (!split.Quals.empty()) {
359  lastTypeWithQuals = split.Ty;
360  quals.addConsistentQualifiers(split.Quals);
361  }
362  }
363 
364  done:
365  return SplitQualType(lastTypeWithQuals, quals);
366 }
367 
369  // FIXME: this seems inherently un-qualifiers-safe.
370  while (const auto *PT = T->getAs<ParenType>())
371  T = PT->getInnerType();
372  return T;
373 }
374 
375 /// This will check for a T (which should be a Type which can act as
376 /// sugar, such as a TypedefType) by removing any existing sugar until it
377 /// reaches a T or a non-sugared type.
378 template<typename T> static const T *getAsSugar(const Type *Cur) {
379  while (true) {
380  if (const auto *Sugar = dyn_cast<T>(Cur))
381  return Sugar;
382  switch (Cur->getTypeClass()) {
383 #define ABSTRACT_TYPE(Class, Parent)
384 #define TYPE(Class, Parent) \
385  case Type::Class: { \
386  const auto *Ty = cast<Class##Type>(Cur); \
387  if (!Ty->isSugared()) return 0; \
388  Cur = Ty->desugar().getTypePtr(); \
389  break; \
390  }
391 #include "clang/AST/TypeNodes.def"
392  }
393  }
394 }
395 
396 template <> const TypedefType *Type::getAs() const {
397  return getAsSugar<TypedefType>(this);
398 }
399 
400 template <> const TemplateSpecializationType *Type::getAs() const {
401  return getAsSugar<TemplateSpecializationType>(this);
402 }
403 
404 template <> const AttributedType *Type::getAs() const {
405  return getAsSugar<AttributedType>(this);
406 }
407 
408 /// getUnqualifiedDesugaredType - Pull any qualifiers and syntactic
409 /// sugar off the given type. This should produce an object of the
410 /// same dynamic type as the canonical type.
412  const Type *Cur = this;
413 
414  while (true) {
415  switch (Cur->getTypeClass()) {
416 #define ABSTRACT_TYPE(Class, Parent)
417 #define TYPE(Class, Parent) \
418  case Class: { \
419  const auto *Ty = cast<Class##Type>(Cur); \
420  if (!Ty->isSugared()) return Cur; \
421  Cur = Ty->desugar().getTypePtr(); \
422  break; \
423  }
424 #include "clang/AST/TypeNodes.def"
425  }
426  }
427 }
428 
429 bool Type::isClassType() const {
430  if (const auto *RT = getAs<RecordType>())
431  return RT->getDecl()->isClass();
432  return false;
433 }
434 
435 bool Type::isStructureType() const {
436  if (const auto *RT = getAs<RecordType>())
437  return RT->getDecl()->isStruct();
438  return false;
439 }
440 
442  if (const auto *RT = getAs<RecordType>())
443  return RT->getDecl()->hasAttr<ObjCBoxableAttr>();
444  return false;
445 }
446 
447 bool Type::isInterfaceType() const {
448  if (const auto *RT = getAs<RecordType>())
449  return RT->getDecl()->isInterface();
450  return false;
451 }
452 
454  if (const auto *RT = getAs<RecordType>()) {
455  RecordDecl *RD = RT->getDecl();
456  return RD->isStruct() || RD->isClass() || RD->isInterface();
457  }
458  return false;
459 }
460 
462  if (const auto *PT = getAs<PointerType>())
463  return PT->getPointeeType()->isVoidType();
464  return false;
465 }
466 
467 bool Type::isUnionType() const {
468  if (const auto *RT = getAs<RecordType>())
469  return RT->getDecl()->isUnion();
470  return false;
471 }
472 
473 bool Type::isComplexType() const {
474  if (const auto *CT = dyn_cast<ComplexType>(CanonicalType))
475  return CT->getElementType()->isFloatingType();
476  return false;
477 }
478 
480  // Check for GCC complex integer extension.
481  return getAsComplexIntegerType();
482 }
483 
485  if (const auto *ET = getAs<EnumType>())
486  return ET->getDecl()->isScoped();
487  return false;
488 }
489 
491  if (const auto *Complex = getAs<ComplexType>())
492  if (Complex->getElementType()->isIntegerType())
493  return Complex;
494  return nullptr;
495 }
496 
498  if (const auto *PT = getAs<PointerType>())
499  return PT->getPointeeType();
500  if (const auto *OPT = getAs<ObjCObjectPointerType>())
501  return OPT->getPointeeType();
502  if (const auto *BPT = getAs<BlockPointerType>())
503  return BPT->getPointeeType();
504  if (const auto *RT = getAs<ReferenceType>())
505  return RT->getPointeeType();
506  if (const auto *MPT = getAs<MemberPointerType>())
507  return MPT->getPointeeType();
508  if (const auto *DT = getAs<DecayedType>())
509  return DT->getPointeeType();
510  return {};
511 }
512 
514  // If this is directly a structure type, return it.
515  if (const auto *RT = dyn_cast<RecordType>(this)) {
516  if (RT->getDecl()->isStruct())
517  return RT;
518  }
519 
520  // If the canonical form of this type isn't the right kind, reject it.
521  if (const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
522  if (!RT->getDecl()->isStruct())
523  return nullptr;
524 
525  // If this is a typedef for a structure type, strip the typedef off without
526  // losing all typedef information.
527  return cast<RecordType>(getUnqualifiedDesugaredType());
528  }
529  return nullptr;
530 }
531 
533  // If this is directly a union type, return it.
534  if (const auto *RT = dyn_cast<RecordType>(this)) {
535  if (RT->getDecl()->isUnion())
536  return RT;
537  }
538 
539  // If the canonical form of this type isn't the right kind, reject it.
540  if (const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
541  if (!RT->getDecl()->isUnion())
542  return nullptr;
543 
544  // If this is a typedef for a union type, strip the typedef off without
545  // losing all typedef information.
546  return cast<RecordType>(getUnqualifiedDesugaredType());
547  }
548 
549  return nullptr;
550 }
551 
553  const ObjCObjectType *&bound) const {
554  bound = nullptr;
555 
556  const auto *OPT = getAs<ObjCObjectPointerType>();
557  if (!OPT)
558  return false;
559 
560  // Easy case: id.
561  if (OPT->isObjCIdType())
562  return true;
563 
564  // If it's not a __kindof type, reject it now.
565  if (!OPT->isKindOfType())
566  return false;
567 
568  // If it's Class or qualified Class, it's not an object type.
569  if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType())
570  return false;
571 
572  // Figure out the type bound for the __kindof type.
573  bound = OPT->getObjectType()->stripObjCKindOfTypeAndQuals(ctx)
574  ->getAs<ObjCObjectType>();
575  return true;
576 }
577 
579  const auto *OPT = getAs<ObjCObjectPointerType>();
580  if (!OPT)
581  return false;
582 
583  // Easy case: Class.
584  if (OPT->isObjCClassType())
585  return true;
586 
587  // If it's not a __kindof type, reject it now.
588  if (!OPT->isKindOfType())
589  return false;
590 
591  // If it's Class or qualified Class, it's a class __kindof type.
592  return OPT->isObjCClassType() || OPT->isObjCQualifiedClassType();
593 }
594 
595 ObjCTypeParamType::ObjCTypeParamType(const ObjCTypeParamDecl *D,
596  QualType can,
598  : Type(ObjCTypeParam, can, can->isDependentType(),
600  can->isVariablyModifiedType(),
601  /*ContainsUnexpandedParameterPack=*/false),
602  OTPDecl(const_cast<ObjCTypeParamDecl*>(D)) {
603  initialize(protocols);
604 }
605 
607  ArrayRef<QualType> typeArgs,
609  bool isKindOf)
610  : Type(ObjCObject, Canonical, Base->isDependentType(),
612  Base->isVariablyModifiedType(),
614  BaseType(Base) {
615  ObjCObjectTypeBits.IsKindOf = isKindOf;
616 
617  ObjCObjectTypeBits.NumTypeArgs = typeArgs.size();
618  assert(getTypeArgsAsWritten().size() == typeArgs.size() &&
619  "bitfield overflow in type argument count");
620  if (!typeArgs.empty())
621  memcpy(getTypeArgStorage(), typeArgs.data(),
622  typeArgs.size() * sizeof(QualType));
623 
624  for (auto typeArg : typeArgs) {
625  if (typeArg->isDependentType())
626  setDependent();
627  else if (typeArg->isInstantiationDependentType())
629 
630  if (typeArg->containsUnexpandedParameterPack())
632  }
633  // Initialize the protocol qualifiers. The protocol storage is known
634  // after we set number of type arguments.
635  initialize(protocols);
636 }
637 
639  // If we have type arguments written here, the type is specialized.
640  if (ObjCObjectTypeBits.NumTypeArgs > 0)
641  return true;
642 
643  // Otherwise, check whether the base type is specialized.
644  if (const auto objcObject = getBaseType()->getAs<ObjCObjectType>()) {
645  // Terminate when we reach an interface type.
646  if (isa<ObjCInterfaceType>(objcObject))
647  return false;
648 
649  return objcObject->isSpecialized();
650  }
651 
652  // Not specialized.
653  return false;
654 }
655 
657  // We have type arguments written on this type.
659  return getTypeArgsAsWritten();
660 
661  // Look at the base type, which might have type arguments.
662  if (const auto objcObject = getBaseType()->getAs<ObjCObjectType>()) {
663  // Terminate when we reach an interface type.
664  if (isa<ObjCInterfaceType>(objcObject))
665  return {};
666 
667  return objcObject->getTypeArgs();
668  }
669 
670  // No type arguments.
671  return {};
672 }
673 
675  if (isKindOfTypeAsWritten())
676  return true;
677 
678  // Look at the base type, which might have type arguments.
679  if (const auto objcObject = getBaseType()->getAs<ObjCObjectType>()) {
680  // Terminate when we reach an interface type.
681  if (isa<ObjCInterfaceType>(objcObject))
682  return false;
683 
684  return objcObject->isKindOfType();
685  }
686 
687  // Not a "__kindof" type.
688  return false;
689 }
690 
692  const ASTContext &ctx) const {
693  if (!isKindOfType() && qual_empty())
694  return QualType(this, 0);
695 
696  // Recursively strip __kindof.
697  SplitQualType splitBaseType = getBaseType().split();
698  QualType baseType(splitBaseType.Ty, 0);
699  if (const auto *baseObj = splitBaseType.Ty->getAs<ObjCObjectType>())
700  baseType = baseObj->stripObjCKindOfTypeAndQuals(ctx);
701 
702  return ctx.getObjCObjectType(ctx.getQualifiedType(baseType,
703  splitBaseType.Quals),
705  /*protocols=*/{},
706  /*isKindOf=*/false);
707 }
708 
710  const ASTContext &ctx) const {
711  if (!isKindOfType() && qual_empty())
712  return this;
713 
714  QualType obj = getObjectType()->stripObjCKindOfTypeAndQuals(ctx);
716 }
717 
718 template<typename F>
719 static QualType simpleTransform(ASTContext &ctx, QualType type, F &&f);
720 
721 namespace {
722 
723 /// Visitor used by simpleTransform() to perform the transformation.
724 template<typename F>
725 struct SimpleTransformVisitor
726  : public TypeVisitor<SimpleTransformVisitor<F>, QualType> {
727  ASTContext &Ctx;
728  F &&TheFunc;
729 
730  QualType recurse(QualType type) {
731  return simpleTransform(Ctx, type, std::move(TheFunc));
732  }
733 
734 public:
735  SimpleTransformVisitor(ASTContext &ctx, F &&f)
736  : Ctx(ctx), TheFunc(std::move(f)) {}
737 
738  // None of the clients of this transformation can occur where
739  // there are dependent types, so skip dependent types.
740 #define TYPE(Class, Base)
741 #define DEPENDENT_TYPE(Class, Base) \
742  QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
743 #include "clang/AST/TypeNodes.def"
744 
745 #define TRIVIAL_TYPE_CLASS(Class) \
746  QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
747 
748  TRIVIAL_TYPE_CLASS(Builtin)
749 
750  QualType VisitComplexType(const ComplexType *T) {
751  QualType elementType = recurse(T->getElementType());
752  if (elementType.isNull())
753  return {};
754 
755  if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
756  return QualType(T, 0);
757 
758  return Ctx.getComplexType(elementType);
759  }
760 
761  QualType VisitPointerType(const PointerType *T) {
762  QualType pointeeType = recurse(T->getPointeeType());
763  if (pointeeType.isNull())
764  return {};
765 
766  if (pointeeType.getAsOpaquePtr() == T->getPointeeType().getAsOpaquePtr())
767  return QualType(T, 0);
768 
769  return Ctx.getPointerType(pointeeType);
770  }
771 
772  QualType VisitBlockPointerType(const BlockPointerType *T) {
773  QualType pointeeType = recurse(T->getPointeeType());
774  if (pointeeType.isNull())
775  return {};
776 
777  if (pointeeType.getAsOpaquePtr() == T->getPointeeType().getAsOpaquePtr())
778  return QualType(T, 0);
779 
780  return Ctx.getBlockPointerType(pointeeType);
781  }
782 
783  QualType VisitLValueReferenceType(const LValueReferenceType *T) {
784  QualType pointeeType = recurse(T->getPointeeTypeAsWritten());
785  if (pointeeType.isNull())
786  return {};
787 
788  if (pointeeType.getAsOpaquePtr()
790  return QualType(T, 0);
791 
792  return Ctx.getLValueReferenceType(pointeeType, T->isSpelledAsLValue());
793  }
794 
795  QualType VisitRValueReferenceType(const RValueReferenceType *T) {
796  QualType pointeeType = recurse(T->getPointeeTypeAsWritten());
797  if (pointeeType.isNull())
798  return {};
799 
800  if (pointeeType.getAsOpaquePtr()
802  return QualType(T, 0);
803 
804  return Ctx.getRValueReferenceType(pointeeType);
805  }
806 
807  QualType VisitMemberPointerType(const MemberPointerType *T) {
808  QualType pointeeType = recurse(T->getPointeeType());
809  if (pointeeType.isNull())
810  return {};
811 
812  if (pointeeType.getAsOpaquePtr() == T->getPointeeType().getAsOpaquePtr())
813  return QualType(T, 0);
814 
815  return Ctx.getMemberPointerType(pointeeType, T->getClass());
816  }
817 
818  QualType VisitConstantArrayType(const ConstantArrayType *T) {
819  QualType elementType = recurse(T->getElementType());
820  if (elementType.isNull())
821  return {};
822 
823  if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
824  return QualType(T, 0);
825 
826  return Ctx.getConstantArrayType(elementType, T->getSize(),
827  T->getSizeModifier(),
829  }
830 
831  QualType VisitVariableArrayType(const VariableArrayType *T) {
832  QualType elementType = recurse(T->getElementType());
833  if (elementType.isNull())
834  return {};
835 
836  if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
837  return QualType(T, 0);
838 
839  return Ctx.getVariableArrayType(elementType, T->getSizeExpr(),
840  T->getSizeModifier(),
842  T->getBracketsRange());
843  }
844 
845  QualType VisitIncompleteArrayType(const IncompleteArrayType *T) {
846  QualType elementType = recurse(T->getElementType());
847  if (elementType.isNull())
848  return {};
849 
850  if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
851  return QualType(T, 0);
852 
853  return Ctx.getIncompleteArrayType(elementType, T->getSizeModifier(),
855  }
856 
857  QualType VisitVectorType(const VectorType *T) {
858  QualType elementType = recurse(T->getElementType());
859  if (elementType.isNull())
860  return {};
861 
862  if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
863  return QualType(T, 0);
864 
865  return Ctx.getVectorType(elementType, T->getNumElements(),
866  T->getVectorKind());
867  }
868 
869  QualType VisitExtVectorType(const ExtVectorType *T) {
870  QualType elementType = recurse(T->getElementType());
871  if (elementType.isNull())
872  return {};
873 
874  if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
875  return QualType(T, 0);
876 
877  return Ctx.getExtVectorType(elementType, T->getNumElements());
878  }
879 
880  QualType VisitFunctionNoProtoType(const FunctionNoProtoType *T) {
881  QualType returnType = recurse(T->getReturnType());
882  if (returnType.isNull())
883  return {};
884 
885  if (returnType.getAsOpaquePtr() == T->getReturnType().getAsOpaquePtr())
886  return QualType(T, 0);
887 
888  return Ctx.getFunctionNoProtoType(returnType, T->getExtInfo());
889  }
890 
891  QualType VisitFunctionProtoType(const FunctionProtoType *T) {
892  QualType returnType = recurse(T->getReturnType());
893  if (returnType.isNull())
894  return {};
895 
896  // Transform parameter types.
897  SmallVector<QualType, 4> paramTypes;
898  bool paramChanged = false;
899  for (auto paramType : T->getParamTypes()) {
900  QualType newParamType = recurse(paramType);
901  if (newParamType.isNull())
902  return {};
903 
904  if (newParamType.getAsOpaquePtr() != paramType.getAsOpaquePtr())
905  paramChanged = true;
906 
907  paramTypes.push_back(newParamType);
908  }
909 
910  // Transform extended info.
912  bool exceptionChanged = false;
913  if (info.ExceptionSpec.Type == EST_Dynamic) {
914  SmallVector<QualType, 4> exceptionTypes;
915  for (auto exceptionType : info.ExceptionSpec.Exceptions) {
916  QualType newExceptionType = recurse(exceptionType);
917  if (newExceptionType.isNull())
918  return {};
919 
920  if (newExceptionType.getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
921  exceptionChanged = true;
922 
923  exceptionTypes.push_back(newExceptionType);
924  }
925 
926  if (exceptionChanged) {
928  llvm::makeArrayRef(exceptionTypes).copy(Ctx);
929  }
930  }
931 
932  if (returnType.getAsOpaquePtr() == T->getReturnType().getAsOpaquePtr() &&
933  !paramChanged && !exceptionChanged)
934  return QualType(T, 0);
935 
936  return Ctx.getFunctionType(returnType, paramTypes, info);
937  }
938 
939  QualType VisitParenType(const ParenType *T) {
940  QualType innerType = recurse(T->getInnerType());
941  if (innerType.isNull())
942  return {};
943 
944  if (innerType.getAsOpaquePtr() == T->getInnerType().getAsOpaquePtr())
945  return QualType(T, 0);
946 
947  return Ctx.getParenType(innerType);
948  }
949 
950  TRIVIAL_TYPE_CLASS(Typedef)
951  TRIVIAL_TYPE_CLASS(ObjCTypeParam)
952 
953  QualType VisitAdjustedType(const AdjustedType *T) {
954  QualType originalType = recurse(T->getOriginalType());
955  if (originalType.isNull())
956  return {};
957 
958  QualType adjustedType = recurse(T->getAdjustedType());
959  if (adjustedType.isNull())
960  return {};
961 
962  if (originalType.getAsOpaquePtr()
963  == T->getOriginalType().getAsOpaquePtr() &&
964  adjustedType.getAsOpaquePtr() == T->getAdjustedType().getAsOpaquePtr())
965  return QualType(T, 0);
966 
967  return Ctx.getAdjustedType(originalType, adjustedType);
968  }
969 
970  QualType VisitDecayedType(const DecayedType *T) {
971  QualType originalType = recurse(T->getOriginalType());
972  if (originalType.isNull())
973  return {};
974 
975  if (originalType.getAsOpaquePtr()
977  return QualType(T, 0);
978 
979  return Ctx.getDecayedType(originalType);
980  }
981 
982  TRIVIAL_TYPE_CLASS(TypeOfExpr)
983  TRIVIAL_TYPE_CLASS(TypeOf)
984  TRIVIAL_TYPE_CLASS(Decltype)
985  TRIVIAL_TYPE_CLASS(UnaryTransform)
986  TRIVIAL_TYPE_CLASS(Record)
987  TRIVIAL_TYPE_CLASS(Enum)
988 
989  // FIXME: Non-trivial to implement, but important for C++
990  TRIVIAL_TYPE_CLASS(Elaborated)
991 
992  QualType VisitAttributedType(const AttributedType *T) {
993  QualType modifiedType = recurse(T->getModifiedType());
994  if (modifiedType.isNull())
995  return {};
996 
997  QualType equivalentType = recurse(T->getEquivalentType());
998  if (equivalentType.isNull())
999  return {};
1000 
1001  if (modifiedType.getAsOpaquePtr()
1002  == T->getModifiedType().getAsOpaquePtr() &&
1003  equivalentType.getAsOpaquePtr()
1005  return QualType(T, 0);
1006 
1007  return Ctx.getAttributedType(T->getAttrKind(), modifiedType,
1008  equivalentType);
1009  }
1010 
1011  QualType VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T) {
1012  QualType replacementType = recurse(T->getReplacementType());
1013  if (replacementType.isNull())
1014  return {};
1015 
1016  if (replacementType.getAsOpaquePtr()
1018  return QualType(T, 0);
1019 
1021  replacementType);
1022  }
1023 
1024  // FIXME: Non-trivial to implement, but important for C++
1025  TRIVIAL_TYPE_CLASS(TemplateSpecialization)
1026 
1027  QualType VisitAutoType(const AutoType *T) {
1028  if (!T->isDeduced())
1029  return QualType(T, 0);
1030 
1031  QualType deducedType = recurse(T->getDeducedType());
1032  if (deducedType.isNull())
1033  return {};
1034 
1035  if (deducedType.getAsOpaquePtr()
1036  == T->getDeducedType().getAsOpaquePtr())
1037  return QualType(T, 0);
1038 
1039  return Ctx.getAutoType(deducedType, T->getKeyword(),
1040  T->isDependentType());
1041  }
1042 
1043  // FIXME: Non-trivial to implement, but important for C++
1044  TRIVIAL_TYPE_CLASS(PackExpansion)
1045 
1046  QualType VisitObjCObjectType(const ObjCObjectType *T) {
1047  QualType baseType = recurse(T->getBaseType());
1048  if (baseType.isNull())
1049  return {};
1050 
1051  // Transform type arguments.
1052  bool typeArgChanged = false;
1053  SmallVector<QualType, 4> typeArgs;
1054  for (auto typeArg : T->getTypeArgsAsWritten()) {
1055  QualType newTypeArg = recurse(typeArg);
1056  if (newTypeArg.isNull())
1057  return {};
1058 
1059  if (newTypeArg.getAsOpaquePtr() != typeArg.getAsOpaquePtr())
1060  typeArgChanged = true;
1061 
1062  typeArgs.push_back(newTypeArg);
1063  }
1064 
1065  if (baseType.getAsOpaquePtr() == T->getBaseType().getAsOpaquePtr() &&
1066  !typeArgChanged)
1067  return QualType(T, 0);
1068 
1069  return Ctx.getObjCObjectType(baseType, typeArgs,
1070  llvm::makeArrayRef(T->qual_begin(),
1071  T->getNumProtocols()),
1072  T->isKindOfTypeAsWritten());
1073  }
1074 
1075  TRIVIAL_TYPE_CLASS(ObjCInterface)
1076 
1077  QualType VisitObjCObjectPointerType(const ObjCObjectPointerType *T) {
1078  QualType pointeeType = recurse(T->getPointeeType());
1079  if (pointeeType.isNull())
1080  return {};
1081 
1082  if (pointeeType.getAsOpaquePtr()
1083  == T->getPointeeType().getAsOpaquePtr())
1084  return QualType(T, 0);
1085 
1086  return Ctx.getObjCObjectPointerType(pointeeType);
1087  }
1088 
1089  QualType VisitAtomicType(const AtomicType *T) {
1090  QualType valueType = recurse(T->getValueType());
1091  if (valueType.isNull())
1092  return {};
1093 
1094  if (valueType.getAsOpaquePtr()
1095  == T->getValueType().getAsOpaquePtr())
1096  return QualType(T, 0);
1097 
1098  return Ctx.getAtomicType(valueType);
1099  }
1100 
1101 #undef TRIVIAL_TYPE_CLASS
1102 };
1103 
1104 } // namespace
1105 
1106 /// Perform a simple type transformation that does not change the
1107 /// semantics of the type.
1108 template<typename F>
1109 static QualType simpleTransform(ASTContext &ctx, QualType type, F &&f) {
1110  // Transform the type. If it changed, return the transformed result.
1111  QualType transformed = f(type);
1112  if (transformed.getAsOpaquePtr() != type.getAsOpaquePtr())
1113  return transformed;
1114 
1115  // Split out the qualifiers from the type.
1116  SplitQualType splitType = type.split();
1117 
1118  // Visit the type itself.
1119  SimpleTransformVisitor<F> visitor(ctx, std::forward<F>(f));
1120  QualType result = visitor.Visit(splitType.Ty);
1121  if (result.isNull())
1122  return result;
1123 
1124  // Reconstruct the transformed type by applying the local qualifiers
1125  // from the split type.
1126  return ctx.getQualifiedType(result, splitType.Quals);
1127 }
1128 
1129 /// Substitute the given type arguments for Objective-C type
1130 /// parameters within the given type, recursively.
1132  ASTContext &ctx,
1133  ArrayRef<QualType> typeArgs,
1134  ObjCSubstitutionContext context) const {
1135  return simpleTransform(ctx, *this,
1136  [&](QualType type) -> QualType {
1137  SplitQualType splitType = type.split();
1138 
1139  // Replace an Objective-C type parameter reference with the corresponding
1140  // type argument.
1141  if (const auto *OTPTy = dyn_cast<ObjCTypeParamType>(splitType.Ty)) {
1142  ObjCTypeParamDecl *typeParam = OTPTy->getDecl();
1143  // If we have type arguments, use them.
1144  if (!typeArgs.empty()) {
1145  QualType argType = typeArgs[typeParam->getIndex()];
1146  if (OTPTy->qual_empty())
1147  return ctx.getQualifiedType(argType, splitType.Quals);
1148 
1149  // Apply protocol lists if exists.
1150  bool hasError;
1151  SmallVector<ObjCProtocolDecl*, 8> protocolsVec;
1152  protocolsVec.append(OTPTy->qual_begin(),
1153  OTPTy->qual_end());
1154  ArrayRef<ObjCProtocolDecl *> protocolsToApply = protocolsVec;
1155  QualType resultTy = ctx.applyObjCProtocolQualifiers(argType,
1156  protocolsToApply, hasError, true/*allowOnPointerType*/);
1157 
1158  return ctx.getQualifiedType(resultTy, splitType.Quals);
1159  }
1160 
1161  switch (context) {
1165  // Substitute the bound.
1166  return ctx.getQualifiedType(typeParam->getUnderlyingType(),
1167  splitType.Quals);
1168 
1171  // Substitute the __kindof form of the underlying type.
1172  const auto *objPtr = typeParam->getUnderlyingType()
1174 
1175  // __kindof types, id, and Class don't need an additional
1176  // __kindof.
1177  if (objPtr->isKindOfType() || objPtr->isObjCIdOrClassType())
1178  return ctx.getQualifiedType(typeParam->getUnderlyingType(),
1179  splitType.Quals);
1180 
1181  // Add __kindof.
1182  const auto *obj = objPtr->getObjectType();
1183  QualType resultTy = ctx.getObjCObjectType(obj->getBaseType(),
1184  obj->getTypeArgsAsWritten(),
1185  obj->getProtocols(),
1186  /*isKindOf=*/true);
1187 
1188  // Rebuild object pointer type.
1189  resultTy = ctx.getObjCObjectPointerType(resultTy);
1190  return ctx.getQualifiedType(resultTy, splitType.Quals);
1191  }
1192  }
1193  }
1194 
1195  // If we have a function type, update the context appropriately.
1196  if (const auto *funcType = dyn_cast<FunctionType>(splitType.Ty)) {
1197  // Substitute result type.
1198  QualType returnType = funcType->getReturnType().substObjCTypeArgs(
1199  ctx,
1200  typeArgs,
1202  if (returnType.isNull())
1203  return {};
1204 
1205  // Handle non-prototyped functions, which only substitute into the result
1206  // type.
1207  if (isa<FunctionNoProtoType>(funcType)) {
1208  // If the return type was unchanged, do nothing.
1209  if (returnType.getAsOpaquePtr()
1210  == funcType->getReturnType().getAsOpaquePtr())
1211  return type;
1212 
1213  // Otherwise, build a new type.
1214  return ctx.getFunctionNoProtoType(returnType, funcType->getExtInfo());
1215  }
1216 
1217  const auto *funcProtoType = cast<FunctionProtoType>(funcType);
1218 
1219  // Transform parameter types.
1220  SmallVector<QualType, 4> paramTypes;
1221  bool paramChanged = false;
1222  for (auto paramType : funcProtoType->getParamTypes()) {
1223  QualType newParamType = paramType.substObjCTypeArgs(
1224  ctx,
1225  typeArgs,
1227  if (newParamType.isNull())
1228  return {};
1229 
1230  if (newParamType.getAsOpaquePtr() != paramType.getAsOpaquePtr())
1231  paramChanged = true;
1232 
1233  paramTypes.push_back(newParamType);
1234  }
1235 
1236  // Transform extended info.
1237  FunctionProtoType::ExtProtoInfo info = funcProtoType->getExtProtoInfo();
1238  bool exceptionChanged = false;
1239  if (info.ExceptionSpec.Type == EST_Dynamic) {
1240  SmallVector<QualType, 4> exceptionTypes;
1241  for (auto exceptionType : info.ExceptionSpec.Exceptions) {
1242  QualType newExceptionType = exceptionType.substObjCTypeArgs(
1243  ctx,
1244  typeArgs,
1246  if (newExceptionType.isNull())
1247  return {};
1248 
1249  if (newExceptionType.getAsOpaquePtr()
1250  != exceptionType.getAsOpaquePtr())
1251  exceptionChanged = true;
1252 
1253  exceptionTypes.push_back(newExceptionType);
1254  }
1255 
1256  if (exceptionChanged) {
1257  info.ExceptionSpec.Exceptions =
1258  llvm::makeArrayRef(exceptionTypes).copy(ctx);
1259  }
1260  }
1261 
1262  if (returnType.getAsOpaquePtr()
1263  == funcProtoType->getReturnType().getAsOpaquePtr() &&
1264  !paramChanged && !exceptionChanged)
1265  return type;
1266 
1267  return ctx.getFunctionType(returnType, paramTypes, info);
1268  }
1269 
1270  // Substitute into the type arguments of a specialized Objective-C object
1271  // type.
1272  if (const auto *objcObjectType = dyn_cast<ObjCObjectType>(splitType.Ty)) {
1273  if (objcObjectType->isSpecializedAsWritten()) {
1274  SmallVector<QualType, 4> newTypeArgs;
1275  bool anyChanged = false;
1276  for (auto typeArg : objcObjectType->getTypeArgsAsWritten()) {
1277  QualType newTypeArg = typeArg.substObjCTypeArgs(
1278  ctx, typeArgs,
1280  if (newTypeArg.isNull())
1281  return {};
1282 
1283  if (newTypeArg.getAsOpaquePtr() != typeArg.getAsOpaquePtr()) {
1284  // If we're substituting based on an unspecialized context type,
1285  // produce an unspecialized type.
1286  ArrayRef<ObjCProtocolDecl *> protocols(
1287  objcObjectType->qual_begin(),
1288  objcObjectType->getNumProtocols());
1289  if (typeArgs.empty() &&
1291  return ctx.getObjCObjectType(
1292  objcObjectType->getBaseType(), {},
1293  protocols,
1294  objcObjectType->isKindOfTypeAsWritten());
1295  }
1296 
1297  anyChanged = true;
1298  }
1299 
1300  newTypeArgs.push_back(newTypeArg);
1301  }
1302 
1303  if (anyChanged) {
1304  ArrayRef<ObjCProtocolDecl *> protocols(
1305  objcObjectType->qual_begin(),
1306  objcObjectType->getNumProtocols());
1307  return ctx.getObjCObjectType(objcObjectType->getBaseType(),
1308  newTypeArgs, protocols,
1309  objcObjectType->isKindOfTypeAsWritten());
1310  }
1311  }
1312 
1313  return type;
1314  }
1315 
1316  return type;
1317  });
1318 }
1319 
1321  const DeclContext *dc,
1322  ObjCSubstitutionContext context) const {
1323  if (auto subs = objectType->getObjCSubstitutions(dc))
1324  return substObjCTypeArgs(dc->getParentASTContext(), *subs, context);
1325 
1326  return *this;
1327 }
1328 
1330  // FIXME: Because ASTContext::getAttributedType() is non-const.
1331  auto &ctx = const_cast<ASTContext &>(constCtx);
1332  return simpleTransform(ctx, *this,
1333  [&](QualType type) -> QualType {
1334  SplitQualType splitType = type.split();
1335  if (auto *objType = splitType.Ty->getAs<ObjCObjectType>()) {
1336  if (!objType->isKindOfType())
1337  return type;
1338 
1339  QualType baseType
1340  = objType->getBaseType().stripObjCKindOfType(ctx);
1341  return ctx.getQualifiedType(
1342  ctx.getObjCObjectType(baseType,
1343  objType->getTypeArgsAsWritten(),
1344  objType->getProtocols(),
1345  /*isKindOf=*/false),
1346  splitType.Quals);
1347  }
1348 
1349  return type;
1350  });
1351 }
1352 
1354  if (const auto AT = getTypePtr()->getAs<AtomicType>())
1355  return AT->getValueType().getUnqualifiedType();
1356  return getUnqualifiedType();
1357 }
1358 
1360  const DeclContext *dc) const {
1361  // Look through method scopes.
1362  if (const auto method = dyn_cast<ObjCMethodDecl>(dc))
1363  dc = method->getDeclContext();
1364 
1365  // Find the class or category in which the type we're substituting
1366  // was declared.
1367  const auto *dcClassDecl = dyn_cast<ObjCInterfaceDecl>(dc);
1368  const ObjCCategoryDecl *dcCategoryDecl = nullptr;
1369  ObjCTypeParamList *dcTypeParams = nullptr;
1370  if (dcClassDecl) {
1371  // If the class does not have any type parameters, there's no
1372  // substitution to do.
1373  dcTypeParams = dcClassDecl->getTypeParamList();
1374  if (!dcTypeParams)
1375  return None;
1376  } else {
1377  // If we are in neither a class nor a category, there's no
1378  // substitution to perform.
1379  dcCategoryDecl = dyn_cast<ObjCCategoryDecl>(dc);
1380  if (!dcCategoryDecl)
1381  return None;
1382 
1383  // If the category does not have any type parameters, there's no
1384  // substitution to do.
1385  dcTypeParams = dcCategoryDecl->getTypeParamList();
1386  if (!dcTypeParams)
1387  return None;
1388 
1389  dcClassDecl = dcCategoryDecl->getClassInterface();
1390  if (!dcClassDecl)
1391  return None;
1392  }
1393  assert(dcTypeParams && "No substitutions to perform");
1394  assert(dcClassDecl && "No class context");
1395 
1396  // Find the underlying object type.
1397  const ObjCObjectType *objectType;
1398  if (const auto *objectPointerType = getAs<ObjCObjectPointerType>()) {
1399  objectType = objectPointerType->getObjectType();
1400  } else if (getAs<BlockPointerType>()) {
1401  ASTContext &ctx = dc->getParentASTContext();
1402  objectType = ctx.getObjCObjectType(ctx.ObjCBuiltinIdTy, {}, {})
1403  ->castAs<ObjCObjectType>();
1404  } else {
1405  objectType = getAs<ObjCObjectType>();
1406  }
1407 
1408  /// Extract the class from the receiver object type.
1409  ObjCInterfaceDecl *curClassDecl = objectType ? objectType->getInterface()
1410  : nullptr;
1411  if (!curClassDecl) {
1412  // If we don't have a context type (e.g., this is "id" or some
1413  // variant thereof), substitute the bounds.
1414  return llvm::ArrayRef<QualType>();
1415  }
1416 
1417  // Follow the superclass chain until we've mapped the receiver type
1418  // to the same class as the context.
1419  while (curClassDecl != dcClassDecl) {
1420  // Map to the superclass type.
1421  QualType superType = objectType->getSuperClassType();
1422  if (superType.isNull()) {
1423  objectType = nullptr;
1424  break;
1425  }
1426 
1427  objectType = superType->castAs<ObjCObjectType>();
1428  curClassDecl = objectType->getInterface();
1429  }
1430 
1431  // If we don't have a receiver type, or the receiver type does not
1432  // have type arguments, substitute in the defaults.
1433  if (!objectType || objectType->isUnspecialized()) {
1434  return llvm::ArrayRef<QualType>();
1435  }
1436 
1437  // The receiver type has the type arguments we want.
1438  return objectType->getTypeArgs();
1439 }
1440 
1442  if (auto *IfaceT = getAsObjCInterfaceType()) {
1443  if (auto *ID = IfaceT->getInterface()) {
1444  if (ID->getTypeParamList())
1445  return true;
1446  }
1447  }
1448 
1449  return false;
1450 }
1451 
1453  // Retrieve the class declaration for this type. If there isn't one
1454  // (e.g., this is some variant of "id" or "Class"), then there is no
1455  // superclass type.
1456  ObjCInterfaceDecl *classDecl = getInterface();
1457  if (!classDecl) {
1458  CachedSuperClassType.setInt(true);
1459  return;
1460  }
1461 
1462  // Extract the superclass type.
1463  const ObjCObjectType *superClassObjTy = classDecl->getSuperClassType();
1464  if (!superClassObjTy) {
1465  CachedSuperClassType.setInt(true);
1466  return;
1467  }
1468 
1469  ObjCInterfaceDecl *superClassDecl = superClassObjTy->getInterface();
1470  if (!superClassDecl) {
1471  CachedSuperClassType.setInt(true);
1472  return;
1473  }
1474 
1475  // If the superclass doesn't have type parameters, then there is no
1476  // substitution to perform.
1477  QualType superClassType(superClassObjTy, 0);
1478  ObjCTypeParamList *superClassTypeParams = superClassDecl->getTypeParamList();
1479  if (!superClassTypeParams) {
1480  CachedSuperClassType.setPointerAndInt(
1481  superClassType->castAs<ObjCObjectType>(), true);
1482  return;
1483  }
1484 
1485  // If the superclass reference is unspecialized, return it.
1486  if (superClassObjTy->isUnspecialized()) {
1487  CachedSuperClassType.setPointerAndInt(superClassObjTy, true);
1488  return;
1489  }
1490 
1491  // If the subclass is not parameterized, there aren't any type
1492  // parameters in the superclass reference to substitute.
1493  ObjCTypeParamList *typeParams = classDecl->getTypeParamList();
1494  if (!typeParams) {
1495  CachedSuperClassType.setPointerAndInt(
1496  superClassType->castAs<ObjCObjectType>(), true);
1497  return;
1498  }
1499 
1500  // If the subclass type isn't specialized, return the unspecialized
1501  // superclass.
1502  if (isUnspecialized()) {
1503  QualType unspecializedSuper
1504  = classDecl->getASTContext().getObjCInterfaceType(
1505  superClassObjTy->getInterface());
1506  CachedSuperClassType.setPointerAndInt(
1507  unspecializedSuper->castAs<ObjCObjectType>(),
1508  true);
1509  return;
1510  }
1511 
1512  // Substitute the provided type arguments into the superclass type.
1513  ArrayRef<QualType> typeArgs = getTypeArgs();
1514  assert(typeArgs.size() == typeParams->size());
1515  CachedSuperClassType.setPointerAndInt(
1516  superClassType.substObjCTypeArgs(classDecl->getASTContext(), typeArgs,
1518  ->castAs<ObjCObjectType>(),
1519  true);
1520 }
1521 
1523  if (auto interfaceDecl = getObjectType()->getInterface()) {
1524  return interfaceDecl->getASTContext().getObjCInterfaceType(interfaceDecl)
1526  }
1527 
1528  return nullptr;
1529 }
1530 
1532  QualType superObjectType = getObjectType()->getSuperClassType();
1533  if (superObjectType.isNull())
1534  return superObjectType;
1535 
1536  ASTContext &ctx = getInterfaceDecl()->getASTContext();
1537  return ctx.getObjCObjectPointerType(superObjectType);
1538 }
1539 
1541  // There is no sugar for ObjCObjectType's, just return the canonical
1542  // type pointer if it is the right class. There is no typedef information to
1543  // return and these cannot be Address-space qualified.
1544  if (const auto *T = getAs<ObjCObjectType>())
1545  if (T->getNumProtocols() && T->getInterface())
1546  return T;
1547  return nullptr;
1548 }
1549 
1551  return getAsObjCQualifiedInterfaceType() != nullptr;
1552 }
1553 
1555  // There is no sugar for ObjCQualifiedIdType's, just return the canonical
1556  // type pointer if it is the right class.
1557  if (const auto *OPT = getAs<ObjCObjectPointerType>()) {
1558  if (OPT->isObjCQualifiedIdType())
1559  return OPT;
1560  }
1561  return nullptr;
1562 }
1563 
1565  // There is no sugar for ObjCQualifiedClassType's, just return the canonical
1566  // type pointer if it is the right class.
1567  if (const auto *OPT = getAs<ObjCObjectPointerType>()) {
1568  if (OPT->isObjCQualifiedClassType())
1569  return OPT;
1570  }
1571  return nullptr;
1572 }
1573 
1575  if (const auto *OT = getAs<ObjCObjectType>()) {
1576  if (OT->getInterface())
1577  return OT;
1578  }
1579  return nullptr;
1580 }
1581 
1583  if (const auto *OPT = getAs<ObjCObjectPointerType>()) {
1584  if (OPT->getInterfaceType())
1585  return OPT;
1586  }
1587  return nullptr;
1588 }
1589 
1591  QualType PointeeType;
1592  if (const auto *PT = getAs<PointerType>())
1593  PointeeType = PT->getPointeeType();
1594  else if (const auto *RT = getAs<ReferenceType>())
1595  PointeeType = RT->getPointeeType();
1596  else
1597  return nullptr;
1598 
1599  if (const auto *RT = PointeeType->getAs<RecordType>())
1600  return dyn_cast<CXXRecordDecl>(RT->getDecl());
1601 
1602  return nullptr;
1603 }
1604 
1606  return dyn_cast_or_null<CXXRecordDecl>(getAsTagDecl());
1607 }
1608 
1610  return dyn_cast_or_null<RecordDecl>(getAsTagDecl());
1611 }
1612 
1614  if (const auto *TT = getAs<TagType>())
1615  return TT->getDecl();
1616  if (const auto *Injected = getAs<InjectedClassNameType>())
1617  return Injected->getDecl();
1618 
1619  return nullptr;
1620 }
1621 
1622 bool Type::hasAttr(attr::Kind AK) const {
1623  const Type *Cur = this;
1624  while (const auto *AT = Cur->getAs<AttributedType>()) {
1625  if (AT->getAttrKind() == AK)
1626  return true;
1627  Cur = AT->getEquivalentType().getTypePtr();
1628  }
1629  return false;
1630 }
1631 
1632 namespace {
1633 
1634  class GetContainedDeducedTypeVisitor :
1635  public TypeVisitor<GetContainedDeducedTypeVisitor, Type*> {
1636  bool Syntactic;
1637 
1638  public:
1639  GetContainedDeducedTypeVisitor(bool Syntactic = false)
1640  : Syntactic(Syntactic) {}
1641 
1643 
1644  Type *Visit(QualType T) {
1645  if (T.isNull())
1646  return nullptr;
1647  return Visit(T.getTypePtr());
1648  }
1649 
1650  // The deduced type itself.
1651  Type *VisitDeducedType(const DeducedType *AT) {
1652  return const_cast<DeducedType*>(AT);
1653  }
1654 
1655  // Only these types can contain the desired 'auto' type.
1656 
1657  Type *VisitElaboratedType(const ElaboratedType *T) {
1658  return Visit(T->getNamedType());
1659  }
1660 
1661  Type *VisitPointerType(const PointerType *T) {
1662  return Visit(T->getPointeeType());
1663  }
1664 
1665  Type *VisitBlockPointerType(const BlockPointerType *T) {
1666  return Visit(T->getPointeeType());
1667  }
1668 
1669  Type *VisitReferenceType(const ReferenceType *T) {
1670  return Visit(T->getPointeeTypeAsWritten());
1671  }
1672 
1673  Type *VisitMemberPointerType(const MemberPointerType *T) {
1674  return Visit(T->getPointeeType());
1675  }
1676 
1677  Type *VisitArrayType(const ArrayType *T) {
1678  return Visit(T->getElementType());
1679  }
1680 
1681  Type *VisitDependentSizedExtVectorType(
1682  const DependentSizedExtVectorType *T) {
1683  return Visit(T->getElementType());
1684  }
1685 
1686  Type *VisitVectorType(const VectorType *T) {
1687  return Visit(T->getElementType());
1688  }
1689 
1690  Type *VisitFunctionProtoType(const FunctionProtoType *T) {
1691  if (Syntactic && T->hasTrailingReturn())
1692  return const_cast<FunctionProtoType*>(T);
1693  return VisitFunctionType(T);
1694  }
1695 
1696  Type *VisitFunctionType(const FunctionType *T) {
1697  return Visit(T->getReturnType());
1698  }
1699 
1700  Type *VisitParenType(const ParenType *T) {
1701  return Visit(T->getInnerType());
1702  }
1703 
1704  Type *VisitAttributedType(const AttributedType *T) {
1705  return Visit(T->getModifiedType());
1706  }
1707 
1708  Type *VisitAdjustedType(const AdjustedType *T) {
1709  return Visit(T->getOriginalType());
1710  }
1711  };
1712 
1713 } // namespace
1714 
1716  return cast_or_null<DeducedType>(
1717  GetContainedDeducedTypeVisitor().Visit(this));
1718 }
1719 
1721  return dyn_cast_or_null<FunctionType>(
1722  GetContainedDeducedTypeVisitor(true).Visit(this));
1723 }
1724 
1726  if (const auto *VT = dyn_cast<VectorType>(CanonicalType))
1727  return VT->getElementType()->isIntegerType();
1728  else
1729  return isIntegerType();
1730 }
1731 
1732 /// Determine whether this type is an integral type.
1733 ///
1734 /// This routine determines whether the given type is an integral type per
1735 /// C++ [basic.fundamental]p7. Although the C standard does not define the
1736 /// term "integral type", it has a similar term "integer type", and in C++
1737 /// the two terms are equivalent. However, C's "integer type" includes
1738 /// enumeration types, while C++'s "integer type" does not. The \c ASTContext
1739 /// parameter is used to determine whether we should be following the C or
1740 /// C++ rules when determining whether this type is an integral/integer type.
1741 ///
1742 /// For cases where C permits "an integer type" and C++ permits "an integral
1743 /// type", use this routine.
1744 ///
1745 /// For cases where C permits "an integer type" and C++ permits "an integral
1746 /// or enumeration type", use \c isIntegralOrEnumerationType() instead.
1747 ///
1748 /// \param Ctx The context in which this type occurs.
1749 ///
1750 /// \returns true if the type is considered an integral type, false otherwise.
1751 bool Type::isIntegralType(const ASTContext &Ctx) const {
1752  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1753  return BT->getKind() >= BuiltinType::Bool &&
1754  BT->getKind() <= BuiltinType::Int128;
1755 
1756  // Complete enum types are integral in C.
1757  if (!Ctx.getLangOpts().CPlusPlus)
1758  if (const auto *ET = dyn_cast<EnumType>(CanonicalType))
1759  return ET->getDecl()->isComplete();
1760 
1761  return false;
1762 }
1763 
1765  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1766  return BT->getKind() >= BuiltinType::Bool &&
1767  BT->getKind() <= BuiltinType::Int128;
1768 
1769  // Check for a complete enum type; incomplete enum types are not properly an
1770  // enumeration type in the sense required here.
1771  // C++0x: However, if the underlying type of the enum is fixed, it is
1772  // considered complete.
1773  if (const auto *ET = dyn_cast<EnumType>(CanonicalType))
1774  return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
1775 
1776  return false;
1777 }
1778 
1779 bool Type::isCharType() const {
1780  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1781  return BT->getKind() == BuiltinType::Char_U ||
1782  BT->getKind() == BuiltinType::UChar ||
1783  BT->getKind() == BuiltinType::Char_S ||
1784  BT->getKind() == BuiltinType::SChar;
1785  return false;
1786 }
1787 
1788 bool Type::isWideCharType() const {
1789  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1790  return BT->getKind() == BuiltinType::WChar_S ||
1791  BT->getKind() == BuiltinType::WChar_U;
1792  return false;
1793 }
1794 
1795 bool Type::isChar8Type() const {
1796  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
1797  return BT->getKind() == BuiltinType::Char8;
1798  return false;
1799 }
1800 
1801 bool Type::isChar16Type() const {
1802  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1803  return BT->getKind() == BuiltinType::Char16;
1804  return false;
1805 }
1806 
1807 bool Type::isChar32Type() const {
1808  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1809  return BT->getKind() == BuiltinType::Char32;
1810  return false;
1811 }
1812 
1813 /// Determine whether this type is any of the built-in character
1814 /// types.
1816  const auto *BT = dyn_cast<BuiltinType>(CanonicalType);
1817  if (!BT) return false;
1818  switch (BT->getKind()) {
1819  default: return false;
1820  case BuiltinType::Char_U:
1821  case BuiltinType::UChar:
1822  case BuiltinType::WChar_U:
1823  case BuiltinType::Char8:
1824  case BuiltinType::Char16:
1825  case BuiltinType::Char32:
1826  case BuiltinType::Char_S:
1827  case BuiltinType::SChar:
1828  case BuiltinType::WChar_S:
1829  return true;
1830  }
1831 }
1832 
1833 /// isSignedIntegerType - Return true if this is an integer type that is
1834 /// signed, according to C99 6.2.5p4 [char, signed char, short, int, long..],
1835 /// an enum decl which has a signed representation
1837  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1838  return BT->getKind() >= BuiltinType::Char_S &&
1839  BT->getKind() <= BuiltinType::Int128;
1840  }
1841 
1842  if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
1843  // Incomplete enum types are not treated as integer types.
1844  // FIXME: In C++, enum types are never integer types.
1845  if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
1846  return ET->getDecl()->getIntegerType()->isSignedIntegerType();
1847  }
1848 
1849  return false;
1850 }
1851 
1853  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1854  return BT->getKind() >= BuiltinType::Char_S &&
1855  BT->getKind() <= BuiltinType::Int128;
1856  }
1857 
1858  if (const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
1859  if (ET->getDecl()->isComplete())
1860  return ET->getDecl()->getIntegerType()->isSignedIntegerType();
1861  }
1862 
1863  return false;
1864 }
1865 
1867  if (const auto *VT = dyn_cast<VectorType>(CanonicalType))
1868  return VT->getElementType()->isSignedIntegerOrEnumerationType();
1869  else
1871 }
1872 
1873 /// isUnsignedIntegerType - Return true if this is an integer type that is
1874 /// unsigned, according to C99 6.2.5p6 [which returns true for _Bool], an enum
1875 /// decl which has an unsigned representation
1877  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1878  return BT->getKind() >= BuiltinType::Bool &&
1879  BT->getKind() <= BuiltinType::UInt128;
1880  }
1881 
1882  if (const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
1883  // Incomplete enum types are not treated as integer types.
1884  // FIXME: In C++, enum types are never integer types.
1885  if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
1886  return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
1887  }
1888 
1889  return false;
1890 }
1891 
1893  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1894  return BT->getKind() >= BuiltinType::Bool &&
1895  BT->getKind() <= BuiltinType::UInt128;
1896  }
1897 
1898  if (const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
1899  if (ET->getDecl()->isComplete())
1900  return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
1901  }
1902 
1903  return false;
1904 }
1905 
1907  if (const auto *VT = dyn_cast<VectorType>(CanonicalType))
1908  return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
1909  else
1911 }
1912 
1913 bool Type::isFloatingType() const {
1914  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1915  return BT->getKind() >= BuiltinType::Half &&
1916  BT->getKind() <= BuiltinType::Float128;
1917  if (const auto *CT = dyn_cast<ComplexType>(CanonicalType))
1918  return CT->getElementType()->isFloatingType();
1919  return false;
1920 }
1921 
1923  if (const auto *VT = dyn_cast<VectorType>(CanonicalType))
1924  return VT->getElementType()->isFloatingType();
1925  else
1926  return isFloatingType();
1927 }
1928 
1930  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1931  return BT->isFloatingPoint();
1932  return false;
1933 }
1934 
1935 bool Type::isRealType() const {
1936  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1937  return BT->getKind() >= BuiltinType::Bool &&
1938  BT->getKind() <= BuiltinType::Float128;
1939  if (const auto *ET = dyn_cast<EnumType>(CanonicalType))
1940  return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
1941  return false;
1942 }
1943 
1945  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1946  return BT->getKind() >= BuiltinType::Bool &&
1947  BT->getKind() <= BuiltinType::Float128;
1948  if (const auto *ET = dyn_cast<EnumType>(CanonicalType))
1949  // GCC allows forward declaration of enum types (forbid by C99 6.7.2.3p2).
1950  // If a body isn't seen by the time we get here, return false.
1951  //
1952  // C++0x: Enumerations are not arithmetic types. For now, just return
1953  // false for scoped enumerations since that will disable any
1954  // unwanted implicit conversions.
1955  return !ET->getDecl()->isScoped() && ET->getDecl()->isComplete();
1956  return isa<ComplexType>(CanonicalType);
1957 }
1958 
1960  assert(isScalarType());
1961 
1962  const Type *T = CanonicalType.getTypePtr();
1963  if (const auto *BT = dyn_cast<BuiltinType>(T)) {
1964  if (BT->getKind() == BuiltinType::Bool) return STK_Bool;
1965  if (BT->getKind() == BuiltinType::NullPtr) return STK_CPointer;
1966  if (BT->isInteger()) return STK_Integral;
1967  if (BT->isFloatingPoint()) return STK_Floating;
1968  llvm_unreachable("unknown scalar builtin type");
1969  } else if (isa<PointerType>(T)) {
1970  return STK_CPointer;
1971  } else if (isa<BlockPointerType>(T)) {
1972  return STK_BlockPointer;
1973  } else if (isa<ObjCObjectPointerType>(T)) {
1974  return STK_ObjCObjectPointer;
1975  } else if (isa<MemberPointerType>(T)) {
1976  return STK_MemberPointer;
1977  } else if (isa<EnumType>(T)) {
1978  assert(cast<EnumType>(T)->getDecl()->isComplete());
1979  return STK_Integral;
1980  } else if (const auto *CT = dyn_cast<ComplexType>(T)) {
1981  if (CT->getElementType()->isRealFloatingType())
1982  return STK_FloatingComplex;
1983  return STK_IntegralComplex;
1984  }
1985 
1986  llvm_unreachable("unknown scalar type");
1987 }
1988 
1989 /// Determines whether the type is a C++ aggregate type or C
1990 /// aggregate or union type.
1991 ///
1992 /// An aggregate type is an array or a class type (struct, union, or
1993 /// class) that has no user-declared constructors, no private or
1994 /// protected non-static data members, no base classes, and no virtual
1995 /// functions (C++ [dcl.init.aggr]p1). The notion of an aggregate type
1996 /// subsumes the notion of C aggregates (C99 6.2.5p21) because it also
1997 /// includes union types.
1999  if (const auto *Record = dyn_cast<RecordType>(CanonicalType)) {
2000  if (const auto *ClassDecl = dyn_cast<CXXRecordDecl>(Record->getDecl()))
2001  return ClassDecl->isAggregate();
2002 
2003  return true;
2004  }
2005 
2006  return isa<ArrayType>(CanonicalType);
2007 }
2008 
2009 /// isConstantSizeType - Return true if this is not a variable sized type,
2010 /// according to the rules of C99 6.7.5p3. It is not legal to call this on
2011 /// incomplete types or dependent types.
2013  assert(!isIncompleteType() && "This doesn't make sense for incomplete types");
2014  assert(!isDependentType() && "This doesn't make sense for dependent types");
2015  // The VAT must have a size, as it is known to be complete.
2016  return !isa<VariableArrayType>(CanonicalType);
2017 }
2018 
2019 /// isIncompleteType - Return true if this is an incomplete type (C99 6.2.5p1)
2020 /// - a type that can describe objects, but which lacks information needed to
2021 /// determine its size.
2023  if (Def)
2024  *Def = nullptr;
2025 
2026  switch (CanonicalType->getTypeClass()) {
2027  default: return false;
2028  case Builtin:
2029  // Void is the only incomplete builtin type. Per C99 6.2.5p19, it can never
2030  // be completed.
2031  return isVoidType();
2032  case Enum: {
2033  EnumDecl *EnumD = cast<EnumType>(CanonicalType)->getDecl();
2034  if (Def)
2035  *Def = EnumD;
2036  return !EnumD->isComplete();
2037  }
2038  case Record: {
2039  // A tagged type (struct/union/enum/class) is incomplete if the decl is a
2040  // forward declaration, but not a full definition (C99 6.2.5p22).
2041  RecordDecl *Rec = cast<RecordType>(CanonicalType)->getDecl();
2042  if (Def)
2043  *Def = Rec;
2044  return !Rec->isCompleteDefinition();
2045  }
2046  case ConstantArray:
2047  // An array is incomplete if its element type is incomplete
2048  // (C++ [dcl.array]p1).
2049  // We don't handle variable arrays (they're not allowed in C++) or
2050  // dependent-sized arrays (dependent types are never treated as incomplete).
2051  return cast<ArrayType>(CanonicalType)->getElementType()
2052  ->isIncompleteType(Def);
2053  case IncompleteArray:
2054  // An array of unknown size is an incomplete type (C99 6.2.5p22).
2055  return true;
2056  case MemberPointer: {
2057  // Member pointers in the MS ABI have special behavior in
2058  // RequireCompleteType: they attach a MSInheritanceAttr to the CXXRecordDecl
2059  // to indicate which inheritance model to use.
2060  auto *MPTy = cast<MemberPointerType>(CanonicalType);
2061  const Type *ClassTy = MPTy->getClass();
2062  // Member pointers with dependent class types don't get special treatment.
2063  if (ClassTy->isDependentType())
2064  return false;
2065  const CXXRecordDecl *RD = ClassTy->getAsCXXRecordDecl();
2066  ASTContext &Context = RD->getASTContext();
2067  // Member pointers not in the MS ABI don't get special treatment.
2068  if (!Context.getTargetInfo().getCXXABI().isMicrosoft())
2069  return false;
2070  // The inheritance attribute might only be present on the most recent
2071  // CXXRecordDecl, use that one.
2072  RD = RD->getMostRecentNonInjectedDecl();
2073  // Nothing interesting to do if the inheritance attribute is already set.
2074  if (RD->hasAttr<MSInheritanceAttr>())
2075  return false;
2076  return true;
2077  }
2078  case ObjCObject:
2079  return cast<ObjCObjectType>(CanonicalType)->getBaseType()
2080  ->isIncompleteType(Def);
2081  case ObjCInterface: {
2082  // ObjC interfaces are incomplete if they are @class, not @interface.
2083  ObjCInterfaceDecl *Interface
2084  = cast<ObjCInterfaceType>(CanonicalType)->getDecl();
2085  if (Def)
2086  *Def = Interface;
2087  return !Interface->hasDefinition();
2088  }
2089  }
2090 }
2091 
2092 bool QualType::isPODType(const ASTContext &Context) const {
2093  // C++11 has a more relaxed definition of POD.
2094  if (Context.getLangOpts().CPlusPlus11)
2095  return isCXX11PODType(Context);
2096 
2097  return isCXX98PODType(Context);
2098 }
2099 
2100 bool QualType::isCXX98PODType(const ASTContext &Context) const {
2101  // The compiler shouldn't query this for incomplete types, but the user might.
2102  // We return false for that case. Except for incomplete arrays of PODs, which
2103  // are PODs according to the standard.
2104  if (isNull())
2105  return false;
2106 
2107  if ((*this)->isIncompleteArrayType())
2108  return Context.getBaseElementType(*this).isCXX98PODType(Context);
2109 
2110  if ((*this)->isIncompleteType())
2111  return false;
2112 
2113  if (hasNonTrivialObjCLifetime())
2114  return false;
2115 
2116  QualType CanonicalType = getTypePtr()->CanonicalType;
2117  switch (CanonicalType->getTypeClass()) {
2118  // Everything not explicitly mentioned is not POD.
2119  default: return false;
2120  case Type::VariableArray:
2121  case Type::ConstantArray:
2122  // IncompleteArray is handled above.
2123  return Context.getBaseElementType(*this).isCXX98PODType(Context);
2124 
2125  case Type::ObjCObjectPointer:
2126  case Type::BlockPointer:
2127  case Type::Builtin:
2128  case Type::Complex:
2129  case Type::Pointer:
2130  case Type::MemberPointer:
2131  case Type::Vector:
2132  case Type::ExtVector:
2133  return true;
2134 
2135  case Type::Enum:
2136  return true;
2137 
2138  case Type::Record:
2139  if (const auto *ClassDecl =
2140  dyn_cast<CXXRecordDecl>(cast<RecordType>(CanonicalType)->getDecl()))
2141  return ClassDecl->isPOD();
2142 
2143  // C struct/union is POD.
2144  return true;
2145  }
2146 }
2147 
2148 bool QualType::isTrivialType(const ASTContext &Context) const {
2149  // The compiler shouldn't query this for incomplete types, but the user might.
2150  // We return false for that case. Except for incomplete arrays of PODs, which
2151  // are PODs according to the standard.
2152  if (isNull())
2153  return false;
2154 
2155  if ((*this)->isArrayType())
2156  return Context.getBaseElementType(*this).isTrivialType(Context);
2157 
2158  // Return false for incomplete types after skipping any incomplete array
2159  // types which are expressly allowed by the standard and thus our API.
2160  if ((*this)->isIncompleteType())
2161  return false;
2162 
2163  if (hasNonTrivialObjCLifetime())
2164  return false;
2165 
2166  QualType CanonicalType = getTypePtr()->CanonicalType;
2167  if (CanonicalType->isDependentType())
2168  return false;
2169 
2170  // C++0x [basic.types]p9:
2171  // Scalar types, trivial class types, arrays of such types, and
2172  // cv-qualified versions of these types are collectively called trivial
2173  // types.
2174 
2175  // As an extension, Clang treats vector types as Scalar types.
2176  if (CanonicalType->isScalarType() || CanonicalType->isVectorType())
2177  return true;
2178  if (const auto *RT = CanonicalType->getAs<RecordType>()) {
2179  if (const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2180  // C++11 [class]p6:
2181  // A trivial class is a class that has a default constructor,
2182  // has no non-trivial default constructors, and is trivially
2183  // copyable.
2184  return ClassDecl->hasDefaultConstructor() &&
2185  !ClassDecl->hasNonTrivialDefaultConstructor() &&
2186  ClassDecl->isTriviallyCopyable();
2187  }
2188 
2189  return true;
2190  }
2191 
2192  // No other types can match.
2193  return false;
2194 }
2195 
2196 bool QualType::isTriviallyCopyableType(const ASTContext &Context) const {
2197  if ((*this)->isArrayType())
2198  return Context.getBaseElementType(*this).isTriviallyCopyableType(Context);
2199 
2200  if (hasNonTrivialObjCLifetime())
2201  return false;
2202 
2203  // C++11 [basic.types]p9 - See Core 2094
2204  // Scalar types, trivially copyable class types, arrays of such types, and
2205  // cv-qualified versions of these types are collectively
2206  // called trivially copyable types.
2207 
2208  QualType CanonicalType = getCanonicalType();
2209  if (CanonicalType->isDependentType())
2210  return false;
2211 
2212  // Return false for incomplete types after skipping any incomplete array types
2213  // which are expressly allowed by the standard and thus our API.
2214  if (CanonicalType->isIncompleteType())
2215  return false;
2216 
2217  // As an extension, Clang treats vector types as Scalar types.
2218  if (CanonicalType->isScalarType() || CanonicalType->isVectorType())
2219  return true;
2220 
2221  if (const auto *RT = CanonicalType->getAs<RecordType>()) {
2222  if (const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2223  if (!ClassDecl->isTriviallyCopyable()) return false;
2224  }
2225 
2226  return true;
2227  }
2228 
2229  // No other types can match.
2230  return false;
2231 }
2232 
2234  return !Context.getLangOpts().ObjCAutoRefCount &&
2235  Context.getLangOpts().ObjCWeak &&
2236  getObjCLifetime() != Qualifiers::OCL_Weak;
2237 }
2238 
2241  if (const auto *RT =
2242  getTypePtr()->getBaseElementTypeUnsafe()->getAs<RecordType>())
2243  if (RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize())
2244  return PDIK_Struct;
2245 
2246  switch (getQualifiers().getObjCLifetime()) {
2248  return PDIK_ARCStrong;
2249  case Qualifiers::OCL_Weak:
2250  return PDIK_ARCWeak;
2251  default:
2252  return PDIK_Trivial;
2253  }
2254 }
2255 
2257  if (const auto *RT =
2258  getTypePtr()->getBaseElementTypeUnsafe()->getAs<RecordType>())
2259  if (RT->getDecl()->isNonTrivialToPrimitiveCopy())
2260  return PCK_Struct;
2261 
2262  Qualifiers Qs = getQualifiers();
2263  switch (Qs.getObjCLifetime()) {
2265  return PCK_ARCStrong;
2266  case Qualifiers::OCL_Weak:
2267  return PCK_ARCWeak;
2268  default:
2269  return Qs.hasVolatile() ? PCK_VolatileTrivial : PCK_Trivial;
2270  }
2271 }
2272 
2275  return isNonTrivialToPrimitiveCopy();
2276 }
2277 
2278 bool Type::isLiteralType(const ASTContext &Ctx) const {
2279  if (isDependentType())
2280  return false;
2281 
2282  // C++1y [basic.types]p10:
2283  // A type is a literal type if it is:
2284  // -- cv void; or
2285  if (Ctx.getLangOpts().CPlusPlus14 && isVoidType())
2286  return true;
2287 
2288  // C++11 [basic.types]p10:
2289  // A type is a literal type if it is:
2290  // [...]
2291  // -- an array of literal type other than an array of runtime bound; or
2292  if (isVariableArrayType())
2293  return false;
2294  const Type *BaseTy = getBaseElementTypeUnsafe();
2295  assert(BaseTy && "NULL element type");
2296 
2297  // Return false for incomplete types after skipping any incomplete array
2298  // types; those are expressly allowed by the standard and thus our API.
2299  if (BaseTy->isIncompleteType())
2300  return false;
2301 
2302  // C++11 [basic.types]p10:
2303  // A type is a literal type if it is:
2304  // -- a scalar type; or
2305  // As an extension, Clang treats vector types and complex types as
2306  // literal types.
2307  if (BaseTy->isScalarType() || BaseTy->isVectorType() ||
2308  BaseTy->isAnyComplexType())
2309  return true;
2310  // -- a reference type; or
2311  if (BaseTy->isReferenceType())
2312  return true;
2313  // -- a class type that has all of the following properties:
2314  if (const auto *RT = BaseTy->getAs<RecordType>()) {
2315  // -- a trivial destructor,
2316  // -- every constructor call and full-expression in the
2317  // brace-or-equal-initializers for non-static data members (if any)
2318  // is a constant expression,
2319  // -- it is an aggregate type or has at least one constexpr
2320  // constructor or constructor template that is not a copy or move
2321  // constructor, and
2322  // -- all non-static data members and base classes of literal types
2323  //
2324  // We resolve DR1361 by ignoring the second bullet.
2325  if (const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2326  return ClassDecl->isLiteral();
2327 
2328  return true;
2329  }
2330 
2331  // We treat _Atomic T as a literal type if T is a literal type.
2332  if (const auto *AT = BaseTy->getAs<AtomicType>())
2333  return AT->getValueType()->isLiteralType(Ctx);
2334 
2335  // If this type hasn't been deduced yet, then conservatively assume that
2336  // it'll work out to be a literal type.
2337  if (isa<AutoType>(BaseTy->getCanonicalTypeInternal()))
2338  return true;
2339 
2340  return false;
2341 }
2342 
2344  if (isDependentType())
2345  return false;
2346 
2347  // C++0x [basic.types]p9:
2348  // Scalar types, standard-layout class types, arrays of such types, and
2349  // cv-qualified versions of these types are collectively called
2350  // standard-layout types.
2351  const Type *BaseTy = getBaseElementTypeUnsafe();
2352  assert(BaseTy && "NULL element type");
2353 
2354  // Return false for incomplete types after skipping any incomplete array
2355  // types which are expressly allowed by the standard and thus our API.
2356  if (BaseTy->isIncompleteType())
2357  return false;
2358 
2359  // As an extension, Clang treats vector types as Scalar types.
2360  if (BaseTy->isScalarType() || BaseTy->isVectorType()) return true;
2361  if (const auto *RT = BaseTy->getAs<RecordType>()) {
2362  if (const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2363  if (!ClassDecl->isStandardLayout())
2364  return false;
2365 
2366  // Default to 'true' for non-C++ class types.
2367  // FIXME: This is a bit dubious, but plain C structs should trivially meet
2368  // all the requirements of standard layout classes.
2369  return true;
2370  }
2371 
2372  // No other types can match.
2373  return false;
2374 }
2375 
2376 // This is effectively the intersection of isTrivialType and
2377 // isStandardLayoutType. We implement it directly to avoid redundant
2378 // conversions from a type to a CXXRecordDecl.
2379 bool QualType::isCXX11PODType(const ASTContext &Context) const {
2380  const Type *ty = getTypePtr();
2381  if (ty->isDependentType())
2382  return false;
2383 
2384  if (hasNonTrivialObjCLifetime())
2385  return false;
2386 
2387  // C++11 [basic.types]p9:
2388  // Scalar types, POD classes, arrays of such types, and cv-qualified
2389  // versions of these types are collectively called trivial types.
2390  const Type *BaseTy = ty->getBaseElementTypeUnsafe();
2391  assert(BaseTy && "NULL element type");
2392 
2393  // Return false for incomplete types after skipping any incomplete array
2394  // types which are expressly allowed by the standard and thus our API.
2395  if (BaseTy->isIncompleteType())
2396  return false;
2397 
2398  // As an extension, Clang treats vector types as Scalar types.
2399  if (BaseTy->isScalarType() || BaseTy->isVectorType()) return true;
2400  if (const auto *RT = BaseTy->getAs<RecordType>()) {
2401  if (const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2402  // C++11 [class]p10:
2403  // A POD struct is a non-union class that is both a trivial class [...]
2404  if (!ClassDecl->isTrivial()) return false;
2405 
2406  // C++11 [class]p10:
2407  // A POD struct is a non-union class that is both a trivial class and
2408  // a standard-layout class [...]
2409  if (!ClassDecl->isStandardLayout()) return false;
2410 
2411  // C++11 [class]p10:
2412  // A POD struct is a non-union class that is both a trivial class and
2413  // a standard-layout class, and has no non-static data members of type
2414  // non-POD struct, non-POD union (or array of such types). [...]
2415  //
2416  // We don't directly query the recursive aspect as the requirements for
2417  // both standard-layout classes and trivial classes apply recursively
2418  // already.
2419  }
2420 
2421  return true;
2422  }
2423 
2424  // No other types can match.
2425  return false;
2426 }
2427 
2428 bool Type::isAlignValT() const {
2429  if (const auto *ET = getAs<EnumType>()) {
2430  IdentifierInfo *II = ET->getDecl()->getIdentifier();
2431  if (II && II->isStr("align_val_t") && ET->getDecl()->isInStdNamespace())
2432  return true;
2433  }
2434  return false;
2435 }
2436 
2437 bool Type::isStdByteType() const {
2438  if (const auto *ET = getAs<EnumType>()) {
2439  IdentifierInfo *II = ET->getDecl()->getIdentifier();
2440  if (II && II->isStr("byte") && ET->getDecl()->isInStdNamespace())
2441  return true;
2442  }
2443  return false;
2444 }
2445 
2447  if (const auto *BT = getAs<BuiltinType>())
2448  switch (BT->getKind()) {
2449  case BuiltinType::Bool:
2450  case BuiltinType::Char_S:
2451  case BuiltinType::Char_U:
2452  case BuiltinType::SChar:
2453  case BuiltinType::UChar:
2454  case BuiltinType::Short:
2455  case BuiltinType::UShort:
2456  case BuiltinType::WChar_S:
2457  case BuiltinType::WChar_U:
2458  case BuiltinType::Char8:
2459  case BuiltinType::Char16:
2460  case BuiltinType::Char32:
2461  return true;
2462  default:
2463  return false;
2464  }
2465 
2466  // Enumerated types are promotable to their compatible integer types
2467  // (C99 6.3.1.1) a.k.a. its underlying type (C++ [conv.prom]p2).
2468  if (const auto *ET = getAs<EnumType>()){
2469  if (this->isDependentType() || ET->getDecl()->getPromotionType().isNull()
2470  || ET->getDecl()->isScoped())
2471  return false;
2472 
2473  return true;
2474  }
2475 
2476  return false;
2477 }
2478 
2480  // Note that this intentionally does not use the canonical type.
2481  switch (getTypeClass()) {
2482  case Builtin:
2483  case Record:
2484  case Enum:
2485  case Typedef:
2486  case Complex:
2487  case TypeOfExpr:
2488  case TypeOf:
2489  case TemplateTypeParm:
2490  case SubstTemplateTypeParm:
2491  case TemplateSpecialization:
2492  case Elaborated:
2493  case DependentName:
2494  case DependentTemplateSpecialization:
2495  case ObjCInterface:
2496  case ObjCObject:
2497  case ObjCObjectPointer: // FIXME: object pointers aren't really specifiers
2498  return true;
2499  default:
2500  return false;
2501  }
2502 }
2503 
2506  switch (TypeSpec) {
2507  default: return ETK_None;
2508  case TST_typename: return ETK_Typename;
2509  case TST_class: return ETK_Class;
2510  case TST_struct: return ETK_Struct;
2511  case TST_interface: return ETK_Interface;
2512  case TST_union: return ETK_Union;
2513  case TST_enum: return ETK_Enum;
2514  }
2515 }
2516 
2519  switch(TypeSpec) {
2520  case TST_class: return TTK_Class;
2521  case TST_struct: return TTK_Struct;
2522  case TST_interface: return TTK_Interface;
2523  case TST_union: return TTK_Union;
2524  case TST_enum: return TTK_Enum;
2525  }
2526 
2527  llvm_unreachable("Type specifier is not a tag type kind.");
2528 }
2529 
2532  switch (Kind) {
2533  case TTK_Class: return ETK_Class;
2534  case TTK_Struct: return ETK_Struct;
2535  case TTK_Interface: return ETK_Interface;
2536  case TTK_Union: return ETK_Union;
2537  case TTK_Enum: return ETK_Enum;
2538  }
2539  llvm_unreachable("Unknown tag type kind.");
2540 }
2541 
2544  switch (Keyword) {
2545  case ETK_Class: return TTK_Class;
2546  case ETK_Struct: return TTK_Struct;
2547  case ETK_Interface: return TTK_Interface;
2548  case ETK_Union: return TTK_Union;
2549  case ETK_Enum: return TTK_Enum;
2550  case ETK_None: // Fall through.
2551  case ETK_Typename:
2552  llvm_unreachable("Elaborated type keyword is not a tag type kind.");
2553  }
2554  llvm_unreachable("Unknown elaborated type keyword.");
2555 }
2556 
2557 bool
2559  switch (Keyword) {
2560  case ETK_None:
2561  case ETK_Typename:
2562  return false;
2563  case ETK_Class:
2564  case ETK_Struct:
2565  case ETK_Interface:
2566  case ETK_Union:
2567  case ETK_Enum:
2568  return true;
2569  }
2570  llvm_unreachable("Unknown elaborated type keyword.");
2571 }
2572 
2574  switch (Keyword) {
2575  case ETK_None: return {};
2576  case ETK_Typename: return "typename";
2577  case ETK_Class: return "class";
2578  case ETK_Struct: return "struct";
2579  case ETK_Interface: return "__interface";
2580  case ETK_Union: return "union";
2581  case ETK_Enum: return "enum";
2582  }
2583 
2584  llvm_unreachable("Unknown elaborated type keyword.");
2585 }
2586 
2587 DependentTemplateSpecializationType::DependentTemplateSpecializationType(
2588  ElaboratedTypeKeyword Keyword,
2589  NestedNameSpecifier *NNS, const IdentifierInfo *Name,
2591  QualType Canon)
2592  : TypeWithKeyword(Keyword, DependentTemplateSpecialization, Canon, true, true,
2593  /*VariablyModified=*/false,
2594  NNS && NNS->containsUnexpandedParameterPack()),
2595  NNS(NNS), Name(Name) {
2596  DependentTemplateSpecializationTypeBits.NumArgs = Args.size();
2597  assert((!NNS || NNS->isDependent()) &&
2598  "DependentTemplateSpecializatonType requires dependent qualifier");
2599  TemplateArgument *ArgBuffer = getArgBuffer();
2600  for (const TemplateArgument &Arg : Args) {
2601  if (Arg.containsUnexpandedParameterPack())
2603 
2604  new (ArgBuffer++) TemplateArgument(Arg);
2605  }
2606 }
2607 
2608 void
2610  const ASTContext &Context,
2611  ElaboratedTypeKeyword Keyword,
2612  NestedNameSpecifier *Qualifier,
2613  const IdentifierInfo *Name,
2615  ID.AddInteger(Keyword);
2616  ID.AddPointer(Qualifier);
2617  ID.AddPointer(Name);
2618  for (const TemplateArgument &Arg : Args)
2619  Arg.Profile(ID, Context);
2620 }
2621 
2623  ElaboratedTypeKeyword Keyword;
2624  if (const auto *Elab = dyn_cast<ElaboratedType>(this))
2625  Keyword = Elab->getKeyword();
2626  else if (const auto *DepName = dyn_cast<DependentNameType>(this))
2627  Keyword = DepName->getKeyword();
2628  else if (const auto *DepTST =
2629  dyn_cast<DependentTemplateSpecializationType>(this))
2630  Keyword = DepTST->getKeyword();
2631  else
2632  return false;
2633 
2634  return TypeWithKeyword::KeywordIsTagTypeKind(Keyword);
2635 }
2636 
2637 const char *Type::getTypeClassName() const {
2638  switch (TypeBits.TC) {
2639 #define ABSTRACT_TYPE(Derived, Base)
2640 #define TYPE(Derived, Base) case Derived: return #Derived;
2641 #include "clang/AST/TypeNodes.def"
2642  }
2643 
2644  llvm_unreachable("Invalid type class.");
2645 }
2646 
2647 StringRef BuiltinType::getName(const PrintingPolicy &Policy) const {
2648  switch (getKind()) {
2649  case Void:
2650  return "void";
2651  case Bool:
2652  return Policy.Bool ? "bool" : "_Bool";
2653  case Char_S:
2654  return "char";
2655  case Char_U:
2656  return "char";
2657  case SChar:
2658  return "signed char";
2659  case Short:
2660  return "short";
2661  case Int:
2662  return "int";
2663  case Long:
2664  return "long";
2665  case LongLong:
2666  return "long long";
2667  case Int128:
2668  return "__int128";
2669  case UChar:
2670  return "unsigned char";
2671  case UShort:
2672  return "unsigned short";
2673  case UInt:
2674  return "unsigned int";
2675  case ULong:
2676  return "unsigned long";
2677  case ULongLong:
2678  return "unsigned long long";
2679  case UInt128:
2680  return "unsigned __int128";
2681  case Half:
2682  return Policy.Half ? "half" : "__fp16";
2683  case Float:
2684  return "float";
2685  case Double:
2686  return "double";
2687  case LongDouble:
2688  return "long double";
2689  case ShortAccum:
2690  return "short _Accum";
2691  case Accum:
2692  return "_Accum";
2693  case LongAccum:
2694  return "long _Accum";
2695  case UShortAccum:
2696  return "unsigned short _Accum";
2697  case UAccum:
2698  return "unsigned _Accum";
2699  case ULongAccum:
2700  return "unsigned long _Accum";
2701  case BuiltinType::ShortFract:
2702  return "short _Fract";
2703  case BuiltinType::Fract:
2704  return "_Fract";
2705  case BuiltinType::LongFract:
2706  return "long _Fract";
2707  case BuiltinType::UShortFract:
2708  return "unsigned short _Fract";
2709  case BuiltinType::UFract:
2710  return "unsigned _Fract";
2711  case BuiltinType::ULongFract:
2712  return "unsigned long _Fract";
2713  case BuiltinType::SatShortAccum:
2714  return "_Sat short _Accum";
2715  case BuiltinType::SatAccum:
2716  return "_Sat _Accum";
2717  case BuiltinType::SatLongAccum:
2718  return "_Sat long _Accum";
2719  case BuiltinType::SatUShortAccum:
2720  return "_Sat unsigned short _Accum";
2721  case BuiltinType::SatUAccum:
2722  return "_Sat unsigned _Accum";
2723  case BuiltinType::SatULongAccum:
2724  return "_Sat unsigned long _Accum";
2725  case BuiltinType::SatShortFract:
2726  return "_Sat short _Fract";
2727  case BuiltinType::SatFract:
2728  return "_Sat _Fract";
2729  case BuiltinType::SatLongFract:
2730  return "_Sat long _Fract";
2731  case BuiltinType::SatUShortFract:
2732  return "_Sat unsigned short _Fract";
2733  case BuiltinType::SatUFract:
2734  return "_Sat unsigned _Fract";
2735  case BuiltinType::SatULongFract:
2736  return "_Sat unsigned long _Fract";
2737  case Float16:
2738  return "_Float16";
2739  case Float128:
2740  return "__float128";
2741  case WChar_S:
2742  case WChar_U:
2743  return Policy.MSWChar ? "__wchar_t" : "wchar_t";
2744  case Char8:
2745  return "char8_t";
2746  case Char16:
2747  return "char16_t";
2748  case Char32:
2749  return "char32_t";
2750  case NullPtr:
2751  return "nullptr_t";
2752  case Overload:
2753  return "<overloaded function type>";
2754  case BoundMember:
2755  return "<bound member function type>";
2756  case PseudoObject:
2757  return "<pseudo-object type>";
2758  case Dependent:
2759  return "<dependent type>";
2760  case UnknownAny:
2761  return "<unknown type>";
2762  case ARCUnbridgedCast:
2763  return "<ARC unbridged cast type>";
2764  case BuiltinFn:
2765  return "<builtin fn type>";
2766  case ObjCId:
2767  return "id";
2768  case ObjCClass:
2769  return "Class";
2770  case ObjCSel:
2771  return "SEL";
2772 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
2773  case Id: \
2774  return "__" #Access " " #ImgType "_t";
2775 #include "clang/Basic/OpenCLImageTypes.def"
2776  case OCLSampler:
2777  return "sampler_t";
2778  case OCLEvent:
2779  return "event_t";
2780  case OCLClkEvent:
2781  return "clk_event_t";
2782  case OCLQueue:
2783  return "queue_t";
2784  case OCLReserveID:
2785  return "reserve_id_t";
2786  case OMPArraySection:
2787  return "<OpenMP array section type>";
2788  }
2789 
2790  llvm_unreachable("Invalid builtin type.");
2791 }
2792 
2794  if (const auto *RefType = getTypePtr()->getAs<ReferenceType>())
2795  return RefType->getPointeeType();
2796 
2797  // C++0x [basic.lval]:
2798  // Class prvalues can have cv-qualified types; non-class prvalues always
2799  // have cv-unqualified types.
2800  //
2801  // See also C99 6.3.2.1p2.
2802  if (!Context.getLangOpts().CPlusPlus ||
2803  (!getTypePtr()->isDependentType() && !getTypePtr()->isRecordType()))
2804  return getUnqualifiedType();
2805 
2806  return *this;
2807 }
2808 
2810  switch (CC) {
2811  case CC_C: return "cdecl";
2812  case CC_X86StdCall: return "stdcall";
2813  case CC_X86FastCall: return "fastcall";
2814  case CC_X86ThisCall: return "thiscall";
2815  case CC_X86Pascal: return "pascal";
2816  case CC_X86VectorCall: return "vectorcall";
2817  case CC_Win64: return "ms_abi";
2818  case CC_X86_64SysV: return "sysv_abi";
2819  case CC_X86RegCall : return "regcall";
2820  case CC_AAPCS: return "aapcs";
2821  case CC_AAPCS_VFP: return "aapcs-vfp";
2822  case CC_IntelOclBicc: return "intel_ocl_bicc";
2823  case CC_SpirFunction: return "spir_function";
2824  case CC_OpenCLKernel: return "opencl_kernel";
2825  case CC_Swift: return "swiftcall";
2826  case CC_PreserveMost: return "preserve_most";
2827  case CC_PreserveAll: return "preserve_all";
2828  }
2829 
2830  llvm_unreachable("Invalid calling convention.");
2831 }
2832 
2833 FunctionProtoType::FunctionProtoType(QualType result, ArrayRef<QualType> params,
2834  QualType canonical,
2835  const ExtProtoInfo &epi)
2836  : FunctionType(FunctionProto, result, canonical,
2837  result->isDependentType(),
2838  result->isInstantiationDependentType(),
2839  result->isVariablyModifiedType(),
2840  result->containsUnexpandedParameterPack(), epi.ExtInfo),
2841  NumParams(params.size()),
2842  NumExceptions(epi.ExceptionSpec.Exceptions.size()),
2843  ExceptionSpecType(epi.ExceptionSpec.Type),
2844  HasExtParameterInfos(epi.ExtParameterInfos != nullptr),
2845  Variadic(epi.Variadic), HasTrailingReturn(epi.HasTrailingReturn) {
2846  assert(NumParams == params.size() && "function has too many parameters");
2847 
2848  FunctionTypeBits.TypeQuals = epi.TypeQuals;
2849  FunctionTypeBits.RefQualifier = epi.RefQualifier;
2850 
2851  // Fill in the trailing argument array.
2852  auto *argSlot = reinterpret_cast<QualType *>(this+1);
2853  for (unsigned i = 0; i != NumParams; ++i) {
2854  if (params[i]->isDependentType())
2855  setDependent();
2856  else if (params[i]->isInstantiationDependentType())
2858 
2859  if (params[i]->containsUnexpandedParameterPack())
2861 
2862  argSlot[i] = params[i];
2863  }
2864 
2865  if (getExceptionSpecType() == EST_Dynamic) {
2866  // Fill in the exception array.
2867  QualType *exnSlot = argSlot + NumParams;
2868  unsigned I = 0;
2869  for (QualType ExceptionType : epi.ExceptionSpec.Exceptions) {
2870  // Note that, before C++17, a dependent exception specification does
2871  // *not* make a type dependent; it's not even part of the C++ type
2872  // system.
2873  if (ExceptionType->isInstantiationDependentType())
2875 
2876  if (ExceptionType->containsUnexpandedParameterPack())
2878 
2879  exnSlot[I++] = ExceptionType;
2880  }
2881  } else if (isComputedNoexcept(getExceptionSpecType())) {
2882  assert(epi.ExceptionSpec.NoexceptExpr && "computed noexcept with no expr");
2883  assert((getExceptionSpecType() == EST_DependentNoexcept) ==
2884  epi.ExceptionSpec.NoexceptExpr->isValueDependent());
2885 
2886  // Store the noexcept expression and context.
2887  auto **noexSlot = reinterpret_cast<Expr **>(argSlot + NumParams);
2888  *noexSlot = epi.ExceptionSpec.NoexceptExpr;
2889 
2890  if (epi.ExceptionSpec.NoexceptExpr->isValueDependent() ||
2891  epi.ExceptionSpec.NoexceptExpr->isInstantiationDependent())
2893 
2894  if (epi.ExceptionSpec.NoexceptExpr->containsUnexpandedParameterPack())
2896  } else if (getExceptionSpecType() == EST_Uninstantiated) {
2897  // Store the function decl from which we will resolve our
2898  // exception specification.
2899  auto **slot = reinterpret_cast<FunctionDecl **>(argSlot + NumParams);
2900  slot[0] = epi.ExceptionSpec.SourceDecl;
2901  slot[1] = epi.ExceptionSpec.SourceTemplate;
2902  // This exception specification doesn't make the type dependent, because
2903  // it's not instantiated as part of instantiating the type.
2904  } else if (getExceptionSpecType() == EST_Unevaluated) {
2905  // Store the function decl from which we will resolve our
2906  // exception specification.
2907  auto **slot = reinterpret_cast<FunctionDecl **>(argSlot + NumParams);
2908  slot[0] = epi.ExceptionSpec.SourceDecl;
2909  }
2910 
2911  // If this is a canonical type, and its exception specification is dependent,
2912  // then it's a dependent type. This only happens in C++17 onwards.
2913  if (isCanonicalUnqualified()) {
2914  if (getExceptionSpecType() == EST_Dynamic ||
2915  getExceptionSpecType() == EST_DependentNoexcept) {
2916  assert(hasDependentExceptionSpec() && "type should not be canonical");
2917  setDependent();
2918  }
2919  } else if (getCanonicalTypeInternal()->isDependentType()) {
2920  // Ask our canonical type whether our exception specification was dependent.
2921  setDependent();
2922  }
2923 
2924  if (epi.ExtParameterInfos) {
2925  auto *extParamInfos =
2926  const_cast<ExtParameterInfo *>(getExtParameterInfosBuffer());
2927  for (unsigned i = 0; i != NumParams; ++i)
2928  extParamInfos[i] = epi.ExtParameterInfos[i];
2929  }
2930 }
2931 
2933  if (Expr *NE = getNoexceptExpr())
2934  return NE->isValueDependent();
2935  for (QualType ET : exceptions())
2936  // A pack expansion with a non-dependent pattern is still dependent,
2937  // because we don't know whether the pattern is in the exception spec
2938  // or not (that depends on whether the pack has 0 expansions).
2939  if (ET->isDependentType() || ET->getAs<PackExpansionType>())
2940  return true;
2941  return false;
2942 }
2943 
2945  if (Expr *NE = getNoexceptExpr())
2946  return NE->isInstantiationDependent();
2947  for (QualType ET : exceptions())
2948  if (ET->isInstantiationDependentType())
2949  return true;
2950  return false;
2951 }
2952 
2954  switch (getExceptionSpecType()) {
2955  case EST_Unparsed:
2956  case EST_Unevaluated:
2957  case EST_Uninstantiated:
2958  llvm_unreachable("should not call this with unresolved exception specs");
2959 
2960  case EST_DynamicNone:
2961  case EST_BasicNoexcept:
2962  case EST_NoexceptTrue:
2963  return CT_Cannot;
2964 
2965  case EST_None:
2966  case EST_MSAny:
2967  case EST_NoexceptFalse:
2968  return CT_Can;
2969 
2970  case EST_Dynamic:
2971  // A dynamic exception specification is throwing unless every exception
2972  // type is an (unexpanded) pack expansion type.
2973  for (unsigned I = 0, N = NumExceptions; I != N; ++I)
2974  if (!getExceptionType(I)->getAs<PackExpansionType>())
2975  return CT_Can;
2976  return CT_Dependent;
2977 
2978  case EST_DependentNoexcept:
2979  return CT_Dependent;
2980  }
2981 
2982  llvm_unreachable("unexpected exception specification kind");
2983 }
2984 
2986  for (unsigned ArgIdx = getNumParams(); ArgIdx; --ArgIdx)
2987  if (isa<PackExpansionType>(getParamType(ArgIdx - 1)))
2988  return true;
2989 
2990  return false;
2991 }
2992 
2993 void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID, QualType Result,
2994  const QualType *ArgTys, unsigned NumParams,
2995  const ExtProtoInfo &epi,
2996  const ASTContext &Context, bool Canonical) {
2997  // We have to be careful not to get ambiguous profile encodings.
2998  // Note that valid type pointers are never ambiguous with anything else.
2999  //
3000  // The encoding grammar begins:
3001  // type type* bool int bool
3002  // If that final bool is true, then there is a section for the EH spec:
3003  // bool type*
3004  // This is followed by an optional "consumed argument" section of the
3005  // same length as the first type sequence:
3006  // bool*
3007  // Finally, we have the ext info and trailing return type flag:
3008  // int bool
3009  //
3010  // There is no ambiguity between the consumed arguments and an empty EH
3011  // spec because of the leading 'bool' which unambiguously indicates
3012  // whether the following bool is the EH spec or part of the arguments.
3013 
3014  ID.AddPointer(Result.getAsOpaquePtr());
3015  for (unsigned i = 0; i != NumParams; ++i)
3016  ID.AddPointer(ArgTys[i].getAsOpaquePtr());
3017  // This method is relatively performance sensitive, so as a performance
3018  // shortcut, use one AddInteger call instead of four for the next four
3019  // fields.
3020  assert(!(unsigned(epi.Variadic) & ~1) &&
3021  !(unsigned(epi.TypeQuals) & ~255) &&
3022  !(unsigned(epi.RefQualifier) & ~3) &&
3023  !(unsigned(epi.ExceptionSpec.Type) & ~15) &&
3024  "Values larger than expected.");
3025  ID.AddInteger(unsigned(epi.Variadic) +
3026  (epi.TypeQuals << 1) +
3027  (epi.RefQualifier << 9) +
3028  (epi.ExceptionSpec.Type << 11));
3029  if (epi.ExceptionSpec.Type == EST_Dynamic) {
3030  for (QualType Ex : epi.ExceptionSpec.Exceptions)
3031  ID.AddPointer(Ex.getAsOpaquePtr());
3032  } else if (isComputedNoexcept(epi.ExceptionSpec.Type)) {
3033  epi.ExceptionSpec.NoexceptExpr->Profile(ID, Context, Canonical);
3034  } else if (epi.ExceptionSpec.Type == EST_Uninstantiated ||
3036  ID.AddPointer(epi.ExceptionSpec.SourceDecl->getCanonicalDecl());
3037  }
3038  if (epi.ExtParameterInfos) {
3039  for (unsigned i = 0; i != NumParams; ++i)
3040  ID.AddInteger(epi.ExtParameterInfos[i].getOpaqueValue());
3041  }
3042  epi.ExtInfo.Profile(ID);
3043  ID.AddBoolean(epi.HasTrailingReturn);
3044 }
3045 
3046 void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID,
3047  const ASTContext &Ctx) {
3048  Profile(ID, getReturnType(), param_type_begin(), NumParams, getExtProtoInfo(),
3049  Ctx, isCanonicalUnqualified());
3050 }
3051 
3053  return getDecl()->getUnderlyingType();
3054 }
3055 
3057  : Type(TypeOfExpr, can, E->isTypeDependent(),
3058  E->isInstantiationDependent(),
3059  E->getType()->isVariablyModifiedType(),
3061  TOExpr(E) {}
3062 
3064  return !TOExpr->isTypeDependent();
3065 }
3066 
3068  if (isSugared())
3069  return getUnderlyingExpr()->getType();
3070 
3071  return QualType(this, 0);
3072 }
3073 
3074 void DependentTypeOfExprType::Profile(llvm::FoldingSetNodeID &ID,
3075  const ASTContext &Context, Expr *E) {
3076  E->Profile(ID, Context, true);
3077 }
3078 
3080  // C++11 [temp.type]p2: "If an expression e involves a template parameter,
3081  // decltype(e) denotes a unique dependent type." Hence a decltype type is
3082  // type-dependent even if its expression is only instantiation-dependent.
3083  : Type(Decltype, can, E->isInstantiationDependent(),
3084  E->isInstantiationDependent(),
3085  E->getType()->isVariablyModifiedType(),
3087  E(E), UnderlyingType(underlyingType) {}
3088 
3090 
3092  if (isSugared())
3093  return getUnderlyingType();
3094 
3095  return QualType(this, 0);
3096 }
3097 
3099  : DecltypeType(E, Context.DependentTy), Context(Context) {}
3100 
3101 void DependentDecltypeType::Profile(llvm::FoldingSetNodeID &ID,
3102  const ASTContext &Context, Expr *E) {
3103  E->Profile(ID, Context, true);
3104 }
3105 
3107  QualType UnderlyingType,
3108  UTTKind UKind,
3109  QualType CanonicalType)
3110  : Type(UnaryTransform, CanonicalType, BaseType->isDependentType(),
3111  BaseType->isInstantiationDependentType(),
3112  BaseType->isVariablyModifiedType(),
3113  BaseType->containsUnexpandedParameterPack()),
3114  BaseType(BaseType), UnderlyingType(UnderlyingType), UKind(UKind) {}
3115 
3117  QualType BaseType,
3118  UTTKind UKind)
3119  : UnaryTransformType(BaseType, C.DependentTy, UKind, QualType()) {}
3120 
3122  : Type(TC, can, D->isDependentType(),
3123  /*InstantiationDependent=*/D->isDependentType(),
3124  /*VariablyModified=*/false,
3125  /*ContainsUnexpandedParameterPack=*/false),
3126  decl(const_cast<TagDecl*>(D)) {}
3127 
3129  for (auto I : decl->redecls()) {
3130  if (I->isCompleteDefinition() || I->isBeingDefined())
3131  return I;
3132  }
3133  // If there's no definition (not even in progress), return what we have.
3134  return decl;
3135 }
3136 
3138  return getInterestingTagDecl(decl);
3139 }
3140 
3142  return getDecl()->isBeingDefined();
3143 }
3144 
3146  for (FieldDecl *FD : getDecl()->fields()) {
3147  QualType FieldTy = FD->getType();
3148  if (FieldTy.isConstQualified())
3149  return true;
3150  FieldTy = FieldTy.getCanonicalType();
3151  if (const auto *FieldRecTy = FieldTy->getAs<RecordType>())
3152  if (FieldRecTy->hasConstFields())
3153  return true;
3154  }
3155  return false;
3156 }
3157 
3159  // FIXME: Generate this with TableGen.
3160  switch (getAttrKind()) {
3161  // These are type qualifiers in the traditional C sense: they annotate
3162  // something about a specific value/variable of a type. (They aren't
3163  // always part of the canonical type, though.)
3164  case attr::ObjCGC:
3165  case attr::ObjCOwnership:
3166  case attr::ObjCInertUnsafeUnretained:
3167  case attr::TypeNonNull:
3168  case attr::TypeNullable:
3169  case attr::TypeNullUnspecified:
3170  case attr::LifetimeBound:
3171  return true;
3172 
3173  // All other type attributes aren't qualifiers; they rewrite the modified
3174  // type to be a semantically different type.
3175  default:
3176  return false;
3177  }
3178 }
3179 
3181  // FIXME: Generate this with TableGen?
3182  switch (getAttrKind()) {
3183  default: return false;
3184  case attr::Ptr32:
3185  case attr::Ptr64:
3186  case attr::SPtr:
3187  case attr::UPtr:
3188  return true;
3189  }
3190  llvm_unreachable("invalid attr kind");
3191 }
3192 
3194  // FIXME: Generate this with TableGen.
3195  switch (getAttrKind()) {
3196  default: return false;
3197  case attr::Pcs:
3198  case attr::CDecl:
3199  case attr::FastCall:
3200  case attr::StdCall:
3201  case attr::ThisCall:
3202  case attr::RegCall:
3203  case attr::SwiftCall:
3204  case attr::VectorCall:
3205  case attr::Pascal:
3206  case attr::MSABI:
3207  case attr::SysVABI:
3208  case attr::IntelOclBicc:
3209  case attr::PreserveMost:
3210  case attr::PreserveAll:
3211  return true;
3212  }
3213  llvm_unreachable("invalid attr kind");
3214 }
3215 
3217  return cast<CXXRecordDecl>(getInterestingTagDecl(Decl));
3218 }
3219 
3221  return isCanonicalUnqualified() ? nullptr : getDecl()->getIdentifier();
3222 }
3223 
3224 SubstTemplateTypeParmPackType::
3225 SubstTemplateTypeParmPackType(const TemplateTypeParmType *Param,
3226  QualType Canon,
3227  const TemplateArgument &ArgPack)
3228  : Type(SubstTemplateTypeParmPack, Canon, true, true, false, true),
3229  Replaced(Param), Arguments(ArgPack.pack_begin()) {
3230  SubstTemplateTypeParmPackTypeBits.NumArgs = ArgPack.pack_size();
3231 }
3232 
3234  return TemplateArgument(llvm::makeArrayRef(Arguments, getNumArgs()));
3235 }
3236 
3237 void SubstTemplateTypeParmPackType::Profile(llvm::FoldingSetNodeID &ID) {
3238  Profile(ID, getReplacedParameter(), getArgumentPack());
3239 }
3240 
3241 void SubstTemplateTypeParmPackType::Profile(llvm::FoldingSetNodeID &ID,
3242  const TemplateTypeParmType *Replaced,
3243  const TemplateArgument &ArgPack) {
3244  ID.AddPointer(Replaced);
3245  ID.AddInteger(ArgPack.pack_size());
3246  for (const auto &P : ArgPack.pack_elements())
3247  ID.AddPointer(P.getAsType().getAsOpaquePtr());
3248 }
3249 
3252  bool &InstantiationDependent) {
3253  return anyDependentTemplateArguments(Args.arguments(),
3254  InstantiationDependent);
3255 }
3256 
3259  bool &InstantiationDependent) {
3260  for (const TemplateArgumentLoc &ArgLoc : Args) {
3261  if (ArgLoc.getArgument().isDependent()) {
3262  InstantiationDependent = true;
3263  return true;
3264  }
3265 
3266  if (ArgLoc.getArgument().isInstantiationDependent())
3267  InstantiationDependent = true;
3268  }
3269  return false;
3270 }
3271 
3272 TemplateSpecializationType::
3273 TemplateSpecializationType(TemplateName T,
3275  QualType Canon, QualType AliasedType)
3276  : Type(TemplateSpecialization,
3277  Canon.isNull()? QualType(this, 0) : Canon,
3278  Canon.isNull()? true : Canon->isDependentType(),
3279  Canon.isNull()? true : Canon->isInstantiationDependentType(),
3280  false,
3281  T.containsUnexpandedParameterPack()), Template(T) {
3282  TemplateSpecializationTypeBits.NumArgs = Args.size();
3283  TemplateSpecializationTypeBits.TypeAlias = !AliasedType.isNull();
3284 
3285  assert(!T.getAsDependentTemplateName() &&
3286  "Use DependentTemplateSpecializationType for dependent template-name");
3287  assert((T.getKind() == TemplateName::Template ||
3290  "Unexpected template name for TemplateSpecializationType");
3291 
3292  auto *TemplateArgs = reinterpret_cast<TemplateArgument *>(this + 1);
3293  for (const TemplateArgument &Arg : Args) {
3294  // Update instantiation-dependent and variably-modified bits.
3295  // If the canonical type exists and is non-dependent, the template
3296  // specialization type can be non-dependent even if one of the type
3297  // arguments is. Given:
3298  // template<typename T> using U = int;
3299  // U<T> is always non-dependent, irrespective of the type T.
3300  // However, U<Ts> contains an unexpanded parameter pack, even though
3301  // its expansion (and thus its desugared type) doesn't.
3302  if (Arg.isInstantiationDependent())
3304  if (Arg.getKind() == TemplateArgument::Type &&
3305  Arg.getAsType()->isVariablyModifiedType())
3307  if (Arg.containsUnexpandedParameterPack())
3309  new (TemplateArgs++) TemplateArgument(Arg);
3310  }
3311 
3312  // Store the aliased type if this is a type alias template specialization.
3313  if (isTypeAlias()) {
3314  auto *Begin = reinterpret_cast<TemplateArgument *>(this + 1);
3315  *reinterpret_cast<QualType*>(Begin + getNumArgs()) = AliasedType;
3316  }
3317 }
3318 
3319 void
3320 TemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,
3321  TemplateName T,
3323  const ASTContext &Context) {
3324  T.Profile(ID);
3325  for (const TemplateArgument &Arg : Args)
3326  Arg.Profile(ID, Context);
3327 }
3328 
3329 QualType
3330 QualifierCollector::apply(const ASTContext &Context, QualType QT) const {
3331  if (!hasNonFastQualifiers())
3332  return QT.withFastQualifiers(getFastQualifiers());
3333 
3334  return Context.getQualifiedType(QT, *this);
3335 }
3336 
3337 QualType
3338 QualifierCollector::apply(const ASTContext &Context, const Type *T) const {
3339  if (!hasNonFastQualifiers())
3340  return QualType(T, getFastQualifiers());
3341 
3342  return Context.getQualifiedType(T, *this);
3343 }
3344 
3345 void ObjCObjectTypeImpl::Profile(llvm::FoldingSetNodeID &ID,
3346  QualType BaseType,
3347  ArrayRef<QualType> typeArgs,
3348  ArrayRef<ObjCProtocolDecl *> protocols,
3349  bool isKindOf) {
3350  ID.AddPointer(BaseType.getAsOpaquePtr());
3351  ID.AddInteger(typeArgs.size());
3352  for (auto typeArg : typeArgs)
3353  ID.AddPointer(typeArg.getAsOpaquePtr());
3354  ID.AddInteger(protocols.size());
3355  for (auto proto : protocols)
3356  ID.AddPointer(proto);
3357  ID.AddBoolean(isKindOf);
3358 }
3359 
3360 void ObjCObjectTypeImpl::Profile(llvm::FoldingSetNodeID &ID) {
3361  Profile(ID, getBaseType(), getTypeArgsAsWritten(),
3362  llvm::makeArrayRef(qual_begin(), getNumProtocols()),
3363  isKindOfTypeAsWritten());
3364 }
3365 
3366 void ObjCTypeParamType::Profile(llvm::FoldingSetNodeID &ID,
3367  const ObjCTypeParamDecl *OTPDecl,
3368  ArrayRef<ObjCProtocolDecl *> protocols) {
3369  ID.AddPointer(OTPDecl);
3370  ID.AddInteger(protocols.size());
3371  for (auto proto : protocols)
3372  ID.AddPointer(proto);
3373 }
3374 
3375 void ObjCTypeParamType::Profile(llvm::FoldingSetNodeID &ID) {
3376  Profile(ID, getDecl(),
3377  llvm::makeArrayRef(qual_begin(), getNumProtocols()));
3378 }
3379 
3380 namespace {
3381 
3382 /// The cached properties of a type.
3383 class CachedProperties {
3384  Linkage L;
3385  bool local;
3386 
3387 public:
3388  CachedProperties(Linkage L, bool local) : L(L), local(local) {}
3389 
3390  Linkage getLinkage() const { return L; }
3391  bool hasLocalOrUnnamedType() const { return local; }
3392 
3393  friend CachedProperties merge(CachedProperties L, CachedProperties R) {
3394  Linkage MergedLinkage = minLinkage(L.L, R.L);
3395  return CachedProperties(MergedLinkage,
3396  L.hasLocalOrUnnamedType() | R.hasLocalOrUnnamedType());
3397  }
3398 };
3399 
3400 } // namespace
3401 
3402 static CachedProperties computeCachedProperties(const Type *T);
3403 
3404 namespace clang {
3405 
3406 /// The type-property cache. This is templated so as to be
3407 /// instantiated at an internal type to prevent unnecessary symbol
3408 /// leakage.
3409 template <class Private> class TypePropertyCache {
3410 public:
3411  static CachedProperties get(QualType T) {
3412  return get(T.getTypePtr());
3413  }
3414 
3415  static CachedProperties get(const Type *T) {
3416  ensure(T);
3417  return CachedProperties(T->TypeBits.getLinkage(),
3418  T->TypeBits.hasLocalOrUnnamedType());
3419  }
3420 
3421  static void ensure(const Type *T) {
3422  // If the cache is valid, we're okay.
3423  if (T->TypeBits.isCacheValid()) return;
3424 
3425  // If this type is non-canonical, ask its canonical type for the
3426  // relevant information.
3427  if (!T->isCanonicalUnqualified()) {
3428  const Type *CT = T->getCanonicalTypeInternal().getTypePtr();
3429  ensure(CT);
3430  T->TypeBits.CacheValid = true;
3431  T->TypeBits.CachedLinkage = CT->TypeBits.CachedLinkage;
3432  T->TypeBits.CachedLocalOrUnnamed = CT->TypeBits.CachedLocalOrUnnamed;
3433  return;
3434  }
3435 
3436  // Compute the cached properties and then set the cache.
3437  CachedProperties Result = computeCachedProperties(T);
3438  T->TypeBits.CacheValid = true;
3439  T->TypeBits.CachedLinkage = Result.getLinkage();
3440  T->TypeBits.CachedLocalOrUnnamed = Result.hasLocalOrUnnamedType();
3441  }
3442 };
3443 
3444 } // namespace clang
3445 
3446 // Instantiate the friend template at a private class. In a
3447 // reasonable implementation, these symbols will be internal.
3448 // It is terrible that this is the best way to accomplish this.
3449 namespace {
3450 
3451 class Private {};
3452 
3453 } // namespace
3454 
3456 
3457 static CachedProperties computeCachedProperties(const Type *T) {
3458  switch (T->getTypeClass()) {
3459 #define TYPE(Class,Base)
3460 #define NON_CANONICAL_TYPE(Class,Base) case Type::Class:
3461 #include "clang/AST/TypeNodes.def"
3462  llvm_unreachable("didn't expect a non-canonical type here");
3463 
3464 #define TYPE(Class,Base)
3465 #define DEPENDENT_TYPE(Class,Base) case Type::Class:
3466 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
3467 #include "clang/AST/TypeNodes.def"
3468  // Treat instantiation-dependent types as external.
3469  assert(T->isInstantiationDependentType());
3470  return CachedProperties(ExternalLinkage, false);
3471 
3472  case Type::Auto:
3473  case Type::DeducedTemplateSpecialization:
3474  // Give non-deduced 'auto' types external linkage. We should only see them
3475  // here in error recovery.
3476  return CachedProperties(ExternalLinkage, false);
3477 
3478  case Type::Builtin:
3479  // C++ [basic.link]p8:
3480  // A type is said to have linkage if and only if:
3481  // - it is a fundamental type (3.9.1); or
3482  return CachedProperties(ExternalLinkage, false);
3483 
3484  case Type::Record:
3485  case Type::Enum: {
3486  const TagDecl *Tag = cast<TagType>(T)->getDecl();
3487 
3488  // C++ [basic.link]p8:
3489  // - it is a class or enumeration type that is named (or has a name
3490  // for linkage purposes (7.1.3)) and the name has linkage; or
3491  // - it is a specialization of a class template (14); or
3492  Linkage L = Tag->getLinkageInternal();
3493  bool IsLocalOrUnnamed =
3494  Tag->getDeclContext()->isFunctionOrMethod() ||
3495  !Tag->hasNameForLinkage();
3496  return CachedProperties(L, IsLocalOrUnnamed);
3497  }
3498 
3499  // C++ [basic.link]p8:
3500  // - it is a compound type (3.9.2) other than a class or enumeration,
3501  // compounded exclusively from types that have linkage; or
3502  case Type::Complex:
3503  return Cache::get(cast<ComplexType>(T)->getElementType());
3504  case Type::Pointer:
3505  return Cache::get(cast<PointerType>(T)->getPointeeType());
3506  case Type::BlockPointer:
3507  return Cache::get(cast<BlockPointerType>(T)->getPointeeType());
3508  case Type::LValueReference:
3509  case Type::RValueReference:
3510  return Cache::get(cast<ReferenceType>(T)->getPointeeType());
3511  case Type::MemberPointer: {
3512  const auto *MPT = cast<MemberPointerType>(T);
3513  return merge(Cache::get(MPT->getClass()),
3514  Cache::get(MPT->getPointeeType()));
3515  }
3516  case Type::ConstantArray:
3517  case Type::IncompleteArray:
3518  case Type::VariableArray:
3519  return Cache::get(cast<ArrayType>(T)->getElementType());
3520  case Type::Vector:
3521  case Type::ExtVector:
3522  return Cache::get(cast<VectorType>(T)->getElementType());
3523  case Type::FunctionNoProto:
3524  return Cache::get(cast<FunctionType>(T)->getReturnType());
3525  case Type::FunctionProto: {
3526  const auto *FPT = cast<FunctionProtoType>(T);
3527  CachedProperties result = Cache::get(FPT->getReturnType());
3528  for (const auto &ai : FPT->param_types())
3529  result = merge(result, Cache::get(ai));
3530  return result;
3531  }
3532  case Type::ObjCInterface: {
3533  Linkage L = cast<ObjCInterfaceType>(T)->getDecl()->getLinkageInternal();
3534  return CachedProperties(L, false);
3535  }
3536  case Type::ObjCObject:
3537  return Cache::get(cast<ObjCObjectType>(T)->getBaseType());
3538  case Type::ObjCObjectPointer:
3539  return Cache::get(cast<ObjCObjectPointerType>(T)->getPointeeType());
3540  case Type::Atomic:
3541  return Cache::get(cast<AtomicType>(T)->getValueType());
3542  case Type::Pipe:
3543  return Cache::get(cast<PipeType>(T)->getElementType());
3544  }
3545 
3546  llvm_unreachable("unhandled type class");
3547 }
3548 
3549 /// Determine the linkage of this type.
3551  Cache::ensure(this);
3552  return TypeBits.getLinkage();
3553 }
3554 
3556  Cache::ensure(this);
3557  return TypeBits.hasLocalOrUnnamedType();
3558 }
3559 
3561  switch (T->getTypeClass()) {
3562 #define TYPE(Class,Base)
3563 #define NON_CANONICAL_TYPE(Class,Base) case Type::Class:
3564 #include "clang/AST/TypeNodes.def"
3565  llvm_unreachable("didn't expect a non-canonical type here");
3566 
3567 #define TYPE(Class,Base)
3568 #define DEPENDENT_TYPE(Class,Base) case Type::Class:
3569 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
3570 #include "clang/AST/TypeNodes.def"
3571  // Treat instantiation-dependent types as external.
3572  assert(T->isInstantiationDependentType());
3573  return LinkageInfo::external();
3574 
3575  case Type::Builtin:
3576  return LinkageInfo::external();
3577 
3578  case Type::Auto:
3579  case Type::DeducedTemplateSpecialization:
3580  return LinkageInfo::external();
3581 
3582  case Type::Record:
3583  case Type::Enum:
3584  return getDeclLinkageAndVisibility(cast<TagType>(T)->getDecl());
3585 
3586  case Type::Complex:
3587  return computeTypeLinkageInfo(cast<ComplexType>(T)->getElementType());
3588  case Type::Pointer:
3589  return computeTypeLinkageInfo(cast<PointerType>(T)->getPointeeType());
3590  case Type::BlockPointer:
3591  return computeTypeLinkageInfo(cast<BlockPointerType>(T)->getPointeeType());
3592  case Type::LValueReference:
3593  case Type::RValueReference:
3594  return computeTypeLinkageInfo(cast<ReferenceType>(T)->getPointeeType());
3595  case Type::MemberPointer: {
3596  const auto *MPT = cast<MemberPointerType>(T);
3597  LinkageInfo LV = computeTypeLinkageInfo(MPT->getClass());
3598  LV.merge(computeTypeLinkageInfo(MPT->getPointeeType()));
3599  return LV;
3600  }
3601  case Type::ConstantArray:
3602  case Type::IncompleteArray:
3603  case Type::VariableArray:
3604  return computeTypeLinkageInfo(cast<ArrayType>(T)->getElementType());
3605  case Type::Vector:
3606  case Type::ExtVector:
3607  return computeTypeLinkageInfo(cast<VectorType>(T)->getElementType());
3608  case Type::FunctionNoProto:
3609  return computeTypeLinkageInfo(cast<FunctionType>(T)->getReturnType());
3610  case Type::FunctionProto: {
3611  const auto *FPT = cast<FunctionProtoType>(T);
3612  LinkageInfo LV = computeTypeLinkageInfo(FPT->getReturnType());
3613  for (const auto &ai : FPT->param_types())
3614  LV.merge(computeTypeLinkageInfo(ai));
3615  return LV;
3616  }
3617  case Type::ObjCInterface:
3618  return getDeclLinkageAndVisibility(cast<ObjCInterfaceType>(T)->getDecl());
3619  case Type::ObjCObject:
3620  return computeTypeLinkageInfo(cast<ObjCObjectType>(T)->getBaseType());
3621  case Type::ObjCObjectPointer:
3622  return computeTypeLinkageInfo(
3623  cast<ObjCObjectPointerType>(T)->getPointeeType());
3624  case Type::Atomic:
3625  return computeTypeLinkageInfo(cast<AtomicType>(T)->getValueType());
3626  case Type::Pipe:
3627  return computeTypeLinkageInfo(cast<PipeType>(T)->getElementType());
3628  }
3629 
3630  llvm_unreachable("unhandled type class");
3631 }
3632 
3633 bool Type::isLinkageValid() const {
3634  if (!TypeBits.isCacheValid())
3635  return true;
3636 
3637  Linkage L = LinkageComputer{}
3639  .getLinkage();
3640  return L == TypeBits.getLinkage();
3641 }
3642 
3644  if (!T->isCanonicalUnqualified())
3645  return computeTypeLinkageInfo(T->getCanonicalTypeInternal());
3646 
3647  LinkageInfo LV = computeTypeLinkageInfo(T);
3648  assert(LV.getLinkage() == T->getLinkage());
3649  return LV;
3650 }
3651 
3654 }
3655 
3657 Type::getNullability(const ASTContext &Context) const {
3658  QualType Type(this, 0);
3659  while (const auto *AT = Type->getAs<AttributedType>()) {
3660  // Check whether this is an attributed type with nullability
3661  // information.
3662  if (auto Nullability = AT->getImmediateNullability())
3663  return Nullability;
3664 
3665  Type = AT->getEquivalentType();
3666  }
3667  return None;
3668 }
3669 
3670 bool Type::canHaveNullability(bool ResultIfUnknown) const {
3672 
3673  switch (type->getTypeClass()) {
3674  // We'll only see canonical types here.
3675 #define NON_CANONICAL_TYPE(Class, Parent) \
3676  case Type::Class: \
3677  llvm_unreachable("non-canonical type");
3678 #define TYPE(Class, Parent)
3679 #include "clang/AST/TypeNodes.def"
3680 
3681  // Pointer types.
3682  case Type::Pointer:
3683  case Type::BlockPointer:
3684  case Type::MemberPointer:
3685  case Type::ObjCObjectPointer:
3686  return true;
3687 
3688  // Dependent types that could instantiate to pointer types.
3689  case Type::UnresolvedUsing:
3690  case Type::TypeOfExpr:
3691  case Type::TypeOf:
3692  case Type::Decltype:
3693  case Type::UnaryTransform:
3694  case Type::TemplateTypeParm:
3695  case Type::SubstTemplateTypeParmPack:
3696  case Type::DependentName:
3697  case Type::DependentTemplateSpecialization:
3698  case Type::Auto:
3699  return ResultIfUnknown;
3700 
3701  // Dependent template specializations can instantiate to pointer
3702  // types unless they're known to be specializations of a class
3703  // template.
3704  case Type::TemplateSpecialization:
3705  if (TemplateDecl *templateDecl
3706  = cast<TemplateSpecializationType>(type.getTypePtr())
3707  ->getTemplateName().getAsTemplateDecl()) {
3708  if (isa<ClassTemplateDecl>(templateDecl))
3709  return false;
3710  }
3711  return ResultIfUnknown;
3712 
3713  case Type::Builtin:
3714  switch (cast<BuiltinType>(type.getTypePtr())->getKind()) {
3715  // Signed, unsigned, and floating-point types cannot have nullability.
3716 #define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
3717 #define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
3718 #define FLOATING_TYPE(Id, SingletonId) case BuiltinType::Id:
3719 #define BUILTIN_TYPE(Id, SingletonId)
3720 #include "clang/AST/BuiltinTypes.def"
3721  return false;
3722 
3723  // Dependent types that could instantiate to a pointer type.
3724  case BuiltinType::Dependent:
3725  case BuiltinType::Overload:
3726  case BuiltinType::BoundMember:
3727  case BuiltinType::PseudoObject:
3728  case BuiltinType::UnknownAny:
3729  case BuiltinType::ARCUnbridgedCast:
3730  return ResultIfUnknown;
3731 
3732  case BuiltinType::Void:
3733  case BuiltinType::ObjCId:
3734  case BuiltinType::ObjCClass:
3735  case BuiltinType::ObjCSel:
3736 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3737  case BuiltinType::Id:
3738 #include "clang/Basic/OpenCLImageTypes.def"
3739  case BuiltinType::OCLSampler:
3740  case BuiltinType::OCLEvent:
3741  case BuiltinType::OCLClkEvent:
3742  case BuiltinType::OCLQueue:
3743  case BuiltinType::OCLReserveID:
3744  case BuiltinType::BuiltinFn:
3745  case BuiltinType::NullPtr:
3746  case BuiltinType::OMPArraySection:
3747  return false;
3748  }
3749  llvm_unreachable("unknown builtin type");
3750 
3751  // Non-pointer types.
3752  case Type::Complex:
3753  case Type::LValueReference:
3754  case Type::RValueReference:
3755  case Type::ConstantArray:
3756  case Type::IncompleteArray:
3757  case Type::VariableArray:
3758  case Type::DependentSizedArray:
3759  case Type::DependentVector:
3760  case Type::DependentSizedExtVector:
3761  case Type::Vector:
3762  case Type::ExtVector:
3763  case Type::DependentAddressSpace:
3764  case Type::FunctionProto:
3765  case Type::FunctionNoProto:
3766  case Type::Record:
3767  case Type::DeducedTemplateSpecialization:
3768  case Type::Enum:
3769  case Type::InjectedClassName:
3770  case Type::PackExpansion:
3771  case Type::ObjCObject:
3772  case Type::ObjCInterface:
3773  case Type::Atomic:
3774  case Type::Pipe:
3775  return false;
3776  }
3777  llvm_unreachable("bad type kind!");
3778 }
3779 
3782  if (getAttrKind() == attr::TypeNonNull)
3783  return NullabilityKind::NonNull;
3784  if (getAttrKind() == attr::TypeNullable)
3786  if (getAttrKind() == attr::TypeNullUnspecified)
3788  return None;
3789 }
3790 
3792  if (auto attributed = dyn_cast<AttributedType>(T.getTypePtr())) {
3793  if (auto nullability = attributed->getImmediateNullability()) {
3794  T = attributed->getModifiedType();
3795  return nullability;
3796  }
3797  }
3798 
3799  return None;
3800 }
3801 
3803  const auto *objcPtr = getAs<ObjCObjectPointerType>();
3804  if (!objcPtr)
3805  return false;
3806 
3807  if (objcPtr->isObjCIdType()) {
3808  // id is always okay.
3809  return true;
3810  }
3811 
3812  // Blocks are NSObjects.
3813  if (ObjCInterfaceDecl *iface = objcPtr->getInterfaceDecl()) {
3814  if (iface->getIdentifier() != ctx.getNSObjectName())
3815  return false;
3816 
3817  // Continue to check qualifiers, below.
3818  } else if (objcPtr->isObjCQualifiedIdType()) {
3819  // Continue to check qualifiers, below.
3820  } else {
3821  return false;
3822  }
3823 
3824  // Check protocol qualifiers.
3825  for (ObjCProtocolDecl *proto : objcPtr->quals()) {
3826  // Blocks conform to NSObject and NSCopying.
3827  if (proto->getIdentifier() != ctx.getNSObjectName() &&
3828  proto->getIdentifier() != ctx.getNSCopyingName())
3829  return false;
3830  }
3831 
3832  return true;
3833 }
3834 
3838  return Qualifiers::OCL_Strong;
3839 }
3840 
3842  assert(isObjCLifetimeType() &&
3843  "cannot query implicit lifetime for non-inferrable type");
3844 
3845  const Type *canon = getCanonicalTypeInternal().getTypePtr();
3846 
3847  // Walk down to the base type. We don't care about qualifiers for this.
3848  while (const auto *array = dyn_cast<ArrayType>(canon))
3849  canon = array->getElementType().getTypePtr();
3850 
3851  if (const auto *opt = dyn_cast<ObjCObjectPointerType>(canon)) {
3852  // Class and Class<Protocol> don't require retention.
3853  if (opt->getObjectType()->isObjCClass())
3854  return true;
3855  }
3856 
3857  return false;
3858 }
3859 
3861  const Type *cur = this;
3862  while (true) {
3863  if (const auto *typedefType = dyn_cast<TypedefType>(cur))
3864  return typedefType->getDecl()->hasAttr<ObjCNSObjectAttr>();
3865 
3866  // Single-step desugar until we run out of sugar.
3868  if (next.getTypePtr() == cur) return false;
3869  cur = next.getTypePtr();
3870  }
3871 }
3872 
3874  if (const auto *typedefType = dyn_cast<TypedefType>(this))
3875  return typedefType->getDecl()->hasAttr<ObjCIndependentClassAttr>();
3876  return false;
3877 }
3878 
3880  return isObjCObjectPointerType() ||
3881  isBlockPointerType() ||
3883 }
3884 
3886  if (isObjCLifetimeType())
3887  return true;
3888  if (const auto *OPT = getAs<PointerType>())
3889  return OPT->getPointeeType()->isObjCIndirectLifetimeType();
3890  if (const auto *Ref = getAs<ReferenceType>())
3891  return Ref->getPointeeType()->isObjCIndirectLifetimeType();
3892  if (const auto *MemPtr = getAs<MemberPointerType>())
3893  return MemPtr->getPointeeType()->isObjCIndirectLifetimeType();
3894  return false;
3895 }
3896 
3897 /// Returns true if objects of this type have lifetime semantics under
3898 /// ARC.
3900  const Type *type = this;
3901  while (const ArrayType *array = type->getAsArrayTypeUnsafe())
3902  type = array->getElementType().getTypePtr();
3903  return type->isObjCRetainableType();
3904 }
3905 
3906 /// Determine whether the given type T is a "bridgable" Objective-C type,
3907 /// which is either an Objective-C object pointer type or an
3910 }
3911 
3912 /// Determine whether the given type T is a "bridgeable" C type.
3914  const auto *Pointer = getAs<PointerType>();
3915  if (!Pointer)
3916  return false;
3917 
3918  QualType Pointee = Pointer->getPointeeType();
3919  return Pointee->isVoidType() || Pointee->isRecordType();
3920 }
3921 
3923  if (!isVariablyModifiedType()) return false;
3924 
3925  if (const auto *ptr = getAs<PointerType>())
3926  return ptr->getPointeeType()->hasSizedVLAType();
3927  if (const auto *ref = getAs<ReferenceType>())
3928  return ref->getPointeeType()->hasSizedVLAType();
3929  if (const ArrayType *arr = getAsArrayTypeUnsafe()) {
3930  if (isa<VariableArrayType>(arr) &&
3931  cast<VariableArrayType>(arr)->getSizeExpr())
3932  return true;
3933 
3934  return arr->getElementType()->hasSizedVLAType();
3935  }
3936 
3937  return false;
3938 }
3939 
3940 QualType::DestructionKind QualType::isDestructedTypeImpl(QualType type) {
3941  switch (type.getObjCLifetime()) {
3942  case Qualifiers::OCL_None:
3945  break;
3946 
3948  return DK_objc_strong_lifetime;
3949  case Qualifiers::OCL_Weak:
3950  return DK_objc_weak_lifetime;
3951  }
3952 
3953  if (const auto *RT =
3955  const RecordDecl *RD = RT->getDecl();
3956  if (const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
3957  /// Check if this is a C++ object with a non-trivial destructor.
3958  if (CXXRD->hasDefinition() && !CXXRD->hasTrivialDestructor())
3959  return DK_cxx_destructor;
3960  } else {
3961  /// Check if this is a C struct that is non-trivial to destroy or an array
3962  /// that contains such a struct.
3964  return DK_nontrivial_c_struct;
3965  }
3966  }
3967 
3968  return DK_none;
3969 }
3970 
3972  return getClass()->getAsCXXRecordDecl()->getMostRecentNonInjectedDecl();
3973 }
3974 
3976  llvm::APSInt Val, unsigned Scale) {
3977  if (Val.isSigned() && Val.isNegative() && Val != -Val) {
3978  Val = -Val;
3979  Str.push_back('-');
3980  }
3981 
3982  llvm::APSInt IntPart = Val >> Scale;
3983 
3984  // Add 4 digits to hold the value after multiplying 10 (the radix)
3985  unsigned Width = Val.getBitWidth() + 4;
3986  llvm::APInt FractPart = Val.zextOrTrunc(Scale).zext(Width);
3987  llvm::APInt FractPartMask = llvm::APInt::getAllOnesValue(Scale).zext(Width);
3988  llvm::APInt RadixInt = llvm::APInt(Width, 10);
3989 
3990  IntPart.toString(Str, /*radix=*/10);
3991  Str.push_back('.');
3992  do {
3993  (FractPart * RadixInt)
3994  .lshr(Scale)
3995  .toString(Str, /*radix=*/10, Val.isSigned());
3996  FractPart = (FractPart * RadixInt) & FractPartMask;
3997  } while (FractPart != 0);
3998 }
unsigned char getOpaqueValue() const
Definition: Type.h:3630
DecltypeType(Expr *E, QualType underlyingType, QualType can=QualType())
Definition: Type.cpp:3079
static StringRef getKeywordName(ElaboratedTypeKeyword Keyword)
Definition: Type.cpp:2573
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
Definition: Type.cpp:1522
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Defines the clang::ASTContext interface.
bool hasDefinition() const
Determine whether this class has been defined.
Definition: DeclObjC.h:1527
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
Definition: Type.cpp:2233
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it&#39;s either not been deduced or was deduce...
Definition: Type.h:4618
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
Definition: Type.h:5010
const Type * Ty
The locally-unqualified type.
Definition: Type.h:583
bool isStruct() const
Definition: Decl.h:3226
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
Definition: Type.h:4813
Represents a function declaration or definition.
Definition: Decl.h:1717
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
Definition: Type.cpp:1622
bool isKindOfTypeAsWritten() const
Whether this is a "__kindof" type as written.
Definition: Type.h:5536
External linkage, which indicates that the entity can be referred to from other translation units...
Definition: Linkage.h:60
bool isStrictSupersetOf(Qualifiers Other) const
Determine whether this set of qualifiers is a strict superset of another set of qualifiers, not considering qualifier compatibility.
Definition: Type.cpp:56
The "enum" keyword introduces the elaborated-type-specifier.
Definition: Type.h:4945
DependentUnaryTransformType(const ASTContext &C, QualType BaseType, UTTKind UKind)
Definition: Type.cpp:3116
void setDependent(bool D=true)
Definition: Type.h:1774
no exception specification
bool isTemplateVariadic() const
Determines whether this function prototype contains a parameter pack at the end.
Definition: Type.cpp:2985
StringRef getName(const PrintingPolicy &Policy) const
Definition: Type.cpp:2647
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2511
ArrayRef< QualType > getTypeArgsAsWritten() const
Retrieve the type arguments of this object type as they were written.
Definition: Type.h:5530
QualType getPointeeType() const
Definition: Type.h:2524
A (possibly-)qualified type.
Definition: Type.h:642
bool isBlockPointerType() const
Definition: Type.h:6185
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
Substitute type arguments for the Objective-C type parameters used in the subject type...
Definition: Type.cpp:1131
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
Definition: Type.cpp:2092
bool isArrayType() const
Definition: Type.h:6226
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
Definition: Type.cpp:1892
static QualType getObjectType(APValue::LValueBase B)
Retrieves the "underlying object type" of the given expression, as used by __builtin_object_size.
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
Definition: Type.h:942
PrimitiveDefaultInitializeKind isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C struct types.
Definition: Type.cpp:2240
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: Type.h:3463
bool isArithmeticType() const
Definition: Type.cpp:1944
void setInstantiationDependent(bool D=true)
Definition: Type.h:1780
Stmt - This represents one statement.
Definition: Stmt.h:66
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3329
bool isObjCClassOrClassKindOfType() const
Whether the type is Objective-C &#39;Class&#39; or a __kindof type of an Class type, e.g., __kindof Class <NSCopying>.
Definition: Type.cpp:578
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
Definition: Type.cpp:497
bool isElaboratedTypeSpecifier() const
Determine wither this type is a C++ elaborated-type-specifier.
Definition: Type.cpp:2622
unsigned MSWChar
When true, print the built-in wchar_t type as __wchar_t.
bool isRealFloatingType() const
Floating point categories.
Definition: Type.cpp:1929
C Language Family Type Representation.
bool isObjCARCBridgableType() const
Determine whether the given type T is a "bridgable" Objective-C type, which is either an Objective-C ...
Definition: Type.cpp:3908
void Profile(llvm::FoldingSetNodeID &ID)
Definition: Type.cpp:3237
bool isRecordType() const
Definition: Type.h:6250
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
Definition: ASTContext.h:1939
const ObjCObjectType * getAsObjCInterfaceType() const
Definition: Type.cpp:1574
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:87
TagDecl * getDecl() const
Definition: Type.cpp:3137
ObjCObjectTypeBitfields ObjCObjectTypeBits
Definition: Type.h:1698
const RecordType * getAsStructureType() const
Definition: Type.cpp:513
SubstTemplateTypeParmPackTypeBitfields SubstTemplateTypeParmPackTypeBits
Definition: Type.h:1703
Defines the C++ template declaration subclasses.
StringRef P
Represents a C++11 auto or C++14 decltype(auto) type.
Definition: Type.h:4632
QualType desugar() const
Remove a single level of sugar.
Definition: Type.cpp:3091
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
Definition: Type.cpp:3046
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
Definition: DeclObjC.cpp:308
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
Definition: Type.cpp:2531
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
The base class of the type hierarchy.
Definition: Type.h:1415
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:2786
bool isObjCBoxableRecordType() const
Definition: Type.cpp:441
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
Definition: Type.cpp:1582
DependentDecltypeType(const ASTContext &Context, Expr *E)
Definition: Type.cpp:3098
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:699
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Definition: Type.h:5864
bool isCARCBridgableType() const
Determine whether the given type T is a "bridgeable" C type.
Definition: Type.cpp:3913
bool isUnspecialized() const
Determine whether this object type is "unspecialized", meaning that it has no type arguments...
Definition: Type.h:5519
Linkage getLinkage() const
Determine the linkage of this type.
Definition: Type.cpp:3550
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
A template template parameter that has been substituted for some other template name.
Definition: TemplateName.h:206
QualType getElementType() const
Definition: Type.h:2821
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition: Decl.h:3146
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
Definition: Type.cpp:532
QualType withFastQualifiers(unsigned TQs) const
Definition: Type.h:857
static CachedProperties computeCachedProperties(const Type *T)
Definition: Type.cpp:3457
bool isTrivialType(const ASTContext &Context) const
Return true if this is a trivial type per (C++0x [basic.types]p9)
Definition: Type.cpp:2148
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
Definition: Type.cpp:1876
bool isInterface() const
Definition: Decl.h:3227
bool isStructureType() const
Definition: Type.cpp:435
bool isEnumeralType() const
Definition: Type.h:6254
const T * getAs() const
Member-template getAs<specific type>&#39;.
Definition: Type.h:6590
The "union" keyword.
Definition: Type.h:4920
Extra information about a function prototype.
Definition: Type.h:3669
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type...
Definition: Type.h:6662
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical) const
Produce a unique representation of the given statement.
The "__interface" keyword.
Definition: Type.h:4917
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
bool isChar32Type() const
Definition: Type.cpp:1807
bool isCallingConv() const
Definition: Type.cpp:3193
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:38
LinkageInfo computeTypeLinkageInfo(const Type *T)
Definition: Type.cpp:3560
Represents the result of substituting a type for a template type parameter.
Definition: Type.h:4486
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
Definition: Linkage.h:24
noexcept(expression), value-dependent
bool isStandardLayoutType() const
Test if this type is a standard-layout type.
Definition: Type.cpp:2343
The collection of all-type qualifiers we support.
Definition: Type.h:141
bool isVariableArrayType() const
Definition: Type.h:6238
bool isSugared() const
Returns whether this type directly provides sugar.
Definition: Type.cpp:3089
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g., it is a floating-point type or a vector thereof.
Definition: Type.cpp:1922
bool isClass() const
Definition: Decl.h:3228
void Profile(llvm::FoldingSetNodeID &ID)
Definition: Type.h:3039
bool canHaveNullability(bool ResultIfUnknown=true) const
Determine whether the given type can have a nullability specifier applied to it, i.e., if it is any kind of pointer type.
Definition: Type.cpp:3670
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:269
Represents a struct/union/class.
Definition: Decl.h:3570
QualType getSubstTemplateTypeParmType(const TemplateTypeParmType *Replaced, QualType Replacement) const
Retrieve a substitution-result type.
QualType getOriginalType() const
Definition: Type.h:2575
bool isWideCharType() const
Definition: Type.cpp:1788
FunctionType::ExtInfo ExtInfo
Definition: Type.h:3670
bool isComplete() const
Returns true if this can be considered a complete type.
Definition: Decl.h:3511
One of these records is kept for each identifier that is lexed.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
Definition: TargetInfo.h:1018
bool isObjCIdOrObjectKindOfType(const ASTContext &ctx, const ObjCObjectType *&bound) const
Whether the type is Objective-C &#39;id&#39; or a __kindof type of an object type, e.g., __kindof NSView * or...
Definition: Type.cpp:552
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
QualType IgnoreParens() const
Returns the specified type after dropping any outer-level parentheses.
Definition: Type.h:961
Represents a class type in Objective C.
Definition: Type.h:5419
bool isObjCIndependentClassType() const
Definition: Type.cpp:3873
QualType getPointeeType() const
Definition: Type.h:2628
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:154
bool isStdByteType() const
Definition: Type.cpp:2437
ArrayRef< QualType > getParamTypes() const
Definition: Type.h:3793
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
Definition: Type.cpp:3899
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
Definition: Type.cpp:3258
bool isCharType() const
Definition: Type.cpp:1779
bool isSpelledAsLValue() const
Definition: Type.h:2663
Represents a member of a struct/union/class.
Definition: Decl.h:2556
bool isCanonicalUnqualified() const
Determines if this type would be canonical if it had no further qualification.
Definition: Type.h:1822
Defines the ExceptionSpecificationType enumeration and various utility functions. ...
An operation on a type.
Definition: TypeVisitor.h:65
const ObjCObjectPointerType * getAsObjCQualifiedIdType() const
Definition: Type.cpp:1554
bool isReferenceType() const
Definition: Type.h:6189
qual_iterator qual_begin() const
Definition: Type.h:5320
const AstTypeMatcher< TypedefType > typedefType
Matches typedef types.
unsigned getIndex() const
Retrieve the index into its type parameter list.
Definition: DeclObjC.h:607
const ObjCObjectPointerType * stripObjCKindOfTypeAndQuals(const ASTContext &ctx) const
Strip off the Objective-C "kindof" type and (with it) any protocol qualifiers.
Definition: Type.cpp:709
Values of this type can be null.
void Profile(llvm::FoldingSetNodeID &ID)
Definition: Type.h:3084
Type(TypeClass tc, QualType canon, bool Dependent, bool InstantiationDependent, bool VariablyModified, bool ContainsUnexpandedParameterPack)
Definition: Type.h:1755
An rvalue reference type, per C++11 [dcl.ref].
Definition: Type.h:2712
bool isMSTypeSpec() const
Definition: Type.cpp:3180
const ObjCObjectType * getAsObjCQualifiedInterfaceType() const
Definition: Type.cpp:1540
bool isCXX11PODType(const ASTContext &Context) const
Return true if this is a POD type according to the more relaxed rules of the C++11 standard...
Definition: Type.cpp:2379
Microsoft throw(...) extension.
A convenient class for passing around template argument information.
Definition: TemplateBase.h:552
ArrayRef< QualType > getTypeArgs() const
Retrieve the type arguments of this object type (semantically).
Definition: Type.cpp:656
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
Definition: Type.cpp:2196
bool hasAddressSpace() const
Definition: Type.h:355
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
Definition: Type.h:6639
The "struct" keyword introduces the elaborated-type-specifier.
Definition: Type.h:4933
static ElaboratedTypeKeyword getKeywordForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into an elaborated type keyword.
Definition: Type.cpp:2505
Whether values of this type can be null is (explicitly) unspecified.
const ObjCObjectPointerType * getAsObjCQualifiedClassType() const
Definition: Type.cpp:1564
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition: Type.h:1816
LangAS getAddressSpace() const
Definition: Type.h:356
const Type * getClass() const
Definition: Type.h:2764
CXXRecordDecl * getDecl() const
Definition: Type.cpp:3216
Values of this type can never be null.
Expr * getSizeExpr() const
Definition: Type.h:2965
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:5953
LinkageInfo getTypeLinkageAndVisibility(const Type *T)
Definition: Type.cpp:3643
static QualType simpleTransform(ASTContext &ctx, QualType type, F &&f)
Perform a simple type transformation that does not change the semantics of the type.
Definition: Type.cpp:1109
static unsigned getNumAddressingBits(const ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
Definition: Type.cpp:111
Defines the Linkage enumeration and various utility functions.
static TagDecl * getInterestingTagDecl(TagDecl *decl)
Definition: Type.cpp:3128
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type...
Definition: Decl.h:3247
unsigned Half
When true, print the half-precision floating-point type as &#39;half&#39; instead of &#39;__fp16&#39;.
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2056
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
Definition: Type.cpp:3802
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
Definition: Expr.h:166
bool isScalarType() const
Definition: Type.h:6489
void * getAsOpaquePtr() const
Definition: Type.h:687
Represents an ObjC class declaration.
Definition: DeclObjC.h:1164
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs, typeofs, etc., as well as any qualifiers.
Definition: Type.cpp:411
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface...
Definition: Type.h:5654
PrimitiveDefaultInitializeKind
Definition: Type.h:1081
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
Definition: Type.h:3657
SplitQualType getSplitDesugaredType() const
Definition: Type.h:946
QualType getPointeeTypeAsWritten() const
Definition: Type.h:2666
TagType(TypeClass TC, const TagDecl *D, QualType can)
Definition: Type.cpp:3121
unsigned getNumProtocols() const
Return the number of qualifying protocols in this type, or 0 if there are none.
Definition: Type.h:5327
QualType getElementType() const
Definition: Type.h:3118
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e.g., it is an unsigned integer type or a vector.
Definition: Type.cpp:1906
Represents an extended vector type where either the type or size is dependent.
Definition: Type.h:3102
This object can be modified without requiring retains or releases.
Definition: Type.h:162
CXXRecordDecl * getMostRecentNonInjectedDecl()
Definition: DeclCXX.h:754
Defines the clang::Visibility enumeration and various utility functions.
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
Definition: Type.cpp:1764
Represents a K&R-style &#39;int foo()&#39; function, which has no information available about its arguments...
Definition: Type.h:3515
Provides definitions for the various language-specific address spaces.
bool isSpecializedAsWritten() const
Determine whether this object type was written with type arguments.
Definition: Type.h:5513
bool hasAttr() const
Definition: DeclBase.h:537
QualType getBaseType() const
Gets the base type of this object type.
Definition: Type.h:5482
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
Definition: Type.cpp:1609
static void ensure(const Type *T)
Definition: Type.cpp:3421
bool acceptsObjCTypeParams() const
Determines if this is an ObjC interface type that may accept type parameters.
Definition: Type.cpp:1441
bool containsUnexpandedParameterPack() const
Determines whether this template name contains an unexpanded parameter pack (for C++0x variadic templ...
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
Definition: Type.cpp:2446
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Definition: Type.cpp:1605
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3550
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
Definition: DeclObjC.h:1557
static bool KeywordIsTagTypeKind(ElaboratedTypeKeyword Keyword)
Definition: Type.cpp:2558
QualType applyObjCProtocolQualifiers(QualType type, ArrayRef< ObjCProtocolDecl *> protocols, bool &hasError, bool allowOnPointerType=false) const
Apply Objective-C protocol qualifiers to the given type.
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
Definition: Type.cpp:473
IdentifierInfo * getNSObjectName() const
Retrieve the identifier &#39;NSObject&#39;.
Definition: ASTContext.h:1680
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition: Type.h:2792
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Definition: CharUnits.h:179
DependentTemplateSpecializationTypeBitfields DependentTemplateSpecializationTypeBits
Definition: Type.h:1706
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we&#39;re targeting...
PrimitiveCopyKind isNonTrivialToPrimitiveDestructiveMove() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
Definition: Type.cpp:2274
QualType getElementType() const
Definition: Type.h:2464
IdentifierInfo * getIdentifier() const
Definition: Type.cpp:3220
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorType::VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
This represents one expression.
Definition: Expr.h:105
Defines the clang::LangOptions interface.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition: Type.h:4949
bool isObjCARCImplicitlyUnretainedType() const
Determines if this type, which must satisfy isObjCLifetimeType(), is implicitly __unsafe_unretained r...
Definition: Type.cpp:3841
QualType desugar() const
Definition: Type.h:3185
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that the type refers to...
Definition: Type.cpp:1590
const IdentifierInfo * getBaseTypeIdentifier() const
Retrieves a pointer to the name of the base type.
Definition: Type.cpp:71
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:6653
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition: Type.h:4931
bool isObjCRetainableType() const
Definition: Type.cpp:3879
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
QualType getParenType(QualType NamedType) const
ObjCSubstitutionContext
The kind of type we are substituting Objective-C type arguments into.
Definition: Type.h:611
bool isChar16Type() const
Definition: Type.cpp:1801
const char * getTypeClassName() const
Definition: Type.cpp:2637
Linkage getLinkage() const
Definition: Visibility.h:84
ObjCLifetime getObjCLifetime() const
Definition: Type.h:330
DeclContext * getDeclContext()
Definition: DeclBase.h:427
bool isAnyComplexType() const
Definition: Type.h:6258
SourceLocation Begin
void Profile(llvm::FoldingSetNodeID &ID)
Definition: Type.h:4163
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
Definition: Type.cpp:2518
ObjCObjectType(QualType Canonical, QualType Base, ArrayRef< QualType > typeArgs, ArrayRef< ObjCProtocolDecl *> protocols, bool isKindOf)
Definition: Type.cpp:606
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
Definition: Type.cpp:1959
Represents a C++ template name within the type system.
Definition: TemplateName.h:178
Represents the type decltype(expr) (C++11).
Definition: Type.h:4129
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
Definition: Type.h:581
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
Definition: Type.cpp:1836
void Profile(llvm::FoldingSetNodeID &ID)
Definition: Type.h:3246
QualType desugar() const
Remove a single level of sugar.
Definition: Type.cpp:3067
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
QualType getType() const
Definition: Expr.h:127
bool isFunctionOrMethod() const
Definition: DeclBase.h:1806
static Optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it&#39;s there.
Definition: Type.cpp:3791
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
Definition: Type.cpp:1613
A unary type transform, which is a type constructed from another.
Definition: Type.h:4172
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
Qualifiers Quals
The local qualifiers.
Definition: Type.h:586
bool isSpecifierType() const
Returns true if this type can be represented by some set of type specifiers.
Definition: Type.cpp:2479
QualType substObjCMemberType(QualType objectType, const DeclContext *dc, ObjCSubstitutionContext context) const
Substitute type arguments from an object type for the Objective-C type parameters used in the subject...
Definition: Type.cpp:1320
#define TRIVIAL_TYPE_CLASS(Class)
Definition: Type.cpp:745
ScalarTypeKind
Definition: Type.h:2039
bool hasInstantiationDependentExceptionSpec() const
Return whether this function has an instantiation-dependent exception spec.
Definition: Type.cpp:2944
A helper class for Type nodes having an ElaboratedTypeKeyword.
Definition: Type.h:4959
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
Definition: ASTContext.h:1386
Represents a GCC generic vector type.
Definition: Type.h:3142
ArraySizeModifier getSizeModifier() const
Definition: Type.h:2823
An lvalue reference type, per C++11 [dcl.ref].
Definition: Type.h:2694
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
Definition: Type.h:4592
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
Definition: Type.h:6548
The result type of a method or function.
bool isUnionType() const
Definition: Type.cpp:467
bool isNull() const
Return true if this QualType doesn&#39;t point to a type yet.
Definition: Type.h:707
bool hasAutoForTrailingReturnType() const
Determine whether this type was written with a leading &#39;auto&#39; corresponding to a trailing return type...
Definition: Type.cpp:1720
bool isChar8Type() const
Definition: Type.cpp:1795
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:236
static LinkageInfo external()
Definition: Visibility.h:68
Expr * getUnderlyingExpr() const
Definition: Type.h:4068
bool isNonTrivialToPrimitiveDestroy() const
Definition: Decl.h:3685
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType)
bool isVoidPointerType() const
Definition: Type.cpp:461
bool isConstQualified() const
Determine whether this type is const-qualified.
Definition: Type.h:6012
IdentifierInfo * getNSCopyingName()
Retrieve the identifier &#39;NSCopying&#39;.
Definition: ASTContext.h:1689
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent) const
C++11 deduced auto type.
bool hasTrailingReturn() const
Definition: Type.h:3902
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
Definition: Type.h:5961
RecordDecl * getDecl() const
Definition: Type.h:4263
noexcept(expression), evals to &#39;false&#39;
bool isAlignValT() const
Definition: Type.cpp:2428
LinkageInfo getLinkageAndVisibility() const
Determine the linkage and visibility of this type.
Definition: Type.cpp:3652
unsigned Bool
Whether we can use &#39;bool&#39; rather than &#39;_Bool&#39; (even if the language doesn&#39;t actually have &#39;bool&#39;...
bool isStructureOrClassType() const
Definition: Type.cpp:453
A template template parameter pack that has been substituted for a template template argument pack...
Definition: TemplateName.h:211
CanThrowResult
Possible results from evaluation of a noexcept expression.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
There is no lifetime qualification on this type.
Definition: Type.h:158
bool containsUnexpandedParameterPack() const
Whether this nested-name-specifier contains an unexpanded parameter pack (for C++11 variadic template...
#define false
Definition: stdbool.h:33
The "struct" keyword.
Definition: Type.h:4914
Assigning into this object requires the old value to be released and the new value to be retained...
Definition: Type.h:169
Kind
QualType getCanonicalType() const
Definition: Type.h:5992
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition: Type.h:3647
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
Definition: Expr.h:190
bool isSpecialized() const
Determine whether this object type is "specialized", meaning that it has type arguments.
Definition: Type.cpp:638
ExtProtoInfo getExtProtoInfo() const
Definition: Type.h:3797
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Definition: Redeclarable.h:295
const ExtParameterInfo * ExtParameterInfos
Definition: Type.h:3676
Encodes a location in the source.
Sugar for parentheses used when specifying types.
Definition: Type.h:2481
QualType getAdjustedType() const
Definition: Type.h:2576
QualType getReturnType() const
Definition: Type.h:3483
bool isLinkageValid() const
True if the computed linkage is valid.
Definition: Type.cpp:3633
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Definition: Type.h:4279
bool mayBeNotDynamicClass() const
Returns true if it is not a class or if the class might not be dynamic.
Definition: Type.cpp:96
LangAS getAddressSpace() const
Return the address space of this type.
Definition: Type.h:6069
Interfaces are the core concept in Objective-C for object oriented design.
Definition: Type.h:5619
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
Definition: Type.h:2072
const ComplexType * getAsComplexIntegerType() const
Definition: Type.cpp:490
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
Definition: Type.cpp:2278
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3041
TemplateArgument getArgumentPack() const
Definition: Type.cpp:3233
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:376
QualType getElementType() const
Definition: Type.h:3177
void FixedPointValueToString(SmallVectorImpl< char > &Str, llvm::APSInt Val, unsigned Scale)
Definition: Type.cpp:3975
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
Definition: Type.cpp:1751
QualType getLocallyUnqualifiedSingleStepDesugaredType() const
Pull a single level of sugar off of this locally-unqualified type.
Definition: Type.cpp:294
void initialize(ArrayRef< ObjCProtocolDecl * > protocols)
Definition: Type.h:5306
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2272
unsigned pack_size() const
The number of template arguments in the given template argument pack.
Definition: TemplateBase.h:360
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
Definition: Type.cpp:1852
QualType getEquivalentType() const
Definition: Type.h:4334
void Profile(llvm::FoldingSetNodeID &ID)
Definition: TemplateName.h:305
QualType getInnerType() const
Definition: Type.h:2494
bool isObjCObjectPointerType() const
Definition: Type.h:6274
AutoTypeKeyword getKeyword() const
Definition: Type.h:4647
TypeClass getTypeClass() const
Definition: Type.h:1796
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
Definition: Type.cpp:1815
PrimitiveCopyKind isNonTrivialToPrimitiveCopy() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
Definition: Type.cpp:2256
QualType getSuperClassType() const
Retrieve the type of the superclass of this object type.
Definition: Type.h:5547
EnumDecl * getDecl() const
Definition: Type.h:4286
bool isVectorType() const
Definition: Type.h:6262
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
bool hasConstFields() const
Recursively check all fields in the record for const-ness.
Definition: Type.cpp:3145
Assigning into this object requires a lifetime extension.
Definition: Type.h:175
TemplateSpecializationTypeBitfields TemplateSpecializationTypeBits
Definition: Type.h:1704
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
Converts an elaborated type keyword into a TagTypeKind.
Definition: Type.cpp:2543
void setVariablyModified(bool VM=true)
Definition: Type.h:1783
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
TypeOfExprType(Expr *E, QualType can=QualType())
Definition: Type.cpp:3056
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
Definition: Type.h:2062
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
Definition: Decl.cpp:1062
Represents a pointer type decayed from an array or function type.
Definition: Type.h:2596
Represents a pack expansion of types.
Definition: Type.h:5236
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Definition: TemplateBase.h:354
Defines various enumerations that describe declaration and type specifiers.
bool isRealType() const
Definition: Type.cpp:1935
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array&#39;s size can require, which limits the maximu...
Definition: Type.cpp:146
Linkage minLinkage(Linkage L1, Linkage L2)
Compute the minimum linkage given two linkages.
Definition: Linkage.h:115
CXXRecordDecl * getMostRecentCXXRecordDecl() const
Definition: Type.cpp:3971
Represents a template argument.
Definition: TemplateBase.h:51
bool isDeduced() const
Definition: Type.h:4621
bool isScopedEnumeralType() const
Determine whether this type is a scoped enumeration type.
Definition: Type.cpp:484
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons...
Definition: Type.h:2559
TagTypeKind
The kind of a tag type.
Definition: Type.h:4912
Optional< types::ID > Type
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
CanQualType ObjCBuiltinIdTy
Definition: ASTContext.h:1057
GC getObjCGCAttr() const
Definition: Type.h:309
Dataflow Directional Tag Classes.
bool isObjCQualifiedInterfaceType() const
Definition: Type.cpp:1550
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type...
Definition: Type.cpp:1715
ExtInfo getExtInfo() const
Definition: Type.h:3494
not evaluated yet, for special member function
A qualifier set is used to build a set of qualifiers.
Definition: Type.h:5920
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1268
void setContainsUnexpandedParameterPack(bool PP=true)
Definition: Type.h:1785
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:399
bool hasUnnamedOrLocalType() const
Whether this type is or contains a local or unnamed type.
Definition: Type.cpp:3555
static CachedProperties get(QualType T)
Definition: Type.cpp:3411
bool hasDependentExceptionSpec() const
Return whether this function has a dependent exception spec.
Definition: Type.cpp:2932
bool isCXX98PODType(const ASTContext &Context) const
Return true if this is a POD type according to the rules of the C++98 standard, regardless of the cur...
Definition: Type.cpp:2100
QualType getUnderlyingType() const
Definition: Decl.h:2948
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
QualType stripObjCKindOfType(const ASTContext &ctx) const
Strip Objective-C "__kindof" types from the given type.
Definition: Type.cpp:1329
QualType getUnderlyingType() const
Definition: Type.h:4140
const Type * getArrayElementTypeNoTypeQual() const
If this is an array type, return the element type of the array, potentially with type qualifiers miss...
Definition: Type.cpp:261
void Profile(llvm::FoldingSetNodeID &ID)
Definition: Type.cpp:3360
VectorKind getVectorKind() const
Definition: Type.h:3187
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:551
The "union" keyword introduces the elaborated-type-specifier.
Definition: Type.h:4939
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
Definition: Type.h:5927
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like &#39;int()&#39;.
void Profile(llvm::FoldingSetNodeID &ID)
Definition: Type.h:3128
void Profile(llvm::FoldingSetNodeID &ID)
Definition: Type.cpp:3375
bool isObjCIndirectLifetimeType() const
Definition: Type.cpp:3885
The "class" keyword introduces the elaborated-type-specifier.
Definition: Type.h:4942
bool isKindOfType() const
Whether this ia a "__kindof" type (semantically).
Definition: Type.cpp:674
static const T * getAsSugar(const Type *Cur)
This will check for a T (which should be a Type which can act as sugar, such as a TypedefType) by rem...
Definition: Type.cpp:378
Represents an enum.
Definition: Decl.h:3303
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2730
bool hasObjCLifetime() const
Definition: Type.h:329
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type. ...
Definition: Type.cpp:1998
bool isQualifier() const
Does this attribute behave like a type qualifier?
Definition: Type.cpp:3158
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Definition: TemplateBase.h:580
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
Definition: Type.cpp:3330
UnaryTransformType(QualType BaseTy, QualType UnderlyingTy, UTTKind UKind, QualType CanonicalTy)
Definition: Type.cpp:3106
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
Definition: TemplateBase.h:340
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
Definition: Type.h:4501
void addConsistentQualifiers(Qualifiers qs)
Add the qualifiers from the given set to this set, given that they don&#39;t conflict.
Definition: Type.h:456
QualType getModifiedType() const
Definition: Type.h:4333
Represents a pointer to an Objective C object.
Definition: Type.h:5675
Pointer to a block type.
Definition: Type.h:2613
bool isSugared() const
Returns whether this type directly provides sugar.
Definition: Type.cpp:3063
FunctionTypeBitfields FunctionTypeBits
Definition: Type.h:1697
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4253
Complex values, per C99 6.2.5p11.
Definition: Type.h:2451
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:450
unsigned getIndexTypeCVRQualifiers() const
Definition: Type.h:2831
bool empty() const
Definition: Type.h:418
bool isConstantSizeType() const
Return true if this is not a variable sized type, according to the rules of C99 6.7.5p3.
Definition: Type.cpp:2012
QualType getCanonicalTypeInternal() const
Definition: Type.h:2332
QualType getAtomicUnqualifiedType() const
Remove all qualifiers including _Atomic.
Definition: Type.cpp:1353
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
Definition: Type.h:6438
CanThrowResult canThrow() const
Determine whether this function type has a non-throwing exception specification.
Definition: Type.cpp:2953
const llvm::APInt & getSize() const
Definition: Type.h:2864
Kind getAttrKind() const
Definition: Type.h:4329
VectorTypeBitfields VectorTypeBits
Definition: Type.h:1702
ExtVectorType - Extended vector type.
Definition: Type.h:3261
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2647
SourceRange getBracketsRange() const
Definition: Type.h:2971
The template argument is a type.
Definition: TemplateBase.h:60
Optional< ArrayRef< QualType > > getObjCSubstitutions(const DeclContext *dc) const
Retrieve the set of substitutions required when accessing a member of the Objective-C receiver type t...
Definition: Type.cpp:1359
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
Definition: Type.cpp:3657
The "class" keyword.
Definition: Type.h:4923
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
Definition: Type.cpp:2793
bool isBeingDefined() const
Determines whether this type is in the process of being defined.
Definition: Type.cpp:3141
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Definition: ASTContext.h:2076
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition: Type.h:3650
void merge(LinkageInfo other)
Merge both linkage and visibility.
Definition: Visibility.h:133
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
Definition: Type.cpp:2022
bool hasObjCGCAttr() const
Definition: Type.h:308
The type-property cache.
Definition: Type.cpp:3409
bool isClassType() const
Definition: Type.cpp:429
TypedefNameDecl * getDecl() const
Definition: Type.h:4050
TypeBitfields TypeBits
Definition: Type.h:1692
Reading or writing from this object requires a barrier call.
Definition: Type.h:172
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition: Type.h:3653
An attributed type is a type to which a type attribute has been applied.
Definition: Type.h:4308
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g., it is an signed integer type or a vector.
Definition: Type.cpp:1866
Represents a C++ struct/union/class.
Definition: DeclCXX.h:300
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
bool isVoidType() const
Definition: Type.h:6404
Represents a C array with an unspecified size.
Definition: Type.h:2900
QualType stripObjCKindOfTypeAndQuals(const ASTContext &ctx) const
Strip off the Objective-C "kindof" type and (with it) any protocol qualifiers.
Definition: Type.cpp:691
bool hasIntegerRepresentation() const
Determine whether this type has an integer representation of some sort, e.g., it is an integer type o...
Definition: Type.cpp:1725
The parameter type of a method or function.
QualType getNamedType() const
Retrieve the type named by the qualified-id.
Definition: Type.h:5050
QualType getReplacementType() const
Gets the type that was substituted for the template parameter.
Definition: Type.h:4507
The "enum" keyword.
Definition: Type.h:4926
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
Definition: Expr.h:213
void Profile(llvm::FoldingSetNodeID &ID)
Definition: Type.h:4093
Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const
Return the implicit lifetime for this type, which must not be dependent.
Definition: Type.cpp:3835
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Definition: DeclObjC.h:629
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
This class is used for builtin types like &#39;int&#39;.
Definition: Type.h:2368
Defines the clang::TargetInfo interface.
bool isComplexIntegerType() const
Definition: Type.cpp:479
ASTContext & getParentASTContext() const
Definition: DeclBase.h:1787
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
Definition: TargetCXXABI.h:154
bool hasVolatile() const
Definition: Type.h:265
__DEVICE__ int max(int __a, int __b)
NameKind getKind() const
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:930
unsigned getNumElements() const
Definition: Type.h:3178
QualType getSuperClassType() const
Retrieve the type of the superclass of this object pointer type.
Definition: Type.cpp:1531
void initialize(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema)
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:2056
bool mayBeDynamicClass() const
Returns true if it is a class and it might be dynamic.
Definition: Type.cpp:91
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:4724
bool isPointerType() const
Definition: Type.h:6177
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
static StringRef getNameForCallConv(CallingConv CC)
Definition: Type.cpp:2809
#define true
Definition: stdbool.h:32
bool isFloatingType() const
Definition: Type.cpp:1913
A trivial tuple used to represent a source range.
VectorType(QualType vecType, unsigned nElements, QualType canonType, VectorKind vecKind)
Definition: Type.cpp:243
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: Decl.cpp:2947
void computeSuperClassTypeSlow() const
Definition: Type.cpp:1452
This represents a decl that may have a name.
Definition: Decl.h:248
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
Represents a C array with a specified size that is not an integer-constant-expression.
Definition: Type.h:2945
No keyword precedes the qualified type name.
Definition: Type.h:4952
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a variable array of the specified element type...
bool isConstant(const ASTContext &Ctx) const
Definition: Type.h:777
bool isInterfaceType() const
Definition: Type.cpp:447
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Definition: Type.h:5198
QualType desugar() const
Definition: Type.cpp:3052
const LangOptions & getLangOpts() const
Definition: ASTContext.h:716
unsigned size() const
Determine the number of type parameters in this list.
Definition: DeclObjC.h:669
llvm::Optional< NullabilityKind > getImmediateNullability() const
Definition: Type.cpp:3781
The "__interface" keyword introduces the elaborated-type-specifier.
Definition: Type.h:4936
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:2846
ExceptionSpecInfo ExceptionSpec
Definition: Type.h:3675
QualType getAdjustedType(QualType Orig, QualType New) const
Return the uniqued reference to a type adjusted from the original type to a new type.
bool isObjCNSObjectType() const
Definition: Type.cpp:3860
bool hasSizedVLAType() const
Whether this type involves a variable-length array type with a definite size.
Definition: Type.cpp:3922
QualType getPointeeType() const
Definition: Type.h:2750
A single template declaration.
Definition: TemplateName.h:191
bool isBeingDefined() const
Return true if this decl is currently being defined.
Definition: Decl.h:3166
static QualType getParamType(Sema &SemaRef, ArrayRef< ResultCandidate > Candidates, unsigned N)
Get the type of the Nth parameter from a given set of overload candidates.
noexcept(expression), evals to &#39;true&#39;
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type...
QualType getIncompleteArrayType(QualType EltTy, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
Definition: Type.h:1066
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
Definition: Type.h:5691