Type.h revision 2ea769b494649b5ca4864acf154f2fedc7718029
14b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner//===--- Type.h - C Language Family Type Representation ---------*- C++ -*-===//
24b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner//
34b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner//                     The LLVM Compiler Infrastructure
44b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner//
5959e5be188a505881058777f35abaaa3fe2de40bChris Lattner// This file is distributed under the University of Illinois Open Source
6959e5be188a505881058777f35abaaa3fe2de40bChris Lattner// License. See LICENSE.TXT for details.
74b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner//
84b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner//===----------------------------------------------------------------------===//
94b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner//
104b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner//  This file defines the Type interface and subclasses.
114b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner//
124b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner//===----------------------------------------------------------------------===//
134b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
144b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner#ifndef LLVM_CLANG_AST_TYPE_H
154b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner#define LLVM_CLANG_AST_TYPE_H
164b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
174b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner#include "llvm/Support/Casting.h"
184b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner#include "llvm/ADT/FoldingSet.h"
1983c13010359c33354c581acee65d0c986a75247eSteve Naroff#include "llvm/ADT/APSInt.h"
2078f138f44886abc5ab7fc1551d501308f1846d80Ted Kremenek#include "llvm/Bitcode/SerializationFwd.h"
214b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
224b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerusing llvm::isa;
234b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerusing llvm::cast;
244b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerusing llvm::cast_or_null;
254b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerusing llvm::dyn_cast;
264b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerusing llvm::dyn_cast_or_null;
274b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
284b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnernamespace clang {
294b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  class ASTContext;
304b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  class Type;
314b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  class TypedefDecl;
324b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  class TagDecl;
334b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  class RecordDecl;
344b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  class EnumDecl;
3564be4ada44c719304c1dee75fb1e551f84b7779aTed Kremenek  class FieldDecl;
3642730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  class ObjCInterfaceDecl;
3742730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  class ObjCProtocolDecl;
3842730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  class ObjCMethodDecl;
394b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  class Expr;
404b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  class SourceLocation;
414b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  class PointerType;
424b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  class ReferenceType;
434b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  class VectorType;
444b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  class ArrayType;
455eb879b0ab7cc0b98c5700b0c19cae3797530d9cSteve Naroff  class ConstantArrayType;
465eb879b0ab7cc0b98c5700b0c19cae3797530d9cSteve Naroff  class VariableArrayType;
472cb6638a26cfa999e5fb999e6af9211127e681c1Steve Naroff  class RecordType;
487a85fa1ba94c9f4cf960463dd3eb444ef6f89446Chris Lattner  class ComplexType;
49806b319509d01bffe47317f11140c930da800dbbSteve Naroff  class TagType;
50806b319509d01bffe47317f11140c930da800dbbSteve Naroff  class FunctionType;
51806b319509d01bffe47317f11140c930da800dbbSteve Naroff  class OCUVectorType;
52c33c060e2f4e7c7e89e3b809f52cfc6d55ea9838Steve Naroff  class BuiltinType;
5342730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  class ObjCQualifiedInterfaceType;
54fce813e3159a67a57a03cdca45ac4e10d4cffac3Ted Kremenek  class StmtIteratorBase;
554b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
564b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// QualType - For efficiency, we don't store CVR-qualified types as nodes on
574b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// their own: instead each reference to a type stores the qualifiers.  This
584b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// greatly reduces the number of nodes we need to allocate for types (for
594b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// example we only need one for 'int', 'const int', 'volatile int',
604b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// 'const volatile int', etc).
614b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner///
624b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// As an added efficiency bonus, instead of making this a pair, we just store
634b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// the three bits we care about in the low bits of the pointer.  To handle the
644b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// packing/unpacking, we make QualType be a simple wrapper class that acts like
654b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// a smart pointer.
664b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerclass QualType {
674b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  uintptr_t ThePtr;
684b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerpublic:
694b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  enum TQ {   // NOTE: These flags must be kept in sync with DeclSpec::TQ.
704b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    Const    = 0x1,
714b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    Restrict = 0x2,
724b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    Volatile = 0x4,
734b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    CVRFlags = Const|Restrict|Volatile
744b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  };
754b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
764b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  QualType() : ThePtr(0) {}
774b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
784b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  QualType(Type *Ptr, unsigned Quals) {
794b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    assert((Quals & ~CVRFlags) == 0 && "Invalid type qualifiers!");
804b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    ThePtr = reinterpret_cast<uintptr_t>(Ptr);
814b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    assert((ThePtr & CVRFlags) == 0 && "Type pointer not 8-byte aligned?");
824b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    ThePtr |= Quals;
834b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
844b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
854b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static QualType getFromOpaquePtr(void *Ptr) {
864b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    QualType T;
874b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    T.ThePtr = reinterpret_cast<uintptr_t>(Ptr);
884b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    return T;
894b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
904b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
914b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  unsigned getQualifiers() const {
924b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    return ThePtr & CVRFlags;
934b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
944b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  Type *getTypePtr() const {
954b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    return reinterpret_cast<Type*>(ThePtr & ~CVRFlags);
964b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
974b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
984b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  void *getAsOpaquePtr() const {
994b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    return reinterpret_cast<void*>(ThePtr);
1004b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
1014b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
1024b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  Type &operator*() const {
1034b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    return *getTypePtr();
1044b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
1054b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
1064b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  Type *operator->() const {
1074b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    return getTypePtr();
1084b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
1094b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
1104b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// isNull - Return true if this QualType doesn't point to a type yet.
1114b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool isNull() const {
1124b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    return ThePtr == 0;
1134b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
1144b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
1154b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool isConstQualified() const {
116c75ccff9e318638cac63fe392f68893ab4177f45Chris Lattner    return (ThePtr & Const) ? true : false;
1174b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
1184b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool isVolatileQualified() const {
119c75ccff9e318638cac63fe392f68893ab4177f45Chris Lattner    return (ThePtr & Volatile) ? true : false;
1204b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
1214b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool isRestrictQualified() const {
122c75ccff9e318638cac63fe392f68893ab4177f45Chris Lattner    return (ThePtr & Restrict) ? true : false;
1234b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
1242e3b1d2ed22e5638fa9c55cc1ea5dac4db6aecdcChris Lattner
1252e3b1d2ed22e5638fa9c55cc1ea5dac4db6aecdcChris Lattner  /// addConst/addVolatile/addRestrict - add the specified type qual to this
1262e3b1d2ed22e5638fa9c55cc1ea5dac4db6aecdcChris Lattner  /// QualType.
1272e3b1d2ed22e5638fa9c55cc1ea5dac4db6aecdcChris Lattner  void addConst()    { ThePtr |= Const; }
1282e3b1d2ed22e5638fa9c55cc1ea5dac4db6aecdcChris Lattner  void addVolatile() { ThePtr |= Volatile; }
1292e3b1d2ed22e5638fa9c55cc1ea5dac4db6aecdcChris Lattner  void addRestrict() { ThePtr |= Restrict; }
1304b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
1314b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  QualType getQualifiedType(unsigned TQs) const {
1324b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    return QualType(getTypePtr(), TQs);
1334b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
1344b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
1354b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  QualType getUnqualifiedType() const {
1364b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    return QualType(getTypePtr(), 0);
1374b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
1384b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
1394b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// operator==/!= - Indicate whether the specified types and qualifiers are
1404b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// identical.
1414b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool operator==(const QualType &RHS) const {
1424b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    return ThePtr == RHS.ThePtr;
1434b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
1444b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool operator!=(const QualType &RHS) const {
1454b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    return ThePtr != RHS.ThePtr;
1464b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
1474b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  std::string getAsString() const {
1484b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    std::string S;
1494b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    getAsStringInternal(S);
1504b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    return S;
1514b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
1524b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  void getAsStringInternal(std::string &Str) const;
1534b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
1544b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  void dump(const char *s = 0) const;
1554b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
1564b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// getCanonicalType - Return the canonical version of this type, with the
1574b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// appropriate type qualifiers on it.
1584b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  inline QualType getCanonicalType() const;
1594b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
160034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek  /// Emit - Serialize a QualType to Bitcode.
16178f138f44886abc5ab7fc1551d501308f1846d80Ted Kremenek  void Emit(llvm::Serializer& S) const;
16278f138f44886abc5ab7fc1551d501308f1846d80Ted Kremenek
163034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek  /// Read - Deserialize a QualType from Bitcode.
164034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek  static QualType ReadVal(llvm::Deserializer& D);
16564be4ada44c719304c1dee75fb1e551f84b7779aTed Kremenek
16664be4ada44c719304c1dee75fb1e551f84b7779aTed Kremenekprivate:
16764be4ada44c719304c1dee75fb1e551f84b7779aTed Kremenek  void ReadBackpatch(llvm::Deserializer& D);
16864be4ada44c719304c1dee75fb1e551f84b7779aTed Kremenek  friend class FieldDecl;
1694b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner};
1704b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
1714b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner} // end clang.
1724b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
1734b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnernamespace llvm {
1744b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// Implement simplify_type for QualType, so that we can dyn_cast from QualType
1754b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// to a specific Type class.
1764b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnertemplate<> struct simplify_type<const ::clang::QualType> {
1774b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  typedef ::clang::Type* SimpleType;
1784b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static SimpleType getSimplifiedValue(const ::clang::QualType &Val) {
1794b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    return Val.getTypePtr();
1804b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
1814b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner};
1824b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnertemplate<> struct simplify_type< ::clang::QualType>
1834b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  : public simplify_type<const ::clang::QualType> {};
18478f138f44886abc5ab7fc1551d501308f1846d80Ted Kremenek
18578f138f44886abc5ab7fc1551d501308f1846d80Ted Kremenek} // end namespace llvm
1864b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
1874b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnernamespace clang {
1884b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
1894b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// Type - This is the base class of the type hierarchy.  A central concept
1904b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// with types is that each type always has a canonical type.  A canonical type
1914b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// is the type with any typedef names stripped out of it or the types it
1924b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// references.  For example, consider:
1934b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner///
1944b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner///  typedef int  foo;
1954b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner///  typedef foo* bar;
1964b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner///    'int *'    'foo *'    'bar'
1974b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner///
1984b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// There will be a Type object created for 'int'.  Since int is canonical, its
1994b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// canonicaltype pointer points to itself.  There is also a Type for 'foo' (a
2004b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// TypeNameType).  Its CanonicalType pointer points to the 'int' Type.  Next
2014b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// there is a PointerType that represents 'int*', which, like 'int', is
2024b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// canonical.  Finally, there is a PointerType type for 'foo*' whose canonical
2034b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// type is 'int*', and there is a TypeNameType for 'bar', whose canonical type
2044b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// is also 'int*'.
2054b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner///
2064b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// Non-canonical types are useful for emitting diagnostics, without losing
2074b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// information about typedefs being used.  Canonical types are useful for type
2084b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// comparisons (they allow by-pointer equality tests) and useful for reasoning
2094b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// about whether something has a particular form (e.g. is a function type),
2104b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// because they implicitly, recursively, strip all typedefs out of a type.
2114b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner///
2124b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// Types, once created, are immutable.
2134b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner///
2144b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerclass Type {
2154b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerpublic:
2164b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  enum TypeClass {
21783c13010359c33354c581acee65d0c986a75247eSteve Naroff    Builtin, Complex, Pointer, Reference,
21883c13010359c33354c581acee65d0c986a75247eSteve Naroff    ConstantArray, VariableArray,
21983c13010359c33354c581acee65d0c986a75247eSteve Naroff    Vector, OCUVector,
2204b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    FunctionNoProto, FunctionProto,
2217cbb14653934a298c09002b87704dc6531261771Steve Naroff    TypeName, Tagged,
22242730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek    ObjCInterface, ObjCQualifiedInterface,
22342730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek    ObjCQualifiedId,
2247cbb14653934a298c09002b87704dc6531261771Steve Naroff    TypeOfExp, TypeOfTyp // GNU typeof extension.
2254b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  };
2264b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerprivate:
2274b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  QualType CanonicalType;
2284b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
2294b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// TypeClass bitfield - Enum that specifies what subclass this belongs to.
2304b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// Note that this should stay at the end of the ivars for Type so that
2314b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// subclasses can pack their bitfields into the same word.
23292803daaa6a40a3899c2e599bddc42732c2ce593Hartmut Kaiser  unsigned TC : 4;
2334b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerprotected:
2347c6f0c755e48a2782bc0a0a4cfc63dc84e0f11d5Hartmut Kaiser  // silence VC++ warning C4355: 'this' : used in base member initializer list
2357c6f0c755e48a2782bc0a0a4cfc63dc84e0f11d5Hartmut Kaiser  Type *this_() { return this; }
2364b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  Type(TypeClass tc, QualType Canonical)
2377c6f0c755e48a2782bc0a0a4cfc63dc84e0f11d5Hartmut Kaiser    : CanonicalType(Canonical.isNull() ? QualType(this_(),0) : Canonical), TC(tc){}
2384b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  virtual ~Type();
2394b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  friend class ASTContext;
24078f138f44886abc5ab7fc1551d501308f1846d80Ted Kremenek
24178f138f44886abc5ab7fc1551d501308f1846d80Ted Kremenek  void EmitTypeInternal(llvm::Serializer& S) const;
24278f138f44886abc5ab7fc1551d501308f1846d80Ted Kremenek  void ReadTypeInternal(llvm::Deserializer& D);
24378f138f44886abc5ab7fc1551d501308f1846d80Ted Kremenek
2444b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerpublic:
24592803daaa6a40a3899c2e599bddc42732c2ce593Hartmut Kaiser  TypeClass getTypeClass() const { return static_cast<TypeClass>(TC); }
2464b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
2474b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool isCanonical() const { return CanonicalType.getTypePtr() == this; }
2484b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
2494b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// Types are partitioned into 3 broad categories (C99 6.2.5p1):
2504b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// object types, function types, and incomplete types.
2514b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
2524b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// isObjectType - types that fully describe objects. An object is a region
2534b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// of memory that can be examined and stored into (H&S).
2544b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool isObjectType() const;
2554b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
2564b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// isIncompleteType - Return true if this is an incomplete type.
2574b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// A type that can describe objects, but which lacks information needed to
2584b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// determine its size (e.g. void, or a fwd declared struct). Clients of this
2594b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// routine will need to determine if the size is actually required.
2604b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool isIncompleteType() const;
2614b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
2625eb879b0ab7cc0b98c5700b0c19cae3797530d9cSteve Naroff  /// isVariablyModifiedType (C99 6.7.5.2p2) - Return true for variable array
2635eb879b0ab7cc0b98c5700b0c19cae3797530d9cSteve Naroff  /// types that have a non-constant expression. This does not include "[]".
2645eb879b0ab7cc0b98c5700b0c19cae3797530d9cSteve Naroff  bool isVariablyModifiedType() const;
2655eb879b0ab7cc0b98c5700b0c19cae3797530d9cSteve Naroff
2664b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// Helper methods to distinguish type categories. All type predicates
2674b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// operate on the canonical type, ignoring typedefs.
2684b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool isIntegerType() const;     // C99 6.2.5p17 (int, char, bool, enum)
2698d3b170e5cb1700b5cbd227182bc29ca0d16819dSteve Naroff  bool isEnumeralType() const;
2708d3b170e5cb1700b5cbd227182bc29ca0d16819dSteve Naroff  bool isBooleanType() const;
2718d3b170e5cb1700b5cbd227182bc29ca0d16819dSteve Naroff  bool isCharType() const;
272c81f316d260b8b8b9da21a0f9a22baa334e063fbFariborz Jahanian  bool isIntegralType() const;
2734b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
2744b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// Floating point categories.
2754b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool isRealFloatingType() const; // C99 6.2.5p10 (float, double, long double)
2764b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool isComplexType() const;      // C99 6.2.5p11 (complex)
2774b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool isFloatingType() const;     // C99 6.2.5p11 (real floating + complex)
2784b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool isRealType() const;         // C99 6.2.5p17 (real floating + integer)
2794b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool isArithmeticType() const;   // C99 6.2.5p18 (integer + floating)
280e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  bool isVoidType() const;         // C99 6.2.5p19
281e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  bool isDerivedType() const;      // C99 6.2.5p20
282e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  bool isScalarType() const;       // C99 6.2.5p21 (arithmetic + pointers)
283e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  bool isAggregateType() const;    // C99 6.2.5p21 (arrays, structures)
2844b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
285e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  // Type Predicates: Check to see if this type is structurally the specified
286e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  // type, ignoring typedefs.
287e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  bool isFunctionType() const;
2887931f4a186bc76b21dd4629ee74d64264a7fb8a2Chris Lattner  bool isPointerType() const;
28983b01279f2e6718581eeb1e5bdba58aa88e4649bTed Kremenek  bool isFunctionPointerType() const;
290f0c4a0a830c9154b1ae72e497c2ce586c10e9b71Chris Lattner  bool isReferenceType() const;
291e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  bool isArrayType() const;
292e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  bool isRecordType() const;
293e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  bool isStructureType() const;
29483b01279f2e6718581eeb1e5bdba58aa88e4649bTed Kremenek  bool isUnionType() const;
295e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  bool isVectorType() const; // GCC vector type.
296e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  bool isOCUVectorType() const; // OCU vector type.
29742730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  bool isObjCInterfaceType() const; // includes conforming protocol type
29842730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  bool isObjCQualifiedIdType() const; // id includes conforming protocol type
299e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner
300e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  // Type Checking Functions: Check to see if this type is structurally the
301e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  // specified type, ignoring typedefs, and return a pointer to the best type
302e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  // we can.
303c33c060e2f4e7c7e89e3b809f52cfc6d55ea9838Steve Naroff  const BuiltinType *getAsBuiltinType() const;
304e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  const FunctionType *getAsFunctionType() const;
3057931f4a186bc76b21dd4629ee74d64264a7fb8a2Chris Lattner  const PointerType *getAsPointerType() const;
306f0c4a0a830c9154b1ae72e497c2ce586c10e9b71Chris Lattner  const ReferenceType *getAsReferenceType() const;
307e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  const ArrayType *getAsArrayType() const;
3085eb879b0ab7cc0b98c5700b0c19cae3797530d9cSteve Naroff  const ConstantArrayType *getAsConstantArrayType() const;
3095eb879b0ab7cc0b98c5700b0c19cae3797530d9cSteve Naroff  const VariableArrayType *getAsVariableArrayType() const;
3105eb879b0ab7cc0b98c5700b0c19cae3797530d9cSteve Naroff  const VariableArrayType *getAsVariablyModifiedType() const;
311e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  const RecordType *getAsRecordType() const;
312e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  const RecordType *getAsStructureType() const;
313e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  const RecordType *getAsUnionType() const;
314e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  const VectorType *getAsVectorType() const; // GCC vector type.
3157a85fa1ba94c9f4cf960463dd3eb444ef6f89446Chris Lattner  const ComplexType *getAsComplexType() const;
316e35a104a7d5caf8fa71117fbaa6f18cacc53c7a7Chris Lattner  const OCUVectorType *getAsOCUVectorType() const; // OCU vector type.
3174b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
3182afc72b0b6b3d2f44ca2576c98d307310d556983Chris Lattner  /// getDesugaredType - Return the specified type with any "sugar" removed from
3192afc72b0b6b3d2f44ca2576c98d307310d556983Chris Lattner  /// type type.  This takes off typedefs, typeof's etc.  If the outer level of
3202afc72b0b6b3d2f44ca2576c98d307310d556983Chris Lattner  /// the type is already concrete, it returns it unmodified.  This is similar
3212afc72b0b6b3d2f44ca2576c98d307310d556983Chris Lattner  /// to getting the canonical type, but it doesn't remove *all* typedefs.  For
3222ea769b494649b5ca4864acf154f2fedc7718029Chris Lattner  /// example, it returns "T*" as "T*", (not as "int*"), because the pointer is
3232afc72b0b6b3d2f44ca2576c98d307310d556983Chris Lattner  /// concrete.
3242afc72b0b6b3d2f44ca2576c98d307310d556983Chris Lattner  const Type *getDesugaredType() const;
3252afc72b0b6b3d2f44ca2576c98d307310d556983Chris Lattner
3264b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// More type predicates useful for type checking/promotion
3274b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool isPromotableIntegerType() const; // C99 6.3.1.1p2
3284b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
3294b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// isSignedIntegerType - Return true if this is an integer type that is
330bbe686be29157b575e53fbed328613117b525f26Chris Lattner  /// signed, according to C99 6.2.5p4 [char, signed char, short, int, long..],
331bbe686be29157b575e53fbed328613117b525f26Chris Lattner  /// an enum decl which has a signed representation, or a vector of signed
332bbe686be29157b575e53fbed328613117b525f26Chris Lattner  /// integer element type.
3334b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool isSignedIntegerType() const;
3344b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
3354b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// isUnsignedIntegerType - Return true if this is an integer type that is
336bbe686be29157b575e53fbed328613117b525f26Chris Lattner  /// unsigned, according to C99 6.2.5p6 [which returns true for _Bool], an enum
337bbe686be29157b575e53fbed328613117b525f26Chris Lattner  /// decl which has an unsigned representation, or a vector of unsigned integer
338bbe686be29157b575e53fbed328613117b525f26Chris Lattner  /// element type.
3394b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool isUnsignedIntegerType() const;
340bbe686be29157b575e53fbed328613117b525f26Chris Lattner
3414b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// isConstantSizeType - Return true if this is not a variable sized type,
3420448b4f2fecceebc0bddd67fe0f2c89afe604fdfChris Lattner  /// according to the rules of C99 6.7.5p3.  It is not legal to call this on
3430448b4f2fecceebc0bddd67fe0f2c89afe604fdfChris Lattner  /// incomplete types.
3440448b4f2fecceebc0bddd67fe0f2c89afe604fdfChris Lattner  bool isConstantSizeType(ASTContext &Ctx) const;
3454b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerprivate:
3464b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  QualType getCanonicalTypeInternal() const { return CanonicalType; }
3474b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  friend class QualType;
3484b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerpublic:
3494b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  virtual void getAsStringInternal(std::string &InnerString) const = 0;
3504b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const Type *) { return true; }
351034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek
352034a78cafc3505323698ea72db19dc5095324e06Ted Kremenekprotected:
353034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek  /// Emit - Emit a Type to bitcode.  Used by ASTContext.
354034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek  void Emit(llvm::Serializer& S) const;
355034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek
356034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek  /// Create - Construct a Type from bitcode.  Used by ASTContext.
357034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek  static void Create(ASTContext& Context, unsigned i, llvm::Deserializer& S);
358034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek
359034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek  /// EmitImpl - Subclasses must implement this method in order to
360034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek  ///  be serialized.
361034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
3624b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner};
3634b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
3644b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// BuiltinType - This class is used for builtin types like 'int'.  Builtin
3654b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// types are always canonical and have a literal name field.
3664b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerclass BuiltinType : public Type {
3674b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerpublic:
3684b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  enum Kind {
3694b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    Void,
3704b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
3714b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    Bool,     // This is bool and/or _Bool.
3724b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    Char_U,   // This is 'char' for targets where char is unsigned.
3734b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    UChar,    // This is explicitly qualified unsigned char.
3744b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    UShort,
3754b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    UInt,
3764b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    ULong,
3774b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    ULongLong,
3784b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
3794b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    Char_S,   // This is 'char' for targets where char is signed.
3804b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    SChar,    // This is explicitly qualified signed char.
3814b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    Short,
3824b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    Int,
3834b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    Long,
3844b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    LongLong,
3854b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
3864b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    Float, Double, LongDouble
3874b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  };
3884b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerprivate:
3894b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  Kind TypeKind;
3904b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerpublic:
3914b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  BuiltinType(Kind K) : Type(Builtin, QualType()), TypeKind(K) {}
3924b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
3934b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  Kind getKind() const { return TypeKind; }
3944b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  const char *getName() const;
3954b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
3964b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  virtual void getAsStringInternal(std::string &InnerString) const;
3974b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
3984b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const Type *T) { return T->getTypeClass() == Builtin; }
3994b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const BuiltinType *) { return true; }
4004b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner};
4014b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
4024b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// ComplexType - C99 6.2.5p11 - Complex values.  This supports the C99 complex
4034b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// types (_Complex float etc) as well as the GCC integer complex extensions.
4044b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner///
4054b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerclass ComplexType : public Type, public llvm::FoldingSetNode {
4064b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  QualType ElementType;
4074b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  ComplexType(QualType Element, QualType CanonicalPtr) :
4084b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    Type(Complex, CanonicalPtr), ElementType(Element) {
4094b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
4104b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  friend class ASTContext;  // ASTContext creates these.
4114b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerpublic:
4124b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  QualType getElementType() const { return ElementType; }
4134b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
4144b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  virtual void getAsStringInternal(std::string &InnerString) const;
415034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek
4164b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  void Profile(llvm::FoldingSetNodeID &ID) {
4174b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    Profile(ID, getElementType());
4184b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
4194b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static void Profile(llvm::FoldingSetNodeID &ID, QualType Element) {
4204b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    ID.AddPointer(Element.getAsOpaquePtr());
4214b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
4224b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
4234b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const Type *T) { return T->getTypeClass() == Complex; }
4244b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const ComplexType *) { return true; }
42578f138f44886abc5ab7fc1551d501308f1846d80Ted Kremenek
426034a78cafc3505323698ea72db19dc5095324e06Ted Kremenekprotected:
427034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
428034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek  static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D);
429034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek  friend class Type;
4304b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner};
4314b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
4324b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
4334b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// PointerType - C99 6.7.5.1 - Pointer Declarators.
4344b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner///
4354b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerclass PointerType : public Type, public llvm::FoldingSetNode {
4364b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  QualType PointeeType;
4374b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  PointerType(QualType Pointee, QualType CanonicalPtr) :
4384b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    Type(Pointer, CanonicalPtr), PointeeType(Pointee) {
4394b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
4404b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  friend class ASTContext;  // ASTContext creates these.
4414b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerpublic:
4424b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
4434b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  QualType getPointeeType() const { return PointeeType; }
4444b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
4454b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  virtual void getAsStringInternal(std::string &InnerString) const;
4464b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
4474b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
4484b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  void Profile(llvm::FoldingSetNodeID &ID) {
4494b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    Profile(ID, getPointeeType());
4504b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
4514b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static void Profile(llvm::FoldingSetNodeID &ID, QualType Pointee) {
4524b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    ID.AddPointer(Pointee.getAsOpaquePtr());
4534b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
4544b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
4554b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const Type *T) { return T->getTypeClass() == Pointer; }
4564b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const PointerType *) { return true; }
457034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek
458034a78cafc3505323698ea72db19dc5095324e06Ted Kremenekprotected:
459034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
460034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek  static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D);
461034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek  friend class Type;
4624b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner};
4634b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
4644b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// ReferenceType - C++ 8.3.2 - Reference Declarators.
4654b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner///
4664b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerclass ReferenceType : public Type, public llvm::FoldingSetNode {
4674b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  QualType ReferenceeType;
4684b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  ReferenceType(QualType Referencee, QualType CanonicalRef) :
4694b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    Type(Reference, CanonicalRef), ReferenceeType(Referencee) {
4704b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
4714b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  friend class ASTContext;  // ASTContext creates these.
4724b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerpublic:
4734b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  virtual void getAsStringInternal(std::string &InnerString) const;
4744b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
4754b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  QualType getReferenceeType() const { return ReferenceeType; }
4764b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
4774b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  void Profile(llvm::FoldingSetNodeID &ID) {
4784b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    Profile(ID, getReferenceeType());
4794b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
4804b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static void Profile(llvm::FoldingSetNodeID &ID, QualType Referencee) {
4814b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    ID.AddPointer(Referencee.getAsOpaquePtr());
4824b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
4834b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
4844b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const Type *T) { return T->getTypeClass() == Reference; }
4854b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const ReferenceType *) { return true; }
4864b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner};
4874b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
4884b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// ArrayType - C99 6.7.5.2 - Array Declarators.
4894b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner///
490c8253192b917a5684717c58f4032e0891d089b00Ted Kremenekclass ArrayType : public Type, public llvm::FoldingSetNode {
4914b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerpublic:
4924b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// ArraySizeModifier - Capture whether this is a normal array (e.g. int X[4])
4934b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// an array with a static size (e.g. int X[static 4]), or with a star size
49424c9b98cc6a8de4a080e2dedb2797bdc2eeb688bSteve Naroff  /// (e.g. int X[*]). 'static' is only allowed on function parameters.
4954b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  enum ArraySizeModifier {
4964b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    Normal, Static, Star
4974b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  };
4984b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerprivate:
49983c13010359c33354c581acee65d0c986a75247eSteve Naroff  /// ElementType - The element type of the array.
50083c13010359c33354c581acee65d0c986a75247eSteve Naroff  QualType ElementType;
50124c9b98cc6a8de4a080e2dedb2797bdc2eeb688bSteve Naroff
50224c9b98cc6a8de4a080e2dedb2797bdc2eeb688bSteve Naroff  /// NOTE: These fields are packed into the bitfields space in the Type class.
50324c9b98cc6a8de4a080e2dedb2797bdc2eeb688bSteve Naroff  ArraySizeModifier SizeModifier : 2;
50424c9b98cc6a8de4a080e2dedb2797bdc2eeb688bSteve Naroff
50524c9b98cc6a8de4a080e2dedb2797bdc2eeb688bSteve Naroff  /// IndexTypeQuals - Capture qualifiers in declarations like:
50624c9b98cc6a8de4a080e2dedb2797bdc2eeb688bSteve Naroff  /// 'int X[static restrict 4]'. For function parameters only.
50724c9b98cc6a8de4a080e2dedb2797bdc2eeb688bSteve Naroff  unsigned IndexTypeQuals : 3;
50824c9b98cc6a8de4a080e2dedb2797bdc2eeb688bSteve Naroff
50983c13010359c33354c581acee65d0c986a75247eSteve Naroffprotected:
51024c9b98cc6a8de4a080e2dedb2797bdc2eeb688bSteve Naroff  ArrayType(TypeClass tc, QualType et, QualType can,
51124c9b98cc6a8de4a080e2dedb2797bdc2eeb688bSteve Naroff            ArraySizeModifier sm, unsigned tq)
51224c9b98cc6a8de4a080e2dedb2797bdc2eeb688bSteve Naroff    : Type(tc, can), ElementType(et), SizeModifier(sm), IndexTypeQuals(tq) {}
51383c13010359c33354c581acee65d0c986a75247eSteve Naroff  friend class ASTContext;  // ASTContext creates these.
51483c13010359c33354c581acee65d0c986a75247eSteve Naroffpublic:
51583c13010359c33354c581acee65d0c986a75247eSteve Naroff  QualType getElementType() const { return ElementType; }
51624c9b98cc6a8de4a080e2dedb2797bdc2eeb688bSteve Naroff  ArraySizeModifier getSizeModifier() const { return SizeModifier; }
51724c9b98cc6a8de4a080e2dedb2797bdc2eeb688bSteve Naroff  unsigned getIndexTypeQualifier() const { return IndexTypeQuals; }
51883c13010359c33354c581acee65d0c986a75247eSteve Naroff
5194f9109983a4b4e69c41436ac4b3ae9a370e9a725Steve Naroff  QualType getBaseType() const {
5204f9109983a4b4e69c41436ac4b3ae9a370e9a725Steve Naroff    const ArrayType *AT;
5214f9109983a4b4e69c41436ac4b3ae9a370e9a725Steve Naroff    QualType ElmtType = getElementType();
5224f9109983a4b4e69c41436ac4b3ae9a370e9a725Steve Naroff    // If we have a multi-dimensional array, navigate to the base type.
5234f9109983a4b4e69c41436ac4b3ae9a370e9a725Steve Naroff    while ((AT = ElmtType->getAsArrayType()))
5244f9109983a4b4e69c41436ac4b3ae9a370e9a725Steve Naroff      ElmtType = AT->getElementType();
5254f9109983a4b4e69c41436ac4b3ae9a370e9a725Steve Naroff    return ElmtType;
5264f9109983a4b4e69c41436ac4b3ae9a370e9a725Steve Naroff  }
52783c13010359c33354c581acee65d0c986a75247eSteve Naroff  static bool classof(const Type *T) {
52883c13010359c33354c581acee65d0c986a75247eSteve Naroff    return T->getTypeClass() == ConstantArray ||
52983c13010359c33354c581acee65d0c986a75247eSteve Naroff           T->getTypeClass() == VariableArray;
53083c13010359c33354c581acee65d0c986a75247eSteve Naroff  }
53183c13010359c33354c581acee65d0c986a75247eSteve Naroff  static bool classof(const ArrayType *) { return true; }
53283c13010359c33354c581acee65d0c986a75247eSteve Naroff};
53383c13010359c33354c581acee65d0c986a75247eSteve Naroff
534c8253192b917a5684717c58f4032e0891d089b00Ted Kremenekclass ConstantArrayType : public ArrayType {
53583c13010359c33354c581acee65d0c986a75247eSteve Naroff  llvm::APInt Size; // Allows us to unique the type.
53683c13010359c33354c581acee65d0c986a75247eSteve Naroff
53724c9b98cc6a8de4a080e2dedb2797bdc2eeb688bSteve Naroff  ConstantArrayType(QualType et, QualType can, llvm::APInt sz,
53824c9b98cc6a8de4a080e2dedb2797bdc2eeb688bSteve Naroff                    ArraySizeModifier sm, unsigned tq)
53924c9b98cc6a8de4a080e2dedb2797bdc2eeb688bSteve Naroff    : ArrayType(ConstantArray, et, can, sm, tq), Size(sz) {}
54083c13010359c33354c581acee65d0c986a75247eSteve Naroff  friend class ASTContext;  // ASTContext creates these.
54183c13010359c33354c581acee65d0c986a75247eSteve Naroffpublic:
54283c13010359c33354c581acee65d0c986a75247eSteve Naroff  llvm::APInt getSize() const { return Size; }
5434f9109983a4b4e69c41436ac4b3ae9a370e9a725Steve Naroff  int getMaximumElements() const {
5444f9109983a4b4e69c41436ac4b3ae9a370e9a725Steve Naroff    QualType ElmtType = getElementType();
5457c6f0c755e48a2782bc0a0a4cfc63dc84e0f11d5Hartmut Kaiser    int maxElements = static_cast<int>(getSize().getZExtValue());
54683c13010359c33354c581acee65d0c986a75247eSteve Naroff
5474f9109983a4b4e69c41436ac4b3ae9a370e9a725Steve Naroff    const ConstantArrayType *CAT;
5484f9109983a4b4e69c41436ac4b3ae9a370e9a725Steve Naroff    // If we have a multi-dimensional array, include it's elements.
5494f9109983a4b4e69c41436ac4b3ae9a370e9a725Steve Naroff    while ((CAT = ElmtType->getAsConstantArrayType())) {
5504f9109983a4b4e69c41436ac4b3ae9a370e9a725Steve Naroff      ElmtType = CAT->getElementType();
5517c6f0c755e48a2782bc0a0a4cfc63dc84e0f11d5Hartmut Kaiser      maxElements *= static_cast<int>(CAT->getSize().getZExtValue());
5524f9109983a4b4e69c41436ac4b3ae9a370e9a725Steve Naroff    }
5534f9109983a4b4e69c41436ac4b3ae9a370e9a725Steve Naroff    return maxElements;
5544f9109983a4b4e69c41436ac4b3ae9a370e9a725Steve Naroff  }
55583c13010359c33354c581acee65d0c986a75247eSteve Naroff  virtual void getAsStringInternal(std::string &InnerString) const;
55683c13010359c33354c581acee65d0c986a75247eSteve Naroff
55783c13010359c33354c581acee65d0c986a75247eSteve Naroff  void Profile(llvm::FoldingSetNodeID &ID) {
55883c13010359c33354c581acee65d0c986a75247eSteve Naroff    Profile(ID, getElementType(), getSize());
55983c13010359c33354c581acee65d0c986a75247eSteve Naroff  }
56083c13010359c33354c581acee65d0c986a75247eSteve Naroff  static void Profile(llvm::FoldingSetNodeID &ID, QualType ET,
56183c13010359c33354c581acee65d0c986a75247eSteve Naroff                      llvm::APInt ArraySize) {
56283c13010359c33354c581acee65d0c986a75247eSteve Naroff    ID.AddPointer(ET.getAsOpaquePtr());
56383c13010359c33354c581acee65d0c986a75247eSteve Naroff    ID.AddInteger(ArraySize.getZExtValue());
56483c13010359c33354c581acee65d0c986a75247eSteve Naroff  }
56583c13010359c33354c581acee65d0c986a75247eSteve Naroff  static bool classof(const Type *T) {
56683c13010359c33354c581acee65d0c986a75247eSteve Naroff    return T->getTypeClass() == ConstantArray;
56783c13010359c33354c581acee65d0c986a75247eSteve Naroff  }
56883c13010359c33354c581acee65d0c986a75247eSteve Naroff  static bool classof(const ConstantArrayType *) { return true; }
5694234c1b1a9c858b005f4ad7dc85908b63adcafddTed Kremenek
5704234c1b1a9c858b005f4ad7dc85908b63adcafddTed Kremenekprotected:
5714234c1b1a9c858b005f4ad7dc85908b63adcafddTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
5724234c1b1a9c858b005f4ad7dc85908b63adcafddTed Kremenek  static Type* CreateImpl(ASTContext& Context, llvm::Deserializer& D);
5734234c1b1a9c858b005f4ad7dc85908b63adcafddTed Kremenek  friend class Type;
57483c13010359c33354c581acee65d0c986a75247eSteve Naroff};
57583c13010359c33354c581acee65d0c986a75247eSteve Naroff
57683c13010359c33354c581acee65d0c986a75247eSteve Naroff// FIXME: VariableArrayType's aren't uniqued (since expressions aren't).
577c8253192b917a5684717c58f4032e0891d089b00Ted Kremenekclass VariableArrayType : public ArrayType {
57883c13010359c33354c581acee65d0c986a75247eSteve Naroff  /// SizeExpr - An assignment expression. VLA's are only permitted within
57983c13010359c33354c581acee65d0c986a75247eSteve Naroff  /// a function block.
5804b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  Expr *SizeExpr;
5814b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
58224c9b98cc6a8de4a080e2dedb2797bdc2eeb688bSteve Naroff  VariableArrayType(QualType et, QualType can, Expr *e,
58324c9b98cc6a8de4a080e2dedb2797bdc2eeb688bSteve Naroff                    ArraySizeModifier sm, unsigned tq)
58424c9b98cc6a8de4a080e2dedb2797bdc2eeb688bSteve Naroff    : ArrayType(VariableArray, et, can, sm, tq), SizeExpr(e) {}
5854b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  friend class ASTContext;  // ASTContext creates these.
5864b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerpublic:
5876df9359cad97dc722c01e3ddbc6686ebcf21189cChris Lattner  const Expr *getSizeExpr() const { return SizeExpr; }
5886df9359cad97dc722c01e3ddbc6686ebcf21189cChris Lattner  Expr *getSizeExpr() { return SizeExpr; }
5894b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
5904b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  virtual void getAsStringInternal(std::string &InnerString) const;
5914b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
59283c13010359c33354c581acee65d0c986a75247eSteve Naroff  static bool classof(const Type *T) {
59383c13010359c33354c581acee65d0c986a75247eSteve Naroff    return T->getTypeClass() == VariableArray;
5944b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
59583c13010359c33354c581acee65d0c986a75247eSteve Naroff  static bool classof(const VariableArrayType *) { return true; }
59627a32d6f18844a97446d6e2002bf181da591332aTed Kremenek
597fce813e3159a67a57a03cdca45ac4e10d4cffac3Ted Kremenek  friend class StmtIteratorBase;
5983793e1ab25169c0d5be43f3abe2b4dc92989c043Ted Kremenek
5993793e1ab25169c0d5be43f3abe2b4dc92989c043Ted Kremenek  void Profile(llvm::FoldingSetNodeID &ID) {
6003793e1ab25169c0d5be43f3abe2b4dc92989c043Ted Kremenek    assert (SizeExpr == NULL
6013793e1ab25169c0d5be43f3abe2b4dc92989c043Ted Kremenek            && "Can only unique VariableArrayTypes with no specified size.");
6023793e1ab25169c0d5be43f3abe2b4dc92989c043Ted Kremenek
6033793e1ab25169c0d5be43f3abe2b4dc92989c043Ted Kremenek    Profile(ID, getElementType());
6043793e1ab25169c0d5be43f3abe2b4dc92989c043Ted Kremenek  }
6053793e1ab25169c0d5be43f3abe2b4dc92989c043Ted Kremenek
6063793e1ab25169c0d5be43f3abe2b4dc92989c043Ted Kremenek  static void Profile(llvm::FoldingSetNodeID &ID, QualType ET) {
6073793e1ab25169c0d5be43f3abe2b4dc92989c043Ted Kremenek    ID.AddPointer(ET.getAsOpaquePtr());
6083793e1ab25169c0d5be43f3abe2b4dc92989c043Ted Kremenek  }
6095cde3834f43c0946ec8debfda9c6fb588b6b33fdTed Kremenek
6105cde3834f43c0946ec8debfda9c6fb588b6b33fdTed Kremenekprotected:
6115cde3834f43c0946ec8debfda9c6fb588b6b33fdTed Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
6125cde3834f43c0946ec8debfda9c6fb588b6b33fdTed Kremenek  static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D);
6135cde3834f43c0946ec8debfda9c6fb588b6b33fdTed Kremenek  friend class Type;
6144b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner};
6154b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
6164b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// VectorType - GCC generic vector type. This type is created using
6174b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// __attribute__((vector_size(n)), where "n" specifies the vector size in
6184b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// bytes. Since the constructor takes the number of vector elements, the
6194b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// client is responsible for converting the size into the number of elements.
6204b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerclass VectorType : public Type, public llvm::FoldingSetNode {
6214b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerprotected:
6224b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// ElementType - The element type of the vector.
6234b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  QualType ElementType;
6244b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
6254b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// NumElements - The number of elements in the vector.
6264b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  unsigned NumElements;
6274b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
6284b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  VectorType(QualType vecType, unsigned nElements, QualType canonType) :
6294b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    Type(Vector, canonType), ElementType(vecType), NumElements(nElements) {}
6304b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  VectorType(TypeClass tc, QualType vecType, unsigned nElements,
6314b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    QualType canonType) : Type(tc, canonType), ElementType(vecType),
6324b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    NumElements(nElements) {}
6334b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  friend class ASTContext;  // ASTContext creates these.
6344b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerpublic:
6354b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
6364b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  QualType getElementType() const { return ElementType; }
6374b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  unsigned getNumElements() const { return NumElements; }
6384b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
6394b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  virtual void getAsStringInternal(std::string &InnerString) const;
6404b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
6414b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  void Profile(llvm::FoldingSetNodeID &ID) {
6424b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    Profile(ID, getElementType(), getNumElements(), getTypeClass());
6434b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
6444b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static void Profile(llvm::FoldingSetNodeID &ID, QualType ElementType,
6454b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner                      unsigned NumElements, TypeClass TypeClass) {
6464b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    ID.AddPointer(ElementType.getAsOpaquePtr());
6474b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    ID.AddInteger(NumElements);
6484b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    ID.AddInteger(TypeClass);
6494b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
6504b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const Type *T) {
6514b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    return T->getTypeClass() == Vector || T->getTypeClass() == OCUVector;
6524b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
6534b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const VectorType *) { return true; }
6544b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner};
6554b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
6564b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// OCUVectorType - Extended vector type. This type is created using
6574b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// __attribute__((ocu_vector_type(n)), where "n" is the number of elements.
6586154214e20225a883a8a00226499534e9b514315Steve Naroff/// Unlike vector_size, ocu_vector_type is only allowed on typedef's. This
6596154214e20225a883a8a00226499534e9b514315Steve Naroff/// class enables syntactic extensions, like Vector Components for accessing
6606154214e20225a883a8a00226499534e9b514315Steve Naroff/// points, colors, and textures (modeled after OpenGL Shading Language).
6614b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerclass OCUVectorType : public VectorType {
6624b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  OCUVectorType(QualType vecType, unsigned nElements, QualType canonType) :
6634b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    VectorType(OCUVector, vecType, nElements, canonType) {}
6644b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  friend class ASTContext;  // ASTContext creates these.
6654b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerpublic:
6669096b795541c783297fb19684a58c54d0fe823b8Chris Lattner  static int getPointAccessorIdx(char c) {
6679096b795541c783297fb19684a58c54d0fe823b8Chris Lattner    switch (c) {
6689096b795541c783297fb19684a58c54d0fe823b8Chris Lattner    default: return -1;
6699096b795541c783297fb19684a58c54d0fe823b8Chris Lattner    case 'x': return 0;
6709096b795541c783297fb19684a58c54d0fe823b8Chris Lattner    case 'y': return 1;
6719096b795541c783297fb19684a58c54d0fe823b8Chris Lattner    case 'z': return 2;
6729096b795541c783297fb19684a58c54d0fe823b8Chris Lattner    case 'w': return 3;
6739096b795541c783297fb19684a58c54d0fe823b8Chris Lattner    }
6741b8a46c945927340ae7e79b771e93e7d36da4851Steve Naroff  }
6759096b795541c783297fb19684a58c54d0fe823b8Chris Lattner  static int getColorAccessorIdx(char c) {
6769096b795541c783297fb19684a58c54d0fe823b8Chris Lattner    switch (c) {
6779096b795541c783297fb19684a58c54d0fe823b8Chris Lattner    default: return -1;
6789096b795541c783297fb19684a58c54d0fe823b8Chris Lattner    case 'r': return 0;
6799096b795541c783297fb19684a58c54d0fe823b8Chris Lattner    case 'g': return 1;
6809096b795541c783297fb19684a58c54d0fe823b8Chris Lattner    case 'b': return 2;
6819096b795541c783297fb19684a58c54d0fe823b8Chris Lattner    case 'a': return 3;
6829096b795541c783297fb19684a58c54d0fe823b8Chris Lattner    }
6831b8a46c945927340ae7e79b771e93e7d36da4851Steve Naroff  }
6849096b795541c783297fb19684a58c54d0fe823b8Chris Lattner  static int getTextureAccessorIdx(char c) {
6859096b795541c783297fb19684a58c54d0fe823b8Chris Lattner    switch (c) {
6869096b795541c783297fb19684a58c54d0fe823b8Chris Lattner    default: return -1;
6879096b795541c783297fb19684a58c54d0fe823b8Chris Lattner    case 's': return 0;
6889096b795541c783297fb19684a58c54d0fe823b8Chris Lattner    case 't': return 1;
6899096b795541c783297fb19684a58c54d0fe823b8Chris Lattner    case 'p': return 2;
6909096b795541c783297fb19684a58c54d0fe823b8Chris Lattner    case 'q': return 3;
6911b8a46c945927340ae7e79b771e93e7d36da4851Steve Naroff    }
6929096b795541c783297fb19684a58c54d0fe823b8Chris Lattner  };
69342158e7b3a95f41d3482f1fb3a67392dbbf745daChris Lattner
69442158e7b3a95f41d3482f1fb3a67392dbbf745daChris Lattner  static int getAccessorIdx(char c) {
69542158e7b3a95f41d3482f1fb3a67392dbbf745daChris Lattner    if (int idx = getPointAccessorIdx(c)+1) return idx-1;
69642158e7b3a95f41d3482f1fb3a67392dbbf745daChris Lattner    if (int idx = getColorAccessorIdx(c)+1) return idx-1;
69742158e7b3a95f41d3482f1fb3a67392dbbf745daChris Lattner    return getTextureAccessorIdx(c);
69842158e7b3a95f41d3482f1fb3a67392dbbf745daChris Lattner  }
69942158e7b3a95f41d3482f1fb3a67392dbbf745daChris Lattner
7009096b795541c783297fb19684a58c54d0fe823b8Chris Lattner  bool isAccessorWithinNumElements(char c) const {
70142158e7b3a95f41d3482f1fb3a67392dbbf745daChris Lattner    if (int idx = getAccessorIdx(c)+1)
7029096b795541c783297fb19684a58c54d0fe823b8Chris Lattner      return unsigned(idx-1) < NumElements;
7039096b795541c783297fb19684a58c54d0fe823b8Chris Lattner    return false;
7041b8a46c945927340ae7e79b771e93e7d36da4851Steve Naroff  }
705c11705f9b742b542724dd56796bf90e07191e342Steve Naroff  virtual void getAsStringInternal(std::string &InnerString) const;
706c11705f9b742b542724dd56796bf90e07191e342Steve Naroff
707806b319509d01bffe47317f11140c930da800dbbSteve Naroff  static bool classof(const Type *T) {
7084b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    return T->getTypeClass() == OCUVector;
7094b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
7104b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const OCUVectorType *) { return true; }
7114b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner};
7124b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
7134b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// FunctionType - C99 6.7.5.3 - Function Declarators.  This is the common base
7144b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// class of FunctionTypeNoProto and FunctionTypeProto.
7154b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner///
7164b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerclass FunctionType : public Type {
7174b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// SubClassData - This field is owned by the subclass, put here to pack
7184b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// tightly with the ivars in Type.
7194b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool SubClassData : 1;
7204b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
7214b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  // The type returned by the function.
7224b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  QualType ResultType;
7234b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerprotected:
7244b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  FunctionType(TypeClass tc, QualType res, bool SubclassInfo,QualType Canonical)
7254b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    : Type(tc, Canonical), SubClassData(SubclassInfo), ResultType(res) {}
7264b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool getSubClassData() const { return SubClassData; }
7274b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerpublic:
7284b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
7294b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  QualType getResultType() const { return ResultType; }
7304b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
7314b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
7324b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const Type *T) {
7334b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    return T->getTypeClass() == FunctionNoProto ||
7344b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner           T->getTypeClass() == FunctionProto;
7354b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
7364b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const FunctionType *) { return true; }
7374b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner};
7384b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
7394b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// FunctionTypeNoProto - Represents a K&R-style 'int foo()' function, which has
7404b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// no information available about its arguments.
7414b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerclass FunctionTypeNoProto : public FunctionType, public llvm::FoldingSetNode {
7424b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  FunctionTypeNoProto(QualType Result, QualType Canonical)
7434b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    : FunctionType(FunctionNoProto, Result, false, Canonical) {}
7444b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  friend class ASTContext;  // ASTContext creates these.
7454b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerpublic:
7464b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  // No additional state past what FunctionType provides.
7474b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
7484b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  virtual void getAsStringInternal(std::string &InnerString) const;
7494b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
7504b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  void Profile(llvm::FoldingSetNodeID &ID) {
7514b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    Profile(ID, getResultType());
7524b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
7534b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static void Profile(llvm::FoldingSetNodeID &ID, QualType ResultType) {
7544b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    ID.AddPointer(ResultType.getAsOpaquePtr());
7554b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
7564b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
7574b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const Type *T) {
7584b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    return T->getTypeClass() == FunctionNoProto;
7594b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
7604b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const FunctionTypeNoProto *) { return true; }
76187f0429f888ee5d332304641611b88f7b54b5065Ted Kremenek
76287f0429f888ee5d332304641611b88f7b54b5065Ted Kremenekprotected:
76387f0429f888ee5d332304641611b88f7b54b5065Ted Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
76487f0429f888ee5d332304641611b88f7b54b5065Ted Kremenek  static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D);
76587f0429f888ee5d332304641611b88f7b54b5065Ted Kremenek  friend class Type;
7664b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner};
7674b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
7684b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// FunctionTypeProto - Represents a prototype with argument type info, e.g.
7694b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// 'int foo(int)' or 'int foo(void)'.  'void' is represented as having no
7704b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// arguments, not as having a single void argument.
7714b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerclass FunctionTypeProto : public FunctionType, public llvm::FoldingSetNode {
7724b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  FunctionTypeProto(QualType Result, QualType *ArgArray, unsigned numArgs,
7734b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner                    bool isVariadic, QualType Canonical)
7744b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    : FunctionType(FunctionProto, Result, isVariadic, Canonical),
7754b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner      NumArgs(numArgs) {
7764b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    // Fill in the trailing argument array.
7774b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    QualType *ArgInfo = reinterpret_cast<QualType *>(this+1);;
7784b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    for (unsigned i = 0; i != numArgs; ++i)
7794b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner      ArgInfo[i] = ArgArray[i];
7804b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
7814b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
7824b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// NumArgs - The number of arguments this function has, not counting '...'.
7834b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  unsigned NumArgs;
7844b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
7854b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// ArgInfo - There is an variable size array after the class in memory that
7864b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// holds the argument types.
7874b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  friend class ASTContext;  // ASTContext creates these.
7884b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerpublic:
7894b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  unsigned getNumArgs() const { return NumArgs; }
7904b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  QualType getArgType(unsigned i) const {
7914b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    assert(i < NumArgs && "Invalid argument number!");
7924b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    return arg_type_begin()[i];
7934b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
7944b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
7954b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool isVariadic() const { return getSubClassData(); }
7964b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
7974b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  typedef const QualType *arg_type_iterator;
7984b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  arg_type_iterator arg_type_begin() const {
7994b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    return reinterpret_cast<const QualType *>(this+1);
8004b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
8014b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  arg_type_iterator arg_type_end() const { return arg_type_begin()+NumArgs; }
8024b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
8034b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  virtual void getAsStringInternal(std::string &InnerString) const;
8044b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
8054b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const Type *T) {
8064b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    return T->getTypeClass() == FunctionProto;
8074b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
8084b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const FunctionTypeProto *) { return true; }
8094b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
8104b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  void Profile(llvm::FoldingSetNodeID &ID);
8114b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static void Profile(llvm::FoldingSetNodeID &ID, QualType Result,
8124b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner                      arg_type_iterator ArgTys, unsigned NumArgs,
8134b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner                      bool isVariadic);
814034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek
815034a78cafc3505323698ea72db19dc5095324e06Ted Kremenekprotected:
816034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
817034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek  static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D);
818034a78cafc3505323698ea72db19dc5095324e06Ted Kremenek  friend class Type;
8194b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner};
8204b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
8214b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
8224b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerclass TypedefType : public Type {
8234b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  TypedefDecl *Decl;
824e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanianprotected:
825e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian  TypedefType(TypeClass tc, TypedefDecl *D, QualType can)
826e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian    : Type(tc, can), Decl(D) {
8274b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    assert(!isa<TypedefType>(can) && "Invalid canonical type");
8284b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
8294b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  friend class ASTContext;  // ASTContext creates these.
8304b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerpublic:
8314b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
8324b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  TypedefDecl *getDecl() const { return Decl; }
8334b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
8344b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// LookThroughTypedefs - Return the ultimate type this typedef corresponds to
8354b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// potentially looking through *all* consequtive typedefs.  This returns the
8364b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// sum of the type qualifiers, so if you have:
8374b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  ///   typedef const int A;
8384b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  ///   typedef volatile A B;
8394b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  /// looking through the typedefs for B will give you "const volatile A".
8404b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  QualType LookThroughTypedefs() const;
8414b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
8424b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  virtual void getAsStringInternal(std::string &InnerString) const;
8434b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
8444b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const Type *T) { return T->getTypeClass() == TypeName; }
8454b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const TypedefType *) { return true; }
8462f665cd2aa263b89ac880dc45283847e5322a6c2Ted Kremenek
8472f665cd2aa263b89ac880dc45283847e5322a6c2Ted Kremenekprotected:
8482f665cd2aa263b89ac880dc45283847e5322a6c2Ted Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
8492f665cd2aa263b89ac880dc45283847e5322a6c2Ted Kremenek  static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D);
8502f665cd2aa263b89ac880dc45283847e5322a6c2Ted Kremenek  friend class Type;
8514b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner};
8524b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
8537cbb14653934a298c09002b87704dc6531261771Steve Naroff/// TypeOfExpr (GCC extension).
8547cbb14653934a298c09002b87704dc6531261771Steve Naroffclass TypeOfExpr : public Type {
8557cbb14653934a298c09002b87704dc6531261771Steve Naroff  Expr *TOExpr;
8567cbb14653934a298c09002b87704dc6531261771Steve Naroff  TypeOfExpr(Expr *E, QualType can) : Type(TypeOfExp, can), TOExpr(E) {
8577cbb14653934a298c09002b87704dc6531261771Steve Naroff    assert(!isa<TypedefType>(can) && "Invalid canonical type");
8587cbb14653934a298c09002b87704dc6531261771Steve Naroff  }
8597cbb14653934a298c09002b87704dc6531261771Steve Naroff  friend class ASTContext;  // ASTContext creates these.
8607cbb14653934a298c09002b87704dc6531261771Steve Naroffpublic:
8617cbb14653934a298c09002b87704dc6531261771Steve Naroff  Expr *getUnderlyingExpr() const { return TOExpr; }
8627cbb14653934a298c09002b87704dc6531261771Steve Naroff
8637cbb14653934a298c09002b87704dc6531261771Steve Naroff  virtual void getAsStringInternal(std::string &InnerString) const;
8647cbb14653934a298c09002b87704dc6531261771Steve Naroff
8657cbb14653934a298c09002b87704dc6531261771Steve Naroff  static bool classof(const Type *T) { return T->getTypeClass() == TypeOfExp; }
8667cbb14653934a298c09002b87704dc6531261771Steve Naroff  static bool classof(const TypeOfExpr *) { return true; }
8677cbb14653934a298c09002b87704dc6531261771Steve Naroff};
8687cbb14653934a298c09002b87704dc6531261771Steve Naroff
8697cbb14653934a298c09002b87704dc6531261771Steve Naroff/// TypeOfType (GCC extension).
8707cbb14653934a298c09002b87704dc6531261771Steve Naroffclass TypeOfType : public Type {
8717cbb14653934a298c09002b87704dc6531261771Steve Naroff  QualType TOType;
8727cbb14653934a298c09002b87704dc6531261771Steve Naroff  TypeOfType(QualType T, QualType can) : Type(TypeOfTyp, can), TOType(T) {
8737cbb14653934a298c09002b87704dc6531261771Steve Naroff    assert(!isa<TypedefType>(can) && "Invalid canonical type");
8747cbb14653934a298c09002b87704dc6531261771Steve Naroff  }
8757cbb14653934a298c09002b87704dc6531261771Steve Naroff  friend class ASTContext;  // ASTContext creates these.
8767cbb14653934a298c09002b87704dc6531261771Steve Naroffpublic:
8777cbb14653934a298c09002b87704dc6531261771Steve Naroff  QualType getUnderlyingType() const { return TOType; }
8787cbb14653934a298c09002b87704dc6531261771Steve Naroff
8797cbb14653934a298c09002b87704dc6531261771Steve Naroff  virtual void getAsStringInternal(std::string &InnerString) const;
8807cbb14653934a298c09002b87704dc6531261771Steve Naroff
8817cbb14653934a298c09002b87704dc6531261771Steve Naroff  static bool classof(const Type *T) { return T->getTypeClass() == TypeOfTyp; }
8827cbb14653934a298c09002b87704dc6531261771Steve Naroff  static bool classof(const TypeOfType *) { return true; }
8837cbb14653934a298c09002b87704dc6531261771Steve Naroff};
8844b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
8854b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerclass TagType : public Type {
886581571c848395ba6c7401b5384f91ead457c9adcTed Kremenek  TagDecl *decl;
887581571c848395ba6c7401b5384f91ead457c9adcTed Kremenek  TagType(TagDecl *D, QualType can) : Type(Tagged, can), decl(D) {}
8884b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  friend class ASTContext;  // ASTContext creates these.
8894b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerpublic:
8904b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
891581571c848395ba6c7401b5384f91ead457c9adcTed Kremenek  TagDecl *getDecl() const { return decl; }
8924b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
8934b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  virtual void getAsStringInternal(std::string &InnerString) const;
8944b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
8954b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const Type *T) { return T->getTypeClass() == Tagged; }
8964b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const TagType *) { return true; }
8978db5aa1ca0d42cf8aeaa78cbe196a50f70fc9fc1Ted Kremenek
8988db5aa1ca0d42cf8aeaa78cbe196a50f70fc9fc1Ted Kremenekprotected:
8998db5aa1ca0d42cf8aeaa78cbe196a50f70fc9fc1Ted Kremenek  virtual void EmitImpl(llvm::Serializer& S) const;
90064be4ada44c719304c1dee75fb1e551f84b7779aTed Kremenek  static Type* CreateImpl(ASTContext& Context, llvm::Deserializer& D);
9018db5aa1ca0d42cf8aeaa78cbe196a50f70fc9fc1Ted Kremenek  friend class Type;
9024b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner};
9034b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
90442730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenekclass ObjCInterfaceType : public Type {
90542730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  ObjCInterfaceDecl *Decl;
9060c2f214d3500d1d080afa36b96db40407b91e70dFariborz Jahanianprotected:
90742730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  ObjCInterfaceType(TypeClass tc, ObjCInterfaceDecl *D) :
9080c2f214d3500d1d080afa36b96db40407b91e70dFariborz Jahanian    Type(tc, QualType()), Decl(D) { }
90981f1bbabbdb7dce07802111e2d9648eedc866d51Steve Naroff  friend class ASTContext;  // ASTContext creates these.
91081f1bbabbdb7dce07802111e2d9648eedc866d51Steve Naroffpublic:
91181f1bbabbdb7dce07802111e2d9648eedc866d51Steve Naroff
91242730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  ObjCInterfaceDecl *getDecl() const { return Decl; }
91381f1bbabbdb7dce07802111e2d9648eedc866d51Steve Naroff
91481f1bbabbdb7dce07802111e2d9648eedc866d51Steve Naroff  virtual void getAsStringInternal(std::string &InnerString) const;
91591193f64449fe1faf9306a04ade6539d26f44037Fariborz Jahanian
91681f1bbabbdb7dce07802111e2d9648eedc866d51Steve Naroff  static bool classof(const Type *T) {
91742730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek    return T->getTypeClass() == ObjCInterface;
91881f1bbabbdb7dce07802111e2d9648eedc866d51Steve Naroff  }
91942730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  static bool classof(const ObjCInterfaceType *) { return true; }
92081f1bbabbdb7dce07802111e2d9648eedc866d51Steve Naroff};
92181f1bbabbdb7dce07802111e2d9648eedc866d51Steve Naroff
92242730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek/// ObjCQualifiedInterfaceType - This class represents interface types
923c04aff17dcfaa5f628bcfed0e393f2e946ea5184Fariborz Jahanian/// conforming to a list of protocols; such as, INTF<Proto1, Proto2, Proto1>.
924c5a342d3b1cc5fa6eef09653a6d8d091928366c0Fariborz Jahanian/// Duplicate protocols are removed and protocol list is canonicalized to be in
925c5a342d3b1cc5fa6eef09653a6d8d091928366c0Fariborz Jahanian/// alphabetical order.
92642730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenekclass ObjCQualifiedInterfaceType : public ObjCInterfaceType,
9270c2f214d3500d1d080afa36b96db40407b91e70dFariborz Jahanian                                   public llvm::FoldingSetNode {
9280c2f214d3500d1d080afa36b96db40407b91e70dFariborz Jahanian
929c04aff17dcfaa5f628bcfed0e393f2e946ea5184Fariborz Jahanian  // List of protocols for this protocol conforming object type
930c04aff17dcfaa5f628bcfed0e393f2e946ea5184Fariborz Jahanian  // List is sorted on protocol name. No protocol is enterred more than once.
93142730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  llvm::SmallVector<ObjCProtocolDecl*, 8> Protocols;
932c04aff17dcfaa5f628bcfed0e393f2e946ea5184Fariborz Jahanian
93342730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  ObjCQualifiedInterfaceType(ObjCInterfaceDecl *D,
93442730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek                             ObjCProtocolDecl **Protos,  unsigned NumP) :
93542730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek    ObjCInterfaceType(ObjCQualifiedInterface, D),
936d855a6ead44e3a875179400c472ac0b37df35f70Chris Lattner    Protocols(Protos, Protos+NumP) { }
93791193f64449fe1faf9306a04ade6539d26f44037Fariborz Jahanian  friend class ASTContext;  // ASTContext creates these.
938c04aff17dcfaa5f628bcfed0e393f2e946ea5184Fariborz Jahanianpublic:
939c04aff17dcfaa5f628bcfed0e393f2e946ea5184Fariborz Jahanian
94042730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  ObjCProtocolDecl *getProtocols(unsigned i) const {
94191193f64449fe1faf9306a04ade6539d26f44037Fariborz Jahanian    return Protocols[i];
94291193f64449fe1faf9306a04ade6539d26f44037Fariborz Jahanian  }
94391193f64449fe1faf9306a04ade6539d26f44037Fariborz Jahanian  unsigned getNumProtocols() const {
94491193f64449fe1faf9306a04ade6539d26f44037Fariborz Jahanian    return Protocols.size();
94591193f64449fe1faf9306a04ade6539d26f44037Fariborz Jahanian  }
94642730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  ObjCProtocolDecl **getReferencedProtocols() {
947957442db1d23f62ee2d0d71310bee240606b267dFariborz Jahanian    return &Protocols[0];
948957442db1d23f62ee2d0d71310bee240606b267dFariborz Jahanian  }
94991193f64449fe1faf9306a04ade6539d26f44037Fariborz Jahanian  virtual void getAsStringInternal(std::string &InnerString) const;
95091193f64449fe1faf9306a04ade6539d26f44037Fariborz Jahanian
95191193f64449fe1faf9306a04ade6539d26f44037Fariborz Jahanian  void Profile(llvm::FoldingSetNodeID &ID);
95291193f64449fe1faf9306a04ade6539d26f44037Fariborz Jahanian  static void Profile(llvm::FoldingSetNodeID &ID,
95342730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek                      ObjCProtocolDecl **protocols, unsigned NumProtocols);
95491193f64449fe1faf9306a04ade6539d26f44037Fariborz Jahanian
955c04aff17dcfaa5f628bcfed0e393f2e946ea5184Fariborz Jahanian  static bool classof(const Type *T) {
95642730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek    return T->getTypeClass() == ObjCQualifiedInterface;
957c04aff17dcfaa5f628bcfed0e393f2e946ea5184Fariborz Jahanian  }
95842730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  static bool classof(const ObjCQualifiedInterfaceType *) { return true; }
959c04aff17dcfaa5f628bcfed0e393f2e946ea5184Fariborz Jahanian};
960e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian
96142730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek/// ObjCQualifiedIdType - to represent id<protocol-list>
96242730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenekclass ObjCQualifiedIdType : public Type,
963e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian                            public llvm::FoldingSetNode {
964e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian  // List of protocols for this protocol conforming 'id' type
965e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian  // List is sorted on protocol name. No protocol is enterred more than once.
96642730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  llvm::SmallVector<ObjCProtocolDecl*, 8> Protocols;
967e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian
96842730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  ObjCQualifiedIdType(QualType can, ObjCProtocolDecl **Protos,  unsigned NumP)
96942730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  : Type(ObjCQualifiedId, can),
970e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian  Protocols(Protos, Protos+NumP) { }
971e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian  friend class ASTContext;  // ASTContext creates these.
972e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanianpublic:
973e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian
97442730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  ObjCProtocolDecl *getProtocols(unsigned i) const {
975e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian    return Protocols[i];
976e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian  }
977e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian  unsigned getNumProtocols() const {
978e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian    return Protocols.size();
979e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian  }
98042730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  ObjCProtocolDecl **getReferencedProtocols() {
981957442db1d23f62ee2d0d71310bee240606b267dFariborz Jahanian    return &Protocols[0];
982957442db1d23f62ee2d0d71310bee240606b267dFariborz Jahanian  }
983e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian
984e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian  virtual void getAsStringInternal(std::string &InnerString) const;
985e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian
986e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian  void Profile(llvm::FoldingSetNodeID &ID);
987e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian  static void Profile(llvm::FoldingSetNodeID &ID,
98842730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek                      ObjCProtocolDecl **protocols, unsigned NumProtocols);
989e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian
990e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian  static bool classof(const Type *T) {
99142730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek    return T->getTypeClass() == ObjCQualifiedId;
992e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian  }
99342730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  static bool classof(const ObjCQualifiedIdType *) { return true; }
994e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian
995e76e8416ff29ee39140b64ed47731237c67434aeFariborz Jahanian};
996c04aff17dcfaa5f628bcfed0e393f2e946ea5184Fariborz Jahanian
9974b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// RecordType - This is a helper class that allows the use of isa/cast/dyncast
9984b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// to detect TagType objects of structs/unions/classes.
9994b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerclass RecordType : public TagType {
10004b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  RecordType(); // DO NOT IMPLEMENT
10014b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerpublic:
10024b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
10032cb6638a26cfa999e5fb999e6af9211127e681c1Steve Naroff  RecordDecl *getDecl() const {
10044b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner    return reinterpret_cast<RecordDecl*>(TagType::getDecl());
10054b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  }
10064b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
10074b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  // FIXME: This predicate is a helper to QualType/Type. It needs to
10084b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  // recursively check all fields for const-ness. If any field is declared
10094b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  // const, it needs to return false.
10104b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  bool hasConstFields() const { return false; }
10114b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
10124b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const Type *T);
10134b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  static bool classof(const RecordType *) { return true; }
10144b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner};
10154b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
10164b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
1017b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattner// Inline function definitions.
10184b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
10194b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// getCanonicalType - Return the canonical version of this type, with the
10204b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner/// appropriate type qualifiers on it.
10214b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattnerinline QualType QualType::getCanonicalType() const {
10224b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner  return QualType(getTypePtr()->getCanonicalTypeInternal().getTypePtr(),
10234b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner                  getQualifiers() |
10244b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner                  getTypePtr()->getCanonicalTypeInternal().getQualifiers());
10254b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner}
1026b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattner
1027b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattner
1028b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattnerinline bool Type::isFunctionType() const {
1029b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattner  return isa<FunctionType>(CanonicalType);
1030b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattner}
1031b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattnerinline bool Type::isPointerType() const {
10325319d9cf6aa4db4992d7c426d0fabfec0a49011aFariborz Jahanian  return isa<PointerType>(CanonicalType);
1033b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattner}
103483b01279f2e6718581eeb1e5bdba58aa88e4649bTed Kremenekinline bool Type::isFunctionPointerType() const {
103574a340749eb63af1ba7098c67f3ef72bd48f5ae8Ted Kremenek  if (const PointerType* T = getAsPointerType())
103683b01279f2e6718581eeb1e5bdba58aa88e4649bTed Kremenek    return T->getPointeeType()->isFunctionType();
103783b01279f2e6718581eeb1e5bdba58aa88e4649bTed Kremenek  else
103883b01279f2e6718581eeb1e5bdba58aa88e4649bTed Kremenek    return false;
103983b01279f2e6718581eeb1e5bdba58aa88e4649bTed Kremenek}
1040b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattnerinline bool Type::isReferenceType() const {
1041b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattner  return isa<ReferenceType>(CanonicalType);
1042b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattner}
1043b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattnerinline bool Type::isArrayType() const {
1044b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattner  return isa<ArrayType>(CanonicalType);
1045b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattner}
1046b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattnerinline bool Type::isRecordType() const {
1047b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattner  return isa<RecordType>(CanonicalType);
1048b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattner}
1049b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattnerinline bool Type::isVectorType() const {
1050b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattner  return isa<VectorType>(CanonicalType);
1051b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattner}
1052b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattnerinline bool Type::isOCUVectorType() const {
1053b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattner  return isa<OCUVectorType>(CanonicalType);
1054b0fdfd50e1e4011486d5cb3773e1e87c8ec4325aChris Lattner}
105542730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenekinline bool Type::isObjCInterfaceType() const {
105642730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  return isa<ObjCInterfaceType>(CanonicalType)
105742730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek           || isa<ObjCQualifiedInterfaceType>(CanonicalType);
1058550e05034c6c8efcb7ab4c65f58048eee0892237Fariborz Jahanian}
105942730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenekinline bool Type::isObjCQualifiedIdType() const {
106042730c53aeef9ac6c258d317065fdf38da4e043cTed Kremenek  return isa<ObjCQualifiedIdType>(CanonicalType);
1061dcb2b1e489948a570ee07ca65e12d42edffa20efFariborz Jahanian}
10624b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner}  // end namespace clang
10634b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner
10644b0096578e961587d1ec0ed5dce45f592a65ed4Chris Lattner#endif
1065