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