Type.cpp revision 5a24acfed51d1233e325f43af5b2147ad9c31e04
1//===--- Type.cpp - Type representation and manipulation ------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10//  This file implements type-related functionality.
11//
12//===----------------------------------------------------------------------===//
13
14#include "clang/AST/ASTContext.h"
15#include "clang/AST/Type.h"
16#include "clang/AST/DeclCXX.h"
17#include "clang/AST/DeclObjC.h"
18#include "clang/AST/DeclTemplate.h"
19#include "clang/AST/Expr.h"
20#include "clang/AST/PrettyPrinter.h"
21#include "clang/Basic/Specifiers.h"
22#include "llvm/ADT/StringExtras.h"
23#include "llvm/Support/raw_ostream.h"
24using namespace clang;
25
26bool QualType::isConstant(QualType T, ASTContext &Ctx) {
27  if (T.isConstQualified())
28    return true;
29
30  if (const ArrayType *AT = Ctx.getAsArrayType(T))
31    return AT->getElementType().isConstant(Ctx);
32
33  return false;
34}
35
36Type::~Type() { }
37
38void DependentSizedArrayType::Profile(llvm::FoldingSetNodeID &ID,
39                                      ASTContext &Context,
40                                      QualType ET,
41                                      ArraySizeModifier SizeMod,
42                                      unsigned TypeQuals,
43                                      Expr *E) {
44  ID.AddPointer(ET.getAsOpaquePtr());
45  ID.AddInteger(SizeMod);
46  ID.AddInteger(TypeQuals);
47  E->Profile(ID, Context, true);
48}
49
50void
51DependentSizedExtVectorType::Profile(llvm::FoldingSetNodeID &ID,
52                                     ASTContext &Context,
53                                     QualType ElementType, Expr *SizeExpr) {
54  ID.AddPointer(ElementType.getAsOpaquePtr());
55  SizeExpr->Profile(ID, Context, true);
56}
57
58/// getArrayElementTypeNoTypeQual - If this is an array type, return the
59/// element type of the array, potentially with type qualifiers missing.
60/// This method should never be used when type qualifiers are meaningful.
61const Type *Type::getArrayElementTypeNoTypeQual() const {
62  // If this is directly an array type, return it.
63  if (const ArrayType *ATy = dyn_cast<ArrayType>(this))
64    return ATy->getElementType().getTypePtr();
65
66  // If the canonical form of this type isn't the right kind, reject it.
67  if (!isa<ArrayType>(CanonicalType))
68    return 0;
69
70  // If this is a typedef for an array type, strip the typedef off without
71  // losing all typedef information.
72  return cast<ArrayType>(getUnqualifiedDesugaredType())
73    ->getElementType().getTypePtr();
74}
75
76/// \brief Retrieve the unqualified variant of the given type, removing as
77/// little sugar as possible.
78///
79/// This routine looks through various kinds of sugar to find the
80/// least-desuraged type that is unqualified. For example, given:
81///
82/// \code
83/// typedef int Integer;
84/// typedef const Integer CInteger;
85/// typedef CInteger DifferenceType;
86/// \endcode
87///
88/// Executing \c getUnqualifiedTypeSlow() on the type \c DifferenceType will
89/// desugar until we hit the type \c Integer, which has no qualifiers on it.
90QualType QualType::getUnqualifiedTypeSlow() const {
91  QualType Cur = *this;
92  while (true) {
93    if (!Cur.hasQualifiers())
94      return Cur;
95
96    const Type *CurTy = Cur.getTypePtr();
97    switch (CurTy->getTypeClass()) {
98#define ABSTRACT_TYPE(Class, Parent)
99#define TYPE(Class, Parent)                                  \
100    case Type::Class: {                                      \
101      const Class##Type *Ty = cast<Class##Type>(CurTy);      \
102      if (!Ty->isSugared())                                  \
103        return Cur.getLocalUnqualifiedType();                \
104      Cur = Ty->desugar();                                   \
105      break;                                                 \
106    }
107#include "clang/AST/TypeNodes.def"
108    }
109  }
110
111  return Cur.getUnqualifiedType();
112}
113
114/// getDesugaredType - Return the specified type with any "sugar" removed from
115/// the type.  This takes off typedefs, typeof's etc.  If the outer level of
116/// the type is already concrete, it returns it unmodified.  This is similar
117/// to getting the canonical type, but it doesn't remove *all* typedefs.  For
118/// example, it returns "T*" as "T*", (not as "int*"), because the pointer is
119/// concrete.
120QualType QualType::getDesugaredType(QualType T) {
121  QualifierCollector Qs;
122
123  QualType Cur = T;
124  while (true) {
125    const Type *CurTy = Qs.strip(Cur);
126    switch (CurTy->getTypeClass()) {
127#define ABSTRACT_TYPE(Class, Parent)
128#define TYPE(Class, Parent) \
129    case Type::Class: { \
130      const Class##Type *Ty = cast<Class##Type>(CurTy); \
131      if (!Ty->isSugared()) \
132        return Qs.apply(Cur); \
133      Cur = Ty->desugar(); \
134      break; \
135    }
136#include "clang/AST/TypeNodes.def"
137    }
138  }
139}
140
141/// getUnqualifiedDesugaredType - Pull any qualifiers and syntactic
142/// sugar off the given type.  This should produce an object of the
143/// same dynamic type as the canonical type.
144const Type *Type::getUnqualifiedDesugaredType() const {
145  const Type *Cur = this;
146
147  while (true) {
148    switch (Cur->getTypeClass()) {
149#define ABSTRACT_TYPE(Class, Parent)
150#define TYPE(Class, Parent) \
151    case Class: { \
152      const Class##Type *Ty = cast<Class##Type>(Cur); \
153      if (!Ty->isSugared()) return Cur; \
154      Cur = Ty->desugar().getTypePtr(); \
155      break; \
156    }
157#include "clang/AST/TypeNodes.def"
158    }
159  }
160}
161
162/// isVoidType - Helper method to determine if this is the 'void' type.
163bool Type::isVoidType() const {
164  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
165    return BT->getKind() == BuiltinType::Void;
166  return false;
167}
168
169bool Type::isDerivedType() const {
170  switch (CanonicalType->getTypeClass()) {
171  case Pointer:
172  case VariableArray:
173  case ConstantArray:
174  case IncompleteArray:
175  case FunctionProto:
176  case FunctionNoProto:
177  case LValueReference:
178  case RValueReference:
179  case Record:
180    return true;
181  default:
182    return false;
183  }
184}
185
186bool Type::isClassType() const {
187  if (const RecordType *RT = getAs<RecordType>())
188    return RT->getDecl()->isClass();
189  return false;
190}
191bool Type::isStructureType() const {
192  if (const RecordType *RT = getAs<RecordType>())
193    return RT->getDecl()->isStruct();
194  return false;
195}
196bool Type::isStructureOrClassType() const {
197  if (const RecordType *RT = getAs<RecordType>())
198    return RT->getDecl()->isStruct() || RT->getDecl()->isClass();
199  return false;
200}
201bool Type::isVoidPointerType() const {
202  if (const PointerType *PT = getAs<PointerType>())
203    return PT->getPointeeType()->isVoidType();
204  return false;
205}
206
207bool Type::isUnionType() const {
208  if (const RecordType *RT = getAs<RecordType>())
209    return RT->getDecl()->isUnion();
210  return false;
211}
212
213bool Type::isComplexType() const {
214  if (const ComplexType *CT = dyn_cast<ComplexType>(CanonicalType))
215    return CT->getElementType()->isFloatingType();
216  return false;
217}
218
219bool Type::isComplexIntegerType() const {
220  // Check for GCC complex integer extension.
221  return getAsComplexIntegerType();
222}
223
224const ComplexType *Type::getAsComplexIntegerType() const {
225  if (const ComplexType *Complex = getAs<ComplexType>())
226    if (Complex->getElementType()->isIntegerType())
227      return Complex;
228  return 0;
229}
230
231QualType Type::getPointeeType() const {
232  if (const PointerType *PT = getAs<PointerType>())
233    return PT->getPointeeType();
234  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>())
235    return OPT->getPointeeType();
236  if (const BlockPointerType *BPT = getAs<BlockPointerType>())
237    return BPT->getPointeeType();
238  if (const ReferenceType *RT = getAs<ReferenceType>())
239    return RT->getPointeeType();
240  return QualType();
241}
242
243/// isVariablyModifiedType (C99 6.7.5p3) - Return true for variable length
244/// array types and types that contain variable array types in their
245/// declarator
246bool Type::isVariablyModifiedType() const {
247  // FIXME: We should really keep a "variably modified" bit in Type, rather
248  // than walking the type hierarchy to recompute it.
249
250  // A VLA is a variably modified type.
251  if (isVariableArrayType())
252    return true;
253
254  // An array can contain a variably modified type
255  if (const Type *T = getArrayElementTypeNoTypeQual())
256    return T->isVariablyModifiedType();
257
258  // A pointer can point to a variably modified type.
259  // Also, C++ references and member pointers can point to a variably modified
260  // type, where VLAs appear as an extension to C++, and should be treated
261  // correctly.
262  if (const PointerType *PT = getAs<PointerType>())
263    return PT->getPointeeType()->isVariablyModifiedType();
264  if (const ReferenceType *RT = getAs<ReferenceType>())
265    return RT->getPointeeType()->isVariablyModifiedType();
266  if (const MemberPointerType *PT = getAs<MemberPointerType>())
267    return PT->getPointeeType()->isVariablyModifiedType();
268
269  // A function can return a variably modified type
270  // This one isn't completely obvious, but it follows from the
271  // definition in C99 6.7.5p3. Because of this rule, it's
272  // illegal to declare a function returning a variably modified type.
273  if (const FunctionType *FT = getAs<FunctionType>())
274    return FT->getResultType()->isVariablyModifiedType();
275
276  return false;
277}
278
279const RecordType *Type::getAsStructureType() const {
280  // If this is directly a structure type, return it.
281  if (const RecordType *RT = dyn_cast<RecordType>(this)) {
282    if (RT->getDecl()->isStruct())
283      return RT;
284  }
285
286  // If the canonical form of this type isn't the right kind, reject it.
287  if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType)) {
288    if (!RT->getDecl()->isStruct())
289      return 0;
290
291    // If this is a typedef for a structure type, strip the typedef off without
292    // losing all typedef information.
293    return cast<RecordType>(getUnqualifiedDesugaredType());
294  }
295  return 0;
296}
297
298const RecordType *Type::getAsUnionType() const {
299  // If this is directly a union type, return it.
300  if (const RecordType *RT = dyn_cast<RecordType>(this)) {
301    if (RT->getDecl()->isUnion())
302      return RT;
303  }
304
305  // If the canonical form of this type isn't the right kind, reject it.
306  if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType)) {
307    if (!RT->getDecl()->isUnion())
308      return 0;
309
310    // If this is a typedef for a union type, strip the typedef off without
311    // losing all typedef information.
312    return cast<RecordType>(getUnqualifiedDesugaredType());
313  }
314
315  return 0;
316}
317
318ObjCObjectType::ObjCObjectType(QualType Canonical, QualType Base,
319                               ObjCProtocolDecl * const *Protocols,
320                               unsigned NumProtocols)
321  : Type(ObjCObject, Canonical, false),
322    NumProtocols(NumProtocols),
323    BaseType(Base) {
324  assert(this->NumProtocols == NumProtocols &&
325         "bitfield overflow in protocol count");
326  if (NumProtocols)
327    memcpy(getProtocolStorage(), Protocols,
328           NumProtocols * sizeof(ObjCProtocolDecl*));
329}
330
331const ObjCObjectType *Type::getAsObjCQualifiedInterfaceType() const {
332  // There is no sugar for ObjCObjectType's, just return the canonical
333  // type pointer if it is the right class.  There is no typedef information to
334  // return and these cannot be Address-space qualified.
335  if (const ObjCObjectType *T = getAs<ObjCObjectType>())
336    if (T->getNumProtocols() && T->getInterface())
337      return T;
338  return 0;
339}
340
341bool Type::isObjCQualifiedInterfaceType() const {
342  return getAsObjCQualifiedInterfaceType() != 0;
343}
344
345const ObjCObjectPointerType *Type::getAsObjCQualifiedIdType() const {
346  // There is no sugar for ObjCQualifiedIdType's, just return the canonical
347  // type pointer if it is the right class.
348  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>()) {
349    if (OPT->isObjCQualifiedIdType())
350      return OPT;
351  }
352  return 0;
353}
354
355const ObjCObjectPointerType *Type::getAsObjCInterfacePointerType() const {
356  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>()) {
357    if (OPT->getInterfaceType())
358      return OPT;
359  }
360  return 0;
361}
362
363const CXXRecordDecl *Type::getCXXRecordDeclForPointerType() const {
364  if (const PointerType *PT = getAs<PointerType>())
365    if (const RecordType *RT = PT->getPointeeType()->getAs<RecordType>())
366      return dyn_cast<CXXRecordDecl>(RT->getDecl());
367  return 0;
368}
369
370CXXRecordDecl *Type::getAsCXXRecordDecl() const {
371  if (const RecordType *RT = getAs<RecordType>())
372    return dyn_cast<CXXRecordDecl>(RT->getDecl());
373  else if (const InjectedClassNameType *Injected
374                                  = getAs<InjectedClassNameType>())
375    return Injected->getDecl();
376
377  return 0;
378}
379
380bool Type::isIntegerType() const {
381  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
382    return BT->getKind() >= BuiltinType::Bool &&
383           BT->getKind() <= BuiltinType::Int128;
384  if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
385    // Incomplete enum types are not treated as integer types.
386    // FIXME: In C++, enum types are never integer types.
387    if (TT->getDecl()->isEnum() && TT->getDecl()->isDefinition())
388      return true;
389  return false;
390}
391
392bool Type::hasIntegerRepresentation() const {
393  if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
394    return VT->getElementType()->isIntegerType();
395  else
396    return isIntegerType();
397}
398
399/// \brief Determine whether this type is an integral type.
400///
401/// This routine determines whether the given type is an integral type per
402/// C++ [basic.fundamental]p7. Although the C standard does not define the
403/// term "integral type", it has a similar term "integer type", and in C++
404/// the two terms are equivalent. However, C's "integer type" includes
405/// enumeration types, while C++'s "integer type" does not. The \c ASTContext
406/// parameter is used to determine whether we should be following the C or
407/// C++ rules when determining whether this type is an integral/integer type.
408///
409/// For cases where C permits "an integer type" and C++ permits "an integral
410/// type", use this routine.
411///
412/// For cases where C permits "an integer type" and C++ permits "an integral
413/// or enumeration type", use \c isIntegralOrEnumerationType() instead.
414///
415/// \param Ctx The context in which this type occurs.
416///
417/// \returns true if the type is considered an integral type, false otherwise.
418bool Type::isIntegralType(ASTContext &Ctx) const {
419  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
420    return BT->getKind() >= BuiltinType::Bool &&
421    BT->getKind() <= BuiltinType::Int128;
422
423  if (!Ctx.getLangOptions().CPlusPlus)
424    if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
425      if (TT->getDecl()->isEnum() && TT->getDecl()->isDefinition())
426        return true;  // Complete enum types are integral in C.
427
428  return false;
429}
430
431bool Type::isIntegralOrEnumerationType() const {
432  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
433    return BT->getKind() >= BuiltinType::Bool &&
434           BT->getKind() <= BuiltinType::Int128;
435
436  if (isa<EnumType>(CanonicalType))
437    return true;
438
439  return false;
440}
441
442bool Type::isEnumeralType() const {
443  if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
444    return TT->getDecl()->isEnum();
445  return false;
446}
447
448bool Type::isBooleanType() const {
449  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
450    return BT->getKind() == BuiltinType::Bool;
451  return false;
452}
453
454bool Type::isCharType() const {
455  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
456    return BT->getKind() == BuiltinType::Char_U ||
457           BT->getKind() == BuiltinType::UChar ||
458           BT->getKind() == BuiltinType::Char_S ||
459           BT->getKind() == BuiltinType::SChar;
460  return false;
461}
462
463bool Type::isWideCharType() const {
464  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
465    return BT->getKind() == BuiltinType::WChar;
466  return false;
467}
468
469/// \brief Determine whether this type is any of the built-in character
470/// types.
471bool Type::isAnyCharacterType() const {
472  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
473    return (BT->getKind() >= BuiltinType::Char_U &&
474            BT->getKind() <= BuiltinType::Char32) ||
475           (BT->getKind() >= BuiltinType::Char_S &&
476            BT->getKind() <= BuiltinType::WChar);
477
478  return false;
479}
480
481/// isSignedIntegerType - Return true if this is an integer type that is
482/// signed, according to C99 6.2.5p4 [char, signed char, short, int, long..],
483/// an enum decl which has a signed representation
484bool Type::isSignedIntegerType() const {
485  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType)) {
486    return BT->getKind() >= BuiltinType::Char_S &&
487           BT->getKind() <= BuiltinType::Int128;
488  }
489
490  if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
491    return ET->getDecl()->getIntegerType()->isSignedIntegerType();
492
493  return false;
494}
495
496bool Type::hasSignedIntegerRepresentation() const {
497  if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
498    return VT->getElementType()->isSignedIntegerType();
499  else
500    return isSignedIntegerType();
501}
502
503/// isUnsignedIntegerType - Return true if this is an integer type that is
504/// unsigned, according to C99 6.2.5p6 [which returns true for _Bool], an enum
505/// decl which has an unsigned representation
506bool Type::isUnsignedIntegerType() const {
507  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType)) {
508    return BT->getKind() >= BuiltinType::Bool &&
509           BT->getKind() <= BuiltinType::UInt128;
510  }
511
512  if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
513    return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
514
515  return false;
516}
517
518bool Type::hasUnsignedIntegerRepresentation() const {
519  if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
520    return VT->getElementType()->isUnsignedIntegerType();
521  else
522    return isUnsignedIntegerType();
523}
524
525bool Type::isFloatingType() const {
526  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
527    return BT->getKind() >= BuiltinType::Float &&
528           BT->getKind() <= BuiltinType::LongDouble;
529  if (const ComplexType *CT = dyn_cast<ComplexType>(CanonicalType))
530    return CT->getElementType()->isFloatingType();
531  return false;
532}
533
534bool Type::hasFloatingRepresentation() const {
535  if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
536    return VT->getElementType()->isFloatingType();
537  else
538    return isFloatingType();
539}
540
541bool Type::isRealFloatingType() const {
542  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
543    return BT->isFloatingPoint();
544  return false;
545}
546
547bool Type::isRealType() const {
548  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
549    return BT->getKind() >= BuiltinType::Bool &&
550           BT->getKind() <= BuiltinType::LongDouble;
551  if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
552    return TT->getDecl()->isEnum() && TT->getDecl()->isDefinition();
553  return false;
554}
555
556bool Type::isArithmeticType() const {
557  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
558    return BT->getKind() >= BuiltinType::Bool &&
559           BT->getKind() <= BuiltinType::LongDouble;
560  if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
561    // GCC allows forward declaration of enum types (forbid by C99 6.7.2.3p2).
562    // If a body isn't seen by the time we get here, return false.
563    return ET->getDecl()->isDefinition();
564  return isa<ComplexType>(CanonicalType);
565}
566
567bool Type::isScalarType() const {
568  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
569    return BT->getKind() != BuiltinType::Void;
570  if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) {
571    // Enums are scalar types, but only if they are defined.  Incomplete enums
572    // are not treated as scalar types.
573    if (TT->getDecl()->isEnum() && TT->getDecl()->isDefinition())
574      return true;
575    return false;
576  }
577  return isa<PointerType>(CanonicalType) ||
578         isa<BlockPointerType>(CanonicalType) ||
579         isa<MemberPointerType>(CanonicalType) ||
580         isa<ComplexType>(CanonicalType) ||
581         isa<ObjCObjectPointerType>(CanonicalType);
582}
583
584/// \brief Determines whether the type is a C++ aggregate type or C
585/// aggregate or union type.
586///
587/// An aggregate type is an array or a class type (struct, union, or
588/// class) that has no user-declared constructors, no private or
589/// protected non-static data members, no base classes, and no virtual
590/// functions (C++ [dcl.init.aggr]p1). The notion of an aggregate type
591/// subsumes the notion of C aggregates (C99 6.2.5p21) because it also
592/// includes union types.
593bool Type::isAggregateType() const {
594  if (const RecordType *Record = dyn_cast<RecordType>(CanonicalType)) {
595    if (CXXRecordDecl *ClassDecl = dyn_cast<CXXRecordDecl>(Record->getDecl()))
596      return ClassDecl->isAggregate();
597
598    return true;
599  }
600
601  return isa<ArrayType>(CanonicalType);
602}
603
604/// isConstantSizeType - Return true if this is not a variable sized type,
605/// according to the rules of C99 6.7.5p3.  It is not legal to call this on
606/// incomplete types or dependent types.
607bool Type::isConstantSizeType() const {
608  assert(!isIncompleteType() && "This doesn't make sense for incomplete types");
609  assert(!isDependentType() && "This doesn't make sense for dependent types");
610  // The VAT must have a size, as it is known to be complete.
611  return !isa<VariableArrayType>(CanonicalType);
612}
613
614/// isIncompleteType - Return true if this is an incomplete type (C99 6.2.5p1)
615/// - a type that can describe objects, but which lacks information needed to
616/// determine its size.
617bool Type::isIncompleteType() const {
618  switch (CanonicalType->getTypeClass()) {
619  default: return false;
620  case Builtin:
621    // Void is the only incomplete builtin type.  Per C99 6.2.5p19, it can never
622    // be completed.
623    return isVoidType();
624  case Record:
625  case Enum:
626    // A tagged type (struct/union/enum/class) is incomplete if the decl is a
627    // forward declaration, but not a full definition (C99 6.2.5p22).
628    return !cast<TagType>(CanonicalType)->getDecl()->isDefinition();
629  case ConstantArray:
630    // An array is incomplete if its element type is incomplete
631    // (C++ [dcl.array]p1).
632    // We don't handle variable arrays (they're not allowed in C++) or
633    // dependent-sized arrays (dependent types are never treated as incomplete).
634    return cast<ArrayType>(CanonicalType)->getElementType()->isIncompleteType();
635  case IncompleteArray:
636    // An array of unknown size is an incomplete type (C99 6.2.5p22).
637    return true;
638  case ObjCObject:
639    return cast<ObjCObjectType>(CanonicalType)->getBaseType()
640                                                         ->isIncompleteType();
641  case ObjCInterface:
642    // ObjC interfaces are incomplete if they are @class, not @interface.
643    return cast<ObjCInterfaceType>(CanonicalType)->getDecl()->isForwardDecl();
644  }
645}
646
647/// isPODType - Return true if this is a plain-old-data type (C++ 3.9p10)
648bool Type::isPODType() const {
649  // The compiler shouldn't query this for incomplete types, but the user might.
650  // We return false for that case.
651  if (isIncompleteType())
652    return false;
653
654  switch (CanonicalType->getTypeClass()) {
655    // Everything not explicitly mentioned is not POD.
656  default: return false;
657  case VariableArray:
658  case ConstantArray:
659    // IncompleteArray is caught by isIncompleteType() above.
660    return cast<ArrayType>(CanonicalType)->getElementType()->isPODType();
661
662  case Builtin:
663  case Complex:
664  case Pointer:
665  case MemberPointer:
666  case Vector:
667  case ExtVector:
668  case ObjCObjectPointer:
669  case BlockPointer:
670    return true;
671
672  case Enum:
673    return true;
674
675  case Record:
676    if (CXXRecordDecl *ClassDecl
677          = dyn_cast<CXXRecordDecl>(cast<RecordType>(CanonicalType)->getDecl()))
678      return ClassDecl->isPOD();
679
680    // C struct/union is POD.
681    return true;
682  }
683}
684
685bool Type::isLiteralType() const {
686  if (isIncompleteType())
687    return false;
688
689  // C++0x [basic.types]p10:
690  //   A type is a literal type if it is:
691  switch (CanonicalType->getTypeClass()) {
692    // We're whitelisting
693  default: return false;
694
695    //   -- a scalar type
696  case Builtin:
697  case Complex:
698  case Pointer:
699  case MemberPointer:
700  case Vector:
701  case ExtVector:
702  case ObjCObjectPointer:
703  case Enum:
704    return true;
705
706    //   -- a class type with ...
707  case Record:
708    // FIXME: Do the tests
709    return false;
710
711    //   -- an array of literal type
712    // Extension: variable arrays cannot be literal types, since they're
713    // runtime-sized.
714  case ConstantArray:
715    return cast<ArrayType>(CanonicalType)->getElementType()->isLiteralType();
716  }
717}
718
719bool Type::isPromotableIntegerType() const {
720  if (const BuiltinType *BT = getAs<BuiltinType>())
721    switch (BT->getKind()) {
722    case BuiltinType::Bool:
723    case BuiltinType::Char_S:
724    case BuiltinType::Char_U:
725    case BuiltinType::SChar:
726    case BuiltinType::UChar:
727    case BuiltinType::Short:
728    case BuiltinType::UShort:
729      return true;
730    default:
731      return false;
732    }
733
734  // Enumerated types are promotable to their compatible integer types
735  // (C99 6.3.1.1) a.k.a. its underlying type (C++ [conv.prom]p2).
736  if (const EnumType *ET = getAs<EnumType>()){
737    if (this->isDependentType() || ET->getDecl()->getPromotionType().isNull())
738      return false;
739
740    const BuiltinType *BT
741      = ET->getDecl()->getPromotionType()->getAs<BuiltinType>();
742    return BT->getKind() == BuiltinType::Int
743           || BT->getKind() == BuiltinType::UInt;
744  }
745
746  return false;
747}
748
749bool Type::isNullPtrType() const {
750  if (const BuiltinType *BT = getAs<BuiltinType>())
751    return BT->getKind() == BuiltinType::NullPtr;
752  return false;
753}
754
755bool Type::isSpecifierType() const {
756  // Note that this intentionally does not use the canonical type.
757  switch (getTypeClass()) {
758  case Builtin:
759  case Record:
760  case Enum:
761  case Typedef:
762  case Complex:
763  case TypeOfExpr:
764  case TypeOf:
765  case TemplateTypeParm:
766  case SubstTemplateTypeParm:
767  case TemplateSpecialization:
768  case Elaborated:
769  case DependentName:
770  case DependentTemplateSpecialization:
771  case ObjCInterface:
772  case ObjCObject:
773  case ObjCObjectPointer: // FIXME: object pointers aren't really specifiers
774    return true;
775  default:
776    return false;
777  }
778}
779
780TypeWithKeyword::~TypeWithKeyword() {
781}
782
783ElaboratedTypeKeyword
784TypeWithKeyword::getKeywordForTypeSpec(unsigned TypeSpec) {
785  switch (TypeSpec) {
786  default: return ETK_None;
787  case TST_typename: return ETK_Typename;
788  case TST_class: return ETK_Class;
789  case TST_struct: return ETK_Struct;
790  case TST_union: return ETK_Union;
791  case TST_enum: return ETK_Enum;
792  }
793}
794
795TagTypeKind
796TypeWithKeyword::getTagTypeKindForTypeSpec(unsigned TypeSpec) {
797  switch(TypeSpec) {
798  case TST_class: return TTK_Class;
799  case TST_struct: return TTK_Struct;
800  case TST_union: return TTK_Union;
801  case TST_enum: return TTK_Enum;
802  default: llvm_unreachable("Type specifier is not a tag type kind.");
803  }
804}
805
806ElaboratedTypeKeyword
807TypeWithKeyword::getKeywordForTagTypeKind(TagTypeKind Kind) {
808  switch (Kind) {
809  case TTK_Class: return ETK_Class;
810  case TTK_Struct: return ETK_Struct;
811  case TTK_Union: return ETK_Union;
812  case TTK_Enum: return ETK_Enum;
813  }
814  llvm_unreachable("Unknown tag type kind.");
815}
816
817TagTypeKind
818TypeWithKeyword::getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword) {
819  switch (Keyword) {
820  case ETK_Class: return TTK_Class;
821  case ETK_Struct: return TTK_Struct;
822  case ETK_Union: return TTK_Union;
823  case ETK_Enum: return TTK_Enum;
824  case ETK_None: // Fall through.
825  case ETK_Typename:
826    llvm_unreachable("Elaborated type keyword is not a tag type kind.");
827  }
828  llvm_unreachable("Unknown elaborated type keyword.");
829}
830
831bool
832TypeWithKeyword::KeywordIsTagTypeKind(ElaboratedTypeKeyword Keyword) {
833  switch (Keyword) {
834  case ETK_None:
835  case ETK_Typename:
836    return false;
837  case ETK_Class:
838  case ETK_Struct:
839  case ETK_Union:
840  case ETK_Enum:
841    return true;
842  }
843  llvm_unreachable("Unknown elaborated type keyword.");
844}
845
846const char*
847TypeWithKeyword::getKeywordName(ElaboratedTypeKeyword Keyword) {
848  switch (Keyword) {
849  default: llvm_unreachable("Unknown elaborated type keyword.");
850  case ETK_None: return "";
851  case ETK_Typename: return "typename";
852  case ETK_Class:  return "class";
853  case ETK_Struct: return "struct";
854  case ETK_Union:  return "union";
855  case ETK_Enum:   return "enum";
856  }
857}
858
859ElaboratedType::~ElaboratedType() {}
860DependentNameType::~DependentNameType() {}
861DependentTemplateSpecializationType::~DependentTemplateSpecializationType() {}
862
863DependentTemplateSpecializationType::DependentTemplateSpecializationType(
864                         ElaboratedTypeKeyword Keyword,
865                         NestedNameSpecifier *NNS, const IdentifierInfo *Name,
866                         unsigned NumArgs, const TemplateArgument *Args,
867                         QualType Canon)
868  : TypeWithKeyword(Keyword, DependentTemplateSpecialization, Canon, true),
869    NNS(NNS), Name(Name), NumArgs(NumArgs) {
870  assert(NNS && NNS->isDependent() &&
871         "DependentTemplateSpecializatonType requires dependent qualifier");
872  for (unsigned I = 0; I != NumArgs; ++I)
873    new (&getArgBuffer()[I]) TemplateArgument(Args[I]);
874}
875
876void
877DependentTemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,
878                                             ASTContext &Context,
879                                             ElaboratedTypeKeyword Keyword,
880                                             NestedNameSpecifier *Qualifier,
881                                             const IdentifierInfo *Name,
882                                             unsigned NumArgs,
883                                             const TemplateArgument *Args) {
884  ID.AddInteger(Keyword);
885  ID.AddPointer(Qualifier);
886  ID.AddPointer(Name);
887  for (unsigned Idx = 0; Idx < NumArgs; ++Idx)
888    Args[Idx].Profile(ID, Context);
889}
890
891bool Type::isElaboratedTypeSpecifier() const {
892  ElaboratedTypeKeyword Keyword;
893  if (const ElaboratedType *Elab = dyn_cast<ElaboratedType>(this))
894    Keyword = Elab->getKeyword();
895  else if (const DependentNameType *DepName = dyn_cast<DependentNameType>(this))
896    Keyword = DepName->getKeyword();
897  else if (const DependentTemplateSpecializationType *DepTST =
898             dyn_cast<DependentTemplateSpecializationType>(this))
899    Keyword = DepTST->getKeyword();
900  else
901    return false;
902
903  return TypeWithKeyword::KeywordIsTagTypeKind(Keyword);
904}
905
906const char *Type::getTypeClassName() const {
907  switch (TC) {
908  default: assert(0 && "Type class not in TypeNodes.def!");
909#define ABSTRACT_TYPE(Derived, Base)
910#define TYPE(Derived, Base) case Derived: return #Derived;
911#include "clang/AST/TypeNodes.def"
912  }
913}
914
915const char *BuiltinType::getName(const LangOptions &LO) const {
916  switch (getKind()) {
917  default: assert(0 && "Unknown builtin type!");
918  case Void:              return "void";
919  case Bool:              return LO.Bool ? "bool" : "_Bool";
920  case Char_S:            return "char";
921  case Char_U:            return "char";
922  case SChar:             return "signed char";
923  case Short:             return "short";
924  case Int:               return "int";
925  case Long:              return "long";
926  case LongLong:          return "long long";
927  case Int128:            return "__int128_t";
928  case UChar:             return "unsigned char";
929  case UShort:            return "unsigned short";
930  case UInt:              return "unsigned int";
931  case ULong:             return "unsigned long";
932  case ULongLong:         return "unsigned long long";
933  case UInt128:           return "__uint128_t";
934  case Float:             return "float";
935  case Double:            return "double";
936  case LongDouble:        return "long double";
937  case WChar:             return "wchar_t";
938  case Char16:            return "char16_t";
939  case Char32:            return "char32_t";
940  case NullPtr:           return "nullptr_t";
941  case Overload:          return "<overloaded function type>";
942  case Dependent:         return "<dependent type>";
943  case UndeducedAuto:     return "auto";
944  case ObjCId:            return "id";
945  case ObjCClass:         return "Class";
946  case ObjCSel:           return "SEL";
947  }
948}
949
950void FunctionType::ANCHOR() {} // Key function for FunctionType.
951
952QualType QualType::getNonLValueExprType(ASTContext &Context) const {
953  if (const ReferenceType *RefType = getTypePtr()->getAs<ReferenceType>())
954    return RefType->getPointeeType();
955
956  // C++0x [basic.lval]:
957  //   Class prvalues can have cv-qualified types; non-class prvalues always
958  //   have cv-unqualified types.
959  //
960  // See also C99 6.3.2.1p2.
961  if (!Context.getLangOptions().CPlusPlus ||
962      (!getTypePtr()->isDependentType() && !getTypePtr()->isRecordType()))
963    return getUnqualifiedType();
964
965  return *this;
966}
967
968llvm::StringRef FunctionType::getNameForCallConv(CallingConv CC) {
969  switch (CC) {
970  case CC_Default: llvm_unreachable("no name for default cc");
971  default: return "";
972
973  case CC_C: return "cdecl";
974  case CC_X86StdCall: return "stdcall";
975  case CC_X86FastCall: return "fastcall";
976  case CC_X86ThisCall: return "thiscall";
977  }
978}
979
980void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID, QualType Result,
981                                arg_type_iterator ArgTys,
982                                unsigned NumArgs, bool isVariadic,
983                                unsigned TypeQuals, bool hasExceptionSpec,
984                                bool anyExceptionSpec, unsigned NumExceptions,
985                                exception_iterator Exs,
986                                const FunctionType::ExtInfo &Info) {
987  ID.AddPointer(Result.getAsOpaquePtr());
988  for (unsigned i = 0; i != NumArgs; ++i)
989    ID.AddPointer(ArgTys[i].getAsOpaquePtr());
990  ID.AddInteger(isVariadic);
991  ID.AddInteger(TypeQuals);
992  ID.AddInteger(hasExceptionSpec);
993  if (hasExceptionSpec) {
994    ID.AddInteger(anyExceptionSpec);
995    for (unsigned i = 0; i != NumExceptions; ++i)
996      ID.AddPointer(Exs[i].getAsOpaquePtr());
997  }
998  ID.AddInteger(Info.getNoReturn());
999  ID.AddInteger(Info.getRegParm());
1000  ID.AddInteger(Info.getCC());
1001}
1002
1003void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID) {
1004  Profile(ID, getResultType(), arg_type_begin(), NumArgs, isVariadic(),
1005          getTypeQuals(), hasExceptionSpec(), hasAnyExceptionSpec(),
1006          getNumExceptions(), exception_begin(),
1007          getExtInfo());
1008}
1009
1010/// LookThroughTypedefs - Return the ultimate type this typedef corresponds to
1011/// potentially looking through *all* consequtive typedefs.  This returns the
1012/// sum of the type qualifiers, so if you have:
1013///   typedef const int A;
1014///   typedef volatile A B;
1015/// looking through the typedefs for B will give you "const volatile A".
1016///
1017QualType TypedefType::LookThroughTypedefs() const {
1018  // Usually, there is only a single level of typedefs, be fast in that case.
1019  QualType FirstType = getDecl()->getUnderlyingType();
1020  if (!isa<TypedefType>(FirstType))
1021    return FirstType;
1022
1023  // Otherwise, do the fully general loop.
1024  QualifierCollector Qs;
1025
1026  QualType CurType;
1027  const TypedefType *TDT = this;
1028  do {
1029    CurType = TDT->getDecl()->getUnderlyingType();
1030    TDT = dyn_cast<TypedefType>(Qs.strip(CurType));
1031  } while (TDT);
1032
1033  return Qs.apply(CurType);
1034}
1035
1036QualType TypedefType::desugar() const {
1037  return getDecl()->getUnderlyingType();
1038}
1039
1040TypeOfExprType::TypeOfExprType(Expr *E, QualType can)
1041  : Type(TypeOfExpr, can, E->isTypeDependent()), TOExpr(E) {
1042}
1043
1044QualType TypeOfExprType::desugar() const {
1045  return getUnderlyingExpr()->getType();
1046}
1047
1048void DependentTypeOfExprType::Profile(llvm::FoldingSetNodeID &ID,
1049                                      ASTContext &Context, Expr *E) {
1050  E->Profile(ID, Context, true);
1051}
1052
1053DecltypeType::DecltypeType(Expr *E, QualType underlyingType, QualType can)
1054  : Type(Decltype, can, E->isTypeDependent()), E(E),
1055  UnderlyingType(underlyingType) {
1056}
1057
1058DependentDecltypeType::DependentDecltypeType(ASTContext &Context, Expr *E)
1059  : DecltypeType(E, Context.DependentTy), Context(Context) { }
1060
1061void DependentDecltypeType::Profile(llvm::FoldingSetNodeID &ID,
1062                                    ASTContext &Context, Expr *E) {
1063  E->Profile(ID, Context, true);
1064}
1065
1066TagType::TagType(TypeClass TC, const TagDecl *D, QualType can)
1067  : Type(TC, can, D->isDependentType()),
1068    decl(const_cast<TagDecl*>(D)) {}
1069
1070static TagDecl *getInterestingTagDecl(TagDecl *decl) {
1071  for (TagDecl::redecl_iterator I = decl->redecls_begin(),
1072                                E = decl->redecls_end();
1073       I != E; ++I) {
1074    if (I->isDefinition() || I->isBeingDefined())
1075      return *I;
1076  }
1077  // If there's no definition (not even in progress), return what we have.
1078  return decl;
1079}
1080
1081TagDecl *TagType::getDecl() const {
1082  return getInterestingTagDecl(decl);
1083}
1084
1085bool TagType::isBeingDefined() const {
1086  return getDecl()->isBeingDefined();
1087}
1088
1089CXXRecordDecl *InjectedClassNameType::getDecl() const {
1090  return cast<CXXRecordDecl>(getInterestingTagDecl(Decl));
1091}
1092
1093bool RecordType::classof(const TagType *TT) {
1094  return isa<RecordDecl>(TT->getDecl());
1095}
1096
1097bool EnumType::classof(const TagType *TT) {
1098  return isa<EnumDecl>(TT->getDecl());
1099}
1100
1101static bool isDependent(const TemplateArgument &Arg) {
1102  switch (Arg.getKind()) {
1103  case TemplateArgument::Null:
1104    assert(false && "Should not have a NULL template argument");
1105    return false;
1106
1107  case TemplateArgument::Type:
1108    return Arg.getAsType()->isDependentType();
1109
1110  case TemplateArgument::Template:
1111    return Arg.getAsTemplate().isDependent();
1112
1113  case TemplateArgument::Declaration:
1114    if (DeclContext *DC = dyn_cast<DeclContext>(Arg.getAsDecl()))
1115      return DC->isDependentContext();
1116    return Arg.getAsDecl()->getDeclContext()->isDependentContext();
1117
1118  case TemplateArgument::Integral:
1119    // Never dependent
1120    return false;
1121
1122  case TemplateArgument::Expression:
1123    return (Arg.getAsExpr()->isTypeDependent() ||
1124            Arg.getAsExpr()->isValueDependent());
1125
1126  case TemplateArgument::Pack:
1127    for (TemplateArgument::pack_iterator P = Arg.pack_begin(),
1128                                      PEnd = Arg.pack_end();
1129         P != PEnd; ++P) {
1130      if (isDependent(*P))
1131        return true;
1132    }
1133
1134    return false;
1135  }
1136
1137  return false;
1138}
1139
1140bool TemplateSpecializationType::
1141anyDependentTemplateArguments(const TemplateArgumentListInfo &Args) {
1142  return anyDependentTemplateArguments(Args.getArgumentArray(), Args.size());
1143}
1144
1145bool TemplateSpecializationType::
1146anyDependentTemplateArguments(const TemplateArgumentLoc *Args, unsigned N) {
1147  for (unsigned i = 0; i != N; ++i)
1148    if (isDependent(Args[i].getArgument()))
1149      return true;
1150  return false;
1151}
1152
1153bool TemplateSpecializationType::
1154anyDependentTemplateArguments(const TemplateArgument *Args, unsigned N) {
1155  for (unsigned i = 0; i != N; ++i)
1156    if (isDependent(Args[i]))
1157      return true;
1158  return false;
1159}
1160
1161TemplateSpecializationType::
1162TemplateSpecializationType(TemplateName T,
1163                           const TemplateArgument *Args,
1164                           unsigned NumArgs, QualType Canon)
1165  : Type(TemplateSpecialization,
1166         Canon.isNull()? QualType(this, 0) : Canon,
1167         T.isDependent() || anyDependentTemplateArguments(Args, NumArgs)),
1168    Template(T), NumArgs(NumArgs) {
1169  assert((!Canon.isNull() ||
1170          T.isDependent() || anyDependentTemplateArguments(Args, NumArgs)) &&
1171         "No canonical type for non-dependent class template specialization");
1172
1173  TemplateArgument *TemplateArgs
1174    = reinterpret_cast<TemplateArgument *>(this + 1);
1175  for (unsigned Arg = 0; Arg < NumArgs; ++Arg)
1176    new (&TemplateArgs[Arg]) TemplateArgument(Args[Arg]);
1177}
1178
1179void
1180TemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,
1181                                    TemplateName T,
1182                                    const TemplateArgument *Args,
1183                                    unsigned NumArgs,
1184                                    ASTContext &Context) {
1185  T.Profile(ID);
1186  for (unsigned Idx = 0; Idx < NumArgs; ++Idx)
1187    Args[Idx].Profile(ID, Context);
1188}
1189
1190QualType QualifierCollector::apply(QualType QT) const {
1191  if (!hasNonFastQualifiers())
1192    return QT.withFastQualifiers(getFastQualifiers());
1193
1194  assert(Context && "extended qualifiers but no context!");
1195  return Context->getQualifiedType(QT, *this);
1196}
1197
1198QualType QualifierCollector::apply(const Type *T) const {
1199  if (!hasNonFastQualifiers())
1200    return QualType(T, getFastQualifiers());
1201
1202  assert(Context && "extended qualifiers but no context!");
1203  return Context->getQualifiedType(T, *this);
1204}
1205
1206void ObjCObjectTypeImpl::Profile(llvm::FoldingSetNodeID &ID,
1207                                 QualType BaseType,
1208                                 ObjCProtocolDecl * const *Protocols,
1209                                 unsigned NumProtocols) {
1210  ID.AddPointer(BaseType.getAsOpaquePtr());
1211  for (unsigned i = 0; i != NumProtocols; i++)
1212    ID.AddPointer(Protocols[i]);
1213}
1214
1215void ObjCObjectTypeImpl::Profile(llvm::FoldingSetNodeID &ID) {
1216  Profile(ID, getBaseType(), qual_begin(), getNumProtocols());
1217}
1218
1219/// \brief Determine the linkage of this type.
1220Linkage Type::getLinkage() const {
1221  if (this != CanonicalType.getTypePtr())
1222    return CanonicalType->getLinkage();
1223
1224  if (!LinkageKnown) {
1225    CachedLinkage = getLinkageImpl();
1226    LinkageKnown = true;
1227  }
1228
1229  return static_cast<clang::Linkage>(CachedLinkage);
1230}
1231
1232Linkage Type::getLinkageImpl() const {
1233  // C++ [basic.link]p8:
1234  //   Names not covered by these rules have no linkage.
1235  return NoLinkage;
1236}
1237
1238void Type::ClearLinkageCache() {
1239  if (this != CanonicalType.getTypePtr())
1240    CanonicalType->ClearLinkageCache();
1241  else
1242    LinkageKnown = false;
1243}
1244
1245Linkage BuiltinType::getLinkageImpl() const {
1246  // C++ [basic.link]p8:
1247  //   A type is said to have linkage if and only if:
1248  //     - it is a fundamental type (3.9.1); or
1249  return ExternalLinkage;
1250}
1251
1252Linkage TagType::getLinkageImpl() const {
1253  // C++ [basic.link]p8:
1254  //     - it is a class or enumeration type that is named (or has a name for
1255  //       linkage purposes (7.1.3)) and the name has linkage; or
1256  //     -  it is a specialization of a class template (14); or
1257  return getDecl()->getLinkage();
1258}
1259
1260// C++ [basic.link]p8:
1261//   - it is a compound type (3.9.2) other than a class or enumeration,
1262//     compounded exclusively from types that have linkage; or
1263Linkage ComplexType::getLinkageImpl() const {
1264  return ElementType->getLinkage();
1265}
1266
1267Linkage PointerType::getLinkageImpl() const {
1268  return PointeeType->getLinkage();
1269}
1270
1271Linkage BlockPointerType::getLinkageImpl() const {
1272  return PointeeType->getLinkage();
1273}
1274
1275Linkage ReferenceType::getLinkageImpl() const {
1276  return PointeeType->getLinkage();
1277}
1278
1279Linkage MemberPointerType::getLinkageImpl() const {
1280  return minLinkage(Class->getLinkage(), PointeeType->getLinkage());
1281}
1282
1283Linkage ArrayType::getLinkageImpl() const {
1284  return ElementType->getLinkage();
1285}
1286
1287Linkage VectorType::getLinkageImpl() const {
1288  return ElementType->getLinkage();
1289}
1290
1291Linkage FunctionNoProtoType::getLinkageImpl() const {
1292  return getResultType()->getLinkage();
1293}
1294
1295Linkage FunctionProtoType::getLinkageImpl() const {
1296  Linkage L = getResultType()->getLinkage();
1297  for (arg_type_iterator A = arg_type_begin(), AEnd = arg_type_end();
1298       A != AEnd; ++A)
1299    L = minLinkage(L, (*A)->getLinkage());
1300
1301  return L;
1302}
1303
1304Linkage ObjCObjectType::getLinkageImpl() const {
1305  return ExternalLinkage;
1306}
1307
1308Linkage ObjCObjectPointerType::getLinkageImpl() const {
1309  return ExternalLinkage;
1310}
1311