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 /// Was this type written with the special inert-in-MRC __unsafe_unretained
596 /// qualifier?
597 ///
598 /// This approximates the answer to the following question: if this
599 /// translation unit were compiled in ARC, would this type be qualified
600 /// with __unsafe_unretained?
602  const Type *cur = this;
603  while (true) {
604  if (const auto attributed = dyn_cast<AttributedType>(cur)) {
605  if (attributed->getAttrKind() ==
607  return true;
608  }
609 
610  // Single-step desugar until we run out of sugar.
612  if (next.getTypePtr() == cur) return false;
613  cur = next.getTypePtr();
614  }
615 }
616 
617 ObjCTypeParamType::ObjCTypeParamType(const ObjCTypeParamDecl *D,
618  QualType can,
620  : Type(ObjCTypeParam, can, can->isDependentType(),
622  can->isVariablyModifiedType(),
623  /*ContainsUnexpandedParameterPack=*/false),
624  OTPDecl(const_cast<ObjCTypeParamDecl*>(D)) {
625  initialize(protocols);
626 }
627 
629  ArrayRef<QualType> typeArgs,
631  bool isKindOf)
632  : Type(ObjCObject, Canonical, Base->isDependentType(),
634  Base->isVariablyModifiedType(),
636  BaseType(Base) {
637  ObjCObjectTypeBits.IsKindOf = isKindOf;
638 
639  ObjCObjectTypeBits.NumTypeArgs = typeArgs.size();
640  assert(getTypeArgsAsWritten().size() == typeArgs.size() &&
641  "bitfield overflow in type argument count");
642  if (!typeArgs.empty())
643  memcpy(getTypeArgStorage(), typeArgs.data(),
644  typeArgs.size() * sizeof(QualType));
645 
646  for (auto typeArg : typeArgs) {
647  if (typeArg->isDependentType())
648  setDependent();
649  else if (typeArg->isInstantiationDependentType())
651 
652  if (typeArg->containsUnexpandedParameterPack())
654  }
655  // Initialize the protocol qualifiers. The protocol storage is known
656  // after we set number of type arguments.
657  initialize(protocols);
658 }
659 
661  // If we have type arguments written here, the type is specialized.
662  if (ObjCObjectTypeBits.NumTypeArgs > 0)
663  return true;
664 
665  // Otherwise, check whether the base type is specialized.
666  if (const auto objcObject = getBaseType()->getAs<ObjCObjectType>()) {
667  // Terminate when we reach an interface type.
668  if (isa<ObjCInterfaceType>(objcObject))
669  return false;
670 
671  return objcObject->isSpecialized();
672  }
673 
674  // Not specialized.
675  return false;
676 }
677 
679  // We have type arguments written on this type.
681  return getTypeArgsAsWritten();
682 
683  // Look at the base type, which might have type arguments.
684  if (const auto objcObject = getBaseType()->getAs<ObjCObjectType>()) {
685  // Terminate when we reach an interface type.
686  if (isa<ObjCInterfaceType>(objcObject))
687  return {};
688 
689  return objcObject->getTypeArgs();
690  }
691 
692  // No type arguments.
693  return {};
694 }
695 
697  if (isKindOfTypeAsWritten())
698  return true;
699 
700  // Look at the base type, which might have type arguments.
701  if (const auto objcObject = getBaseType()->getAs<ObjCObjectType>()) {
702  // Terminate when we reach an interface type.
703  if (isa<ObjCInterfaceType>(objcObject))
704  return false;
705 
706  return objcObject->isKindOfType();
707  }
708 
709  // Not a "__kindof" type.
710  return false;
711 }
712 
714  const ASTContext &ctx) const {
715  if (!isKindOfType() && qual_empty())
716  return QualType(this, 0);
717 
718  // Recursively strip __kindof.
719  SplitQualType splitBaseType = getBaseType().split();
720  QualType baseType(splitBaseType.Ty, 0);
721  if (const auto *baseObj = splitBaseType.Ty->getAs<ObjCObjectType>())
722  baseType = baseObj->stripObjCKindOfTypeAndQuals(ctx);
723 
724  return ctx.getObjCObjectType(ctx.getQualifiedType(baseType,
725  splitBaseType.Quals),
727  /*protocols=*/{},
728  /*isKindOf=*/false);
729 }
730 
732  const ASTContext &ctx) const {
733  if (!isKindOfType() && qual_empty())
734  return this;
735 
736  QualType obj = getObjectType()->stripObjCKindOfTypeAndQuals(ctx);
738 }
739 
740 template<typename F>
741 static QualType simpleTransform(ASTContext &ctx, QualType type, F &&f);
742 
743 namespace {
744 
745 /// Visitor used by simpleTransform() to perform the transformation.
746 template<typename F>
747 struct SimpleTransformVisitor
748  : public TypeVisitor<SimpleTransformVisitor<F>, QualType> {
749  ASTContext &Ctx;
750  F &&TheFunc;
751 
752  QualType recurse(QualType type) {
753  return simpleTransform(Ctx, type, std::move(TheFunc));
754  }
755 
756 public:
757  SimpleTransformVisitor(ASTContext &ctx, F &&f)
758  : Ctx(ctx), TheFunc(std::move(f)) {}
759 
760  // None of the clients of this transformation can occur where
761  // there are dependent types, so skip dependent types.
762 #define TYPE(Class, Base)
763 #define DEPENDENT_TYPE(Class, Base) \
764  QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
765 #include "clang/AST/TypeNodes.def"
766 
767 #define TRIVIAL_TYPE_CLASS(Class) \
768  QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
769 
770  TRIVIAL_TYPE_CLASS(Builtin)
771 
772  QualType VisitComplexType(const ComplexType *T) {
773  QualType elementType = recurse(T->getElementType());
774  if (elementType.isNull())
775  return {};
776 
777  if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
778  return QualType(T, 0);
779 
780  return Ctx.getComplexType(elementType);
781  }
782 
783  QualType VisitPointerType(const PointerType *T) {
784  QualType pointeeType = recurse(T->getPointeeType());
785  if (pointeeType.isNull())
786  return {};
787 
788  if (pointeeType.getAsOpaquePtr() == T->getPointeeType().getAsOpaquePtr())
789  return QualType(T, 0);
790 
791  return Ctx.getPointerType(pointeeType);
792  }
793 
794  QualType VisitBlockPointerType(const BlockPointerType *T) {
795  QualType pointeeType = recurse(T->getPointeeType());
796  if (pointeeType.isNull())
797  return {};
798 
799  if (pointeeType.getAsOpaquePtr() == T->getPointeeType().getAsOpaquePtr())
800  return QualType(T, 0);
801 
802  return Ctx.getBlockPointerType(pointeeType);
803  }
804 
805  QualType VisitLValueReferenceType(const LValueReferenceType *T) {
806  QualType pointeeType = recurse(T->getPointeeTypeAsWritten());
807  if (pointeeType.isNull())
808  return {};
809 
810  if (pointeeType.getAsOpaquePtr()
812  return QualType(T, 0);
813 
814  return Ctx.getLValueReferenceType(pointeeType, T->isSpelledAsLValue());
815  }
816 
817  QualType VisitRValueReferenceType(const RValueReferenceType *T) {
818  QualType pointeeType = recurse(T->getPointeeTypeAsWritten());
819  if (pointeeType.isNull())
820  return {};
821 
822  if (pointeeType.getAsOpaquePtr()
824  return QualType(T, 0);
825 
826  return Ctx.getRValueReferenceType(pointeeType);
827  }
828 
829  QualType VisitMemberPointerType(const MemberPointerType *T) {
830  QualType pointeeType = recurse(T->getPointeeType());
831  if (pointeeType.isNull())
832  return {};
833 
834  if (pointeeType.getAsOpaquePtr() == T->getPointeeType().getAsOpaquePtr())
835  return QualType(T, 0);
836 
837  return Ctx.getMemberPointerType(pointeeType, T->getClass());
838  }
839 
840  QualType VisitConstantArrayType(const ConstantArrayType *T) {
841  QualType elementType = recurse(T->getElementType());
842  if (elementType.isNull())
843  return {};
844 
845  if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
846  return QualType(T, 0);
847 
848  return Ctx.getConstantArrayType(elementType, T->getSize(),
849  T->getSizeModifier(),
851  }
852 
853  QualType VisitVariableArrayType(const VariableArrayType *T) {
854  QualType elementType = recurse(T->getElementType());
855  if (elementType.isNull())
856  return {};
857 
858  if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
859  return QualType(T, 0);
860 
861  return Ctx.getVariableArrayType(elementType, T->getSizeExpr(),
862  T->getSizeModifier(),
864  T->getBracketsRange());
865  }
866 
867  QualType VisitIncompleteArrayType(const IncompleteArrayType *T) {
868  QualType elementType = recurse(T->getElementType());
869  if (elementType.isNull())
870  return {};
871 
872  if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
873  return QualType(T, 0);
874 
875  return Ctx.getIncompleteArrayType(elementType, T->getSizeModifier(),
877  }
878 
879  QualType VisitVectorType(const VectorType *T) {
880  QualType elementType = recurse(T->getElementType());
881  if (elementType.isNull())
882  return {};
883 
884  if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
885  return QualType(T, 0);
886 
887  return Ctx.getVectorType(elementType, T->getNumElements(),
888  T->getVectorKind());
889  }
890 
891  QualType VisitExtVectorType(const ExtVectorType *T) {
892  QualType elementType = recurse(T->getElementType());
893  if (elementType.isNull())
894  return {};
895 
896  if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
897  return QualType(T, 0);
898 
899  return Ctx.getExtVectorType(elementType, T->getNumElements());
900  }
901 
902  QualType VisitFunctionNoProtoType(const FunctionNoProtoType *T) {
903  QualType returnType = recurse(T->getReturnType());
904  if (returnType.isNull())
905  return {};
906 
907  if (returnType.getAsOpaquePtr() == T->getReturnType().getAsOpaquePtr())
908  return QualType(T, 0);
909 
910  return Ctx.getFunctionNoProtoType(returnType, T->getExtInfo());
911  }
912 
913  QualType VisitFunctionProtoType(const FunctionProtoType *T) {
914  QualType returnType = recurse(T->getReturnType());
915  if (returnType.isNull())
916  return {};
917 
918  // Transform parameter types.
919  SmallVector<QualType, 4> paramTypes;
920  bool paramChanged = false;
921  for (auto paramType : T->getParamTypes()) {
922  QualType newParamType = recurse(paramType);
923  if (newParamType.isNull())
924  return {};
925 
926  if (newParamType.getAsOpaquePtr() != paramType.getAsOpaquePtr())
927  paramChanged = true;
928 
929  paramTypes.push_back(newParamType);
930  }
931 
932  // Transform extended info.
934  bool exceptionChanged = false;
935  if (info.ExceptionSpec.Type == EST_Dynamic) {
936  SmallVector<QualType, 4> exceptionTypes;
937  for (auto exceptionType : info.ExceptionSpec.Exceptions) {
938  QualType newExceptionType = recurse(exceptionType);
939  if (newExceptionType.isNull())
940  return {};
941 
942  if (newExceptionType.getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
943  exceptionChanged = true;
944 
945  exceptionTypes.push_back(newExceptionType);
946  }
947 
948  if (exceptionChanged) {
950  llvm::makeArrayRef(exceptionTypes).copy(Ctx);
951  }
952  }
953 
954  if (returnType.getAsOpaquePtr() == T->getReturnType().getAsOpaquePtr() &&
955  !paramChanged && !exceptionChanged)
956  return QualType(T, 0);
957 
958  return Ctx.getFunctionType(returnType, paramTypes, info);
959  }
960 
961  QualType VisitParenType(const ParenType *T) {
962  QualType innerType = recurse(T->getInnerType());
963  if (innerType.isNull())
964  return {};
965 
966  if (innerType.getAsOpaquePtr() == T->getInnerType().getAsOpaquePtr())
967  return QualType(T, 0);
968 
969  return Ctx.getParenType(innerType);
970  }
971 
972  TRIVIAL_TYPE_CLASS(Typedef)
973  TRIVIAL_TYPE_CLASS(ObjCTypeParam)
974 
975  QualType VisitAdjustedType(const AdjustedType *T) {
976  QualType originalType = recurse(T->getOriginalType());
977  if (originalType.isNull())
978  return {};
979 
980  QualType adjustedType = recurse(T->getAdjustedType());
981  if (adjustedType.isNull())
982  return {};
983 
984  if (originalType.getAsOpaquePtr()
985  == T->getOriginalType().getAsOpaquePtr() &&
986  adjustedType.getAsOpaquePtr() == T->getAdjustedType().getAsOpaquePtr())
987  return QualType(T, 0);
988 
989  return Ctx.getAdjustedType(originalType, adjustedType);
990  }
991 
992  QualType VisitDecayedType(const DecayedType *T) {
993  QualType originalType = recurse(T->getOriginalType());
994  if (originalType.isNull())
995  return {};
996 
997  if (originalType.getAsOpaquePtr()
999  return QualType(T, 0);
1000 
1001  return Ctx.getDecayedType(originalType);
1002  }
1003 
1004  TRIVIAL_TYPE_CLASS(TypeOfExpr)
1005  TRIVIAL_TYPE_CLASS(TypeOf)
1006  TRIVIAL_TYPE_CLASS(Decltype)
1007  TRIVIAL_TYPE_CLASS(UnaryTransform)
1008  TRIVIAL_TYPE_CLASS(Record)
1009  TRIVIAL_TYPE_CLASS(Enum)
1010 
1011  // FIXME: Non-trivial to implement, but important for C++
1012  TRIVIAL_TYPE_CLASS(Elaborated)
1013 
1014  QualType VisitAttributedType(const AttributedType *T) {
1015  QualType modifiedType = recurse(T->getModifiedType());
1016  if (modifiedType.isNull())
1017  return {};
1018 
1019  QualType equivalentType = recurse(T->getEquivalentType());
1020  if (equivalentType.isNull())
1021  return {};
1022 
1023  if (modifiedType.getAsOpaquePtr()
1024  == T->getModifiedType().getAsOpaquePtr() &&
1025  equivalentType.getAsOpaquePtr()
1027  return QualType(T, 0);
1028 
1029  return Ctx.getAttributedType(T->getAttrKind(), modifiedType,
1030  equivalentType);
1031  }
1032 
1033  QualType VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T) {
1034  QualType replacementType = recurse(T->getReplacementType());
1035  if (replacementType.isNull())
1036  return {};
1037 
1038  if (replacementType.getAsOpaquePtr()
1040  return QualType(T, 0);
1041 
1043  replacementType);
1044  }
1045 
1046  // FIXME: Non-trivial to implement, but important for C++
1047  TRIVIAL_TYPE_CLASS(TemplateSpecialization)
1048 
1049  QualType VisitAutoType(const AutoType *T) {
1050  if (!T->isDeduced())
1051  return QualType(T, 0);
1052 
1053  QualType deducedType = recurse(T->getDeducedType());
1054  if (deducedType.isNull())
1055  return {};
1056 
1057  if (deducedType.getAsOpaquePtr()
1058  == T->getDeducedType().getAsOpaquePtr())
1059  return QualType(T, 0);
1060 
1061  return Ctx.getAutoType(deducedType, T->getKeyword(),
1062  T->isDependentType());
1063  }
1064 
1065  // FIXME: Non-trivial to implement, but important for C++
1066  TRIVIAL_TYPE_CLASS(PackExpansion)
1067 
1068  QualType VisitObjCObjectType(const ObjCObjectType *T) {
1069  QualType baseType = recurse(T->getBaseType());
1070  if (baseType.isNull())
1071  return {};
1072 
1073  // Transform type arguments.
1074  bool typeArgChanged = false;
1075  SmallVector<QualType, 4> typeArgs;
1076  for (auto typeArg : T->getTypeArgsAsWritten()) {
1077  QualType newTypeArg = recurse(typeArg);
1078  if (newTypeArg.isNull())
1079  return {};
1080 
1081  if (newTypeArg.getAsOpaquePtr() != typeArg.getAsOpaquePtr())
1082  typeArgChanged = true;
1083 
1084  typeArgs.push_back(newTypeArg);
1085  }
1086 
1087  if (baseType.getAsOpaquePtr() == T->getBaseType().getAsOpaquePtr() &&
1088  !typeArgChanged)
1089  return QualType(T, 0);
1090 
1091  return Ctx.getObjCObjectType(baseType, typeArgs,
1092  llvm::makeArrayRef(T->qual_begin(),
1093  T->getNumProtocols()),
1094  T->isKindOfTypeAsWritten());
1095  }
1096 
1097  TRIVIAL_TYPE_CLASS(ObjCInterface)
1098 
1099  QualType VisitObjCObjectPointerType(const ObjCObjectPointerType *T) {
1100  QualType pointeeType = recurse(T->getPointeeType());
1101  if (pointeeType.isNull())
1102  return {};
1103 
1104  if (pointeeType.getAsOpaquePtr()
1105  == T->getPointeeType().getAsOpaquePtr())
1106  return QualType(T, 0);
1107 
1108  return Ctx.getObjCObjectPointerType(pointeeType);
1109  }
1110 
1111  QualType VisitAtomicType(const AtomicType *T) {
1112  QualType valueType = recurse(T->getValueType());
1113  if (valueType.isNull())
1114  return {};
1115 
1116  if (valueType.getAsOpaquePtr()
1117  == T->getValueType().getAsOpaquePtr())
1118  return QualType(T, 0);
1119 
1120  return Ctx.getAtomicType(valueType);
1121  }
1122 
1123 #undef TRIVIAL_TYPE_CLASS
1124 };
1125 
1126 } // namespace
1127 
1128 /// Perform a simple type transformation that does not change the
1129 /// semantics of the type.
1130 template<typename F>
1131 static QualType simpleTransform(ASTContext &ctx, QualType type, F &&f) {
1132  // Transform the type. If it changed, return the transformed result.
1133  QualType transformed = f(type);
1134  if (transformed.getAsOpaquePtr() != type.getAsOpaquePtr())
1135  return transformed;
1136 
1137  // Split out the qualifiers from the type.
1138  SplitQualType splitType = type.split();
1139 
1140  // Visit the type itself.
1141  SimpleTransformVisitor<F> visitor(ctx, std::forward<F>(f));
1142  QualType result = visitor.Visit(splitType.Ty);
1143  if (result.isNull())
1144  return result;
1145 
1146  // Reconstruct the transformed type by applying the local qualifiers
1147  // from the split type.
1148  return ctx.getQualifiedType(result, splitType.Quals);
1149 }
1150 
1151 /// Substitute the given type arguments for Objective-C type
1152 /// parameters within the given type, recursively.
1154  ASTContext &ctx,
1155  ArrayRef<QualType> typeArgs,
1156  ObjCSubstitutionContext context) const {
1157  return simpleTransform(ctx, *this,
1158  [&](QualType type) -> QualType {
1159  SplitQualType splitType = type.split();
1160 
1161  // Replace an Objective-C type parameter reference with the corresponding
1162  // type argument.
1163  if (const auto *OTPTy = dyn_cast<ObjCTypeParamType>(splitType.Ty)) {
1164  ObjCTypeParamDecl *typeParam = OTPTy->getDecl();
1165  // If we have type arguments, use them.
1166  if (!typeArgs.empty()) {
1167  QualType argType = typeArgs[typeParam->getIndex()];
1168  if (OTPTy->qual_empty())
1169  return ctx.getQualifiedType(argType, splitType.Quals);
1170 
1171  // Apply protocol lists if exists.
1172  bool hasError;
1173  SmallVector<ObjCProtocolDecl*, 8> protocolsVec;
1174  protocolsVec.append(OTPTy->qual_begin(),
1175  OTPTy->qual_end());
1176  ArrayRef<ObjCProtocolDecl *> protocolsToApply = protocolsVec;
1177  QualType resultTy = ctx.applyObjCProtocolQualifiers(argType,
1178  protocolsToApply, hasError, true/*allowOnPointerType*/);
1179 
1180  return ctx.getQualifiedType(resultTy, splitType.Quals);
1181  }
1182 
1183  switch (context) {
1187  // Substitute the bound.
1188  return ctx.getQualifiedType(typeParam->getUnderlyingType(),
1189  splitType.Quals);
1190 
1193  // Substitute the __kindof form of the underlying type.
1194  const auto *objPtr = typeParam->getUnderlyingType()
1196 
1197  // __kindof types, id, and Class don't need an additional
1198  // __kindof.
1199  if (objPtr->isKindOfType() || objPtr->isObjCIdOrClassType())
1200  return ctx.getQualifiedType(typeParam->getUnderlyingType(),
1201  splitType.Quals);
1202 
1203  // Add __kindof.
1204  const auto *obj = objPtr->getObjectType();
1205  QualType resultTy = ctx.getObjCObjectType(obj->getBaseType(),
1206  obj->getTypeArgsAsWritten(),
1207  obj->getProtocols(),
1208  /*isKindOf=*/true);
1209 
1210  // Rebuild object pointer type.
1211  resultTy = ctx.getObjCObjectPointerType(resultTy);
1212  return ctx.getQualifiedType(resultTy, splitType.Quals);
1213  }
1214  }
1215  }
1216 
1217  // If we have a function type, update the context appropriately.
1218  if (const auto *funcType = dyn_cast<FunctionType>(splitType.Ty)) {
1219  // Substitute result type.
1220  QualType returnType = funcType->getReturnType().substObjCTypeArgs(
1221  ctx,
1222  typeArgs,
1224  if (returnType.isNull())
1225  return {};
1226 
1227  // Handle non-prototyped functions, which only substitute into the result
1228  // type.
1229  if (isa<FunctionNoProtoType>(funcType)) {
1230  // If the return type was unchanged, do nothing.
1231  if (returnType.getAsOpaquePtr()
1232  == funcType->getReturnType().getAsOpaquePtr())
1233  return type;
1234 
1235  // Otherwise, build a new type.
1236  return ctx.getFunctionNoProtoType(returnType, funcType->getExtInfo());
1237  }
1238 
1239  const auto *funcProtoType = cast<FunctionProtoType>(funcType);
1240 
1241  // Transform parameter types.
1242  SmallVector<QualType, 4> paramTypes;
1243  bool paramChanged = false;
1244  for (auto paramType : funcProtoType->getParamTypes()) {
1245  QualType newParamType = paramType.substObjCTypeArgs(
1246  ctx,
1247  typeArgs,
1249  if (newParamType.isNull())
1250  return {};
1251 
1252  if (newParamType.getAsOpaquePtr() != paramType.getAsOpaquePtr())
1253  paramChanged = true;
1254 
1255  paramTypes.push_back(newParamType);
1256  }
1257 
1258  // Transform extended info.
1259  FunctionProtoType::ExtProtoInfo info = funcProtoType->getExtProtoInfo();
1260  bool exceptionChanged = false;
1261  if (info.ExceptionSpec.Type == EST_Dynamic) {
1262  SmallVector<QualType, 4> exceptionTypes;
1263  for (auto exceptionType : info.ExceptionSpec.Exceptions) {
1264  QualType newExceptionType = exceptionType.substObjCTypeArgs(
1265  ctx,
1266  typeArgs,
1268  if (newExceptionType.isNull())
1269  return {};
1270 
1271  if (newExceptionType.getAsOpaquePtr()
1272  != exceptionType.getAsOpaquePtr())
1273  exceptionChanged = true;
1274 
1275  exceptionTypes.push_back(newExceptionType);
1276  }
1277 
1278  if (exceptionChanged) {
1279  info.ExceptionSpec.Exceptions =
1280  llvm::makeArrayRef(exceptionTypes).copy(ctx);
1281  }
1282  }
1283 
1284  if (returnType.getAsOpaquePtr()
1285  == funcProtoType->getReturnType().getAsOpaquePtr() &&
1286  !paramChanged && !exceptionChanged)
1287  return type;
1288 
1289  return ctx.getFunctionType(returnType, paramTypes, info);
1290  }
1291 
1292  // Substitute into the type arguments of a specialized Objective-C object
1293  // type.
1294  if (const auto *objcObjectType = dyn_cast<ObjCObjectType>(splitType.Ty)) {
1295  if (objcObjectType->isSpecializedAsWritten()) {
1296  SmallVector<QualType, 4> newTypeArgs;
1297  bool anyChanged = false;
1298  for (auto typeArg : objcObjectType->getTypeArgsAsWritten()) {
1299  QualType newTypeArg = typeArg.substObjCTypeArgs(
1300  ctx, typeArgs,
1302  if (newTypeArg.isNull())
1303  return {};
1304 
1305  if (newTypeArg.getAsOpaquePtr() != typeArg.getAsOpaquePtr()) {
1306  // If we're substituting based on an unspecialized context type,
1307  // produce an unspecialized type.
1308  ArrayRef<ObjCProtocolDecl *> protocols(
1309  objcObjectType->qual_begin(),
1310  objcObjectType->getNumProtocols());
1311  if (typeArgs.empty() &&
1313  return ctx.getObjCObjectType(
1314  objcObjectType->getBaseType(), {},
1315  protocols,
1316  objcObjectType->isKindOfTypeAsWritten());
1317  }
1318 
1319  anyChanged = true;
1320  }
1321 
1322  newTypeArgs.push_back(newTypeArg);
1323  }
1324 
1325  if (anyChanged) {
1326  ArrayRef<ObjCProtocolDecl *> protocols(
1327  objcObjectType->qual_begin(),
1328  objcObjectType->getNumProtocols());
1329  return ctx.getObjCObjectType(objcObjectType->getBaseType(),
1330  newTypeArgs, protocols,
1331  objcObjectType->isKindOfTypeAsWritten());
1332  }
1333  }
1334 
1335  return type;
1336  }
1337 
1338  return type;
1339  });
1340 }
1341 
1343  const DeclContext *dc,
1344  ObjCSubstitutionContext context) const {
1345  if (auto subs = objectType->getObjCSubstitutions(dc))
1346  return substObjCTypeArgs(dc->getParentASTContext(), *subs, context);
1347 
1348  return *this;
1349 }
1350 
1352  // FIXME: Because ASTContext::getAttributedType() is non-const.
1353  auto &ctx = const_cast<ASTContext &>(constCtx);
1354  return simpleTransform(ctx, *this,
1355  [&](QualType type) -> QualType {
1356  SplitQualType splitType = type.split();
1357  if (auto *objType = splitType.Ty->getAs<ObjCObjectType>()) {
1358  if (!objType->isKindOfType())
1359  return type;
1360 
1361  QualType baseType
1362  = objType->getBaseType().stripObjCKindOfType(ctx);
1363  return ctx.getQualifiedType(
1364  ctx.getObjCObjectType(baseType,
1365  objType->getTypeArgsAsWritten(),
1366  objType->getProtocols(),
1367  /*isKindOf=*/false),
1368  splitType.Quals);
1369  }
1370 
1371  return type;
1372  });
1373 }
1374 
1376  if (const auto AT = getTypePtr()->getAs<AtomicType>())
1377  return AT->getValueType().getUnqualifiedType();
1378  return getUnqualifiedType();
1379 }
1380 
1382  const DeclContext *dc) const {
1383  // Look through method scopes.
1384  if (const auto method = dyn_cast<ObjCMethodDecl>(dc))
1385  dc = method->getDeclContext();
1386 
1387  // Find the class or category in which the type we're substituting
1388  // was declared.
1389  const auto *dcClassDecl = dyn_cast<ObjCInterfaceDecl>(dc);
1390  const ObjCCategoryDecl *dcCategoryDecl = nullptr;
1391  ObjCTypeParamList *dcTypeParams = nullptr;
1392  if (dcClassDecl) {
1393  // If the class does not have any type parameters, there's no
1394  // substitution to do.
1395  dcTypeParams = dcClassDecl->getTypeParamList();
1396  if (!dcTypeParams)
1397  return None;
1398  } else {
1399  // If we are in neither a class nor a category, there's no
1400  // substitution to perform.
1401  dcCategoryDecl = dyn_cast<ObjCCategoryDecl>(dc);
1402  if (!dcCategoryDecl)
1403  return None;
1404 
1405  // If the category does not have any type parameters, there's no
1406  // substitution to do.
1407  dcTypeParams = dcCategoryDecl->getTypeParamList();
1408  if (!dcTypeParams)
1409  return None;
1410 
1411  dcClassDecl = dcCategoryDecl->getClassInterface();
1412  if (!dcClassDecl)
1413  return None;
1414  }
1415  assert(dcTypeParams && "No substitutions to perform");
1416  assert(dcClassDecl && "No class context");
1417 
1418  // Find the underlying object type.
1419  const ObjCObjectType *objectType;
1420  if (const auto *objectPointerType = getAs<ObjCObjectPointerType>()) {
1421  objectType = objectPointerType->getObjectType();
1422  } else if (getAs<BlockPointerType>()) {
1423  ASTContext &ctx = dc->getParentASTContext();
1424  objectType = ctx.getObjCObjectType(ctx.ObjCBuiltinIdTy, {}, {})
1425  ->castAs<ObjCObjectType>();
1426  } else {
1427  objectType = getAs<ObjCObjectType>();
1428  }
1429 
1430  /// Extract the class from the receiver object type.
1431  ObjCInterfaceDecl *curClassDecl = objectType ? objectType->getInterface()
1432  : nullptr;
1433  if (!curClassDecl) {
1434  // If we don't have a context type (e.g., this is "id" or some
1435  // variant thereof), substitute the bounds.
1436  return llvm::ArrayRef<QualType>();
1437  }
1438 
1439  // Follow the superclass chain until we've mapped the receiver type
1440  // to the same class as the context.
1441  while (curClassDecl != dcClassDecl) {
1442  // Map to the superclass type.
1443  QualType superType = objectType->getSuperClassType();
1444  if (superType.isNull()) {
1445  objectType = nullptr;
1446  break;
1447  }
1448 
1449  objectType = superType->castAs<ObjCObjectType>();
1450  curClassDecl = objectType->getInterface();
1451  }
1452 
1453  // If we don't have a receiver type, or the receiver type does not
1454  // have type arguments, substitute in the defaults.
1455  if (!objectType || objectType->isUnspecialized()) {
1456  return llvm::ArrayRef<QualType>();
1457  }
1458 
1459  // The receiver type has the type arguments we want.
1460  return objectType->getTypeArgs();
1461 }
1462 
1464  if (auto *IfaceT = getAsObjCInterfaceType()) {
1465  if (auto *ID = IfaceT->getInterface()) {
1466  if (ID->getTypeParamList())
1467  return true;
1468  }
1469  }
1470 
1471  return false;
1472 }
1473 
1475  // Retrieve the class declaration for this type. If there isn't one
1476  // (e.g., this is some variant of "id" or "Class"), then there is no
1477  // superclass type.
1478  ObjCInterfaceDecl *classDecl = getInterface();
1479  if (!classDecl) {
1480  CachedSuperClassType.setInt(true);
1481  return;
1482  }
1483 
1484  // Extract the superclass type.
1485  const ObjCObjectType *superClassObjTy = classDecl->getSuperClassType();
1486  if (!superClassObjTy) {
1487  CachedSuperClassType.setInt(true);
1488  return;
1489  }
1490 
1491  ObjCInterfaceDecl *superClassDecl = superClassObjTy->getInterface();
1492  if (!superClassDecl) {
1493  CachedSuperClassType.setInt(true);
1494  return;
1495  }
1496 
1497  // If the superclass doesn't have type parameters, then there is no
1498  // substitution to perform.
1499  QualType superClassType(superClassObjTy, 0);
1500  ObjCTypeParamList *superClassTypeParams = superClassDecl->getTypeParamList();
1501  if (!superClassTypeParams) {
1502  CachedSuperClassType.setPointerAndInt(
1503  superClassType->castAs<ObjCObjectType>(), true);
1504  return;
1505  }
1506 
1507  // If the superclass reference is unspecialized, return it.
1508  if (superClassObjTy->isUnspecialized()) {
1509  CachedSuperClassType.setPointerAndInt(superClassObjTy, true);
1510  return;
1511  }
1512 
1513  // If the subclass is not parameterized, there aren't any type
1514  // parameters in the superclass reference to substitute.
1515  ObjCTypeParamList *typeParams = classDecl->getTypeParamList();
1516  if (!typeParams) {
1517  CachedSuperClassType.setPointerAndInt(
1518  superClassType->castAs<ObjCObjectType>(), true);
1519  return;
1520  }
1521 
1522  // If the subclass type isn't specialized, return the unspecialized
1523  // superclass.
1524  if (isUnspecialized()) {
1525  QualType unspecializedSuper
1526  = classDecl->getASTContext().getObjCInterfaceType(
1527  superClassObjTy->getInterface());
1528  CachedSuperClassType.setPointerAndInt(
1529  unspecializedSuper->castAs<ObjCObjectType>(),
1530  true);
1531  return;
1532  }
1533 
1534  // Substitute the provided type arguments into the superclass type.
1535  ArrayRef<QualType> typeArgs = getTypeArgs();
1536  assert(typeArgs.size() == typeParams->size());
1537  CachedSuperClassType.setPointerAndInt(
1538  superClassType.substObjCTypeArgs(classDecl->getASTContext(), typeArgs,
1540  ->castAs<ObjCObjectType>(),
1541  true);
1542 }
1543 
1545  if (auto interfaceDecl = getObjectType()->getInterface()) {
1546  return interfaceDecl->getASTContext().getObjCInterfaceType(interfaceDecl)
1548  }
1549 
1550  return nullptr;
1551 }
1552 
1554  QualType superObjectType = getObjectType()->getSuperClassType();
1555  if (superObjectType.isNull())
1556  return superObjectType;
1557 
1558  ASTContext &ctx = getInterfaceDecl()->getASTContext();
1559  return ctx.getObjCObjectPointerType(superObjectType);
1560 }
1561 
1563  // There is no sugar for ObjCObjectType's, just return the canonical
1564  // type pointer if it is the right class. There is no typedef information to
1565  // return and these cannot be Address-space qualified.
1566  if (const auto *T = getAs<ObjCObjectType>())
1567  if (T->getNumProtocols() && T->getInterface())
1568  return T;
1569  return nullptr;
1570 }
1571 
1573  return getAsObjCQualifiedInterfaceType() != nullptr;
1574 }
1575 
1577  // There is no sugar for ObjCQualifiedIdType's, just return the canonical
1578  // type pointer if it is the right class.
1579  if (const auto *OPT = getAs<ObjCObjectPointerType>()) {
1580  if (OPT->isObjCQualifiedIdType())
1581  return OPT;
1582  }
1583  return nullptr;
1584 }
1585 
1587  // There is no sugar for ObjCQualifiedClassType's, just return the canonical
1588  // type pointer if it is the right class.
1589  if (const auto *OPT = getAs<ObjCObjectPointerType>()) {
1590  if (OPT->isObjCQualifiedClassType())
1591  return OPT;
1592  }
1593  return nullptr;
1594 }
1595 
1597  if (const auto *OT = getAs<ObjCObjectType>()) {
1598  if (OT->getInterface())
1599  return OT;
1600  }
1601  return nullptr;
1602 }
1603 
1605  if (const auto *OPT = getAs<ObjCObjectPointerType>()) {
1606  if (OPT->getInterfaceType())
1607  return OPT;
1608  }
1609  return nullptr;
1610 }
1611 
1613  QualType PointeeType;
1614  if (const auto *PT = getAs<PointerType>())
1615  PointeeType = PT->getPointeeType();
1616  else if (const auto *RT = getAs<ReferenceType>())
1617  PointeeType = RT->getPointeeType();
1618  else
1619  return nullptr;
1620 
1621  if (const auto *RT = PointeeType->getAs<RecordType>())
1622  return dyn_cast<CXXRecordDecl>(RT->getDecl());
1623 
1624  return nullptr;
1625 }
1626 
1628  return dyn_cast_or_null<CXXRecordDecl>(getAsTagDecl());
1629 }
1630 
1632  return dyn_cast_or_null<RecordDecl>(getAsTagDecl());
1633 }
1634 
1636  if (const auto *TT = getAs<TagType>())
1637  return TT->getDecl();
1638  if (const auto *Injected = getAs<InjectedClassNameType>())
1639  return Injected->getDecl();
1640 
1641  return nullptr;
1642 }
1643 
1644 namespace {
1645 
1646  class GetContainedDeducedTypeVisitor :
1647  public TypeVisitor<GetContainedDeducedTypeVisitor, Type*> {
1648  bool Syntactic;
1649 
1650  public:
1651  GetContainedDeducedTypeVisitor(bool Syntactic = false)
1652  : Syntactic(Syntactic) {}
1653 
1655 
1656  Type *Visit(QualType T) {
1657  if (T.isNull())
1658  return nullptr;
1659  return Visit(T.getTypePtr());
1660  }
1661 
1662  // The deduced type itself.
1663  Type *VisitDeducedType(const DeducedType *AT) {
1664  return const_cast<DeducedType*>(AT);
1665  }
1666 
1667  // Only these types can contain the desired 'auto' type.
1668 
1669  Type *VisitElaboratedType(const ElaboratedType *T) {
1670  return Visit(T->getNamedType());
1671  }
1672 
1673  Type *VisitPointerType(const PointerType *T) {
1674  return Visit(T->getPointeeType());
1675  }
1676 
1677  Type *VisitBlockPointerType(const BlockPointerType *T) {
1678  return Visit(T->getPointeeType());
1679  }
1680 
1681  Type *VisitReferenceType(const ReferenceType *T) {
1682  return Visit(T->getPointeeTypeAsWritten());
1683  }
1684 
1685  Type *VisitMemberPointerType(const MemberPointerType *T) {
1686  return Visit(T->getPointeeType());
1687  }
1688 
1689  Type *VisitArrayType(const ArrayType *T) {
1690  return Visit(T->getElementType());
1691  }
1692 
1693  Type *VisitDependentSizedExtVectorType(
1694  const DependentSizedExtVectorType *T) {
1695  return Visit(T->getElementType());
1696  }
1697 
1698  Type *VisitVectorType(const VectorType *T) {
1699  return Visit(T->getElementType());
1700  }
1701 
1702  Type *VisitFunctionProtoType(const FunctionProtoType *T) {
1703  if (Syntactic && T->hasTrailingReturn())
1704  return const_cast<FunctionProtoType*>(T);
1705  return VisitFunctionType(T);
1706  }
1707 
1708  Type *VisitFunctionType(const FunctionType *T) {
1709  return Visit(T->getReturnType());
1710  }
1711 
1712  Type *VisitParenType(const ParenType *T) {
1713  return Visit(T->getInnerType());
1714  }
1715 
1716  Type *VisitAttributedType(const AttributedType *T) {
1717  return Visit(T->getModifiedType());
1718  }
1719 
1720  Type *VisitAdjustedType(const AdjustedType *T) {
1721  return Visit(T->getOriginalType());
1722  }
1723  };
1724 
1725 } // namespace
1726 
1728  return cast_or_null<DeducedType>(
1729  GetContainedDeducedTypeVisitor().Visit(this));
1730 }
1731 
1733  return dyn_cast_or_null<FunctionType>(
1734  GetContainedDeducedTypeVisitor(true).Visit(this));
1735 }
1736 
1738  if (const auto *VT = dyn_cast<VectorType>(CanonicalType))
1739  return VT->getElementType()->isIntegerType();
1740  else
1741  return isIntegerType();
1742 }
1743 
1744 /// Determine whether this type is an integral type.
1745 ///
1746 /// This routine determines whether the given type is an integral type per
1747 /// C++ [basic.fundamental]p7. Although the C standard does not define the
1748 /// term "integral type", it has a similar term "integer type", and in C++
1749 /// the two terms are equivalent. However, C's "integer type" includes
1750 /// enumeration types, while C++'s "integer type" does not. The \c ASTContext
1751 /// parameter is used to determine whether we should be following the C or
1752 /// C++ rules when determining whether this type is an integral/integer type.
1753 ///
1754 /// For cases where C permits "an integer type" and C++ permits "an integral
1755 /// type", use this routine.
1756 ///
1757 /// For cases where C permits "an integer type" and C++ permits "an integral
1758 /// or enumeration type", use \c isIntegralOrEnumerationType() instead.
1759 ///
1760 /// \param Ctx The context in which this type occurs.
1761 ///
1762 /// \returns true if the type is considered an integral type, false otherwise.
1763 bool Type::isIntegralType(const ASTContext &Ctx) const {
1764  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1765  return BT->getKind() >= BuiltinType::Bool &&
1766  BT->getKind() <= BuiltinType::Int128;
1767 
1768  // Complete enum types are integral in C.
1769  if (!Ctx.getLangOpts().CPlusPlus)
1770  if (const auto *ET = dyn_cast<EnumType>(CanonicalType))
1771  return ET->getDecl()->isComplete();
1772 
1773  return false;
1774 }
1775 
1777  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1778  return BT->getKind() >= BuiltinType::Bool &&
1779  BT->getKind() <= BuiltinType::Int128;
1780 
1781  // Check for a complete enum type; incomplete enum types are not properly an
1782  // enumeration type in the sense required here.
1783  // C++0x: However, if the underlying type of the enum is fixed, it is
1784  // considered complete.
1785  if (const auto *ET = dyn_cast<EnumType>(CanonicalType))
1786  return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
1787 
1788  return false;
1789 }
1790 
1791 bool Type::isCharType() const {
1792  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1793  return BT->getKind() == BuiltinType::Char_U ||
1794  BT->getKind() == BuiltinType::UChar ||
1795  BT->getKind() == BuiltinType::Char_S ||
1796  BT->getKind() == BuiltinType::SChar;
1797  return false;
1798 }
1799 
1800 bool Type::isWideCharType() const {
1801  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1802  return BT->getKind() == BuiltinType::WChar_S ||
1803  BT->getKind() == BuiltinType::WChar_U;
1804  return false;
1805 }
1806 
1807 bool Type::isChar8Type() const {
1808  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
1809  return BT->getKind() == BuiltinType::Char8;
1810  return false;
1811 }
1812 
1813 bool Type::isChar16Type() const {
1814  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1815  return BT->getKind() == BuiltinType::Char16;
1816  return false;
1817 }
1818 
1819 bool Type::isChar32Type() const {
1820  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1821  return BT->getKind() == BuiltinType::Char32;
1822  return false;
1823 }
1824 
1825 /// Determine whether this type is any of the built-in character
1826 /// types.
1828  const auto *BT = dyn_cast<BuiltinType>(CanonicalType);
1829  if (!BT) return false;
1830  switch (BT->getKind()) {
1831  default: return false;
1832  case BuiltinType::Char_U:
1833  case BuiltinType::UChar:
1834  case BuiltinType::WChar_U:
1835  case BuiltinType::Char8:
1836  case BuiltinType::Char16:
1837  case BuiltinType::Char32:
1838  case BuiltinType::Char_S:
1839  case BuiltinType::SChar:
1840  case BuiltinType::WChar_S:
1841  return true;
1842  }
1843 }
1844 
1845 /// isSignedIntegerType - Return true if this is an integer type that is
1846 /// signed, according to C99 6.2.5p4 [char, signed char, short, int, long..],
1847 /// an enum decl which has a signed representation
1849  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1850  return BT->getKind() >= BuiltinType::Char_S &&
1851  BT->getKind() <= BuiltinType::Int128;
1852  }
1853 
1854  if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
1855  // Incomplete enum types are not treated as integer types.
1856  // FIXME: In C++, enum types are never integer types.
1857  if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
1858  return ET->getDecl()->getIntegerType()->isSignedIntegerType();
1859  }
1860 
1861  return false;
1862 }
1863 
1865  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1866  return BT->getKind() >= BuiltinType::Char_S &&
1867  BT->getKind() <= BuiltinType::Int128;
1868  }
1869 
1870  if (const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
1871  if (ET->getDecl()->isComplete())
1872  return ET->getDecl()->getIntegerType()->isSignedIntegerType();
1873  }
1874 
1875  return false;
1876 }
1877 
1879  if (const auto *VT = dyn_cast<VectorType>(CanonicalType))
1880  return VT->getElementType()->isSignedIntegerOrEnumerationType();
1881  else
1883 }
1884 
1885 /// isUnsignedIntegerType - Return true if this is an integer type that is
1886 /// unsigned, according to C99 6.2.5p6 [which returns true for _Bool], an enum
1887 /// decl which has an unsigned representation
1889  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1890  return BT->getKind() >= BuiltinType::Bool &&
1891  BT->getKind() <= BuiltinType::UInt128;
1892  }
1893 
1894  if (const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
1895  // Incomplete enum types are not treated as integer types.
1896  // FIXME: In C++, enum types are never integer types.
1897  if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
1898  return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
1899  }
1900 
1901  return false;
1902 }
1903 
1905  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
1906  return BT->getKind() >= BuiltinType::Bool &&
1907  BT->getKind() <= BuiltinType::UInt128;
1908  }
1909 
1910  if (const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
1911  if (ET->getDecl()->isComplete())
1912  return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
1913  }
1914 
1915  return false;
1916 }
1917 
1919  if (const auto *VT = dyn_cast<VectorType>(CanonicalType))
1920  return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
1921  else
1923 }
1924 
1925 bool Type::isFloatingType() const {
1926  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1927  return BT->getKind() >= BuiltinType::Half &&
1928  BT->getKind() <= BuiltinType::Float128;
1929  if (const auto *CT = dyn_cast<ComplexType>(CanonicalType))
1930  return CT->getElementType()->isFloatingType();
1931  return false;
1932 }
1933 
1935  if (const auto *VT = dyn_cast<VectorType>(CanonicalType))
1936  return VT->getElementType()->isFloatingType();
1937  else
1938  return isFloatingType();
1939 }
1940 
1942  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1943  return BT->isFloatingPoint();
1944  return false;
1945 }
1946 
1947 bool Type::isRealType() const {
1948  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1949  return BT->getKind() >= BuiltinType::Bool &&
1950  BT->getKind() <= BuiltinType::Float128;
1951  if (const auto *ET = dyn_cast<EnumType>(CanonicalType))
1952  return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
1953  return false;
1954 }
1955 
1957  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
1958  return BT->getKind() >= BuiltinType::Bool &&
1959  BT->getKind() <= BuiltinType::Float128;
1960  if (const auto *ET = dyn_cast<EnumType>(CanonicalType))
1961  // GCC allows forward declaration of enum types (forbid by C99 6.7.2.3p2).
1962  // If a body isn't seen by the time we get here, return false.
1963  //
1964  // C++0x: Enumerations are not arithmetic types. For now, just return
1965  // false for scoped enumerations since that will disable any
1966  // unwanted implicit conversions.
1967  return !ET->getDecl()->isScoped() && ET->getDecl()->isComplete();
1968  return isa<ComplexType>(CanonicalType);
1969 }
1970 
1972  assert(isScalarType());
1973 
1974  const Type *T = CanonicalType.getTypePtr();
1975  if (const auto *BT = dyn_cast<BuiltinType>(T)) {
1976  if (BT->getKind() == BuiltinType::Bool) return STK_Bool;
1977  if (BT->getKind() == BuiltinType::NullPtr) return STK_CPointer;
1978  if (BT->isInteger()) return STK_Integral;
1979  if (BT->isFloatingPoint()) return STK_Floating;
1980  llvm_unreachable("unknown scalar builtin type");
1981  } else if (isa<PointerType>(T)) {
1982  return STK_CPointer;
1983  } else if (isa<BlockPointerType>(T)) {
1984  return STK_BlockPointer;
1985  } else if (isa<ObjCObjectPointerType>(T)) {
1986  return STK_ObjCObjectPointer;
1987  } else if (isa<MemberPointerType>(T)) {
1988  return STK_MemberPointer;
1989  } else if (isa<EnumType>(T)) {
1990  assert(cast<EnumType>(T)->getDecl()->isComplete());
1991  return STK_Integral;
1992  } else if (const auto *CT = dyn_cast<ComplexType>(T)) {
1993  if (CT->getElementType()->isRealFloatingType())
1994  return STK_FloatingComplex;
1995  return STK_IntegralComplex;
1996  }
1997 
1998  llvm_unreachable("unknown scalar type");
1999 }
2000 
2001 /// Determines whether the type is a C++ aggregate type or C
2002 /// aggregate or union type.
2003 ///
2004 /// An aggregate type is an array or a class type (struct, union, or
2005 /// class) that has no user-declared constructors, no private or
2006 /// protected non-static data members, no base classes, and no virtual
2007 /// functions (C++ [dcl.init.aggr]p1). The notion of an aggregate type
2008 /// subsumes the notion of C aggregates (C99 6.2.5p21) because it also
2009 /// includes union types.
2011  if (const auto *Record = dyn_cast<RecordType>(CanonicalType)) {
2012  if (const auto *ClassDecl = dyn_cast<CXXRecordDecl>(Record->getDecl()))
2013  return ClassDecl->isAggregate();
2014 
2015  return true;
2016  }
2017 
2018  return isa<ArrayType>(CanonicalType);
2019 }
2020 
2021 /// isConstantSizeType - Return true if this is not a variable sized type,
2022 /// according to the rules of C99 6.7.5p3. It is not legal to call this on
2023 /// incomplete types or dependent types.
2025  assert(!isIncompleteType() && "This doesn't make sense for incomplete types");
2026  assert(!isDependentType() && "This doesn't make sense for dependent types");
2027  // The VAT must have a size, as it is known to be complete.
2028  return !isa<VariableArrayType>(CanonicalType);
2029 }
2030 
2031 /// isIncompleteType - Return true if this is an incomplete type (C99 6.2.5p1)
2032 /// - a type that can describe objects, but which lacks information needed to
2033 /// determine its size.
2035  if (Def)
2036  *Def = nullptr;
2037 
2038  switch (CanonicalType->getTypeClass()) {
2039  default: return false;
2040  case Builtin:
2041  // Void is the only incomplete builtin type. Per C99 6.2.5p19, it can never
2042  // be completed.
2043  return isVoidType();
2044  case Enum: {
2045  EnumDecl *EnumD = cast<EnumType>(CanonicalType)->getDecl();
2046  if (Def)
2047  *Def = EnumD;
2048  return !EnumD->isComplete();
2049  }
2050  case Record: {
2051  // A tagged type (struct/union/enum/class) is incomplete if the decl is a
2052  // forward declaration, but not a full definition (C99 6.2.5p22).
2053  RecordDecl *Rec = cast<RecordType>(CanonicalType)->getDecl();
2054  if (Def)
2055  *Def = Rec;
2056  return !Rec->isCompleteDefinition();
2057  }
2058  case ConstantArray:
2059  // An array is incomplete if its element type is incomplete
2060  // (C++ [dcl.array]p1).
2061  // We don't handle variable arrays (they're not allowed in C++) or
2062  // dependent-sized arrays (dependent types are never treated as incomplete).
2063  return cast<ArrayType>(CanonicalType)->getElementType()
2064  ->isIncompleteType(Def);
2065  case IncompleteArray:
2066  // An array of unknown size is an incomplete type (C99 6.2.5p22).
2067  return true;
2068  case MemberPointer: {
2069  // Member pointers in the MS ABI have special behavior in
2070  // RequireCompleteType: they attach a MSInheritanceAttr to the CXXRecordDecl
2071  // to indicate which inheritance model to use.
2072  auto *MPTy = cast<MemberPointerType>(CanonicalType);
2073  const Type *ClassTy = MPTy->getClass();
2074  // Member pointers with dependent class types don't get special treatment.
2075  if (ClassTy->isDependentType())
2076  return false;
2077  const CXXRecordDecl *RD = ClassTy->getAsCXXRecordDecl();
2078  ASTContext &Context = RD->getASTContext();
2079  // Member pointers not in the MS ABI don't get special treatment.
2080  if (!Context.getTargetInfo().getCXXABI().isMicrosoft())
2081  return false;
2082  // The inheritance attribute might only be present on the most recent
2083  // CXXRecordDecl, use that one.
2084  RD = RD->getMostRecentNonInjectedDecl();
2085  // Nothing interesting to do if the inheritance attribute is already set.
2086  if (RD->hasAttr<MSInheritanceAttr>())
2087  return false;
2088  return true;
2089  }
2090  case ObjCObject:
2091  return cast<ObjCObjectType>(CanonicalType)->getBaseType()
2092  ->isIncompleteType(Def);
2093  case ObjCInterface: {
2094  // ObjC interfaces are incomplete if they are @class, not @interface.
2095  ObjCInterfaceDecl *Interface
2096  = cast<ObjCInterfaceType>(CanonicalType)->getDecl();
2097  if (Def)
2098  *Def = Interface;
2099  return !Interface->hasDefinition();
2100  }
2101  }
2102 }
2103 
2104 bool QualType::isPODType(const ASTContext &Context) const {
2105  // C++11 has a more relaxed definition of POD.
2106  if (Context.getLangOpts().CPlusPlus11)
2107  return isCXX11PODType(Context);
2108 
2109  return isCXX98PODType(Context);
2110 }
2111 
2112 bool QualType::isCXX98PODType(const ASTContext &Context) const {
2113  // The compiler shouldn't query this for incomplete types, but the user might.
2114  // We return false for that case. Except for incomplete arrays of PODs, which
2115  // are PODs according to the standard.
2116  if (isNull())
2117  return false;
2118 
2119  if ((*this)->isIncompleteArrayType())
2120  return Context.getBaseElementType(*this).isCXX98PODType(Context);
2121 
2122  if ((*this)->isIncompleteType())
2123  return false;
2124 
2125  if (hasNonTrivialObjCLifetime())
2126  return false;
2127 
2128  QualType CanonicalType = getTypePtr()->CanonicalType;
2129  switch (CanonicalType->getTypeClass()) {
2130  // Everything not explicitly mentioned is not POD.
2131  default: return false;
2132  case Type::VariableArray:
2133  case Type::ConstantArray:
2134  // IncompleteArray is handled above.
2135  return Context.getBaseElementType(*this).isCXX98PODType(Context);
2136 
2137  case Type::ObjCObjectPointer:
2138  case Type::BlockPointer:
2139  case Type::Builtin:
2140  case Type::Complex:
2141  case Type::Pointer:
2142  case Type::MemberPointer:
2143  case Type::Vector:
2144  case Type::ExtVector:
2145  return true;
2146 
2147  case Type::Enum:
2148  return true;
2149 
2150  case Type::Record:
2151  if (const auto *ClassDecl =
2152  dyn_cast<CXXRecordDecl>(cast<RecordType>(CanonicalType)->getDecl()))
2153  return ClassDecl->isPOD();
2154 
2155  // C struct/union is POD.
2156  return true;
2157  }
2158 }
2159 
2160 bool QualType::isTrivialType(const ASTContext &Context) const {
2161  // The compiler shouldn't query this for incomplete types, but the user might.
2162  // We return false for that case. Except for incomplete arrays of PODs, which
2163  // are PODs according to the standard.
2164  if (isNull())
2165  return false;
2166 
2167  if ((*this)->isArrayType())
2168  return Context.getBaseElementType(*this).isTrivialType(Context);
2169 
2170  // Return false for incomplete types after skipping any incomplete array
2171  // types which are expressly allowed by the standard and thus our API.
2172  if ((*this)->isIncompleteType())
2173  return false;
2174 
2175  if (hasNonTrivialObjCLifetime())
2176  return false;
2177 
2178  QualType CanonicalType = getTypePtr()->CanonicalType;
2179  if (CanonicalType->isDependentType())
2180  return false;
2181 
2182  // C++0x [basic.types]p9:
2183  // Scalar types, trivial class types, arrays of such types, and
2184  // cv-qualified versions of these types are collectively called trivial
2185  // types.
2186 
2187  // As an extension, Clang treats vector types as Scalar types.
2188  if (CanonicalType->isScalarType() || CanonicalType->isVectorType())
2189  return true;
2190  if (const auto *RT = CanonicalType->getAs<RecordType>()) {
2191  if (const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2192  // C++11 [class]p6:
2193  // A trivial class is a class that has a default constructor,
2194  // has no non-trivial default constructors, and is trivially
2195  // copyable.
2196  return ClassDecl->hasDefaultConstructor() &&
2197  !ClassDecl->hasNonTrivialDefaultConstructor() &&
2198  ClassDecl->isTriviallyCopyable();
2199  }
2200 
2201  return true;
2202  }
2203 
2204  // No other types can match.
2205  return false;
2206 }
2207 
2208 bool QualType::isTriviallyCopyableType(const ASTContext &Context) const {
2209  if ((*this)->isArrayType())
2210  return Context.getBaseElementType(*this).isTriviallyCopyableType(Context);
2211 
2212  if (hasNonTrivialObjCLifetime())
2213  return false;
2214 
2215  // C++11 [basic.types]p9 - See Core 2094
2216  // Scalar types, trivially copyable class types, arrays of such types, and
2217  // cv-qualified versions of these types are collectively
2218  // called trivially copyable types.
2219 
2220  QualType CanonicalType = getCanonicalType();
2221  if (CanonicalType->isDependentType())
2222  return false;
2223 
2224  // Return false for incomplete types after skipping any incomplete array types
2225  // which are expressly allowed by the standard and thus our API.
2226  if (CanonicalType->isIncompleteType())
2227  return false;
2228 
2229  // As an extension, Clang treats vector types as Scalar types.
2230  if (CanonicalType->isScalarType() || CanonicalType->isVectorType())
2231  return true;
2232 
2233  if (const auto *RT = CanonicalType->getAs<RecordType>()) {
2234  if (const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2235  if (!ClassDecl->isTriviallyCopyable()) return false;
2236  }
2237 
2238  return true;
2239  }
2240 
2241  // No other types can match.
2242  return false;
2243 }
2244 
2246  return !Context.getLangOpts().ObjCAutoRefCount &&
2247  Context.getLangOpts().ObjCWeak &&
2248  getObjCLifetime() != Qualifiers::OCL_Weak;
2249 }
2250 
2253  if (const auto *RT =
2254  getTypePtr()->getBaseElementTypeUnsafe()->getAs<RecordType>())
2255  if (RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize())
2256  return PDIK_Struct;
2257 
2258  switch (getQualifiers().getObjCLifetime()) {
2260  return PDIK_ARCStrong;
2261  case Qualifiers::OCL_Weak:
2262  return PDIK_ARCWeak;
2263  default:
2264  return PDIK_Trivial;
2265  }
2266 }
2267 
2269  if (const auto *RT =
2270  getTypePtr()->getBaseElementTypeUnsafe()->getAs<RecordType>())
2271  if (RT->getDecl()->isNonTrivialToPrimitiveCopy())
2272  return PCK_Struct;
2273 
2274  Qualifiers Qs = getQualifiers();
2275  switch (Qs.getObjCLifetime()) {
2277  return PCK_ARCStrong;
2278  case Qualifiers::OCL_Weak:
2279  return PCK_ARCWeak;
2280  default:
2281  return Qs.hasVolatile() ? PCK_VolatileTrivial : PCK_Trivial;
2282  }
2283 }
2284 
2287  return isNonTrivialToPrimitiveCopy();
2288 }
2289 
2290 bool Type::isLiteralType(const ASTContext &Ctx) const {
2291  if (isDependentType())
2292  return false;
2293 
2294  // C++1y [basic.types]p10:
2295  // A type is a literal type if it is:
2296  // -- cv void; or
2297  if (Ctx.getLangOpts().CPlusPlus14 && isVoidType())
2298  return true;
2299 
2300  // C++11 [basic.types]p10:
2301  // A type is a literal type if it is:
2302  // [...]
2303  // -- an array of literal type other than an array of runtime bound; or
2304  if (isVariableArrayType())
2305  return false;
2306  const Type *BaseTy = getBaseElementTypeUnsafe();
2307  assert(BaseTy && "NULL element type");
2308 
2309  // Return false for incomplete types after skipping any incomplete array
2310  // types; those are expressly allowed by the standard and thus our API.
2311  if (BaseTy->isIncompleteType())
2312  return false;
2313 
2314  // C++11 [basic.types]p10:
2315  // A type is a literal type if it is:
2316  // -- a scalar type; or
2317  // As an extension, Clang treats vector types and complex types as
2318  // literal types.
2319  if (BaseTy->isScalarType() || BaseTy->isVectorType() ||
2320  BaseTy->isAnyComplexType())
2321  return true;
2322  // -- a reference type; or
2323  if (BaseTy->isReferenceType())
2324  return true;
2325  // -- a class type that has all of the following properties:
2326  if (const auto *RT = BaseTy->getAs<RecordType>()) {
2327  // -- a trivial destructor,
2328  // -- every constructor call and full-expression in the
2329  // brace-or-equal-initializers for non-static data members (if any)
2330  // is a constant expression,
2331  // -- it is an aggregate type or has at least one constexpr
2332  // constructor or constructor template that is not a copy or move
2333  // constructor, and
2334  // -- all non-static data members and base classes of literal types
2335  //
2336  // We resolve DR1361 by ignoring the second bullet.
2337  if (const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2338  return ClassDecl->isLiteral();
2339 
2340  return true;
2341  }
2342 
2343  // We treat _Atomic T as a literal type if T is a literal type.
2344  if (const auto *AT = BaseTy->getAs<AtomicType>())
2345  return AT->getValueType()->isLiteralType(Ctx);
2346 
2347  // If this type hasn't been deduced yet, then conservatively assume that
2348  // it'll work out to be a literal type.
2349  if (isa<AutoType>(BaseTy->getCanonicalTypeInternal()))
2350  return true;
2351 
2352  return false;
2353 }
2354 
2356  if (isDependentType())
2357  return false;
2358 
2359  // C++0x [basic.types]p9:
2360  // Scalar types, standard-layout class types, arrays of such types, and
2361  // cv-qualified versions of these types are collectively called
2362  // standard-layout types.
2363  const Type *BaseTy = getBaseElementTypeUnsafe();
2364  assert(BaseTy && "NULL element type");
2365 
2366  // Return false for incomplete types after skipping any incomplete array
2367  // types which are expressly allowed by the standard and thus our API.
2368  if (BaseTy->isIncompleteType())
2369  return false;
2370 
2371  // As an extension, Clang treats vector types as Scalar types.
2372  if (BaseTy->isScalarType() || BaseTy->isVectorType()) return true;
2373  if (const auto *RT = BaseTy->getAs<RecordType>()) {
2374  if (const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
2375  if (!ClassDecl->isStandardLayout())
2376  return false;
2377 
2378  // Default to 'true' for non-C++ class types.
2379  // FIXME: This is a bit dubious, but plain C structs should trivially meet
2380  // all the requirements of standard layout classes.
2381  return true;
2382  }
2383 
2384  // No other types can match.
2385  return false;
2386 }
2387 
2388 // This is effectively the intersection of isTrivialType and
2389 // isStandardLayoutType. We implement it directly to avoid redundant
2390 // conversions from a type to a CXXRecordDecl.
2391 bool QualType::isCXX11PODType(const ASTContext &Context) const {
2392  const Type *ty = getTypePtr();
2393  if (ty->isDependentType())
2394  return false;
2395 
2396  if (hasNonTrivialObjCLifetime())
2397  return false;
2398 
2399  // C++11 [basic.types]p9:
2400  // Scalar types, POD classes, arrays of such types, and cv-qualified
2401  // versions of these types are collectively called trivial types.
2402  const Type *BaseTy = ty->getBaseElementTypeUnsafe();
2403  assert(BaseTy && "NULL element type");
2404 
2405  // Return false for incomplete types after skipping any incomplete array
2406  // types which are expressly allowed by the standard and thus our API.
2407  if (BaseTy->isIncompleteType())
2408  return false;
2409 
2410  // As an extension, Clang treats vector types as Scalar types.
2411  if (BaseTy->isScalarType() || BaseTy->isVectorType()) return true;
2412  if (const auto *RT = BaseTy->getAs<RecordType>()) {
2413  if (const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
2414  // C++11 [class]p10:
2415  // A POD struct is a non-union class that is both a trivial class [...]
2416  if (!ClassDecl->isTrivial()) return false;
2417 
2418  // C++11 [class]p10:
2419  // A POD struct is a non-union class that is both a trivial class and
2420  // a standard-layout class [...]
2421  if (!ClassDecl->isStandardLayout()) return false;
2422 
2423  // C++11 [class]p10:
2424  // A POD struct is a non-union class that is both a trivial class and
2425  // a standard-layout class, and has no non-static data members of type
2426  // non-POD struct, non-POD union (or array of such types). [...]
2427  //
2428  // We don't directly query the recursive aspect as the requirements for
2429  // both standard-layout classes and trivial classes apply recursively
2430  // already.
2431  }
2432 
2433  return true;
2434  }
2435 
2436  // No other types can match.
2437  return false;
2438 }
2439 
2440 bool Type::isAlignValT() const {
2441  if (const auto *ET = getAs<EnumType>()) {
2442  IdentifierInfo *II = ET->getDecl()->getIdentifier();
2443  if (II && II->isStr("align_val_t") && ET->getDecl()->isInStdNamespace())
2444  return true;
2445  }
2446  return false;
2447 }
2448 
2449 bool Type::isStdByteType() const {
2450  if (const auto *ET = getAs<EnumType>()) {
2451  IdentifierInfo *II = ET->getDecl()->getIdentifier();
2452  if (II && II->isStr("byte") && ET->getDecl()->isInStdNamespace())
2453  return true;
2454  }
2455  return false;
2456 }
2457 
2459  if (const auto *BT = getAs<BuiltinType>())
2460  switch (BT->getKind()) {
2461  case BuiltinType::Bool:
2462  case BuiltinType::Char_S:
2463  case BuiltinType::Char_U:
2464  case BuiltinType::SChar:
2465  case BuiltinType::UChar:
2466  case BuiltinType::Short:
2467  case BuiltinType::UShort:
2468  case BuiltinType::WChar_S:
2469  case BuiltinType::WChar_U:
2470  case BuiltinType::Char8:
2471  case BuiltinType::Char16:
2472  case BuiltinType::Char32:
2473  return true;
2474  default:
2475  return false;
2476  }
2477 
2478  // Enumerated types are promotable to their compatible integer types
2479  // (C99 6.3.1.1) a.k.a. its underlying type (C++ [conv.prom]p2).
2480  if (const auto *ET = getAs<EnumType>()){
2481  if (this->isDependentType() || ET->getDecl()->getPromotionType().isNull()
2482  || ET->getDecl()->isScoped())
2483  return false;
2484 
2485  return true;
2486  }
2487 
2488  return false;
2489 }
2490 
2492  // Note that this intentionally does not use the canonical type.
2493  switch (getTypeClass()) {
2494  case Builtin:
2495  case Record:
2496  case Enum:
2497  case Typedef:
2498  case Complex:
2499  case TypeOfExpr:
2500  case TypeOf:
2501  case TemplateTypeParm:
2502  case SubstTemplateTypeParm:
2503  case TemplateSpecialization:
2504  case Elaborated:
2505  case DependentName:
2506  case DependentTemplateSpecialization:
2507  case ObjCInterface:
2508  case ObjCObject:
2509  case ObjCObjectPointer: // FIXME: object pointers aren't really specifiers
2510  return true;
2511  default:
2512  return false;
2513  }
2514 }
2515 
2518  switch (TypeSpec) {
2519  default: return ETK_None;
2520  case TST_typename: return ETK_Typename;
2521  case TST_class: return ETK_Class;
2522  case TST_struct: return ETK_Struct;
2523  case TST_interface: return ETK_Interface;
2524  case TST_union: return ETK_Union;
2525  case TST_enum: return ETK_Enum;
2526  }
2527 }
2528 
2531  switch(TypeSpec) {
2532  case TST_class: return TTK_Class;
2533  case TST_struct: return TTK_Struct;
2534  case TST_interface: return TTK_Interface;
2535  case TST_union: return TTK_Union;
2536  case TST_enum: return TTK_Enum;
2537  }
2538 
2539  llvm_unreachable("Type specifier is not a tag type kind.");
2540 }
2541 
2544  switch (Kind) {
2545  case TTK_Class: return ETK_Class;
2546  case TTK_Struct: return ETK_Struct;
2547  case TTK_Interface: return ETK_Interface;
2548  case TTK_Union: return ETK_Union;
2549  case TTK_Enum: return ETK_Enum;
2550  }
2551  llvm_unreachable("Unknown tag type kind.");
2552 }
2553 
2556  switch (Keyword) {
2557  case ETK_Class: return TTK_Class;
2558  case ETK_Struct: return TTK_Struct;
2559  case ETK_Interface: return TTK_Interface;
2560  case ETK_Union: return TTK_Union;
2561  case ETK_Enum: return TTK_Enum;
2562  case ETK_None: // Fall through.
2563  case ETK_Typename:
2564  llvm_unreachable("Elaborated type keyword is not a tag type kind.");
2565  }
2566  llvm_unreachable("Unknown elaborated type keyword.");
2567 }
2568 
2569 bool
2571  switch (Keyword) {
2572  case ETK_None:
2573  case ETK_Typename:
2574  return false;
2575  case ETK_Class:
2576  case ETK_Struct:
2577  case ETK_Interface:
2578  case ETK_Union:
2579  case ETK_Enum:
2580  return true;
2581  }
2582  llvm_unreachable("Unknown elaborated type keyword.");
2583 }
2584 
2586  switch (Keyword) {
2587  case ETK_None: return {};
2588  case ETK_Typename: return "typename";
2589  case ETK_Class: return "class";
2590  case ETK_Struct: return "struct";
2591  case ETK_Interface: return "__interface";
2592  case ETK_Union: return "union";
2593  case ETK_Enum: return "enum";
2594  }
2595 
2596  llvm_unreachable("Unknown elaborated type keyword.");
2597 }
2598 
2599 DependentTemplateSpecializationType::DependentTemplateSpecializationType(
2600  ElaboratedTypeKeyword Keyword,
2601  NestedNameSpecifier *NNS, const IdentifierInfo *Name,
2603  QualType Canon)
2604  : TypeWithKeyword(Keyword, DependentTemplateSpecialization, Canon, true, true,
2605  /*VariablyModified=*/false,
2606  NNS && NNS->containsUnexpandedParameterPack()),
2607  NNS(NNS), Name(Name), NumArgs(Args.size()) {
2608  assert((!NNS || NNS->isDependent()) &&
2609  "DependentTemplateSpecializatonType requires dependent qualifier");
2610  TemplateArgument *ArgBuffer = getArgBuffer();
2611  for (const TemplateArgument &Arg : Args) {
2612  if (Arg.containsUnexpandedParameterPack())
2614 
2615  new (ArgBuffer++) TemplateArgument(Arg);
2616  }
2617 }
2618 
2619 void
2621  const ASTContext &Context,
2622  ElaboratedTypeKeyword Keyword,
2623  NestedNameSpecifier *Qualifier,
2624  const IdentifierInfo *Name,
2626  ID.AddInteger(Keyword);
2627  ID.AddPointer(Qualifier);
2628  ID.AddPointer(Name);
2629  for (const TemplateArgument &Arg : Args)
2630  Arg.Profile(ID, Context);
2631 }
2632 
2634  ElaboratedTypeKeyword Keyword;
2635  if (const auto *Elab = dyn_cast<ElaboratedType>(this))
2636  Keyword = Elab->getKeyword();
2637  else if (const auto *DepName = dyn_cast<DependentNameType>(this))
2638  Keyword = DepName->getKeyword();
2639  else if (const auto *DepTST =
2640  dyn_cast<DependentTemplateSpecializationType>(this))
2641  Keyword = DepTST->getKeyword();
2642  else
2643  return false;
2644 
2645  return TypeWithKeyword::KeywordIsTagTypeKind(Keyword);
2646 }
2647 
2648 const char *Type::getTypeClassName() const {
2649  switch (TypeBits.TC) {
2650 #define ABSTRACT_TYPE(Derived, Base)
2651 #define TYPE(Derived, Base) case Derived: return #Derived;
2652 #include "clang/AST/TypeNodes.def"
2653  }
2654 
2655  llvm_unreachable("Invalid type class.");
2656 }
2657 
2658 StringRef BuiltinType::getName(const PrintingPolicy &Policy) const {
2659  switch (getKind()) {
2660  case Void:
2661  return "void";
2662  case Bool:
2663  return Policy.Bool ? "bool" : "_Bool";
2664  case Char_S:
2665  return "char";
2666  case Char_U:
2667  return "char";
2668  case SChar:
2669  return "signed char";
2670  case Short:
2671  return "short";
2672  case Int:
2673  return "int";
2674  case Long:
2675  return "long";
2676  case LongLong:
2677  return "long long";
2678  case Int128:
2679  return "__int128";
2680  case UChar:
2681  return "unsigned char";
2682  case UShort:
2683  return "unsigned short";
2684  case UInt:
2685  return "unsigned int";
2686  case ULong:
2687  return "unsigned long";
2688  case ULongLong:
2689  return "unsigned long long";
2690  case UInt128:
2691  return "unsigned __int128";
2692  case Half:
2693  return Policy.Half ? "half" : "__fp16";
2694  case Float:
2695  return "float";
2696  case Double:
2697  return "double";
2698  case LongDouble:
2699  return "long double";
2700  case ShortAccum:
2701  return "short _Accum";
2702  case Accum:
2703  return "_Accum";
2704  case LongAccum:
2705  return "long _Accum";
2706  case UShortAccum:
2707  return "unsigned short _Accum";
2708  case UAccum:
2709  return "unsigned _Accum";
2710  case ULongAccum:
2711  return "unsigned long _Accum";
2712  case BuiltinType::ShortFract:
2713  return "short _Fract";
2714  case BuiltinType::Fract:
2715  return "_Fract";
2716  case BuiltinType::LongFract:
2717  return "long _Fract";
2718  case BuiltinType::UShortFract:
2719  return "unsigned short _Fract";
2720  case BuiltinType::UFract:
2721  return "unsigned _Fract";
2722  case BuiltinType::ULongFract:
2723  return "unsigned long _Fract";
2724  case BuiltinType::SatShortAccum:
2725  return "_Sat short _Accum";
2726  case BuiltinType::SatAccum:
2727  return "_Sat _Accum";
2728  case BuiltinType::SatLongAccum:
2729  return "_Sat long _Accum";
2730  case BuiltinType::SatUShortAccum:
2731  return "_Sat unsigned short _Accum";
2732  case BuiltinType::SatUAccum:
2733  return "_Sat unsigned _Accum";
2734  case BuiltinType::SatULongAccum:
2735  return "_Sat unsigned long _Accum";
2736  case BuiltinType::SatShortFract:
2737  return "_Sat short _Fract";
2738  case BuiltinType::SatFract:
2739  return "_Sat _Fract";
2740  case BuiltinType::SatLongFract:
2741  return "_Sat long _Fract";
2742  case BuiltinType::SatUShortFract:
2743  return "_Sat unsigned short _Fract";
2744  case BuiltinType::SatUFract:
2745  return "_Sat unsigned _Fract";
2746  case BuiltinType::SatULongFract:
2747  return "_Sat unsigned long _Fract";
2748  case Float16:
2749  return "_Float16";
2750  case Float128:
2751  return "__float128";
2752  case WChar_S:
2753  case WChar_U:
2754  return Policy.MSWChar ? "__wchar_t" : "wchar_t";
2755  case Char8:
2756  return "char8_t";
2757  case Char16:
2758  return "char16_t";
2759  case Char32:
2760  return "char32_t";
2761  case NullPtr:
2762  return "nullptr_t";
2763  case Overload:
2764  return "<overloaded function type>";
2765  case BoundMember:
2766  return "<bound member function type>";
2767  case PseudoObject:
2768  return "<pseudo-object type>";
2769  case Dependent:
2770  return "<dependent type>";
2771  case UnknownAny:
2772  return "<unknown type>";
2773  case ARCUnbridgedCast:
2774  return "<ARC unbridged cast type>";
2775  case BuiltinFn:
2776  return "<builtin fn type>";
2777  case ObjCId:
2778  return "id";
2779  case ObjCClass:
2780  return "Class";
2781  case ObjCSel:
2782  return "SEL";
2783 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
2784  case Id: \
2785  return "__" #Access " " #ImgType "_t";
2786 #include "clang/Basic/OpenCLImageTypes.def"
2787  case OCLSampler:
2788  return "sampler_t";
2789  case OCLEvent:
2790  return "event_t";
2791  case OCLClkEvent:
2792  return "clk_event_t";
2793  case OCLQueue:
2794  return "queue_t";
2795  case OCLReserveID:
2796  return "reserve_id_t";
2797  case OMPArraySection:
2798  return "<OpenMP array section type>";
2799  }
2800 
2801  llvm_unreachable("Invalid builtin type.");
2802 }
2803 
2805  if (const auto *RefType = getTypePtr()->getAs<ReferenceType>())
2806  return RefType->getPointeeType();
2807 
2808  // C++0x [basic.lval]:
2809  // Class prvalues can have cv-qualified types; non-class prvalues always
2810  // have cv-unqualified types.
2811  //
2812  // See also C99 6.3.2.1p2.
2813  if (!Context.getLangOpts().CPlusPlus ||
2814  (!getTypePtr()->isDependentType() && !getTypePtr()->isRecordType()))
2815  return getUnqualifiedType();
2816 
2817  return *this;
2818 }
2819 
2821  switch (CC) {
2822  case CC_C: return "cdecl";
2823  case CC_X86StdCall: return "stdcall";
2824  case CC_X86FastCall: return "fastcall";
2825  case CC_X86ThisCall: return "thiscall";
2826  case CC_X86Pascal: return "pascal";
2827  case CC_X86VectorCall: return "vectorcall";
2828  case CC_Win64: return "ms_abi";
2829  case CC_X86_64SysV: return "sysv_abi";
2830  case CC_X86RegCall : return "regcall";
2831  case CC_AAPCS: return "aapcs";
2832  case CC_AAPCS_VFP: return "aapcs-vfp";
2833  case CC_IntelOclBicc: return "intel_ocl_bicc";
2834  case CC_SpirFunction: return "spir_function";
2835  case CC_OpenCLKernel: return "opencl_kernel";
2836  case CC_Swift: return "swiftcall";
2837  case CC_PreserveMost: return "preserve_most";
2838  case CC_PreserveAll: return "preserve_all";
2839  }
2840 
2841  llvm_unreachable("Invalid calling convention.");
2842 }
2843 
2844 FunctionProtoType::FunctionProtoType(QualType result, ArrayRef<QualType> params,
2845  QualType canonical,
2846  const ExtProtoInfo &epi)
2847  : FunctionType(FunctionProto, result, canonical,
2848  result->isDependentType(),
2849  result->isInstantiationDependentType(),
2850  result->isVariablyModifiedType(),
2851  result->containsUnexpandedParameterPack(), epi.ExtInfo),
2852  NumParams(params.size()),
2853  NumExceptions(epi.ExceptionSpec.Exceptions.size()),
2854  ExceptionSpecType(epi.ExceptionSpec.Type),
2855  HasExtParameterInfos(epi.ExtParameterInfos != nullptr),
2856  Variadic(epi.Variadic), HasTrailingReturn(epi.HasTrailingReturn) {
2857  assert(NumParams == params.size() && "function has too many parameters");
2858 
2859  FunctionTypeBits.TypeQuals = epi.TypeQuals;
2860  FunctionTypeBits.RefQualifier = epi.RefQualifier;
2861 
2862  // Fill in the trailing argument array.
2863  auto *argSlot = reinterpret_cast<QualType *>(this+1);
2864  for (unsigned i = 0; i != NumParams; ++i) {
2865  if (params[i]->isDependentType())
2866  setDependent();
2867  else if (params[i]->isInstantiationDependentType())
2869 
2870  if (params[i]->containsUnexpandedParameterPack())
2872 
2873  argSlot[i] = params[i];
2874  }
2875 
2876  if (getExceptionSpecType() == EST_Dynamic) {
2877  // Fill in the exception array.
2878  QualType *exnSlot = argSlot + NumParams;
2879  unsigned I = 0;
2880  for (QualType ExceptionType : epi.ExceptionSpec.Exceptions) {
2881  // Note that, before C++17, a dependent exception specification does
2882  // *not* make a type dependent; it's not even part of the C++ type
2883  // system.
2884  if (ExceptionType->isInstantiationDependentType())
2886 
2887  if (ExceptionType->containsUnexpandedParameterPack())
2889 
2890  exnSlot[I++] = ExceptionType;
2891  }
2892  } else if (isComputedNoexcept(getExceptionSpecType())) {
2893  assert(epi.ExceptionSpec.NoexceptExpr && "computed noexcept with no expr");
2894  assert((getExceptionSpecType() == EST_DependentNoexcept) ==
2895  epi.ExceptionSpec.NoexceptExpr->isValueDependent());
2896 
2897  // Store the noexcept expression and context.
2898  auto **noexSlot = reinterpret_cast<Expr **>(argSlot + NumParams);
2899  *noexSlot = epi.ExceptionSpec.NoexceptExpr;
2900 
2901  if (epi.ExceptionSpec.NoexceptExpr->isValueDependent() ||
2902  epi.ExceptionSpec.NoexceptExpr->isInstantiationDependent())
2904 
2905  if (epi.ExceptionSpec.NoexceptExpr->containsUnexpandedParameterPack())
2907  } else if (getExceptionSpecType() == EST_Uninstantiated) {
2908  // Store the function decl from which we will resolve our
2909  // exception specification.
2910  auto **slot = reinterpret_cast<FunctionDecl **>(argSlot + NumParams);
2911  slot[0] = epi.ExceptionSpec.SourceDecl;
2912  slot[1] = epi.ExceptionSpec.SourceTemplate;
2913  // This exception specification doesn't make the type dependent, because
2914  // it's not instantiated as part of instantiating the type.
2915  } else if (getExceptionSpecType() == EST_Unevaluated) {
2916  // Store the function decl from which we will resolve our
2917  // exception specification.
2918  auto **slot = reinterpret_cast<FunctionDecl **>(argSlot + NumParams);
2919  slot[0] = epi.ExceptionSpec.SourceDecl;
2920  }
2921 
2922  // If this is a canonical type, and its exception specification is dependent,
2923  // then it's a dependent type. This only happens in C++17 onwards.
2924  if (isCanonicalUnqualified()) {
2925  if (getExceptionSpecType() == EST_Dynamic ||
2926  getExceptionSpecType() == EST_DependentNoexcept) {
2927  assert(hasDependentExceptionSpec() && "type should not be canonical");
2928  setDependent();
2929  }
2930  } else if (getCanonicalTypeInternal()->isDependentType()) {
2931  // Ask our canonical type whether our exception specification was dependent.
2932  setDependent();
2933  }
2934 
2935  if (epi.ExtParameterInfos) {
2936  auto *extParamInfos =
2937  const_cast<ExtParameterInfo *>(getExtParameterInfosBuffer());
2938  for (unsigned i = 0; i != NumParams; ++i)
2939  extParamInfos[i] = epi.ExtParameterInfos[i];
2940  }
2941 }
2942 
2944  if (Expr *NE = getNoexceptExpr())
2945  return NE->isValueDependent();
2946  for (QualType ET : exceptions())
2947  // A pack expansion with a non-dependent pattern is still dependent,
2948  // because we don't know whether the pattern is in the exception spec
2949  // or not (that depends on whether the pack has 0 expansions).
2950  if (ET->isDependentType() || ET->getAs<PackExpansionType>())
2951  return true;
2952  return false;
2953 }
2954 
2956  if (Expr *NE = getNoexceptExpr())
2957  return NE->isInstantiationDependent();
2958  for (QualType ET : exceptions())
2959  if (ET->isInstantiationDependentType())
2960  return true;
2961  return false;
2962 }
2963 
2965  switch (getExceptionSpecType()) {
2966  case EST_Unparsed:
2967  case EST_Unevaluated:
2968  case EST_Uninstantiated:
2969  llvm_unreachable("should not call this with unresolved exception specs");
2970 
2971  case EST_DynamicNone:
2972  case EST_BasicNoexcept:
2973  case EST_NoexceptTrue:
2974  return CT_Cannot;
2975 
2976  case EST_None:
2977  case EST_MSAny:
2978  case EST_NoexceptFalse:
2979  return CT_Can;
2980 
2981  case EST_Dynamic:
2982  // A dynamic exception specification is throwing unless every exception
2983  // type is an (unexpanded) pack expansion type.
2984  for (unsigned I = 0, N = NumExceptions; I != N; ++I)
2985  if (!getExceptionType(I)->getAs<PackExpansionType>())
2986  return CT_Can;
2987  return CT_Dependent;
2988 
2989  case EST_DependentNoexcept:
2990  return CT_Dependent;
2991  }
2992 
2993  llvm_unreachable("unexpected exception specification kind");
2994 }
2995 
2997  for (unsigned ArgIdx = getNumParams(); ArgIdx; --ArgIdx)
2998  if (isa<PackExpansionType>(getParamType(ArgIdx - 1)))
2999  return true;
3000 
3001  return false;
3002 }
3003 
3004 void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID, QualType Result,
3005  const QualType *ArgTys, unsigned NumParams,
3006  const ExtProtoInfo &epi,
3007  const ASTContext &Context, bool Canonical) {
3008  // We have to be careful not to get ambiguous profile encodings.
3009  // Note that valid type pointers are never ambiguous with anything else.
3010  //
3011  // The encoding grammar begins:
3012  // type type* bool int bool
3013  // If that final bool is true, then there is a section for the EH spec:
3014  // bool type*
3015  // This is followed by an optional "consumed argument" section of the
3016  // same length as the first type sequence:
3017  // bool*
3018  // Finally, we have the ext info and trailing return type flag:
3019  // int bool
3020  //
3021  // There is no ambiguity between the consumed arguments and an empty EH
3022  // spec because of the leading 'bool' which unambiguously indicates
3023  // whether the following bool is the EH spec or part of the arguments.
3024 
3025  ID.AddPointer(Result.getAsOpaquePtr());
3026  for (unsigned i = 0; i != NumParams; ++i)
3027  ID.AddPointer(ArgTys[i].getAsOpaquePtr());
3028  // This method is relatively performance sensitive, so as a performance
3029  // shortcut, use one AddInteger call instead of four for the next four
3030  // fields.
3031  assert(!(unsigned(epi.Variadic) & ~1) &&
3032  !(unsigned(epi.TypeQuals) & ~255) &&
3033  !(unsigned(epi.RefQualifier) & ~3) &&
3034  !(unsigned(epi.ExceptionSpec.Type) & ~15) &&
3035  "Values larger than expected.");
3036  ID.AddInteger(unsigned(epi.Variadic) +
3037  (epi.TypeQuals << 1) +
3038  (epi.RefQualifier << 9) +
3039  (epi.ExceptionSpec.Type << 11));
3040  if (epi.ExceptionSpec.Type == EST_Dynamic) {
3041  for (QualType Ex : epi.ExceptionSpec.Exceptions)
3042  ID.AddPointer(Ex.getAsOpaquePtr());
3043  } else if (isComputedNoexcept(epi.ExceptionSpec.Type)) {
3044  epi.ExceptionSpec.NoexceptExpr->Profile(ID, Context, Canonical);
3045  } else if (epi.ExceptionSpec.Type == EST_Uninstantiated ||
3047  ID.AddPointer(epi.ExceptionSpec.SourceDecl->getCanonicalDecl());
3048  }
3049  if (epi.ExtParameterInfos) {
3050  for (unsigned i = 0; i != NumParams; ++i)
3051  ID.AddInteger(epi.ExtParameterInfos[i].getOpaqueValue());
3052  }
3053  epi.ExtInfo.Profile(ID);
3054  ID.AddBoolean(epi.HasTrailingReturn);
3055 }
3056 
3057 void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID,
3058  const ASTContext &Ctx) {
3059  Profile(ID, getReturnType(), param_type_begin(), NumParams, getExtProtoInfo(),
3060  Ctx, isCanonicalUnqualified());
3061 }
3062 
3064  return getDecl()->getUnderlyingType();
3065 }
3066 
3068  : Type(TypeOfExpr, can, E->isTypeDependent(),
3069  E->isInstantiationDependent(),
3070  E->getType()->isVariablyModifiedType(),
3072  TOExpr(E) {}
3073 
3075  return !TOExpr->isTypeDependent();
3076 }
3077 
3079  if (isSugared())
3080  return getUnderlyingExpr()->getType();
3081 
3082  return QualType(this, 0);
3083 }
3084 
3085 void DependentTypeOfExprType::Profile(llvm::FoldingSetNodeID &ID,
3086  const ASTContext &Context, Expr *E) {
3087  E->Profile(ID, Context, true);
3088 }
3089 
3091  // C++11 [temp.type]p2: "If an expression e involves a template parameter,
3092  // decltype(e) denotes a unique dependent type." Hence a decltype type is
3093  // type-dependent even if its expression is only instantiation-dependent.
3094  : Type(Decltype, can, E->isInstantiationDependent(),
3095  E->isInstantiationDependent(),
3096  E->getType()->isVariablyModifiedType(),
3098  E(E), UnderlyingType(underlyingType) {}
3099 
3101 
3103  if (isSugared())
3104  return getUnderlyingType();
3105 
3106  return QualType(this, 0);
3107 }
3108 
3110  : DecltypeType(E, Context.DependentTy), Context(Context) {}
3111 
3112 void DependentDecltypeType::Profile(llvm::FoldingSetNodeID &ID,
3113  const ASTContext &Context, Expr *E) {
3114  E->Profile(ID, Context, true);
3115 }
3116 
3118  QualType UnderlyingType,
3119  UTTKind UKind,
3120  QualType CanonicalType)
3121  : Type(UnaryTransform, CanonicalType, BaseType->isDependentType(),
3122  BaseType->isInstantiationDependentType(),
3123  BaseType->isVariablyModifiedType(),
3124  BaseType->containsUnexpandedParameterPack()),
3125  BaseType(BaseType), UnderlyingType(UnderlyingType), UKind(UKind) {}
3126 
3128  QualType BaseType,
3129  UTTKind UKind)
3130  : UnaryTransformType(BaseType, C.DependentTy, UKind, QualType()) {}
3131 
3133  : Type(TC, can, D->isDependentType(),
3134  /*InstantiationDependent=*/D->isDependentType(),
3135  /*VariablyModified=*/false,
3136  /*ContainsUnexpandedParameterPack=*/false),
3137  decl(const_cast<TagDecl*>(D)) {}
3138 
3140  for (auto I : decl->redecls()) {
3141  if (I->isCompleteDefinition() || I->isBeingDefined())
3142  return I;
3143  }
3144  // If there's no definition (not even in progress), return what we have.
3145  return decl;
3146 }
3147 
3149  return getInterestingTagDecl(decl);
3150 }
3151 
3153  return getDecl()->isBeingDefined();
3154 }
3155 
3157  for (FieldDecl *FD : getDecl()->fields()) {
3158  QualType FieldTy = FD->getType();
3159  if (FieldTy.isConstQualified())
3160  return true;
3161  FieldTy = FieldTy.getCanonicalType();
3162  if (const auto *FieldRecTy = FieldTy->getAs<RecordType>())
3163  if (FieldRecTy->hasConstFields())
3164  return true;
3165  }
3166  return false;
3167 }
3168 
3170  switch (getAttrKind()) {
3171  // These are type qualifiers in the traditional C sense: they annotate
3172  // something about a specific value/variable of a type. (They aren't
3173  // always part of the canonical type, though.)
3182  return true;
3183 
3184  // These aren't qualifiers; they rewrite the modified type to be a
3185  // semantically different type.
3213  return false;
3214  }
3215  llvm_unreachable("bad attributed type kind");
3216 }
3217 
3219  switch (getAttrKind()) {
3220  default: return false;
3221  case attr_ptr32:
3222  case attr_ptr64:
3223  case attr_sptr:
3224  case attr_uptr:
3225  return true;
3226  }
3227  llvm_unreachable("invalid attr kind");
3228 }
3229 
3231  switch (getAttrKind()) {
3232  case attr_ptr32:
3233  case attr_ptr64:
3234  case attr_sptr:
3235  case attr_uptr:
3236  case attr_address_space:
3237  case attr_regparm:
3238  case attr_vector_size:
3239  case attr_neon_vector_type:
3240  case attr_neon_polyvector_type:
3241  case attr_objc_gc:
3242  case attr_objc_ownership:
3243  case attr_objc_inert_unsafe_unretained:
3244  case attr_noreturn:
3245  case attr_nonnull:
3246  case attr_ns_returns_retained:
3247  case attr_nullable:
3248  case attr_null_unspecified:
3249  case attr_objc_kindof:
3250  case attr_nocf_check:
3251  case attr_lifetimebound:
3252  return false;
3253 
3254  case attr_pcs:
3255  case attr_pcs_vfp:
3256  case attr_cdecl:
3257  case attr_fastcall:
3258  case attr_stdcall:
3259  case attr_thiscall:
3260  case attr_regcall:
3261  case attr_swiftcall:
3262  case attr_vectorcall:
3263  case attr_pascal:
3264  case attr_ms_abi:
3265  case attr_sysv_abi:
3266  case attr_inteloclbicc:
3267  case attr_preserve_most:
3268  case attr_preserve_all:
3269  return true;
3270  }
3271  llvm_unreachable("invalid attr kind");
3272 }
3273 
3275  return cast<CXXRecordDecl>(getInterestingTagDecl(Decl));
3276 }
3277 
3279  return isCanonicalUnqualified() ? nullptr : getDecl()->getIdentifier();
3280 }
3281 
3282 SubstTemplateTypeParmPackType::
3283 SubstTemplateTypeParmPackType(const TemplateTypeParmType *Param,
3284  QualType Canon,
3285  const TemplateArgument &ArgPack)
3286  : Type(SubstTemplateTypeParmPack, Canon, true, true, false, true),
3287  Replaced(Param),
3288  Arguments(ArgPack.pack_begin()), NumArguments(ArgPack.pack_size()) {}
3289 
3291  return TemplateArgument(llvm::makeArrayRef(Arguments, NumArguments));
3292 }
3293 
3294 void SubstTemplateTypeParmPackType::Profile(llvm::FoldingSetNodeID &ID) {
3295  Profile(ID, getReplacedParameter(), getArgumentPack());
3296 }
3297 
3298 void SubstTemplateTypeParmPackType::Profile(llvm::FoldingSetNodeID &ID,
3299  const TemplateTypeParmType *Replaced,
3300  const TemplateArgument &ArgPack) {
3301  ID.AddPointer(Replaced);
3302  ID.AddInteger(ArgPack.pack_size());
3303  for (const auto &P : ArgPack.pack_elements())
3304  ID.AddPointer(P.getAsType().getAsOpaquePtr());
3305 }
3306 
3309  bool &InstantiationDependent) {
3310  return anyDependentTemplateArguments(Args.arguments(),
3311  InstantiationDependent);
3312 }
3313 
3316  bool &InstantiationDependent) {
3317  for (const TemplateArgumentLoc &ArgLoc : Args) {
3318  if (ArgLoc.getArgument().isDependent()) {
3319  InstantiationDependent = true;
3320  return true;
3321  }
3322 
3323  if (ArgLoc.getArgument().isInstantiationDependent())
3324  InstantiationDependent = true;
3325  }
3326  return false;
3327 }
3328 
3329 TemplateSpecializationType::
3330 TemplateSpecializationType(TemplateName T,
3332  QualType Canon, QualType AliasedType)
3333  : Type(TemplateSpecialization,
3334  Canon.isNull()? QualType(this, 0) : Canon,
3335  Canon.isNull()? true : Canon->isDependentType(),
3336  Canon.isNull()? true : Canon->isInstantiationDependentType(),
3337  false,
3339  Template(T), NumArgs(Args.size()), TypeAlias(!AliasedType.isNull()) {
3340  assert(!T.getAsDependentTemplateName() &&
3341  "Use DependentTemplateSpecializationType for dependent template-name");
3342  assert((T.getKind() == TemplateName::Template ||
3345  "Unexpected template name for TemplateSpecializationType");
3346 
3347  auto *TemplateArgs = reinterpret_cast<TemplateArgument *>(this + 1);
3348  for (const TemplateArgument &Arg : Args) {
3349  // Update instantiation-dependent and variably-modified bits.
3350  // If the canonical type exists and is non-dependent, the template
3351  // specialization type can be non-dependent even if one of the type
3352  // arguments is. Given:
3353  // template<typename T> using U = int;
3354  // U<T> is always non-dependent, irrespective of the type T.
3355  // However, U<Ts> contains an unexpanded parameter pack, even though
3356  // its expansion (and thus its desugared type) doesn't.
3357  if (Arg.isInstantiationDependent())
3359  if (Arg.getKind() == TemplateArgument::Type &&
3360  Arg.getAsType()->isVariablyModifiedType())
3362  if (Arg.containsUnexpandedParameterPack())
3364  new (TemplateArgs++) TemplateArgument(Arg);
3365  }
3366 
3367  // Store the aliased type if this is a type alias template specialization.
3368  if (TypeAlias) {
3369  auto *Begin = reinterpret_cast<TemplateArgument *>(this + 1);
3370  *reinterpret_cast<QualType*>(Begin + getNumArgs()) = AliasedType;
3371  }
3372 }
3373 
3374 void
3375 TemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,
3376  TemplateName T,
3378  const ASTContext &Context) {
3379  T.Profile(ID);
3380  for (const TemplateArgument &Arg : Args)
3381  Arg.Profile(ID, Context);
3382 }
3383 
3384 QualType
3385 QualifierCollector::apply(const ASTContext &Context, QualType QT) const {
3386  if (!hasNonFastQualifiers())
3387  return QT.withFastQualifiers(getFastQualifiers());
3388 
3389  return Context.getQualifiedType(QT, *this);
3390 }
3391 
3392 QualType
3393 QualifierCollector::apply(const ASTContext &Context, const Type *T) const {
3394  if (!hasNonFastQualifiers())
3395  return QualType(T, getFastQualifiers());
3396 
3397  return Context.getQualifiedType(T, *this);
3398 }
3399 
3400 void ObjCObjectTypeImpl::Profile(llvm::FoldingSetNodeID &ID,
3401  QualType BaseType,
3402  ArrayRef<QualType> typeArgs,
3403  ArrayRef<ObjCProtocolDecl *> protocols,
3404  bool isKindOf) {
3405  ID.AddPointer(BaseType.getAsOpaquePtr());
3406  ID.AddInteger(typeArgs.size());
3407  for (auto typeArg : typeArgs)
3408  ID.AddPointer(typeArg.getAsOpaquePtr());
3409  ID.AddInteger(protocols.size());
3410  for (auto proto : protocols)
3411  ID.AddPointer(proto);
3412  ID.AddBoolean(isKindOf);
3413 }
3414 
3415 void ObjCObjectTypeImpl::Profile(llvm::FoldingSetNodeID &ID) {
3416  Profile(ID, getBaseType(), getTypeArgsAsWritten(),
3417  llvm::makeArrayRef(qual_begin(), getNumProtocols()),
3418  isKindOfTypeAsWritten());
3419 }
3420 
3421 void ObjCTypeParamType::Profile(llvm::FoldingSetNodeID &ID,
3422  const ObjCTypeParamDecl *OTPDecl,
3423  ArrayRef<ObjCProtocolDecl *> protocols) {
3424  ID.AddPointer(OTPDecl);
3425  ID.AddInteger(protocols.size());
3426  for (auto proto : protocols)
3427  ID.AddPointer(proto);
3428 }
3429 
3430 void ObjCTypeParamType::Profile(llvm::FoldingSetNodeID &ID) {
3431  Profile(ID, getDecl(),
3432  llvm::makeArrayRef(qual_begin(), getNumProtocols()));
3433 }
3434 
3435 namespace {
3436 
3437 /// The cached properties of a type.
3438 class CachedProperties {
3439  Linkage L;
3440  bool local;
3441 
3442 public:
3443  CachedProperties(Linkage L, bool local) : L(L), local(local) {}
3444 
3445  Linkage getLinkage() const { return L; }
3446  bool hasLocalOrUnnamedType() const { return local; }
3447 
3448  friend CachedProperties merge(CachedProperties L, CachedProperties R) {
3449  Linkage MergedLinkage = minLinkage(L.L, R.L);
3450  return CachedProperties(MergedLinkage,
3451  L.hasLocalOrUnnamedType() | R.hasLocalOrUnnamedType());
3452  }
3453 };
3454 
3455 } // namespace
3456 
3457 static CachedProperties computeCachedProperties(const Type *T);
3458 
3459 namespace clang {
3460 
3461 /// The type-property cache. This is templated so as to be
3462 /// instantiated at an internal type to prevent unnecessary symbol
3463 /// leakage.
3464 template <class Private> class TypePropertyCache {
3465 public:
3466  static CachedProperties get(QualType T) {
3467  return get(T.getTypePtr());
3468  }
3469 
3470  static CachedProperties get(const Type *T) {
3471  ensure(T);
3472  return CachedProperties(T->TypeBits.getLinkage(),
3473  T->TypeBits.hasLocalOrUnnamedType());
3474  }
3475 
3476  static void ensure(const Type *T) {
3477  // If the cache is valid, we're okay.
3478  if (T->TypeBits.isCacheValid()) return;
3479 
3480  // If this type is non-canonical, ask its canonical type for the
3481  // relevant information.
3482  if (!T->isCanonicalUnqualified()) {
3483  const Type *CT = T->getCanonicalTypeInternal().getTypePtr();
3484  ensure(CT);
3485  T->TypeBits.CacheValid = true;
3486  T->TypeBits.CachedLinkage = CT->TypeBits.CachedLinkage;
3487  T->TypeBits.CachedLocalOrUnnamed = CT->TypeBits.CachedLocalOrUnnamed;
3488  return;
3489  }
3490 
3491  // Compute the cached properties and then set the cache.
3492  CachedProperties Result = computeCachedProperties(T);
3493  T->TypeBits.CacheValid = true;
3494  T->TypeBits.CachedLinkage = Result.getLinkage();
3495  T->TypeBits.CachedLocalOrUnnamed = Result.hasLocalOrUnnamedType();
3496  }
3497 };
3498 
3499 } // namespace clang
3500 
3501 // Instantiate the friend template at a private class. In a
3502 // reasonable implementation, these symbols will be internal.
3503 // It is terrible that this is the best way to accomplish this.
3504 namespace {
3505 
3506 class Private {};
3507 
3508 } // namespace
3509 
3511 
3512 static CachedProperties computeCachedProperties(const Type *T) {
3513  switch (T->getTypeClass()) {
3514 #define TYPE(Class,Base)
3515 #define NON_CANONICAL_TYPE(Class,Base) case Type::Class:
3516 #include "clang/AST/TypeNodes.def"
3517  llvm_unreachable("didn't expect a non-canonical type here");
3518 
3519 #define TYPE(Class,Base)
3520 #define DEPENDENT_TYPE(Class,Base) case Type::Class:
3521 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
3522 #include "clang/AST/TypeNodes.def"
3523  // Treat instantiation-dependent types as external.
3524  assert(T->isInstantiationDependentType());
3525  return CachedProperties(ExternalLinkage, false);
3526 
3527  case Type::Auto:
3528  case Type::DeducedTemplateSpecialization:
3529  // Give non-deduced 'auto' types external linkage. We should only see them
3530  // here in error recovery.
3531  return CachedProperties(ExternalLinkage, false);
3532 
3533  case Type::Builtin:
3534  // C++ [basic.link]p8:
3535  // A type is said to have linkage if and only if:
3536  // - it is a fundamental type (3.9.1); or
3537  return CachedProperties(ExternalLinkage, false);
3538 
3539  case Type::Record:
3540  case Type::Enum: {
3541  const TagDecl *Tag = cast<TagType>(T)->getDecl();
3542 
3543  // C++ [basic.link]p8:
3544  // - it is a class or enumeration type that is named (or has a name
3545  // for linkage purposes (7.1.3)) and the name has linkage; or
3546  // - it is a specialization of a class template (14); or
3547  Linkage L = Tag->getLinkageInternal();
3548  bool IsLocalOrUnnamed =
3549  Tag->getDeclContext()->isFunctionOrMethod() ||
3550  !Tag->hasNameForLinkage();
3551  return CachedProperties(L, IsLocalOrUnnamed);
3552  }
3553 
3554  // C++ [basic.link]p8:
3555  // - it is a compound type (3.9.2) other than a class or enumeration,
3556  // compounded exclusively from types that have linkage; or
3557  case Type::Complex:
3558  return Cache::get(cast<ComplexType>(T)->getElementType());
3559  case Type::Pointer:
3560  return Cache::get(cast<PointerType>(T)->getPointeeType());
3561  case Type::BlockPointer:
3562  return Cache::get(cast<BlockPointerType>(T)->getPointeeType());
3563  case Type::LValueReference:
3564  case Type::RValueReference:
3565  return Cache::get(cast<ReferenceType>(T)->getPointeeType());
3566  case Type::MemberPointer: {
3567  const auto *MPT = cast<MemberPointerType>(T);
3568  return merge(Cache::get(MPT->getClass()),
3569  Cache::get(MPT->getPointeeType()));
3570  }
3571  case Type::ConstantArray:
3572  case Type::IncompleteArray:
3573  case Type::VariableArray:
3574  return Cache::get(cast<ArrayType>(T)->getElementType());
3575  case Type::Vector:
3576  case Type::ExtVector:
3577  return Cache::get(cast<VectorType>(T)->getElementType());
3578  case Type::FunctionNoProto:
3579  return Cache::get(cast<FunctionType>(T)->getReturnType());
3580  case Type::FunctionProto: {
3581  const auto *FPT = cast<FunctionProtoType>(T);
3582  CachedProperties result = Cache::get(FPT->getReturnType());
3583  for (const auto &ai : FPT->param_types())
3584  result = merge(result, Cache::get(ai));
3585  return result;
3586  }
3587  case Type::ObjCInterface: {
3588  Linkage L = cast<ObjCInterfaceType>(T)->getDecl()->getLinkageInternal();
3589  return CachedProperties(L, false);
3590  }
3591  case Type::ObjCObject:
3592  return Cache::get(cast<ObjCObjectType>(T)->getBaseType());
3593  case Type::ObjCObjectPointer:
3594  return Cache::get(cast<ObjCObjectPointerType>(T)->getPointeeType());
3595  case Type::Atomic:
3596  return Cache::get(cast<AtomicType>(T)->getValueType());
3597  case Type::Pipe:
3598  return Cache::get(cast<PipeType>(T)->getElementType());
3599  }
3600 
3601  llvm_unreachable("unhandled type class");
3602 }
3603 
3604 /// Determine the linkage of this type.
3606  Cache::ensure(this);
3607  return TypeBits.getLinkage();
3608 }
3609 
3611  Cache::ensure(this);
3612  return TypeBits.hasLocalOrUnnamedType();
3613 }
3614 
3616  switch (T->getTypeClass()) {
3617 #define TYPE(Class,Base)
3618 #define NON_CANONICAL_TYPE(Class,Base) case Type::Class:
3619 #include "clang/AST/TypeNodes.def"
3620  llvm_unreachable("didn't expect a non-canonical type here");
3621 
3622 #define TYPE(Class,Base)
3623 #define DEPENDENT_TYPE(Class,Base) case Type::Class:
3624 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
3625 #include "clang/AST/TypeNodes.def"
3626  // Treat instantiation-dependent types as external.
3627  assert(T->isInstantiationDependentType());
3628  return LinkageInfo::external();
3629 
3630  case Type::Builtin:
3631  return LinkageInfo::external();
3632 
3633  case Type::Auto:
3634  case Type::DeducedTemplateSpecialization:
3635  return LinkageInfo::external();
3636 
3637  case Type::Record:
3638  case Type::Enum:
3639  return getDeclLinkageAndVisibility(cast<TagType>(T)->getDecl());
3640 
3641  case Type::Complex:
3642  return computeTypeLinkageInfo(cast<ComplexType>(T)->getElementType());
3643  case Type::Pointer:
3644  return computeTypeLinkageInfo(cast<PointerType>(T)->getPointeeType());
3645  case Type::BlockPointer:
3646  return computeTypeLinkageInfo(cast<BlockPointerType>(T)->getPointeeType());
3647  case Type::LValueReference:
3648  case Type::RValueReference:
3649  return computeTypeLinkageInfo(cast<ReferenceType>(T)->getPointeeType());
3650  case Type::MemberPointer: {
3651  const auto *MPT = cast<MemberPointerType>(T);
3652  LinkageInfo LV = computeTypeLinkageInfo(MPT->getClass());
3653  LV.merge(computeTypeLinkageInfo(MPT->getPointeeType()));
3654  return LV;
3655  }
3656  case Type::ConstantArray:
3657  case Type::IncompleteArray:
3658  case Type::VariableArray:
3659  return computeTypeLinkageInfo(cast<ArrayType>(T)->getElementType());
3660  case Type::Vector:
3661  case Type::ExtVector:
3662  return computeTypeLinkageInfo(cast<VectorType>(T)->getElementType());
3663  case Type::FunctionNoProto:
3664  return computeTypeLinkageInfo(cast<FunctionType>(T)->getReturnType());
3665  case Type::FunctionProto: {
3666  const auto *FPT = cast<FunctionProtoType>(T);
3667  LinkageInfo LV = computeTypeLinkageInfo(FPT->getReturnType());
3668  for (const auto &ai : FPT->param_types())
3669  LV.merge(computeTypeLinkageInfo(ai));
3670  return LV;
3671  }
3672  case Type::ObjCInterface:
3673  return getDeclLinkageAndVisibility(cast<ObjCInterfaceType>(T)->getDecl());
3674  case Type::ObjCObject:
3675  return computeTypeLinkageInfo(cast<ObjCObjectType>(T)->getBaseType());
3676  case Type::ObjCObjectPointer:
3677  return computeTypeLinkageInfo(
3678  cast<ObjCObjectPointerType>(T)->getPointeeType());
3679  case Type::Atomic:
3680  return computeTypeLinkageInfo(cast<AtomicType>(T)->getValueType());
3681  case Type::Pipe:
3682  return computeTypeLinkageInfo(cast<PipeType>(T)->getElementType());
3683  }
3684 
3685  llvm_unreachable("unhandled type class");
3686 }
3687 
3688 bool Type::isLinkageValid() const {
3689  if (!TypeBits.isCacheValid())
3690  return true;
3691 
3692  Linkage L = LinkageComputer{}
3694  .getLinkage();
3695  return L == TypeBits.getLinkage();
3696 }
3697 
3699  if (!T->isCanonicalUnqualified())
3700  return computeTypeLinkageInfo(T->getCanonicalTypeInternal());
3701 
3702  LinkageInfo LV = computeTypeLinkageInfo(T);
3703  assert(LV.getLinkage() == T->getLinkage());
3704  return LV;
3705 }
3706 
3709 }
3710 
3712  QualType type(this, 0);
3713  do {
3714  // Check whether this is an attributed type with nullability
3715  // information.
3716  if (auto attributed = dyn_cast<AttributedType>(type.getTypePtr())) {
3717  if (auto nullability = attributed->getImmediateNullability())
3718  return nullability;
3719  }
3720 
3721  // Desugar the type. If desugaring does nothing, we're done.
3722  QualType desugared = type.getSingleStepDesugaredType(context);
3723  if (desugared.getTypePtr() == type.getTypePtr())
3724  return None;
3725 
3726  type = desugared;
3727  } while (true);
3728 }
3729 
3730 bool Type::canHaveNullability(bool ResultIfUnknown) const {
3732 
3733  switch (type->getTypeClass()) {
3734  // We'll only see canonical types here.
3735 #define NON_CANONICAL_TYPE(Class, Parent) \
3736  case Type::Class: \
3737  llvm_unreachable("non-canonical type");
3738 #define TYPE(Class, Parent)
3739 #include "clang/AST/TypeNodes.def"
3740 
3741  // Pointer types.
3742  case Type::Pointer:
3743  case Type::BlockPointer:
3744  case Type::MemberPointer:
3745  case Type::ObjCObjectPointer:
3746  return true;
3747 
3748  // Dependent types that could instantiate to pointer types.
3749  case Type::UnresolvedUsing:
3750  case Type::TypeOfExpr:
3751  case Type::TypeOf:
3752  case Type::Decltype:
3753  case Type::UnaryTransform:
3754  case Type::TemplateTypeParm:
3755  case Type::SubstTemplateTypeParmPack:
3756  case Type::DependentName:
3757  case Type::DependentTemplateSpecialization:
3758  case Type::Auto:
3759  return ResultIfUnknown;
3760 
3761  // Dependent template specializations can instantiate to pointer
3762  // types unless they're known to be specializations of a class
3763  // template.
3764  case Type::TemplateSpecialization:
3765  if (TemplateDecl *templateDecl
3766  = cast<TemplateSpecializationType>(type.getTypePtr())
3767  ->getTemplateName().getAsTemplateDecl()) {
3768  if (isa<ClassTemplateDecl>(templateDecl))
3769  return false;
3770  }
3771  return ResultIfUnknown;
3772 
3773  case Type::Builtin:
3774  switch (cast<BuiltinType>(type.getTypePtr())->getKind()) {
3775  // Signed, unsigned, and floating-point types cannot have nullability.
3776 #define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
3777 #define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
3778 #define FLOATING_TYPE(Id, SingletonId) case BuiltinType::Id:
3779 #define BUILTIN_TYPE(Id, SingletonId)
3780 #include "clang/AST/BuiltinTypes.def"
3781  return false;
3782 
3783  // Dependent types that could instantiate to a pointer type.
3784  case BuiltinType::Dependent:
3785  case BuiltinType::Overload:
3786  case BuiltinType::BoundMember:
3787  case BuiltinType::PseudoObject:
3788  case BuiltinType::UnknownAny:
3789  case BuiltinType::ARCUnbridgedCast:
3790  return ResultIfUnknown;
3791 
3792  case BuiltinType::Void:
3793  case BuiltinType::ObjCId:
3794  case BuiltinType::ObjCClass:
3795  case BuiltinType::ObjCSel:
3796 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
3797  case BuiltinType::Id:
3798 #include "clang/Basic/OpenCLImageTypes.def"
3799  case BuiltinType::OCLSampler:
3800  case BuiltinType::OCLEvent:
3801  case BuiltinType::OCLClkEvent:
3802  case BuiltinType::OCLQueue:
3803  case BuiltinType::OCLReserveID:
3804  case BuiltinType::BuiltinFn:
3805  case BuiltinType::NullPtr:
3806  case BuiltinType::OMPArraySection:
3807  return false;
3808  }
3809  llvm_unreachable("unknown builtin type");
3810 
3811  // Non-pointer types.
3812  case Type::Complex:
3813  case Type::LValueReference:
3814  case Type::RValueReference:
3815  case Type::ConstantArray:
3816  case Type::IncompleteArray:
3817  case Type::VariableArray:
3818  case Type::DependentSizedArray:
3819  case Type::DependentVector:
3820  case Type::DependentSizedExtVector:
3821  case Type::Vector:
3822  case Type::ExtVector:
3823  case Type::DependentAddressSpace:
3824  case Type::FunctionProto:
3825  case Type::FunctionNoProto:
3826  case Type::Record:
3827  case Type::DeducedTemplateSpecialization:
3828  case Type::Enum:
3829  case Type::InjectedClassName:
3830  case Type::PackExpansion:
3831  case Type::ObjCObject:
3832  case Type::ObjCInterface:
3833  case Type::Atomic:
3834  case Type::Pipe:
3835  return false;
3836  }
3837  llvm_unreachable("bad type kind!");
3838 }
3839 
3841  if (getAttrKind() == AttributedType::attr_nonnull)
3842  return NullabilityKind::NonNull;
3843  if (getAttrKind() == AttributedType::attr_nullable)
3845  if (getAttrKind() == AttributedType::attr_null_unspecified)
3847  return None;
3848 }
3849 
3851  if (auto attributed = dyn_cast<AttributedType>(T.getTypePtr())) {
3852  if (auto nullability = attributed->getImmediateNullability()) {
3853  T = attributed->getModifiedType();
3854  return nullability;
3855  }
3856  }
3857 
3858  return None;
3859 }
3860 
3862  const auto *objcPtr = getAs<ObjCObjectPointerType>();
3863  if (!objcPtr)
3864  return false;
3865 
3866  if (objcPtr->isObjCIdType()) {
3867  // id is always okay.
3868  return true;
3869  }
3870 
3871  // Blocks are NSObjects.
3872  if (ObjCInterfaceDecl *iface = objcPtr->getInterfaceDecl()) {
3873  if (iface->getIdentifier() != ctx.getNSObjectName())
3874  return false;
3875 
3876  // Continue to check qualifiers, below.
3877  } else if (objcPtr->isObjCQualifiedIdType()) {
3878  // Continue to check qualifiers, below.
3879  } else {
3880  return false;
3881  }
3882 
3883  // Check protocol qualifiers.
3884  for (ObjCProtocolDecl *proto : objcPtr->quals()) {
3885  // Blocks conform to NSObject and NSCopying.
3886  if (proto->getIdentifier() != ctx.getNSObjectName() &&
3887  proto->getIdentifier() != ctx.getNSCopyingName())
3888  return false;
3889  }
3890 
3891  return true;
3892 }
3893 
3897  return Qualifiers::OCL_Strong;
3898 }
3899 
3901  assert(isObjCLifetimeType() &&
3902  "cannot query implicit lifetime for non-inferrable type");
3903 
3904  const Type *canon = getCanonicalTypeInternal().getTypePtr();
3905 
3906  // Walk down to the base type. We don't care about qualifiers for this.
3907  while (const auto *array = dyn_cast<ArrayType>(canon))
3908  canon = array->getElementType().getTypePtr();
3909 
3910  if (const auto *opt = dyn_cast<ObjCObjectPointerType>(canon)) {
3911  // Class and Class<Protocol> don't require retention.
3912  if (opt->getObjectType()->isObjCClass())
3913  return true;
3914  }
3915 
3916  return false;
3917 }
3918 
3920  const Type *cur = this;
3921  while (true) {
3922  if (const auto *typedefType = dyn_cast<TypedefType>(cur))
3923  return typedefType->getDecl()->hasAttr<ObjCNSObjectAttr>();
3924 
3925  // Single-step desugar until we run out of sugar.
3927  if (next.getTypePtr() == cur) return false;
3928  cur = next.getTypePtr();
3929  }
3930 }
3931 
3933  if (const auto *typedefType = dyn_cast<TypedefType>(this))
3934  return typedefType->getDecl()->hasAttr<ObjCIndependentClassAttr>();
3935  return false;
3936 }
3937 
3939  return isObjCObjectPointerType() ||
3940  isBlockPointerType() ||
3942 }
3943 
3945  if (isObjCLifetimeType())
3946  return true;
3947  if (const auto *OPT = getAs<PointerType>())
3948  return OPT->getPointeeType()->isObjCIndirectLifetimeType();
3949  if (const auto *Ref = getAs<ReferenceType>())
3950  return Ref->getPointeeType()->isObjCIndirectLifetimeType();
3951  if (const auto *MemPtr = getAs<MemberPointerType>())
3952  return MemPtr->getPointeeType()->isObjCIndirectLifetimeType();
3953  return false;
3954 }
3955 
3956 /// Returns true if objects of this type have lifetime semantics under
3957 /// ARC.
3959  const Type *type = this;
3960  while (const ArrayType *array = type->getAsArrayTypeUnsafe())
3961  type = array->getElementType().getTypePtr();
3962  return type->isObjCRetainableType();
3963 }
3964 
3965 /// Determine whether the given type T is a "bridgable" Objective-C type,
3966 /// which is either an Objective-C object pointer type or an
3969 }
3970 
3971 /// Determine whether the given type T is a "bridgeable" C type.
3973  const auto *Pointer = getAs<PointerType>();
3974  if (!Pointer)
3975  return false;
3976 
3977  QualType Pointee = Pointer->getPointeeType();
3978  return Pointee->isVoidType() || Pointee->isRecordType();
3979 }
3980 
3982  if (!isVariablyModifiedType()) return false;
3983 
3984  if (const auto *ptr = getAs<PointerType>())
3985  return ptr->getPointeeType()->hasSizedVLAType();
3986  if (const auto *ref = getAs<ReferenceType>())
3987  return ref->getPointeeType()->hasSizedVLAType();
3988  if (const ArrayType *arr = getAsArrayTypeUnsafe()) {
3989  if (isa<VariableArrayType>(arr) &&
3990  cast<VariableArrayType>(arr)->getSizeExpr())
3991  return true;
3992 
3993  return arr->getElementType()->hasSizedVLAType();
3994  }
3995 
3996  return false;
3997 }
3998 
3999 QualType::DestructionKind QualType::isDestructedTypeImpl(QualType type) {
4000  switch (type.getObjCLifetime()) {
4001  case Qualifiers::OCL_None:
4004  break;
4005 
4007  return DK_objc_strong_lifetime;
4008  case Qualifiers::OCL_Weak:
4009  return DK_objc_weak_lifetime;
4010  }
4011 
4012  if (const auto *RT =
4014  const RecordDecl *RD = RT->getDecl();
4015  if (const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
4016  /// Check if this is a C++ object with a non-trivial destructor.
4017  if (CXXRD->hasDefinition() && !CXXRD->hasTrivialDestructor())
4018  return DK_cxx_destructor;
4019  } else {
4020  /// Check if this is a C struct that is non-trivial to destroy or an array
4021  /// that contains such a struct.
4023  return DK_nontrivial_c_struct;
4024  }
4025  }
4026 
4027  return DK_none;
4028 }
4029 
4031  return getClass()->getAsCXXRecordDecl()->getMostRecentNonInjectedDecl();
4032 }
4033 
4035  llvm::APSInt Val, unsigned Scale) {
4036  if (Val.isSigned() && Val.isNegative() && Val != -Val) {
4037  Val = -Val;
4038  Str.push_back('-');
4039  }
4040 
4041  llvm::APSInt IntPart = Val >> Scale;
4042 
4043  // Add 4 digits to hold the value after multiplying 10 (the radix)
4044  unsigned Width = Val.getBitWidth() + 4;
4045  llvm::APInt FractPart = Val.zextOrTrunc(Scale).zext(Width);
4046  llvm::APInt FractPartMask = llvm::APInt::getAllOnesValue(Scale).zext(Width);
4047  llvm::APInt RadixInt = llvm::APInt(Width, 10);
4048 
4049  IntPart.toString(Str, /*radix=*/10);
4050  Str.push_back('.');
4051  do {
4052  (FractPart * RadixInt)
4053  .lshr(Scale)
4054  .toString(Str, /*radix=*/10, Val.isSigned());
4055  FractPart = (FractPart * RadixInt) & FractPartMask;
4056  } while (FractPart != 0);
4057 }
unsigned char getOpaqueValue() const
Definition: Type.h:3516
DecltypeType(Expr *E, QualType underlyingType, QualType can=QualType())
Definition: Type.cpp:3090
static StringRef getKeywordName(ElaboratedTypeKeyword Keyword)
Definition: Type.cpp:2585
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
Definition: Type.cpp:1544
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:1532
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
Definition: Type.cpp:2245
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:4552
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
Definition: Type.h:4949
const Type * Ty
The locally-unqualified type.
Definition: Type.h:581
bool isStruct() const
Definition: Decl.h:3228
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:4752
Represents a function declaration or definition.
Definition: Decl.h:1722
bool isKindOfTypeAsWritten() const
Whether this is a "__kindof" type as written.
Definition: Type.h:5476
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:4884
DependentUnaryTransformType(const ASTContext &C, QualType BaseType, UTTKind UKind)
Definition: Type.cpp:3127
void setDependent(bool D=true)
Definition: Type.h:1673
no exception specification
bool isTemplateVariadic() const
Determines whether this function prototype contains a parameter pack at the end.
Definition: Type.cpp:2996
StringRef getName(const PrintingPolicy &Policy) const
Definition: Type.cpp:2658
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2397
ArrayRef< QualType > getTypeArgsAsWritten() const
Retrieve the type arguments of this object type as they were written.
Definition: Type.h:5470
QualType getPointeeType() const
Definition: Type.h:2410
A (possibly-)qualified type.
Definition: Type.h:640
bool isBlockPointerType() const
Definition: Type.h:6125
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:1153
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
Definition: Type.cpp:2104
bool isArrayType() const
Definition: Type.h:6166
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
Definition: Type.cpp:1904
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:940
PrimitiveDefaultInitializeKind isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C struct types.
Definition: Type.cpp:2252
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: Type.h:3349
bool isArithmeticType() const
Definition: Type.cpp:1956
void setInstantiationDependent(bool D=true)
Definition: Type.h:1679
Stmt - This represents one statement.
Definition: Stmt.h:66
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:3215
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:2633
unsigned MSWChar
When true, print the built-in wchar_t type as __wchar_t.
bool isRealFloatingType() const
Floating point categories.
Definition: Type.cpp:1941
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:3967
void Profile(llvm::FoldingSetNodeID &ID)
Definition: Type.cpp:3294
bool isRecordType() const
Definition: Type.h:6190
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
Definition: ASTContext.h:1937
const ObjCObjectType * getAsObjCInterfaceType() const
Definition: Type.cpp:1596
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:86
TagDecl * getDecl() const
Definition: Type.cpp:3148
ObjCObjectTypeBitfields ObjCObjectTypeBits
Definition: Type.h:1616
const RecordType * getAsStructureType() const
Definition: Type.cpp:513
Defines the C++ template declaration subclasses.
StringRef P
Represents a C++11 auto or C++14 decltype(auto) type.
Definition: Type.h:4566
QualType desugar() const
Remove a single level of sugar.
Definition: Type.cpp:3102
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
Definition: Type.cpp:3057
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:2543
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:1413
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:2672
bool isObjCBoxableRecordType() const
Definition: Type.cpp:441
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
Definition: Type.cpp:1604
DependentDecltypeType(const ASTContext &Context, Expr *E)
Definition: Type.cpp:3109
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:698
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Definition: Type.h:5804
bool isCARCBridgableType() const
Determine whether the given type T is a "bridgeable" C type.
Definition: Type.cpp:3972
bool isUnspecialized() const
Determine whether this object type is "unspecialized", meaning that it has no type arguments...
Definition: Type.h:5459
Linkage getLinkage() const
Determine the linkage of this type.
Definition: Type.cpp:3605
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:2707
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition: Decl.h:3148
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
Definition: Type.cpp:532
QualType withFastQualifiers(unsigned TQs) const
Definition: Type.h:855
static CachedProperties computeCachedProperties(const Type *T)
Definition: Type.cpp:3512
bool isTrivialType(const ASTContext &Context) const
Return true if this is a trivial type per (C++0x [basic.types]p9)
Definition: Type.cpp:2160
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:1888
bool isInterface() const
Definition: Decl.h:3229
bool isStructureType() const
Definition: Type.cpp:435
bool isEnumeralType() const
Definition: Type.h:6194
const T * getAs() const
Member-template getAs<specific type>&#39;.
Definition: Type.h:6530
The "union" keyword.
Definition: Type.h:4859
Extra information about a function prototype.
Definition: Type.h:3555
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type...
Definition: Type.h:6602
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:4856
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:1819
bool isCallingConv() const
Definition: Type.cpp:3230
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:38
LinkageInfo computeTypeLinkageInfo(const Type *T)
Definition: Type.cpp:3615
Represents the result of substituting a type for a template type parameter.
Definition: Type.h:4421
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:2355
The collection of all-type qualifiers we support.
Definition: Type.h:139
bool isVariableArrayType() const
Definition: Type.h:6178
bool isSugared() const
Returns whether this type directly provides sugar.
Definition: Type.cpp:3100
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:1934
bool isClass() const
Definition: Decl.h:3230
void Profile(llvm::FoldingSetNodeID &ID)
Definition: Type.h:2925
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:3730
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:3572
QualType getSubstTemplateTypeParmType(const TemplateTypeParmType *Replaced, QualType Replacement) const
Retrieve a substitution-result type.
QualType getOriginalType() const
Definition: Type.h:2461
bool isWideCharType() const
Definition: Type.cpp:1800
FunctionType::ExtInfo ExtInfo
Definition: Type.h:3556
bool isComplete() const
Returns true if this can be considered a complete type.
Definition: Decl.h:3513
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:959
Represents a class type in Objective C.
Definition: Type.h:5359
bool isObjCIndependentClassType() const
Definition: Type.cpp:3932
QualType getPointeeType() const
Definition: Type.h:2514
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:153
bool isStdByteType() const
Definition: Type.cpp:2449
ArrayRef< QualType > getParamTypes() const
Definition: Type.h:3679
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
Definition: Type.cpp:3958
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
Definition: Type.cpp:3315
bool isCharType() const
Definition: Type.cpp:1791
bool isSpelledAsLValue() const
Definition: Type.h:2549
Represents a member of a struct/union/class.
Definition: Decl.h:2554
bool isCanonicalUnqualified() const
Determines if this type would be canonical if it had no further qualification.
Definition: Type.h:1721
Defines the ExceptionSpecificationType enumeration and various utility functions. ...
An operation on a type.
Definition: TypeVisitor.h:65
const ObjCObjectPointerType * getAsObjCQualifiedIdType() const
Definition: Type.cpp:1576
bool isReferenceType() const
Definition: Type.h:6129
qual_iterator qual_begin() const
Definition: Type.h:5260
const AstTypeMatcher< TypedefType > typedefType
Matches typedef types.
unsigned getIndex() const
Retrieve the index into its type parameter list.
Definition: DeclObjC.h:612
const ObjCObjectPointerType * stripObjCKindOfTypeAndQuals(const ASTContext &ctx) const
Strip off the Objective-C "kindof" type and (with it) any protocol qualifiers.
Definition: Type.cpp:731
Values of this type can be null.
void Profile(llvm::FoldingSetNodeID &ID)
Definition: Type.h:2970
Type(TypeClass tc, QualType canon, bool Dependent, bool InstantiationDependent, bool VariablyModified, bool ContainsUnexpandedParameterPack)
Definition: Type.h:1654
An rvalue reference type, per C++11 [dcl.ref].
Definition: Type.h:2598
bool isMSTypeSpec() const
Definition: Type.cpp:3218
const ObjCObjectType * getAsObjCQualifiedInterfaceType() const
Definition: Type.cpp:1562
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:2391
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:678
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
Definition: Type.cpp:2208
bool hasAddressSpace() const
Definition: Type.h:353
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:6579
The "struct" keyword introduces the elaborated-type-specifier.
Definition: Type.h:4872
static ElaboratedTypeKeyword getKeywordForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into an elaborated type keyword.
Definition: Type.cpp:2517
Whether values of this type can be null is (explicitly) unspecified.
const ObjCObjectPointerType * getAsObjCQualifiedClassType() const
Definition: Type.cpp:1586
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition: Type.h:1715
LangAS getAddressSpace() const
Definition: Type.h:354
const Type * getClass() const
Definition: Type.h:2650
CXXRecordDecl * getDecl() const
Definition: Type.cpp:3274
Values of this type can never be null.
Expr * getSizeExpr() const
Definition: Type.h:2851
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:5893
LinkageInfo getTypeLinkageAndVisibility(const Type *T)
Definition: Type.cpp:3698
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:1131
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:3139
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type...
Definition: Decl.h:3249
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:2061
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
Definition: Type.cpp:3861
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:167
bool isScalarType() const
Definition: Type.h:6429
void * getAsOpaquePtr() const
Definition: Type.h:685
Represents an ObjC class declaration.
Definition: DeclObjC.h:1169
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:5594
PrimitiveDefaultInitializeKind
Definition: Type.h:1079
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
Definition: Type.h:3543
SplitQualType getSplitDesugaredType() const
Definition: Type.h:944
QualType getPointeeTypeAsWritten() const
Definition: Type.h:2552
TagType(TypeClass TC, const TagDecl *D, QualType can)
Definition: Type.cpp:3132
unsigned getNumProtocols() const
Return the number of qualifying protocols in this type, or 0 if there are none.
Definition: Type.h:5267
QualType getElementType() const
Definition: Type.h:3004
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:1918
Represents an extended vector type where either the type or size is dependent.
Definition: Type.h:2988
This object can be modified without requiring retains or releases.
Definition: Type.h:160
CXXRecordDecl * getMostRecentNonInjectedDecl()
Definition: DeclCXX.h:762
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:1776
Represents a K&R-style &#39;int foo()&#39; function, which has no information available about its arguments...
Definition: Type.h:3401
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:5453
bool hasAttr() const
Definition: DeclBase.h:544
QualType getBaseType() const
Gets the base type of this object type.
Definition: Type.h:5422
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
Definition: Type.cpp:1631
static void ensure(const Type *T)
Definition: Type.cpp:3476
bool acceptsObjCTypeParams() const
Determines if this is an ObjC interface type that may accept type parameters.
Definition: Type.cpp:1463
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:2458
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Definition: Type.cpp:1627
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3436
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
Definition: DeclObjC.h:1562
static bool KeywordIsTagTypeKind(ElaboratedTypeKeyword Keyword)
Definition: Type.cpp:2570
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
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition: Type.h:2678
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Definition: CharUnits.h:179
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:2286
QualType getElementType() const
Definition: Type.h:2350
IdentifierInfo * getIdentifier() const
Definition: Type.cpp:3278
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.
Expr - This represents one expression.
Definition: Expr.h:106
Defines the clang::LangOptions interface.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition: Type.h:4888
bool isObjCARCImplicitlyUnretainedType() const
Determines if this type, which must satisfy isObjCLifetimeType(), is implicitly __unsafe_unretained r...
Definition: Type.cpp:3900
QualType desugar() const
Definition: Type.h:3071
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:1612
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:6593
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition: Type.h:4870
bool isObjCRetainableType() const
Definition: Type.cpp:3938
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:609
bool isChar16Type() const
Definition: Type.cpp:1813
const char * getTypeClassName() const
Definition: Type.cpp:2648
Linkage getLinkage() const
Definition: Visibility.h:84
ObjCLifetime getObjCLifetime() const
Definition: Type.h:328
DeclContext * getDeclContext()
Definition: DeclBase.h:434
bool isAnyComplexType() const
Definition: Type.h:6198
SourceLocation Begin
void Profile(llvm::FoldingSetNodeID &ID)
Definition: Type.h:4049
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
Definition: Type.cpp:2530
ObjCObjectType(QualType Canonical, QualType Base, ArrayRef< QualType > typeArgs, ArrayRef< ObjCProtocolDecl *> protocols, bool isKindOf)
Definition: Type.cpp:628
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
Definition: Type.cpp:1971
Represents a C++ template name within the type system.
Definition: TemplateName.h:178
Represents the type decltype(expr) (C++11).
Definition: Type.h:4015
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
Definition: Type.h:579
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:1848
void Profile(llvm::FoldingSetNodeID &ID)
Definition: Type.h:3132
QualType desugar() const
Remove a single level of sugar.
Definition: Type.cpp:3078
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
QualType getType() const
Definition: Expr.h:128
bool isFunctionOrMethod() const
Definition: DeclBase.h:1817
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:3850
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:1635
A unary type transform, which is a type constructed from another.
Definition: Type.h:4058
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:584
bool isSpecifierType() const
Returns true if this type can be represented by some set of type specifiers.
Definition: Type.cpp:2491
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:1342
#define TRIVIAL_TYPE_CLASS(Class)
Definition: Type.cpp:767
bool isObjCInertUnsafeUnretainedType() const
Was this type written with the special inert-in-MRC __unsafe_unretained qualifier?
Definition: Type.cpp:601
ScalarTypeKind
Definition: Type.h:1929
bool hasInstantiationDependentExceptionSpec() const
Return whether this function has an instantiation-dependent exception spec.
Definition: Type.cpp:2955
A helper class for Type nodes having an ElaboratedTypeKeyword.
Definition: Type.h:4898
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:1384
Represents a GCC generic vector type.
Definition: Type.h:3028
ArraySizeModifier getSizeModifier() const
Definition: Type.h:2709
An lvalue reference type, per C++11 [dcl.ref].
Definition: Type.h:2580
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
Definition: Type.h:4526
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
Definition: Type.h:6488
The result type of a method or function.
bool isUnionType() const
Definition: Type.cpp:467
IdentifierInfo * getNSObjectName()
Retrieve the identifier &#39;NSObject&#39;.
Definition: ASTContext.h:1678
bool isNull() const
Return true if this QualType doesn&#39;t point to a type yet.
Definition: Type.h:705
bool hasAutoForTrailingReturnType() const
Determine whether this type was written with a leading &#39;auto&#39; corresponding to a trailing return type...
Definition: Type.cpp:1732
bool isChar8Type() const
Definition: Type.cpp:1807
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:3954
bool isNonTrivialToPrimitiveDestroy() const
Definition: Decl.h:3687
bool isVoidPointerType() const
Definition: Type.cpp:461
bool isConstQualified() const
Determine whether this type is const-qualified.
Definition: Type.h:5952
IdentifierInfo * getNSCopyingName()
Retrieve the identifier &#39;NSCopying&#39;.
Definition: ASTContext.h:1687
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent) const
C++11 deduced auto type.
bool hasTrailingReturn() const
Definition: Type.h:3788
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
Definition: Type.h:5901
RecordDecl * getDecl() const
Definition: Type.h:4149
noexcept(expression), evals to &#39;false&#39;
bool isAlignValT() const
Definition: Type.cpp:2440
LinkageInfo getLinkageAndVisibility() const
Determine the linkage and visibility of this type.
Definition: Type.cpp:3707
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:156
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:4853
Assigning into this object requires the old value to be released and the new value to be retained...
Definition: Type.h:167
Kind
QualType getCanonicalType() const
Definition: Type.h:5932
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition: Type.h:3533
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
Definition: Expr.h:191
bool isSpecialized() const
Determine whether this object type is "specialized", meaning that it has type arguments.
Definition: Type.cpp:660
ExtProtoInfo getExtProtoInfo() const
Definition: Type.h:3683
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:3562
Encodes a location in the source.
Sugar for parentheses used when specifying types.
Definition: Type.h:2367
QualType getAdjustedType() const
Definition: Type.h:2462
QualType getReturnType() const
Definition: Type.h:3369
bool isLinkageValid() const
True if the computed linkage is valid.
Definition: Type.cpp:3688
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Definition: Type.h:4165
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:6009
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
Definition: Type.h:953
Interfaces are the core concept in Objective-C for object oriented design.
Definition: Type.h:5559
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
Definition: Type.h:1962
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:2290
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3043
TemplateArgument getArgumentPack() const
Definition: Type.cpp:3290
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:376
QualType getElementType() const
Definition: Type.h:3063
void FixedPointValueToString(SmallVectorImpl< char > &Str, llvm::APSInt Val, unsigned Scale)
Definition: Type.cpp:4034
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:1763
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:5246
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:2277
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:1864
QualType getEquivalentType() const
Definition: Type.h:4269
void Profile(llvm::FoldingSetNodeID &ID)
Definition: TemplateName.h:305
QualType getInnerType() const
Definition: Type.h:2380
bool isObjCObjectPointerType() const
Definition: Type.h:6214
AutoTypeKeyword getKeyword() const
Definition: Type.h:4581
TypeClass getTypeClass() const
Definition: Type.h:1695
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
Definition: Type.cpp:1827
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:2268
QualType getSuperClassType() const
Retrieve the type of the superclass of this object type.
Definition: Type.h:5487
EnumDecl * getDecl() const
Definition: Type.h:4172
bool isVectorType() const
Definition: Type.h:6202
__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:3156
Assigning into this object requires a lifetime extension.
Definition: Type.h:173
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
Converts an elaborated type keyword into a TagTypeKind.
Definition: Type.cpp:2555
void setVariablyModified(bool VM=true)
Definition: Type.h:1682
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
TypeOfExprType(Expr *E, QualType can=QualType())
Definition: Type.cpp:3067
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
Definition: Type.h:1952
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:2482
Represents a pack expansion of types.
Definition: Type.h:5169
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:1947
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:4030
Represents a template argument.
Definition: TemplateBase.h:51
bool isDeduced() const
Definition: Type.h:4555
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:2445
TagTypeKind
The kind of a tag type.
Definition: Type.h:4851
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
CanQualType ObjCBuiltinIdTy
Definition: ASTContext.h:1055
GC getObjCGCAttr() const
Definition: Type.h:307
Dataflow Directional Tag Classes.
bool isObjCQualifiedInterfaceType() const
Definition: Type.cpp:1572
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type...
Definition: Type.cpp:1727
ExtInfo getExtInfo() const
Definition: Type.h:3380
not evaluated yet, for special member function
A qualifier set is used to build a set of qualifiers.
Definition: Type.h:5860
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1272
void setContainsUnexpandedParameterPack(bool PP=true)
Definition: Type.h:1684
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:3610
static CachedProperties get(QualType T)
Definition: Type.cpp:3466
bool hasDependentExceptionSpec() const
Return whether this function has a dependent exception spec.
Definition: Type.cpp:2943
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:2112
QualType getUnderlyingType() const
Definition: Decl.h:2950
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:1351
QualType getUnderlyingType() const
Definition: Type.h:4026
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:3415
VectorKind getVectorKind() const
Definition: Type.h:3073
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:556
The "union" keyword introduces the elaborated-type-specifier.
Definition: Type.h:4878
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
Definition: Type.h:5867
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:3014
void Profile(llvm::FoldingSetNodeID &ID)
Definition: Type.cpp:3430
bool isObjCIndirectLifetimeType() const
Definition: Type.cpp:3944
The "class" keyword introduces the elaborated-type-specifier.
Definition: Type.h:4881
bool isKindOfType() const
Whether this ia a "__kindof" type (semantically).
Definition: Type.cpp:696
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:3305
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2616
bool hasObjCLifetime() const
Definition: Type.h:327
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type. ...
Definition: Type.cpp:2010
bool isQualifier() const
Does this attribute behave like a type qualifier?
Definition: Type.cpp:3169
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:3385
UnaryTransformType(QualType BaseTy, QualType UnderlyingTy, UTTKind UKind, QualType CanonicalTy)
Definition: Type.cpp:3117
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:4436
void addConsistentQualifiers(Qualifiers qs)
Add the qualifiers from the given set to this set, given that they don&#39;t conflict.
Definition: Type.h:454
QualType getModifiedType() const
Definition: Type.h:4268
Represents a pointer to an Objective C object.
Definition: Type.h:5615
Pointer to a block type.
Definition: Type.h:2499
bool isSugared() const
Returns whether this type directly provides sugar.
Definition: Type.cpp:3074
FunctionTypeBitfields FunctionTypeBits
Definition: Type.h:1615
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4139
Complex values, per C99 6.2.5p11.
Definition: Type.h:2337
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:450
unsigned getIndexTypeCVRQualifiers() const
Definition: Type.h:2717
bool empty() const
Definition: Type.h:416
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:2024
QualType getCanonicalTypeInternal() const
Definition: Type.h:2218
QualType getAtomicUnqualifiedType() const
Remove all qualifiers including _Atomic.
Definition: Type.cpp:1375
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
Definition: Type.h:6378
CanThrowResult canThrow() const
Determine whether this function type has a non-throwing exception specification.
Definition: Type.cpp:2964
const llvm::APInt & getSize() const
Definition: Type.h:2750
Kind getAttrKind() const
Definition: Type.h:4264
VectorTypeBitfields VectorTypeBits
Definition: Type.h:1619
ExtVectorType - Extended vector type.
Definition: Type.h:3147
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2533
SourceRange getBracketsRange() const
Definition: Type.h:2857
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:1381
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
Definition: Type.cpp:3711
The "class" keyword.
Definition: Type.h:4862
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
Definition: Type.cpp:2804
bool isBeingDefined() const
Determines whether this type is in the process of being defined.
Definition: Type.cpp:3152
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Definition: ASTContext.h:2074
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition: Type.h:3536
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:2034
bool hasObjCGCAttr() const
Definition: Type.h:306
The type-property cache.
Definition: Type.cpp:3464
bool isClassType() const
Definition: Type.cpp:429
TypedefNameDecl * getDecl() const
Definition: Type.h:3936
TypeBitfields TypeBits
Definition: Type.h:1610
Reading or writing from this object requires a barrier call.
Definition: Type.h:170
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition: Type.h:3539
An attributed type is a type to which a type attribute has been applied.
Definition: Type.h:4194
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:1878
Represents a C++ struct/union/class.
Definition: DeclCXX.h:308
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:6344
Represents a C array with an unspecified size.
Definition: Type.h:2786
QualType stripObjCKindOfTypeAndQuals(const ASTContext &ctx) const
Strip off the Objective-C "kindof" type and (with it) any protocol qualifiers.
Definition: Type.cpp:713
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:1737
The parameter type of a method or function.
QualType getNamedType() const
Retrieve the type named by the qualified-id.
Definition: Type.h:4982
QualType getReplacementType() const
Gets the type that was substituted for the template parameter.
Definition: Type.h:4442
The "enum" keyword.
Definition: Type.h:4865
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
Definition: Expr.h:214
void Profile(llvm::FoldingSetNodeID &ID)
Definition: Type.h:3979
Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const
Return the implicit lifetime for this type, which must not be dependent.
Definition: Type.cpp:3894
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Definition: DeclObjC.h:634
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:2254
Defines the clang::TargetInfo interface.
bool isComplexIntegerType() const
Definition: Type.cpp:479
ASTContext & getParentASTContext() const
Definition: DeclBase.h:1798
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
Definition: TargetCXXABI.h:154
bool hasVolatile() const
Definition: Type.h:263
__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:3064
QualType getSuperClassType() const
Retrieve the type of the superclass of this object pointer type.
Definition: Type.cpp:1553
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:1946
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:4658
bool isPointerType() const
Definition: Type.h:6117
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
static StringRef getNameForCallConv(CallingConv CC)
Definition: Type.cpp:2820
#define true
Definition: stdbool.h:32
bool isFloatingType() const
Definition: Type.cpp:1925
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:2931
void computeSuperClassTypeSlow() const
Definition: Type.cpp:1474
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:2831
No keyword precedes the qualified type name.
Definition: Type.h:4891
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:775
bool isInterfaceType() const
Definition: Type.cpp:447
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context)
Definition: Type.h:5131
QualType desugar() const
Definition: Type.cpp:3063
const LangOptions & getLangOpts() const
Definition: ASTContext.h:715
unsigned size() const
Determine the number of type parameters in this list.
Definition: DeclObjC.h:674
llvm::Optional< NullabilityKind > getImmediateNullability() const
Definition: Type.cpp:3840
The "__interface" keyword introduces the elaborated-type-specifier.
Definition: Type.h:4875
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:2732
ExceptionSpecInfo ExceptionSpec
Definition: Type.h:3561
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:3919
bool hasSizedVLAType() const
Whether this type involves a variable-length array type with a definite size.
Definition: Type.cpp:3981
QualType getPointeeType() const
Definition: Type.h:2636
A single template declaration.
Definition: TemplateName.h:191
bool isBeingDefined() const
Return true if this decl is currently being defined.
Definition: Decl.h:3168
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:1064
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
Definition: Type.h:5631