Type.h revision 55f6b14230c94272efbbcdd89a92224c8db9f225
15f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===--- Type.h - C Language Family Type Representation ---------*- C++ -*-===// 25f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 35f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// The LLVM Compiler Infrastructure 45f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 50bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// This file is distributed under the University of Illinois Open Source 60bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// License. See LICENSE.TXT for details. 75f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 85f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===// 95f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// This file defines the Type interface and subclasses. 115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===// 135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#ifndef LLVM_CLANG_AST_TYPE_H 155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#define LLVM_CLANG_AST_TYPE_H 165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1722caddc91d2f6186739c6b20ec58ed38cd68e595Chris Lattner#include "clang/Basic/Diagnostic.h" 185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "llvm/Support/Casting.h" 19fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff#include "llvm/ADT/APSInt.h" 205cf243a883872441d73ca49cea7e20de5802629bChris Lattner#include "llvm/ADT/FoldingSet.h" 215cf243a883872441d73ca49cea7e20de5802629bChris Lattner#include "llvm/ADT/PointerIntPair.h" 2273af669633e13c813f80cd15ecf3e6414778aee4Ted Kremenek#include "llvm/Bitcode/SerializationFwd.h" 235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerusing llvm::isa; 245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerusing llvm::cast; 255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerusing llvm::cast_or_null; 265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerusing llvm::dyn_cast; 275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerusing llvm::dyn_cast_or_null; 285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang { 305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer class ASTContext; 315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer class Type; 325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer class TypedefDecl; 3355f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor class TemplateDecl; 3472c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor class TemplateTypeParmDecl; 35aaba5e346dffdbad5d1c42765a89e4a7afb0da67Douglas Gregor class NonTypeTemplateParmDecl; 36aaba5e346dffdbad5d1c42765a89e4a7afb0da67Douglas Gregor class TemplateTemplateParamDecl; 375f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer class TagDecl; 385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer class RecordDecl; 3949aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis class CXXRecordDecl; 405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer class EnumDecl; 4121d50e12c3c412d8457071dc419363b7a7e8b855Ted Kremenek class FieldDecl; 42a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek class ObjCInterfaceDecl; 43a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek class ObjCProtocolDecl; 44a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek class ObjCMethodDecl; 455f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer class Expr; 46b3064041583eb134fbf56906728bf752bc65b572Ted Kremenek class Stmt; 475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer class SourceLocation; 48bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner class PointerLikeType; 493acb13805673d47be95829bd5a4b1707952c0b6fChris Lattner class PointerType; 505618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff class BlockPointerType; 51251dcaf8616c6f04051e214f35cadb7de42aef7eBill Wendling class ReferenceType; 52f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl class MemberPointerType; 533acb13805673d47be95829bd5a4b1707952c0b6fChris Lattner class VectorType; 54700204c74b455746752e851b25565ebf932f5340Steve Naroff class ArrayType; 55d7444aac1af1c2c1d5e5b7467ecf6006ee2d8abeSteve Naroff class ConstantArrayType; 56d7444aac1af1c2c1d5e5b7467ecf6006ee2d8abeSteve Naroff class VariableArrayType; 57c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman class IncompleteArrayType; 58898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor class DependentSizedArrayType; 59dfa6aae5a119a527e537c35566ba3272fd8c5d74Steve Naroff class RecordType; 60ad74a758189180b8ab8faea648e4766c3bfd7fcbEli Friedman class EnumType; 61c6fb90a7246c2d5d3233e70107bf9d8c7c9e535bChris Lattner class ComplexType; 627064f5c95bbdb17680d0ea658d4090898c2592d3Steve Naroff class TagType; 63769c9cfc6e06bd9d8ffe7a4397b939f19b0e4dc3Ted Kremenek class TypedefType; 6472c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor class TemplateTypeParmType; 657064f5c95bbdb17680d0ea658d4090898c2592d3Steve Naroff class FunctionType; 66b77792eabf5882cf9af8cc810599b20432fda6c2Chris Lattner class FunctionTypeProto; 67213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman class ExtVectorType; 6877878cc5aa6ad01fc0c91bac1a61819dbf3bf691Steve Naroff class BuiltinType; 69368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner class ObjCInterfaceType; 70368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner class ObjCQualifiedIdType; 71a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek class ObjCQualifiedInterfaceType; 7292866e2e90f6d93fb95e25a7ac4438e239d89ce6Ted Kremenek class StmtIteratorBase; 7355f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor class ClassTemplateSpecializationType; 74f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl 755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// QualType - For efficiency, we don't store CVR-qualified types as nodes on 765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// their own: instead each reference to a type stores the qualifiers. This 775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// greatly reduces the number of nodes we need to allocate for types (for 785f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// example we only need one for 'int', 'const int', 'volatile int', 795f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 'const volatile int', etc). 805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 815f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// As an added efficiency bonus, instead of making this a pair, we just store 825f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// the three bits we care about in the low bits of the pointer. To handle the 835f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// packing/unpacking, we make QualType be a simple wrapper class that acts like 845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// a smart pointer. 855f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass QualType { 865cf243a883872441d73ca49cea7e20de5802629bChris Lattner llvm::PointerIntPair<Type*, 3> Value; 875f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 885f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer enum TQ { // NOTE: These flags must be kept in sync with DeclSpec::TQ. 895f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Const = 0x1, 905f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Restrict = 0x2, 915f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Volatile = 0x4, 925f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer CVRFlags = Const|Restrict|Volatile 935f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer }; 945f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 955cf243a883872441d73ca49cea7e20de5802629bChris Lattner QualType() {} 965f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 975cf243a883872441d73ca49cea7e20de5802629bChris Lattner QualType(const Type *Ptr, unsigned Quals) 985cf243a883872441d73ca49cea7e20de5802629bChris Lattner : Value(const_cast<Type*>(Ptr), Quals) {} 995f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1005cf243a883872441d73ca49cea7e20de5802629bChris Lattner unsigned getCVRQualifiers() const { return Value.getInt(); } 101a3ab4b85f54090927c2dfa2585b9f0e48509e944Chris Lattner void setCVRQualifiers(unsigned Quals) { Value.setInt(Quals); } 1025cf243a883872441d73ca49cea7e20de5802629bChris Lattner Type *getTypePtr() const { return Value.getPointer(); } 1035cf243a883872441d73ca49cea7e20de5802629bChris Lattner 1045cf243a883872441d73ca49cea7e20de5802629bChris Lattner void *getAsOpaquePtr() const { return Value.getOpaqueValue(); } 1055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static QualType getFromOpaquePtr(void *Ptr) { 1065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType T; 1075cf243a883872441d73ca49cea7e20de5802629bChris Lattner T.Value.setFromOpaqueValue(Ptr); 1085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return T; 1095f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Type &operator*() const { 1125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return *getTypePtr(); 1135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Type *operator->() const { 1165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return getTypePtr(); 1175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1195f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// isNull - Return true if this QualType doesn't point to a type yet. 1205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isNull() const { 1215cf243a883872441d73ca49cea7e20de5802629bChris Lattner return getTypePtr() == 0; 1225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isConstQualified() const { 1255cf243a883872441d73ca49cea7e20de5802629bChris Lattner return (getCVRQualifiers() & Const) ? true : false; 1265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isVolatileQualified() const { 1285cf243a883872441d73ca49cea7e20de5802629bChris Lattner return (getCVRQualifiers() & Volatile) ? true : false; 1295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isRestrictQualified() const { 1315cf243a883872441d73ca49cea7e20de5802629bChris Lattner return (getCVRQualifiers() & Restrict) ? true : false; 1325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 133b381aac9bae6d608c72267dd0ed08ec6369e94e4Nuno Lopes 134b381aac9bae6d608c72267dd0ed08ec6369e94e4Nuno Lopes bool isConstant(ASTContext& Ctx) const; 1357effa1aceac1219529af23c776835f855b8d905cChris Lattner 1367effa1aceac1219529af23c776835f855b8d905cChris Lattner /// addConst/addVolatile/addRestrict - add the specified type qual to this 1377effa1aceac1219529af23c776835f855b8d905cChris Lattner /// QualType. 1385cf243a883872441d73ca49cea7e20de5802629bChris Lattner void addConst() { Value.setInt(Value.getInt() | Const); } 1395cf243a883872441d73ca49cea7e20de5802629bChris Lattner void addVolatile() { Value.setInt(Value.getInt() | Volatile); } 1405cf243a883872441d73ca49cea7e20de5802629bChris Lattner void addRestrict() { Value.setInt(Value.getInt() | Restrict); } 1415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1425cf243a883872441d73ca49cea7e20de5802629bChris Lattner void removeConst() { Value.setInt(Value.getInt() & ~Const); } 1435cf243a883872441d73ca49cea7e20de5802629bChris Lattner void removeVolatile() { Value.setInt(Value.getInt() & ~Volatile); } 1445cf243a883872441d73ca49cea7e20de5802629bChris Lattner void removeRestrict() { Value.setInt(Value.getInt() & ~Restrict); } 1451c6a38bcea17801e9a4738753aee845381af2b6cSanjiv Gupta 1465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType getQualifiedType(unsigned TQs) const { 1475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return QualType(getTypePtr(), TQs); 1485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 149c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner QualType getWithAdditionalQualifiers(unsigned TQs) const { 150c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner return QualType(getTypePtr(), TQs|getCVRQualifiers()); 151c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner } 152971c4fae6092976338b755af1d47dac07c8f16e3Argyrios Kyrtzidis 153971c4fae6092976338b755af1d47dac07c8f16e3Argyrios Kyrtzidis QualType withConst() const { return getWithAdditionalQualifiers(Const); } 154971c4fae6092976338b755af1d47dac07c8f16e3Argyrios Kyrtzidis QualType withVolatile() const { return getWithAdditionalQualifiers(Volatile);} 155971c4fae6092976338b755af1d47dac07c8f16e3Argyrios Kyrtzidis QualType withRestrict() const { return getWithAdditionalQualifiers(Restrict);} 1565f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 157e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor QualType getUnqualifiedType() const; 158e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor bool isMoreQualifiedThan(QualType Other) const; 159e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor bool isAtLeastAsQualifiedAs(QualType Other) const; 160e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor QualType getNonReferenceType() const; 1615f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 16298cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor 1635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// operator==/!= - Indicate whether the specified types and qualifiers are 1645f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// identical. 1655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool operator==(const QualType &RHS) const { 1665cf243a883872441d73ca49cea7e20de5802629bChris Lattner return Value == RHS.Value; 1675f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1685f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool operator!=(const QualType &RHS) const { 1695cf243a883872441d73ca49cea7e20de5802629bChris Lattner return Value != RHS.Value; 1705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer std::string getAsString() const { 1725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer std::string S; 1735f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer getAsStringInternal(S); 1745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return S; 1755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void getAsStringInternal(std::string &Str) const; 1775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 178c36d405a02fab41f6c45cb2bc750d64949742903Chris Lattner void dump(const char *s) const; 179c36d405a02fab41f6c45cb2bc750d64949742903Chris Lattner void dump() const; 1803f2dcb1ca8bd2d5d3ccc5c80f4ab06f949d88a89Ted Kremenek 1813f2dcb1ca8bd2d5d3ccc5c80f4ab06f949d88a89Ted Kremenek void Profile(llvm::FoldingSetNodeID &ID) const { 1823f2dcb1ca8bd2d5d3ccc5c80f4ab06f949d88a89Ted Kremenek ID.AddPointer(getAsOpaquePtr()); 1833f2dcb1ca8bd2d5d3ccc5c80f4ab06f949d88a89Ted Kremenek } 1845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 185368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattnerpublic: 1865f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 187ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb /// getAddressSpace - Return the address space of this type. 188ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb inline unsigned getAddressSpace() const; 189ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb 19003ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek /// Emit - Serialize a QualType to Bitcode. 19173af669633e13c813f80cd15ecf3e6414778aee4Ted Kremenek void Emit(llvm::Serializer& S) const; 19273af669633e13c813f80cd15ecf3e6414778aee4Ted Kremenek 19303ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek /// Read - Deserialize a QualType from Bitcode. 19403ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek static QualType ReadVal(llvm::Deserializer& D); 19521d50e12c3c412d8457071dc419363b7a7e8b855Ted Kremenek 19621d50e12c3c412d8457071dc419363b7a7e8b855Ted Kremenek void ReadBackpatch(llvm::Deserializer& D); 1975f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 1985f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1995f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end clang. 2005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace llvm { 2025f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// Implement simplify_type for QualType, so that we can dyn_cast from QualType 2035f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// to a specific Type class. 2045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencertemplate<> struct simplify_type<const ::clang::QualType> { 2055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer typedef ::clang::Type* SimpleType; 2065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static SimpleType getSimplifiedValue(const ::clang::QualType &Val) { 2075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return Val.getTypePtr(); 2085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 2095f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 2105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencertemplate<> struct simplify_type< ::clang::QualType> 2115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer : public simplify_type<const ::clang::QualType> {}; 21273af669633e13c813f80cd15ecf3e6414778aee4Ted Kremenek 21373af669633e13c813f80cd15ecf3e6414778aee4Ted Kremenek} // end namespace llvm 2145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang { 2165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// Type - This is the base class of the type hierarchy. A central concept 2185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// with types is that each type always has a canonical type. A canonical type 2195f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// is the type with any typedef names stripped out of it or the types it 2205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// references. For example, consider: 2215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 2225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// typedef int foo; 2235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// typedef foo* bar; 2245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 'int *' 'foo *' 'bar' 2255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 2265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// There will be a Type object created for 'int'. Since int is canonical, its 2275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// canonicaltype pointer points to itself. There is also a Type for 'foo' (a 2285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// TypeNameType). Its CanonicalType pointer points to the 'int' Type. Next 2295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// there is a PointerType that represents 'int*', which, like 'int', is 2305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// canonical. Finally, there is a PointerType type for 'foo*' whose canonical 2315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// type is 'int*', and there is a TypeNameType for 'bar', whose canonical type 2325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// is also 'int*'. 2335f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 2345f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// Non-canonical types are useful for emitting diagnostics, without losing 2355f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// information about typedefs being used. Canonical types are useful for type 2365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// comparisons (they allow by-pointer equality tests) and useful for reasoning 2375f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// about whether something has a particular form (e.g. is a function type), 2385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// because they implicitly, recursively, strip all typedefs out of a type. 2395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 2405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// Types, once created, are immutable. 2415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 2425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass Type { 2435f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 2445f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer enum TypeClass { 245f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl Builtin, Complex, Pointer, Reference, MemberPointer, 246898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor ConstantArray, VariableArray, IncompleteArray, DependentSizedArray, 247213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman Vector, ExtVector, 2485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer FunctionNoProto, FunctionProto, 249ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb TypeName, Tagged, ASQual, 25055f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor TemplateTypeParm, ClassTemplateSpecialization, 251a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterface, ObjCQualifiedInterface, 252a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCQualifiedId, 2535618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff TypeOfExp, TypeOfTyp, // GNU typeof extension. 2545618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff BlockPointer // C extension 2555f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer }; 2565f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerprivate: 2575f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType CanonicalType; 2585f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 259898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor /// Dependent - Whether this type is a dependent type (C++ [temp.dep.type]). 260898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor bool Dependent : 1; 261898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor 2625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// TypeClass bitfield - Enum that specifies what subclass this belongs to. 2635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// Note that this should stay at the end of the ivars for Type so that 2645f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// subclasses can pack their bitfields into the same word. 265ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb unsigned TC : 5; 266898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor 2675f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerprotected: 268124dd7b5777e29ecac006822bd4d4623f0dc4264Hartmut Kaiser // silence VC++ warning C4355: 'this' : used in base member initializer list 269124dd7b5777e29ecac006822bd4d4623f0dc4264Hartmut Kaiser Type *this_() { return this; } 270898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor Type(TypeClass tc, QualType Canonical, bool dependent) 271f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner : CanonicalType(Canonical.isNull() ? QualType(this_(), 0) : Canonical), 272898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor Dependent(dependent), TC(tc) {} 273898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor virtual ~Type() {} 2744b05b1dee6cc65ae61d93dab7edff72710f24589Ted Kremenek virtual void Destroy(ASTContext& C); 2755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer friend class ASTContext; 27673af669633e13c813f80cd15ecf3e6414778aee4Ted Kremenek 27773af669633e13c813f80cd15ecf3e6414778aee4Ted Kremenek void EmitTypeInternal(llvm::Serializer& S) const; 27873af669633e13c813f80cd15ecf3e6414778aee4Ted Kremenek void ReadTypeInternal(llvm::Deserializer& D); 27973af669633e13c813f80cd15ecf3e6414778aee4Ted Kremenek 2808b9023ba35a86838789e2c9034a6128728c547aaChris Lattnerpublic: 281a8ae51f79d35b7c1822ba4a086176b4a8c862862Hartmut Kaiser TypeClass getTypeClass() const { return static_cast<TypeClass>(TC); } 2825f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2835f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isCanonical() const { return CanonicalType.getTypePtr() == this; } 2845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2855f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// Types are partitioned into 3 broad categories (C99 6.2.5p1): 2865f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// object types, function types, and incomplete types. 2875f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2885f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// isObjectType - types that fully describe objects. An object is a region 2895f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// of memory that can be examined and stored into (H&S). 2905f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isObjectType() const; 2915f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2925f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// isIncompleteType - Return true if this is an incomplete type. 2935f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// A type that can describe objects, but which lacks information needed to 2945f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// determine its size (e.g. void, or a fwd declared struct). Clients of this 2955f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// routine will need to determine if the size is actually required. 2965f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isIncompleteType() const; 297d805bec0fbb98aa10abbb41bfdcb2e2fab1bac96Chris Lattner 298d805bec0fbb98aa10abbb41bfdcb2e2fab1bac96Chris Lattner /// isIncompleteOrObjectType - Return true if this is an incomplete or object 299d805bec0fbb98aa10abbb41bfdcb2e2fab1bac96Chris Lattner /// type, in other words, not a function type. 300d805bec0fbb98aa10abbb41bfdcb2e2fab1bac96Chris Lattner bool isIncompleteOrObjectType() const { 301d805bec0fbb98aa10abbb41bfdcb2e2fab1bac96Chris Lattner return !isFunctionType(); 302d805bec0fbb98aa10abbb41bfdcb2e2fab1bac96Chris Lattner } 30364b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 30464b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl /// isPODType - Return true if this is a plain-old-data type (C++ 3.9p10). 30564b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl bool isPODType() const; 30664b45f7e0d3167f040841ac2920aead7f080730dSebastian Redl 307d7444aac1af1c2c1d5e5b7467ecf6006ee2d8abeSteve Naroff /// isVariablyModifiedType (C99 6.7.5.2p2) - Return true for variable array 308d7444aac1af1c2c1d5e5b7467ecf6006ee2d8abeSteve Naroff /// types that have a non-constant expression. This does not include "[]". 309d7444aac1af1c2c1d5e5b7467ecf6006ee2d8abeSteve Naroff bool isVariablyModifiedType() const; 310d7444aac1af1c2c1d5e5b7467ecf6006ee2d8abeSteve Naroff 3115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// Helper methods to distinguish type categories. All type predicates 312ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb /// operate on the canonical type, ignoring typedefs and qualifiers. 31396d2c438f5c9ada8229f7f2ac049d2e9957bc954Steve Naroff 31496d2c438f5c9ada8229f7f2ac049d2e9957bc954Steve Naroff /// isIntegerType() does *not* include complex integers (a GCC extension). 31596d2c438f5c9ada8229f7f2ac049d2e9957bc954Steve Naroff /// isComplexIntegerType() can be used to test for complex integers. 3165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isIntegerType() const; // C99 6.2.5p17 (int, char, bool, enum) 31713b7c5ff42d6077a8d59e2c9ec9e7fedd0150ae6Steve Naroff bool isEnumeralType() const; 31813b7c5ff42d6077a8d59e2c9ec9e7fedd0150ae6Steve Naroff bool isBooleanType() const; 31913b7c5ff42d6077a8d59e2c9ec9e7fedd0150ae6Steve Naroff bool isCharType() const; 32077a52233f7c0f162672652051bfe78b65ad4f789Douglas Gregor bool isWideCharType() const; 32133e1d64ab5cd5d27f8530ccd056191fe2c9f3f2eFariborz Jahanian bool isIntegralType() const; 3225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 3235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// Floating point categories. 3245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isRealFloatingType() const; // C99 6.2.5p10 (float, double, long double) 32502f62a9fedbc370fba081303399410a3afdde29fSteve Naroff /// isComplexType() does *not* include complex integers (a GCC extension). 32602f62a9fedbc370fba081303399410a3afdde29fSteve Naroff /// isComplexIntegerType() can be used to test for complex integers. 3275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isComplexType() const; // C99 6.2.5p11 (complex) 328f23d364084d1aabea688222780d6fc1dd8c7f78cChris Lattner bool isAnyComplexType() const; // C99 6.2.5p11 (complex) + Complex Int. 3295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isFloatingType() const; // C99 6.2.5p11 (real floating + complex) 3305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isRealType() const; // C99 6.2.5p17 (real floating + integer) 3315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isArithmeticType() const; // C99 6.2.5p18 (integer + floating) 332c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner bool isVoidType() const; // C99 6.2.5p19 333c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner bool isDerivedType() const; // C99 6.2.5p20 334c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner bool isScalarType() const; // C99 6.2.5p21 (arithmetic + pointers) 335d7eb846aaf5ee4a8d22c3cd0796d1e7229d46013Douglas Gregor bool isAggregateType() const; 3365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 337c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner // Type Predicates: Check to see if this type is structurally the specified 338ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb // type, ignoring typedefs and qualifiers. 339c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner bool isFunctionType() const; 340bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner bool isPointerLikeType() const; // Pointer or Reference. 341befee48ff2a1dab236c5700f00ecca1cfdcd5837Chris Lattner bool isPointerType() const; 3425618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff bool isBlockPointerType() const; 343a1d9fdea79ba7bbd71862b9f9f78f5f117331fc7Chris Lattner bool isReferenceType() const; 344bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner bool isFunctionPointerType() const; 345f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl bool isMemberPointerType() const; 346f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl bool isMemberFunctionPointerType() const; 347c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner bool isArrayType() const; 348c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner bool isConstantArrayType() const; 349c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner bool isIncompleteArrayType() const; 350c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner bool isVariableArrayType() const; 351898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor bool isDependentSizedArrayType() const; 352c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner bool isRecordType() const; 35399dc91422144483c20d1c7381bc9ac634b646b04Chris Lattner bool isClassType() const; 354c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner bool isStructureType() const; 3554cdec1c3ca80124024a787ce32833fd5b20cbb15Steve Naroff bool isUnionType() const; 356368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner bool isComplexIntegerType() const; // GCC _Complex integer type. 357368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner bool isVectorType() const; // GCC vector type. 358213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman bool isExtVectorType() const; // Extended vector type. 359368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner bool isObjCInterfaceType() const; // NSString or NSString<foo> 360368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner bool isObjCQualifiedInterfaceType() const; // NSString<foo> 361368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner bool isObjCQualifiedIdType() const; // id<foo> 36272c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor bool isTemplateTypeParmType() const; // C++ template type parameter 363898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor 364898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor /// isDependentType - Whether this type is a dependent type, meaning 365898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor /// that its definition somehow depends on a template parameter 366898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor /// (C++ [temp.dep.type]). 367898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor bool isDependentType() const { return Dependent; } 368904eed3f6148758d39a2d3c88f3133274460d645Douglas Gregor bool isOverloadType() const; // C++ overloaded function 36972c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor 370c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner // Type Checking Functions: Check to see if this type is structurally the 371f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner // specified type, ignoring typedefs and qualifiers, and return a pointer to 372f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner // the best type we can. 373f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl const BuiltinType *getAsBuiltinType() const; 374f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl const FunctionType *getAsFunctionType() const; 375f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl const FunctionTypeProto *getAsFunctionTypeProto() const; 376bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner const PointerLikeType *getAsPointerLikeType() const; // Pointer or Reference. 377befee48ff2a1dab236c5700f00ecca1cfdcd5837Chris Lattner const PointerType *getAsPointerType() const; 3785618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff const BlockPointerType *getAsBlockPointerType() const; 379a1d9fdea79ba7bbd71862b9f9f78f5f117331fc7Chris Lattner const ReferenceType *getAsReferenceType() const; 380f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl const MemberPointerType *getAsMemberPointerType() const; 381c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner const RecordType *getAsRecordType() const; 382769c9cfc6e06bd9d8ffe7a4397b939f19b0e4dc3Ted Kremenek const RecordType *getAsStructureType() const; 383898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor /// NOTE: getAs*ArrayType are methods on ASTContext. 384769c9cfc6e06bd9d8ffe7a4397b939f19b0e4dc3Ted Kremenek const TypedefType *getAsTypedefType() const; 385c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner const RecordType *getAsUnionType() const; 386ad74a758189180b8ab8faea648e4766c3bfd7fcbEli Friedman const EnumType *getAsEnumType() const; 387c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner const VectorType *getAsVectorType() const; // GCC vector type. 388c6fb90a7246c2d5d3233e70107bf9d8c7c9e535bChris Lattner const ComplexType *getAsComplexType() const; 3894cdec1c3ca80124024a787ce32833fd5b20cbb15Steve Naroff const ComplexType *getAsComplexIntegerType() const; // GCC complex int type. 390213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman const ExtVectorType *getAsExtVectorType() const; // Extended vector type. 391368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner const ObjCInterfaceType *getAsObjCInterfaceType() const; 392368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner const ObjCQualifiedInterfaceType *getAsObjCQualifiedInterfaceType() const; 393368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner const ObjCQualifiedIdType *getAsObjCQualifiedIdType() const; 39472c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor const TemplateTypeParmType *getAsTemplateTypeParmType() const; 39572c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor 39655f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor const ClassTemplateSpecializationType * 39755f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor getClassTemplateSpecializationType() const; 39855f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 3992b1cc8be4dda4cd122485be0168b3c43d7dff15fChris Lattner /// getAsPointerToObjCInterfaceType - If this is a pointer to an ObjC 4002b1cc8be4dda4cd122485be0168b3c43d7dff15fChris Lattner /// interface, return the interface type, otherwise return null. 4012b1cc8be4dda4cd122485be0168b3c43d7dff15fChris Lattner const ObjCInterfaceType *getAsPointerToObjCInterfaceType() const; 4022b1cc8be4dda4cd122485be0168b3c43d7dff15fChris Lattner 403c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner /// getArrayElementTypeNoTypeQual - If this is an array type, return the 404c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner /// element type of the array, potentially with type qualifiers missing. 405c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner /// This method should never be used when type qualifiers are meaningful. 406c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner const Type *getArrayElementTypeNoTypeQual() const; 407c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner 408dea6146deede4b89a1757d46cd92ebf158659c25Chris Lattner /// getDesugaredType - Return the specified type with any "sugar" removed from 409769c9cfc6e06bd9d8ffe7a4397b939f19b0e4dc3Ted Kremenek /// the type. This takes off typedefs, typeof's etc. If the outer level of 410dea6146deede4b89a1757d46cd92ebf158659c25Chris Lattner /// the type is already concrete, it returns it unmodified. This is similar 411dea6146deede4b89a1757d46cd92ebf158659c25Chris Lattner /// to getting the canonical type, but it doesn't remove *all* typedefs. For 4123830f68e9e461a1b812b70f93103f8fb4ccb8c40Chris Lattner /// example, it returns "T*" as "T*", (not as "int*"), because the pointer is 413dea6146deede4b89a1757d46cd92ebf158659c25Chris Lattner /// concrete. 414c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner QualType getDesugaredType() const; 415dea6146deede4b89a1757d46cd92ebf158659c25Chris Lattner 4165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// More type predicates useful for type checking/promotion 4175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isPromotableIntegerType() const; // C99 6.3.1.1p2 4185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 4195f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// isSignedIntegerType - Return true if this is an integer type that is 420d5bbce4382622feb4ca5978c4bb8fcceb7aaec00Chris Lattner /// signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], 421d5bbce4382622feb4ca5978c4bb8fcceb7aaec00Chris Lattner /// an enum decl which has a signed representation, or a vector of signed 422d5bbce4382622feb4ca5978c4bb8fcceb7aaec00Chris Lattner /// integer element type. 4235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isSignedIntegerType() const; 4245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 4255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// isUnsignedIntegerType - Return true if this is an integer type that is 426d5bbce4382622feb4ca5978c4bb8fcceb7aaec00Chris Lattner /// unsigned, according to C99 6.2.5p6 [which returns true for _Bool], an enum 427d5bbce4382622feb4ca5978c4bb8fcceb7aaec00Chris Lattner /// decl which has an unsigned representation, or a vector of unsigned integer 428d5bbce4382622feb4ca5978c4bb8fcceb7aaec00Chris Lattner /// element type. 4295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isUnsignedIntegerType() const; 430d5bbce4382622feb4ca5978c4bb8fcceb7aaec00Chris Lattner 4315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// isConstantSizeType - Return true if this is not a variable sized type, 4329bfa73c5ab7bf4b0e749d04f29da6884e8d5bd9fChris Lattner /// according to the rules of C99 6.7.5p3. It is not legal to call this on 4339bfa73c5ab7bf4b0e749d04f29da6884e8d5bd9fChris Lattner /// incomplete types. 4343c2b3170041f69a92904e3bab9b6d654eaf260acEli Friedman bool isConstantSizeType() const; 435c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner 4365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType getCanonicalTypeInternal() const { return CanonicalType; } 437c36d405a02fab41f6c45cb2bc750d64949742903Chris Lattner void dump() const; 4385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void getAsStringInternal(std::string &InnerString) const = 0; 4395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const Type *) { return true; } 44003ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek 44103ed44061df258e74a40383bda849e14b892a8c6Ted Kremenekprotected: 44203ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek /// Emit - Emit a Type to bitcode. Used by ASTContext. 44303ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek void Emit(llvm::Serializer& S) const; 44403ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek 44503ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek /// Create - Construct a Type from bitcode. Used by ASTContext. 44603ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek static void Create(ASTContext& Context, unsigned i, llvm::Deserializer& S); 44703ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek 44803ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek /// EmitImpl - Subclasses must implement this method in order to 44903ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek /// be serialized. 450708ef456a182030de3cf20ad98e653d2741ecb13Daniel Dunbar // FIXME: Make this abstract once implemented. 451708ef456a182030de3cf20ad98e653d2741ecb13Daniel Dunbar virtual void EmitImpl(llvm::Serializer& S) const { 452708ef456a182030de3cf20ad98e653d2741ecb13Daniel Dunbar assert (false && "Serializization for type not supported."); 453708ef456a182030de3cf20ad98e653d2741ecb13Daniel Dunbar } 4545f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 4555f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 456ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb/// ASQualType - TR18037 (C embedded extensions) 6.2.5p26 457ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb/// This supports address space qualified types. 458ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb/// 459ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lambclass ASQualType : public Type, public llvm::FoldingSetNode { 460f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner /// BaseType - This is the underlying type that this qualifies. All CVR 461f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner /// qualifiers are stored on the QualType that references this type, so we 462f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner /// can't have any here. 463f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner Type *BaseType; 464ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb /// Address Space ID - The address space ID this type is qualified with. 465ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb unsigned AddressSpace; 466f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner ASQualType(Type *Base, QualType CanonicalPtr, unsigned AddrSpace) : 467898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor Type(ASQual, CanonicalPtr, Base->isDependentType()), BaseType(Base), 468898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor AddressSpace(AddrSpace) { 469ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb } 470ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb friend class ASTContext; // ASTContext creates these. 471ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lambpublic: 472f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner Type *getBaseType() const { return BaseType; } 473ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb unsigned getAddressSpace() const { return AddressSpace; } 474ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb 475ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb virtual void getAsStringInternal(std::string &InnerString) const; 476ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb 477ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb void Profile(llvm::FoldingSetNodeID &ID) { 478ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb Profile(ID, getBaseType(), AddressSpace); 479ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb } 480f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner static void Profile(llvm::FoldingSetNodeID &ID, Type *Base, 481ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb unsigned AddrSpace) { 482f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner ID.AddPointer(Base); 483ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb ID.AddInteger(AddrSpace); 484ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb } 485ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb 486ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb static bool classof(const Type *T) { return T->getTypeClass() == ASQual; } 487ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb static bool classof(const ASQualType *) { return true; } 488ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb 489ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lambprotected: 490ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb virtual void EmitImpl(llvm::Serializer& S) const; 491ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D); 492ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb friend class Type; 493ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb}; 494ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb 495ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb 4965f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// BuiltinType - This class is used for builtin types like 'int'. Builtin 4975f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// types are always canonical and have a literal name field. 4985f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass BuiltinType : public Type { 4995f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 5005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer enum Kind { 5015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Void, 5025f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5035f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Bool, // This is bool and/or _Bool. 5045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Char_U, // This is 'char' for targets where char is unsigned. 5055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer UChar, // This is explicitly qualified unsigned char. 5065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer UShort, 5075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer UInt, 5085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ULong, 5095f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ULongLong, 5105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Char_S, // This is 'char' for targets where char is signed. 5125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer SChar, // This is explicitly qualified signed char. 5132ff9b4c7c8fed9233a0b8de2e9507368c451aab6Argyrios Kyrtzidis WChar, // This is 'wchar_t' for C++. 5145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Short, 5155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Int, 5165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Long, 5175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer LongLong, 5185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5198e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregor Float, Double, LongDouble, 5208e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregor 521898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor Overload, // This represents the type of an overloaded function declaration. 522898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor Dependent // This represents the type of a type-dependent expression. 5235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer }; 5245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerprivate: 5255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Kind TypeKind; 5265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 527898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor BuiltinType(Kind K) 528898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor : Type(Builtin, QualType(), /*Dependent=*/(K == Dependent)), 529898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor TypeKind(K) {} 5305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Kind getKind() const { return TypeKind; } 5325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer const char *getName() const; 5335f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5345f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void getAsStringInternal(std::string &InnerString) const; 5355f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const Type *T) { return T->getTypeClass() == Builtin; } 5375f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const BuiltinType *) { return true; } 5385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 5395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// ComplexType - C99 6.2.5p11 - Complex values. This supports the C99 complex 5415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// types (_Complex float etc) as well as the GCC integer complex extensions. 5425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 5435f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass ComplexType : public Type, public llvm::FoldingSetNode { 5445f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType ElementType; 5455f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ComplexType(QualType Element, QualType CanonicalPtr) : 546898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor Type(Complex, CanonicalPtr, Element->isDependentType()), 547898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor ElementType(Element) { 5485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 5495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer friend class ASTContext; // ASTContext creates these. 5505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 5515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType getElementType() const { return ElementType; } 5525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void getAsStringInternal(std::string &InnerString) const; 55403ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek 5555f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void Profile(llvm::FoldingSetNodeID &ID) { 5565f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Profile(ID, getElementType()); 5575f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 5585f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static void Profile(llvm::FoldingSetNodeID &ID, QualType Element) { 5595f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ID.AddPointer(Element.getAsOpaquePtr()); 5605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 5615f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const Type *T) { return T->getTypeClass() == Complex; } 5635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const ComplexType *) { return true; } 56473af669633e13c813f80cd15ecf3e6414778aee4Ted Kremenek 56503ed44061df258e74a40383bda849e14b892a8c6Ted Kremenekprotected: 56603ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek virtual void EmitImpl(llvm::Serializer& S) const; 56703ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D); 56803ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek friend class Type; 5695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 5705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 571bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner/// PointerLikeType - Common base class for pointers and references. 57239218dfef550ad1cd7b7ece83a715996a113ffd1Steve Naroff/// FIXME: Add more documentation on this classes design point. For example, 57339218dfef550ad1cd7b7ece83a715996a113ffd1Steve Naroff/// should BlockPointerType inherit from it? Is the concept of a PointerLikeType 57439218dfef550ad1cd7b7ece83a715996a113ffd1Steve Naroff/// in the C++ standard? 575bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner/// 576bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattnerclass PointerLikeType : public Type { 577bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner QualType PointeeType; 578bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattnerprotected: 579bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner PointerLikeType(TypeClass K, QualType Pointee, QualType CanonicalPtr) : 580898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor Type(K, CanonicalPtr, Pointee->isDependentType()), PointeeType(Pointee) { 581bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner } 582bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattnerpublic: 583bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner 584bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner QualType getPointeeType() const { return PointeeType; } 585bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner 586bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner static bool classof(const Type *T) { 587bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner return T->getTypeClass() == Pointer || T->getTypeClass() == Reference; 588bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner } 589bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner static bool classof(const PointerLikeType *) { return true; } 590bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner}; 5915f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5925f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// PointerType - C99 6.7.5.1 - Pointer Declarators. 5935f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 594bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattnerclass PointerType : public PointerLikeType, public llvm::FoldingSetNode { 5955f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer PointerType(QualType Pointee, QualType CanonicalPtr) : 596bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner PointerLikeType(Pointer, Pointee, CanonicalPtr) { 5975f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 5985f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer friend class ASTContext; // ASTContext creates these. 5995f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 6005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 6015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void getAsStringInternal(std::string &InnerString) const; 6025f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 6035f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void Profile(llvm::FoldingSetNodeID &ID) { 6045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Profile(ID, getPointeeType()); 6055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 6065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static void Profile(llvm::FoldingSetNodeID &ID, QualType Pointee) { 6075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ID.AddPointer(Pointee.getAsOpaquePtr()); 6085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 6095f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 6105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const Type *T) { return T->getTypeClass() == Pointer; } 6115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const PointerType *) { return true; } 61203ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek 61303ed44061df258e74a40383bda849e14b892a8c6Ted Kremenekprotected: 61403ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek virtual void EmitImpl(llvm::Serializer& S) const; 61503ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D); 61603ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek friend class Type; 6175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 6185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 6195618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff/// BlockPointerType - pointer to a block type. 6205618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff/// This type is to represent types syntactically represented as 6215618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff/// "void (^)(int)", etc. Pointee is required to always be a function type. 62239218dfef550ad1cd7b7ece83a715996a113ffd1Steve Naroff/// FIXME: Should BlockPointerType inherit from PointerLikeType? It could 62339218dfef550ad1cd7b7ece83a715996a113ffd1Steve Naroff/// simplfy some type checking code, however PointerLikeType doesn't appear 62439218dfef550ad1cd7b7ece83a715996a113ffd1Steve Naroff/// to be used by the type checker. 6255618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff/// 6265618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroffclass BlockPointerType : public Type, public llvm::FoldingSetNode { 6275618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff QualType PointeeType; // Block is some kind of pointer type 6285618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff BlockPointerType(QualType Pointee, QualType CanonicalCls) : 629898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor Type(BlockPointer, CanonicalCls, Pointee->isDependentType()), 630898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor PointeeType(Pointee) { 6315618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff } 6325618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff friend class ASTContext; // ASTContext creates these. 6335618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroffpublic: 6345618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff 6355618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff // Get the pointee type. Pointee is required to always be a function type. 6365618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff QualType getPointeeType() const { return PointeeType; } 6375618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff 6385618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff virtual void getAsStringInternal(std::string &InnerString) const; 6395618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff 6405618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff void Profile(llvm::FoldingSetNodeID &ID) { 6415618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff Profile(ID, getPointeeType()); 6425618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff } 6435618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff static void Profile(llvm::FoldingSetNodeID &ID, QualType Pointee) { 6445618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff ID.AddPointer(Pointee.getAsOpaquePtr()); 6455618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff } 6465618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff 6475618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff static bool classof(const Type *T) { 6485618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff return T->getTypeClass() == BlockPointer; 6495618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff } 6505618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff static bool classof(const BlockPointerType *) { return true; } 6515618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff 6525618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff protected: 6535618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff virtual void EmitImpl(llvm::Serializer& S) const; 6545618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D); 6555618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff friend class Type; 6565618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff}; 6575618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff 6585f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// ReferenceType - C++ 8.3.2 - Reference Declarators. 6595f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 660bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattnerclass ReferenceType : public PointerLikeType, public llvm::FoldingSetNode { 6615f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ReferenceType(QualType Referencee, QualType CanonicalRef) : 662bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner PointerLikeType(Reference, Referencee, CanonicalRef) { 6635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 6645f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer friend class ASTContext; // ASTContext creates these. 6655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 6665f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void getAsStringInternal(std::string &InnerString) const; 6675f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 6685f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void Profile(llvm::FoldingSetNodeID &ID) { 669bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner Profile(ID, getPointeeType()); 6705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 6715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static void Profile(llvm::FoldingSetNodeID &ID, QualType Referencee) { 6725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ID.AddPointer(Referencee.getAsOpaquePtr()); 6735f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 6745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 6755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const Type *T) { return T->getTypeClass() == Reference; } 6765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const ReferenceType *) { return true; } 677f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl 678f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redlprotected: 679f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl virtual void EmitImpl(llvm::Serializer& S) const; 680f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl static Type* CreateImpl(ASTContext& Context, llvm::Deserializer& D); 681f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl friend class Type; 682f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl}; 683f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl 684f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl/// MemberPointerType - C++ 8.3.3 - Pointers to members 685f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl/// 686f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redlclass MemberPointerType : public Type, public llvm::FoldingSetNode { 687f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl QualType PointeeType; 688f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl /// The class of which the pointee is a member. Must ultimately be a 689f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl /// RecordType, but could be a typedef or a template parameter too. 690f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl const Type *Class; 691f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl 692f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl MemberPointerType(QualType Pointee, const Type *Cls, QualType CanonicalPtr) : 693f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl Type(MemberPointer, CanonicalPtr, 694f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl Cls->isDependentType() || Pointee->isDependentType()), 695f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl PointeeType(Pointee), Class(Cls) { 696f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl } 697f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl friend class ASTContext; // ASTContext creates these. 698f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redlpublic: 699f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl 700f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl QualType getPointeeType() const { return PointeeType; } 701f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl 702f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl const Type *getClass() const { return Class; } 703f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl 704f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl virtual void getAsStringInternal(std::string &InnerString) const; 705f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl 706f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl void Profile(llvm::FoldingSetNodeID &ID) { 707f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl Profile(ID, getPointeeType(), getClass()); 708f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl } 709f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl static void Profile(llvm::FoldingSetNodeID &ID, QualType Pointee, 710f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl const Type *Class) { 711f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl ID.AddPointer(Pointee.getAsOpaquePtr()); 712f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl ID.AddPointer(Class); 713f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl } 714f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl 715f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl static bool classof(const Type *T) { 716f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl return T->getTypeClass() == MemberPointer; 717f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl } 718f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl static bool classof(const MemberPointerType *) { return true; } 719f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl 720f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redlprotected: 721f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl virtual void EmitImpl(llvm::Serializer& S) const; 722f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl static Type* CreateImpl(ASTContext& Context, llvm::Deserializer& D); 723f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl friend class Type; 7245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 7255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 7265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// ArrayType - C99 6.7.5.2 - Array Declarators. 7275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 7282e7d352dbec06755105237afba183492d31d03cbTed Kremenekclass ArrayType : public Type, public llvm::FoldingSetNode { 7295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 7305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ArraySizeModifier - Capture whether this is a normal array (e.g. int X[4]) 731898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor /// an array with a static size (e.g. int X[static 4]), or an array 732898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor /// with a star size (e.g. int X[*]). 733898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor /// 'static' is only allowed on function parameters. 7345f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer enum ArraySizeModifier { 7355f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Normal, Static, Star 7365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer }; 7375f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerprivate: 738fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff /// ElementType - The element type of the array. 739fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff QualType ElementType; 740c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff 741ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek // NOTE: VC++ treats enums as signed, avoid using the ArraySizeModifier enum 742c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff /// NOTE: These fields are packed into the bitfields space in the Type class. 743ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek unsigned SizeModifier : 2; 744c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff 745c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff /// IndexTypeQuals - Capture qualifiers in declarations like: 746c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff /// 'int X[static restrict 4]'. For function parameters only. 747c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff unsigned IndexTypeQuals : 3; 748c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff 749fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroffprotected: 750898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor // C++ [temp.dep.type]p1: 751898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor // A type is dependent if it is... 752898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor // - an array type constructed from any dependent type or whose 753898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor // size is specified by a constant expression that is 754898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor // value-dependent, 755c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff ArrayType(TypeClass tc, QualType et, QualType can, 756c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff ArraySizeModifier sm, unsigned tq) 757898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor : Type(tc, can, et->isDependentType() || tc == DependentSizedArray), 758898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor ElementType(et), SizeModifier(sm), IndexTypeQuals(tq) {} 759898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor 760fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff friend class ASTContext; // ASTContext creates these. 761fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroffpublic: 762fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff QualType getElementType() const { return ElementType; } 763ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek ArraySizeModifier getSizeModifier() const { 764ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek return ArraySizeModifier(SizeModifier); 765ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek } 766c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff unsigned getIndexTypeQualifier() const { return IndexTypeQuals; } 767fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff 768fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff static bool classof(const Type *T) { 769fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff return T->getTypeClass() == ConstantArray || 770c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman T->getTypeClass() == VariableArray || 771898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor T->getTypeClass() == IncompleteArray || 772898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor T->getTypeClass() == DependentSizedArray; 773fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff } 774fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff static bool classof(const ArrayType *) { return true; } 775fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff}; 776fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff 777da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// ConstantArrayType - This class represents C arrays with a specified constant 778da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// size. For example 'int A[100]' has ConstantArrayType where the element type 779da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// is 'int' and the size is 100. 7802e7d352dbec06755105237afba183492d31d03cbTed Kremenekclass ConstantArrayType : public ArrayType { 781fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff llvm::APInt Size; // Allows us to unique the type. 782fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff 783c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff ConstantArrayType(QualType et, QualType can, llvm::APInt sz, 784c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff ArraySizeModifier sm, unsigned tq) 785c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff : ArrayType(ConstantArray, et, can, sm, tq), Size(sz) {} 786fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff friend class ASTContext; // ASTContext creates these. 787fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroffpublic: 788c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner const llvm::APInt &getSize() const { return Size; } 789fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff virtual void getAsStringInternal(std::string &InnerString) const; 790fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff 791fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff void Profile(llvm::FoldingSetNodeID &ID) { 792fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff Profile(ID, getElementType(), getSize()); 793fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff } 794fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff static void Profile(llvm::FoldingSetNodeID &ID, QualType ET, 795fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff llvm::APInt ArraySize) { 796fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff ID.AddPointer(ET.getAsOpaquePtr()); 797fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff ID.AddInteger(ArraySize.getZExtValue()); 798fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff } 799fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff static bool classof(const Type *T) { 800fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff return T->getTypeClass() == ConstantArray; 801fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff } 802fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff static bool classof(const ConstantArrayType *) { return true; } 803da5dbb4a0ad091791bdb0dad1b9ceba3c04a7f5cTed Kremenek 804da5dbb4a0ad091791bdb0dad1b9ceba3c04a7f5cTed Kremenekprotected: 805da5dbb4a0ad091791bdb0dad1b9ceba3c04a7f5cTed Kremenek virtual void EmitImpl(llvm::Serializer& S) const; 806da5dbb4a0ad091791bdb0dad1b9ceba3c04a7f5cTed Kremenek static Type* CreateImpl(ASTContext& Context, llvm::Deserializer& D); 807da5dbb4a0ad091791bdb0dad1b9ceba3c04a7f5cTed Kremenek friend class Type; 808fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff}; 809fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff 810da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// IncompleteArrayType - This class represents C arrays with an unspecified 811da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// size. For example 'int A[]' has an IncompleteArrayType where the element 812da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// type is 'int' and the size is unspecified. 813c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedmanclass IncompleteArrayType : public ArrayType { 814c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman IncompleteArrayType(QualType et, QualType can, 815c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman ArraySizeModifier sm, unsigned tq) 816c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman : ArrayType(IncompleteArray, et, can, sm, tq) {} 817c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman friend class ASTContext; // ASTContext creates these. 818c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedmanpublic: 819c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman 820c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman virtual void getAsStringInternal(std::string &InnerString) const; 821c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman 822c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman static bool classof(const Type *T) { 823c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman return T->getTypeClass() == IncompleteArray; 824c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman } 825c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman static bool classof(const IncompleteArrayType *) { return true; } 826c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman 827c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman friend class StmtIteratorBase; 828c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman 829c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman void Profile(llvm::FoldingSetNodeID &ID) { 830c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman Profile(ID, getElementType()); 831c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman } 832c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman 833c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman static void Profile(llvm::FoldingSetNodeID &ID, QualType ET) { 834c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman ID.AddPointer(ET.getAsOpaquePtr()); 835c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman } 836c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman 837c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedmanprotected: 838c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman virtual void EmitImpl(llvm::Serializer& S) const; 839c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D); 840c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman friend class Type; 841c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman}; 842c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman 843da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// VariableArrayType - This class represents C arrays with a specified size 844da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// which is not an integer-constant-expression. For example, 'int s[x+foo()]'. 845da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// Since the size expression is an arbitrary expression, we store it as such. 846da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// 847da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// Note: VariableArrayType's aren't uniqued (since the expressions aren't) and 848da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// should not be: two lexically equivalent variable array types could mean 849da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// different things, for example, these variables do not have the same type 850da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// dynamically: 851da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// 852da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// void foo(int x) { 853da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// int Y[x]; 854da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// ++x; 855da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// int Z[x]; 856da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// } 857da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// 8582e7d352dbec06755105237afba183492d31d03cbTed Kremenekclass VariableArrayType : public ArrayType { 859fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff /// SizeExpr - An assignment expression. VLA's are only permitted within 860fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff /// a function block. 861b3064041583eb134fbf56906728bf752bc65b572Ted Kremenek Stmt *SizeExpr; 8625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 863c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff VariableArrayType(QualType et, QualType can, Expr *e, 864c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff ArraySizeModifier sm, unsigned tq) 865b3064041583eb134fbf56906728bf752bc65b572Ted Kremenek : ArrayType(VariableArray, et, can, sm, tq), SizeExpr((Stmt*) e) {} 8665f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer friend class ASTContext; // ASTContext creates these. 8674b05b1dee6cc65ae61d93dab7edff72710f24589Ted Kremenek virtual void Destroy(ASTContext& C); 8684b05b1dee6cc65ae61d93dab7edff72710f24589Ted Kremenek 8695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 870c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner Expr *getSizeExpr() const { 871b3064041583eb134fbf56906728bf752bc65b572Ted Kremenek // We use C-style casts instead of cast<> here because we do not wish 872b3064041583eb134fbf56906728bf752bc65b572Ted Kremenek // to have a dependency of Type.h on Stmt.h/Expr.h. 873b3064041583eb134fbf56906728bf752bc65b572Ted Kremenek return (Expr*) SizeExpr; 874b3064041583eb134fbf56906728bf752bc65b572Ted Kremenek } 8755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 8765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void getAsStringInternal(std::string &InnerString) const; 8775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 878fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff static bool classof(const Type *T) { 879fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff return T->getTypeClass() == VariableArray; 8805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 881fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff static bool classof(const VariableArrayType *) { return true; } 882a4cb4525cf4bf8f61299147f22ffc187ed1eac9eTed Kremenek 88392866e2e90f6d93fb95e25a7ac4438e239d89ce6Ted Kremenek friend class StmtIteratorBase; 8842bd24ba6d10f8c811c8e2a57c8397e07082ba497Ted Kremenek 8852bd24ba6d10f8c811c8e2a57c8397e07082ba497Ted Kremenek void Profile(llvm::FoldingSetNodeID &ID) { 886c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman assert (0 && "Cannnot unique VariableArrayTypes."); 8872bd24ba6d10f8c811c8e2a57c8397e07082ba497Ted Kremenek } 888ed1a01d4d0ee773eb6478ff9701b46d2f0c06952Ted Kremenek 889ed1a01d4d0ee773eb6478ff9701b46d2f0c06952Ted Kremenekprotected: 890ed1a01d4d0ee773eb6478ff9701b46d2f0c06952Ted Kremenek virtual void EmitImpl(llvm::Serializer& S) const; 891ed1a01d4d0ee773eb6478ff9701b46d2f0c06952Ted Kremenek static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D); 892ed1a01d4d0ee773eb6478ff9701b46d2f0c06952Ted Kremenek friend class Type; 8935f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 8945f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 895898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor/// DependentSizedArrayType - This type represents an array type in 896898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor/// C++ whose size is a value-dependent expression. For example: 897898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor/// @code 898898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor/// template<typename T, int Size> 899898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor/// class array { 900898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor/// T data[Size]; 901898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor/// }; 902898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor/// @endcode 903898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor/// For these types, we won't actually know what the array bound is 904898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor/// until template instantiation occurs, at which point this will 905898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor/// become either a ConstantArrayType or a VariableArrayType. 906898574e7496ba8fd76290079d3a9d06954992734Douglas Gregorclass DependentSizedArrayType : public ArrayType { 907898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor /// SizeExpr - An assignment expression that will instantiate to the 908898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor /// size of the array. 909898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor Stmt *SizeExpr; 910898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor 911898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor DependentSizedArrayType(QualType et, QualType can, Expr *e, 912898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor ArraySizeModifier sm, unsigned tq) 913898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor : ArrayType(DependentSizedArray, et, can, sm, tq), SizeExpr((Stmt*) e) {} 914898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor friend class ASTContext; // ASTContext creates these. 915898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor virtual void Destroy(ASTContext& C); 916898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor 917898574e7496ba8fd76290079d3a9d06954992734Douglas Gregorpublic: 918898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor Expr *getSizeExpr() const { 919898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor // We use C-style casts instead of cast<> here because we do not wish 920898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor // to have a dependency of Type.h on Stmt.h/Expr.h. 921898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor return (Expr*) SizeExpr; 922898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor } 923898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor 924898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor virtual void getAsStringInternal(std::string &InnerString) const; 925898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor 926898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor static bool classof(const Type *T) { 927898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor return T->getTypeClass() == DependentSizedArray; 928898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor } 929898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor static bool classof(const DependentSizedArrayType *) { return true; } 930898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor 931898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor friend class StmtIteratorBase; 932898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor 933898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor void Profile(llvm::FoldingSetNodeID &ID) { 934898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor assert (0 && "Cannnot unique DependentSizedArrayTypes."); 935898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor } 936898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor 937898574e7496ba8fd76290079d3a9d06954992734Douglas Gregorprotected: 938898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor virtual void EmitImpl(llvm::Serializer& S) const; 939898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D); 940898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor friend class Type; 941898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor}; 942898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor 94373322924127c873c13101b705dd823f5539ffa5fSteve Naroff/// VectorType - GCC generic vector type. This type is created using 94473322924127c873c13101b705dd823f5539ffa5fSteve Naroff/// __attribute__((vector_size(n)), where "n" specifies the vector size in 94573322924127c873c13101b705dd823f5539ffa5fSteve Naroff/// bytes. Since the constructor takes the number of vector elements, the 94673322924127c873c13101b705dd823f5539ffa5fSteve Naroff/// client is responsible for converting the size into the number of elements. 9475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass VectorType : public Type, public llvm::FoldingSetNode { 94873322924127c873c13101b705dd823f5539ffa5fSteve Naroffprotected: 9495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ElementType - The element type of the vector. 9505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType ElementType; 9515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 9525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// NumElements - The number of elements in the vector. 9535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer unsigned NumElements; 9545f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 95573322924127c873c13101b705dd823f5539ffa5fSteve Naroff VectorType(QualType vecType, unsigned nElements, QualType canonType) : 956898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor Type(Vector, canonType, vecType->isDependentType()), 957898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor ElementType(vecType), NumElements(nElements) {} 95873322924127c873c13101b705dd823f5539ffa5fSteve Naroff VectorType(TypeClass tc, QualType vecType, unsigned nElements, 959353417af9d254d4fd0eb7d0a3ff71c4d8594ac58Nate Begeman QualType canonType) 960898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor : Type(tc, canonType, vecType->isDependentType()), ElementType(vecType), 961898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor NumElements(nElements) {} 9625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer friend class ASTContext; // ASTContext creates these. 9635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 9645f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 9655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType getElementType() const { return ElementType; } 9665f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer unsigned getNumElements() const { return NumElements; } 9675f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 9685f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void getAsStringInternal(std::string &InnerString) const; 9695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 9705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void Profile(llvm::FoldingSetNodeID &ID) { 97173322924127c873c13101b705dd823f5539ffa5fSteve Naroff Profile(ID, getElementType(), getNumElements(), getTypeClass()); 9725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 97373322924127c873c13101b705dd823f5539ffa5fSteve Naroff static void Profile(llvm::FoldingSetNodeID &ID, QualType ElementType, 97473322924127c873c13101b705dd823f5539ffa5fSteve Naroff unsigned NumElements, TypeClass TypeClass) { 9755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ID.AddPointer(ElementType.getAsOpaquePtr()); 9765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ID.AddInteger(NumElements); 97773322924127c873c13101b705dd823f5539ffa5fSteve Naroff ID.AddInteger(TypeClass); 97873322924127c873c13101b705dd823f5539ffa5fSteve Naroff } 97973322924127c873c13101b705dd823f5539ffa5fSteve Naroff static bool classof(const Type *T) { 980213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman return T->getTypeClass() == Vector || T->getTypeClass() == ExtVector; 9815f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 9825f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const VectorType *) { return true; } 9835f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 9845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 985213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman/// ExtVectorType - Extended vector type. This type is created using 986213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman/// __attribute__((ext_vector_type(n)), where "n" is the number of elements. 987213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman/// Unlike vector_size, ext_vector_type is only allowed on typedef's. This 988fcac0fff877a461bc5d5a57e6c6727a4c819d95aSteve Naroff/// class enables syntactic extensions, like Vector Components for accessing 989fcac0fff877a461bc5d5a57e6c6727a4c819d95aSteve Naroff/// points, colors, and textures (modeled after OpenGL Shading Language). 990213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begemanclass ExtVectorType : public VectorType { 991213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman ExtVectorType(QualType vecType, unsigned nElements, QualType canonType) : 992213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman VectorType(ExtVector, vecType, nElements, canonType) {} 99373322924127c873c13101b705dd823f5539ffa5fSteve Naroff friend class ASTContext; // ASTContext creates these. 99473322924127c873c13101b705dd823f5539ffa5fSteve Naroffpublic: 99588dca0464804b8b26ae605f89784c927e8493dddChris Lattner static int getPointAccessorIdx(char c) { 99688dca0464804b8b26ae605f89784c927e8493dddChris Lattner switch (c) { 99788dca0464804b8b26ae605f89784c927e8493dddChris Lattner default: return -1; 99888dca0464804b8b26ae605f89784c927e8493dddChris Lattner case 'x': return 0; 99988dca0464804b8b26ae605f89784c927e8493dddChris Lattner case 'y': return 1; 100088dca0464804b8b26ae605f89784c927e8493dddChris Lattner case 'z': return 2; 100188dca0464804b8b26ae605f89784c927e8493dddChris Lattner case 'w': return 3; 100288dca0464804b8b26ae605f89784c927e8493dddChris Lattner } 1003e1b31fedbc006e6e4071bbb4f74c6116b56cfa9fSteve Naroff } 1004353417af9d254d4fd0eb7d0a3ff71c4d8594ac58Nate Begeman static int getNumericAccessorIdx(char c) { 100588dca0464804b8b26ae605f89784c927e8493dddChris Lattner switch (c) { 1006353417af9d254d4fd0eb7d0a3ff71c4d8594ac58Nate Begeman default: return -1; 1007353417af9d254d4fd0eb7d0a3ff71c4d8594ac58Nate Begeman case '0': return 0; 1008353417af9d254d4fd0eb7d0a3ff71c4d8594ac58Nate Begeman case '1': return 1; 1009353417af9d254d4fd0eb7d0a3ff71c4d8594ac58Nate Begeman case '2': return 2; 1010353417af9d254d4fd0eb7d0a3ff71c4d8594ac58Nate Begeman case '3': return 3; 1011353417af9d254d4fd0eb7d0a3ff71c4d8594ac58Nate Begeman case '4': return 4; 1012353417af9d254d4fd0eb7d0a3ff71c4d8594ac58Nate Begeman case '5': return 5; 1013353417af9d254d4fd0eb7d0a3ff71c4d8594ac58Nate Begeman case '6': return 6; 1014353417af9d254d4fd0eb7d0a3ff71c4d8594ac58Nate Begeman case '7': return 7; 1015353417af9d254d4fd0eb7d0a3ff71c4d8594ac58Nate Begeman case '8': return 8; 1016353417af9d254d4fd0eb7d0a3ff71c4d8594ac58Nate Begeman case '9': return 9; 1017353417af9d254d4fd0eb7d0a3ff71c4d8594ac58Nate Begeman case 'a': return 10; 1018353417af9d254d4fd0eb7d0a3ff71c4d8594ac58Nate Begeman case 'b': return 11; 1019353417af9d254d4fd0eb7d0a3ff71c4d8594ac58Nate Begeman case 'c': return 12; 1020353417af9d254d4fd0eb7d0a3ff71c4d8594ac58Nate Begeman case 'd': return 13; 1021353417af9d254d4fd0eb7d0a3ff71c4d8594ac58Nate Begeman case 'e': return 14; 1022353417af9d254d4fd0eb7d0a3ff71c4d8594ac58Nate Begeman case 'f': return 15; 102388dca0464804b8b26ae605f89784c927e8493dddChris Lattner } 1024e1b31fedbc006e6e4071bbb4f74c6116b56cfa9fSteve Naroff } 1025b8f849da3cedee2f61ad98389115ddd04e439d60Chris Lattner 1026b8f849da3cedee2f61ad98389115ddd04e439d60Chris Lattner static int getAccessorIdx(char c) { 1027b8f849da3cedee2f61ad98389115ddd04e439d60Chris Lattner if (int idx = getPointAccessorIdx(c)+1) return idx-1; 1028353417af9d254d4fd0eb7d0a3ff71c4d8594ac58Nate Begeman return getNumericAccessorIdx(c); 1029b8f849da3cedee2f61ad98389115ddd04e439d60Chris Lattner } 1030b8f849da3cedee2f61ad98389115ddd04e439d60Chris Lattner 103188dca0464804b8b26ae605f89784c927e8493dddChris Lattner bool isAccessorWithinNumElements(char c) const { 1032b8f849da3cedee2f61ad98389115ddd04e439d60Chris Lattner if (int idx = getAccessorIdx(c)+1) 103388dca0464804b8b26ae605f89784c927e8493dddChris Lattner return unsigned(idx-1) < NumElements; 103488dca0464804b8b26ae605f89784c927e8493dddChris Lattner return false; 1035e1b31fedbc006e6e4071bbb4f74c6116b56cfa9fSteve Naroff } 103631a458462c6cf417a84e0c47852b18fb22d79acbSteve Naroff virtual void getAsStringInternal(std::string &InnerString) const; 103731a458462c6cf417a84e0c47852b18fb22d79acbSteve Naroff 10387064f5c95bbdb17680d0ea658d4090898c2592d3Steve Naroff static bool classof(const Type *T) { 1039213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman return T->getTypeClass() == ExtVector; 104073322924127c873c13101b705dd823f5539ffa5fSteve Naroff } 1041213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman static bool classof(const ExtVectorType *) { return true; } 104273322924127c873c13101b705dd823f5539ffa5fSteve Naroff}; 104373322924127c873c13101b705dd823f5539ffa5fSteve Naroff 10445f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// FunctionType - C99 6.7.5.3 - Function Declarators. This is the common base 10455f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// class of FunctionTypeNoProto and FunctionTypeProto. 10465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 10475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass FunctionType : public Type { 10485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// SubClassData - This field is owned by the subclass, put here to pack 10495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// tightly with the ivars in Type. 10505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool SubClassData : 1; 1051971c4fae6092976338b755af1d47dac07c8f16e3Argyrios Kyrtzidis 1052971c4fae6092976338b755af1d47dac07c8f16e3Argyrios Kyrtzidis /// TypeQuals - Used only by FunctionTypeProto, put here to pack with the 1053971c4fae6092976338b755af1d47dac07c8f16e3Argyrios Kyrtzidis /// other bitfields. 1054971c4fae6092976338b755af1d47dac07c8f16e3Argyrios Kyrtzidis /// The qualifiers are part of FunctionTypeProto because... 1055971c4fae6092976338b755af1d47dac07c8f16e3Argyrios Kyrtzidis /// 1056971c4fae6092976338b755af1d47dac07c8f16e3Argyrios Kyrtzidis /// C++ 8.3.5p4: The return type, the parameter type list and the 1057971c4fae6092976338b755af1d47dac07c8f16e3Argyrios Kyrtzidis /// cv-qualifier-seq, [...], are part of the function type. 1058971c4fae6092976338b755af1d47dac07c8f16e3Argyrios Kyrtzidis /// 1059971c4fae6092976338b755af1d47dac07c8f16e3Argyrios Kyrtzidis unsigned TypeQuals : 3; 10605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 10615f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // The type returned by the function. 10625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType ResultType; 10635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerprotected: 1064971c4fae6092976338b755af1d47dac07c8f16e3Argyrios Kyrtzidis FunctionType(TypeClass tc, QualType res, bool SubclassInfo, 1065898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor unsigned typeQuals, QualType Canonical, bool Dependent) 1066898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor : Type(tc, Canonical, Dependent), 1067971c4fae6092976338b755af1d47dac07c8f16e3Argyrios Kyrtzidis SubClassData(SubclassInfo), TypeQuals(typeQuals), ResultType(res) {} 10685f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool getSubClassData() const { return SubClassData; } 1069971c4fae6092976338b755af1d47dac07c8f16e3Argyrios Kyrtzidis unsigned getTypeQuals() const { return TypeQuals; } 10705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 10715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 10725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType getResultType() const { return ResultType; } 10735f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 10745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 10755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const Type *T) { 10765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return T->getTypeClass() == FunctionNoProto || 10775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer T->getTypeClass() == FunctionProto; 10785f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 10795f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const FunctionType *) { return true; } 10805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 10815f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 10825f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// FunctionTypeNoProto - Represents a K&R-style 'int foo()' function, which has 10835f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// no information available about its arguments. 10845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass FunctionTypeNoProto : public FunctionType, public llvm::FoldingSetNode { 10855f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer FunctionTypeNoProto(QualType Result, QualType Canonical) 1086898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor : FunctionType(FunctionNoProto, Result, false, 0, Canonical, 10874b4218f48fef71a179c5a8287dae281580faf52fNate Begeman /*Dependent=*/false) {} 10885f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer friend class ASTContext; // ASTContext creates these. 10895f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 10905f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // No additional state past what FunctionType provides. 10915f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 10925f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void getAsStringInternal(std::string &InnerString) const; 10935f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 10945f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void Profile(llvm::FoldingSetNodeID &ID) { 10955f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Profile(ID, getResultType()); 10965f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 10975f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static void Profile(llvm::FoldingSetNodeID &ID, QualType ResultType) { 10985f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ID.AddPointer(ResultType.getAsOpaquePtr()); 10995f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 11005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 11015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const Type *T) { 11025f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return T->getTypeClass() == FunctionNoProto; 11035f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 11045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const FunctionTypeNoProto *) { return true; } 11052b14d46231fd75ad1e58043e9fab029c54c817cbTed Kremenek 11062b14d46231fd75ad1e58043e9fab029c54c817cbTed Kremenekprotected: 11072b14d46231fd75ad1e58043e9fab029c54c817cbTed Kremenek virtual void EmitImpl(llvm::Serializer& S) const; 11082b14d46231fd75ad1e58043e9fab029c54c817cbTed Kremenek static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D); 11092b14d46231fd75ad1e58043e9fab029c54c817cbTed Kremenek friend class Type; 11105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 11115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 11125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// FunctionTypeProto - Represents a prototype with argument type info, e.g. 11135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 'int foo(int)' or 'int foo(void)'. 'void' is represented as having no 11145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// arguments, not as having a single void argument. 11155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass FunctionTypeProto : public FunctionType, public llvm::FoldingSetNode { 1116898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor /// hasAnyDependentType - Determine whether there are any dependent 1117898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor /// types within the arguments passed in. 1118898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor static bool hasAnyDependentType(const QualType *ArgArray, unsigned numArgs) { 1119898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor for (unsigned Idx = 0; Idx < numArgs; ++Idx) 1120898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor if (ArgArray[Idx]->isDependentType()) 11214b4218f48fef71a179c5a8287dae281580faf52fNate Begeman return true; 1122898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor 1123898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor return false; 1124898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor } 1125898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor 112686da77fdaf4c0237eafb9670f54eee20b08635bfEli Friedman FunctionTypeProto(QualType Result, const QualType *ArgArray, unsigned numArgs, 1127971c4fae6092976338b755af1d47dac07c8f16e3Argyrios Kyrtzidis bool isVariadic, unsigned typeQuals, QualType Canonical) 1128898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor : FunctionType(FunctionProto, Result, isVariadic, typeQuals, Canonical, 11294b4218f48fef71a179c5a8287dae281580faf52fNate Begeman (Result->isDependentType() || 11304b4218f48fef71a179c5a8287dae281580faf52fNate Begeman hasAnyDependentType(ArgArray, numArgs))), 11315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer NumArgs(numArgs) { 1132942cfd37297528918616d06cd6e4e8bd6e4915a2Chris Lattner // Fill in the trailing argument array. 1133942cfd37297528918616d06cd6e4e8bd6e4915a2Chris Lattner QualType *ArgInfo = reinterpret_cast<QualType *>(this+1);; 11345f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer for (unsigned i = 0; i != numArgs; ++i) 11355f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ArgInfo[i] = ArgArray[i]; 11365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 11375f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 11385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// NumArgs - The number of arguments this function has, not counting '...'. 11395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer unsigned NumArgs; 11405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1141942cfd37297528918616d06cd6e4e8bd6e4915a2Chris Lattner /// ArgInfo - There is an variable size array after the class in memory that 1142942cfd37297528918616d06cd6e4e8bd6e4915a2Chris Lattner /// holds the argument types. 11434b05b1dee6cc65ae61d93dab7edff72710f24589Ted Kremenek 11445f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer friend class ASTContext; // ASTContext creates these. 11454b05b1dee6cc65ae61d93dab7edff72710f24589Ted Kremenek 11465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 11475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer unsigned getNumArgs() const { return NumArgs; } 11485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType getArgType(unsigned i) const { 11495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer assert(i < NumArgs && "Invalid argument number!"); 1150942cfd37297528918616d06cd6e4e8bd6e4915a2Chris Lattner return arg_type_begin()[i]; 11515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 11525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 11535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isVariadic() const { return getSubClassData(); } 1154971c4fae6092976338b755af1d47dac07c8f16e3Argyrios Kyrtzidis unsigned getTypeQuals() const { return FunctionType::getTypeQuals(); } 11555f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 11565f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer typedef const QualType *arg_type_iterator; 1157942cfd37297528918616d06cd6e4e8bd6e4915a2Chris Lattner arg_type_iterator arg_type_begin() const { 1158942cfd37297528918616d06cd6e4e8bd6e4915a2Chris Lattner return reinterpret_cast<const QualType *>(this+1); 1159942cfd37297528918616d06cd6e4e8bd6e4915a2Chris Lattner } 1160942cfd37297528918616d06cd6e4e8bd6e4915a2Chris Lattner arg_type_iterator arg_type_end() const { return arg_type_begin()+NumArgs; } 11615f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 11625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void getAsStringInternal(std::string &InnerString) const; 11635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 11645f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const Type *T) { 11655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return T->getTypeClass() == FunctionProto; 11665f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 11675f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const FunctionTypeProto *) { return true; } 11685f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 11695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void Profile(llvm::FoldingSetNodeID &ID); 11705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static void Profile(llvm::FoldingSetNodeID &ID, QualType Result, 1171942cfd37297528918616d06cd6e4e8bd6e4915a2Chris Lattner arg_type_iterator ArgTys, unsigned NumArgs, 1172971c4fae6092976338b755af1d47dac07c8f16e3Argyrios Kyrtzidis bool isVariadic, unsigned TypeQuals); 117303ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek 117403ed44061df258e74a40383bda849e14b892a8c6Ted Kremenekprotected: 117503ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek virtual void EmitImpl(llvm::Serializer& S) const; 117603ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D); 117703ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek friend class Type; 11785f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 11795f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 11805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 11815f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass TypedefType : public Type { 11825f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer TypedefDecl *Decl; 1183c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanianprotected: 1184c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian TypedefType(TypeClass tc, TypedefDecl *D, QualType can) 1185898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor : Type(tc, can, can->isDependentType()), Decl(D) { 11865f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer assert(!isa<TypedefType>(can) && "Invalid canonical type"); 11875f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 11885f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer friend class ASTContext; // ASTContext creates these. 11895f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 11905f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 11915f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer TypedefDecl *getDecl() const { return Decl; } 1192a2c7767ce7d8feb10253f4b650826a20f3324c6fChris Lattner 1193a2c7767ce7d8feb10253f4b650826a20f3324c6fChris Lattner /// LookThroughTypedefs - Return the ultimate type this typedef corresponds to 1194fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor /// potentially looking through *all* consecutive typedefs. This returns the 1195a2c7767ce7d8feb10253f4b650826a20f3324c6fChris Lattner /// sum of the type qualifiers, so if you have: 1196a2c7767ce7d8feb10253f4b650826a20f3324c6fChris Lattner /// typedef const int A; 1197a2c7767ce7d8feb10253f4b650826a20f3324c6fChris Lattner /// typedef volatile A B; 1198a2c7767ce7d8feb10253f4b650826a20f3324c6fChris Lattner /// looking through the typedefs for B will give you "const volatile A". 1199a2c7767ce7d8feb10253f4b650826a20f3324c6fChris Lattner QualType LookThroughTypedefs() const; 12005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 12015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void getAsStringInternal(std::string &InnerString) const; 12025f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 12035f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const Type *T) { return T->getTypeClass() == TypeName; } 12045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const TypedefType *) { return true; } 1205b28166d11e788bc99fd5cd47c4f649ea0195c3b1Ted Kremenek 1206b28166d11e788bc99fd5cd47c4f649ea0195c3b1Ted Kremenekprotected: 1207b28166d11e788bc99fd5cd47c4f649ea0195c3b1Ted Kremenek virtual void EmitImpl(llvm::Serializer& S) const; 1208b28166d11e788bc99fd5cd47c4f649ea0195c3b1Ted Kremenek static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D); 1209b28166d11e788bc99fd5cd47c4f649ea0195c3b1Ted Kremenek friend class Type; 12105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 12115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1212d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff/// TypeOfExpr (GCC extension). 1213d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroffclass TypeOfExpr : public Type { 1214d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff Expr *TOExpr; 1215898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor TypeOfExpr(Expr *E, QualType can); 1216d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff friend class ASTContext; // ASTContext creates these. 1217d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroffpublic: 1218d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff Expr *getUnderlyingExpr() const { return TOExpr; } 1219d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff 1220d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff virtual void getAsStringInternal(std::string &InnerString) const; 1221d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff 1222d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff static bool classof(const Type *T) { return T->getTypeClass() == TypeOfExp; } 1223d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff static bool classof(const TypeOfExpr *) { return true; } 12248fbc5274c416967de5338778f685b7830464ad13Zhongxing Xu 12258fbc5274c416967de5338778f685b7830464ad13Zhongxing Xuprotected: 12268fbc5274c416967de5338778f685b7830464ad13Zhongxing Xu virtual void EmitImpl(llvm::Serializer& S) const; 12278fbc5274c416967de5338778f685b7830464ad13Zhongxing Xu static Type* CreateImpl(ASTContext& Context, llvm::Deserializer& D); 12288fbc5274c416967de5338778f685b7830464ad13Zhongxing Xu friend class Type; 1229d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff}; 1230d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff 1231d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff/// TypeOfType (GCC extension). 1232d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroffclass TypeOfType : public Type { 1233d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff QualType TOType; 1234898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor TypeOfType(QualType T, QualType can) 1235898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor : Type(TypeOfTyp, can, T->isDependentType()), TOType(T) { 1236d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff assert(!isa<TypedefType>(can) && "Invalid canonical type"); 1237d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff } 1238d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff friend class ASTContext; // ASTContext creates these. 1239d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroffpublic: 1240d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff QualType getUnderlyingType() const { return TOType; } 1241d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff 1242d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff virtual void getAsStringInternal(std::string &InnerString) const; 1243d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff 1244d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff static bool classof(const Type *T) { return T->getTypeClass() == TypeOfTyp; } 1245d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff static bool classof(const TypeOfType *) { return true; } 1246501c7252bd4752bc542630446494eb15b27f1f88Zhongxing Xu 1247501c7252bd4752bc542630446494eb15b27f1f88Zhongxing Xuprotected: 1248501c7252bd4752bc542630446494eb15b27f1f88Zhongxing Xu virtual void EmitImpl(llvm::Serializer& S) const; 1249501c7252bd4752bc542630446494eb15b27f1f88Zhongxing Xu static Type* CreateImpl(ASTContext& Context, llvm::Deserializer& D); 1250501c7252bd4752bc542630446494eb15b27f1f88Zhongxing Xu friend class Type; 1251d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff}; 12525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 12535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass TagType : public Type { 12540b7a158d120ac8d78c114a823e17eedfec6b6658Douglas Gregor /// Stores the TagDecl associated with this type. The decl will 12550b7a158d120ac8d78c114a823e17eedfec6b6658Douglas Gregor /// point to the TagDecl that actually defines the entity (or is a 12560b7a158d120ac8d78c114a823e17eedfec6b6658Douglas Gregor /// definition in progress), if there is such a definition. The 12570b7a158d120ac8d78c114a823e17eedfec6b6658Douglas Gregor /// single-bit value will be non-zero when this tag is in the 12580b7a158d120ac8d78c114a823e17eedfec6b6658Douglas Gregor /// process of being defined. 12590b7a158d120ac8d78c114a823e17eedfec6b6658Douglas Gregor llvm::PointerIntPair<TagDecl *, 1> decl; 12604b7c98378ae0c1a3635f0b7756848b4a9923f8bcTed Kremenek friend class ASTContext; 12610b7a158d120ac8d78c114a823e17eedfec6b6658Douglas Gregor friend class TagDecl; 12622ce52f3fb95bf544db6bd3d91a72bce7d9cceb6cDouglas Gregor 12632ce52f3fb95bf544db6bd3d91a72bce7d9cceb6cDouglas Gregorprotected: 1264898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor // FIXME: We'll need the user to pass in information about whether 1265898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor // this type is dependent or not, because we don't have enough 1266898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor // information to compute it here. 1267898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor TagType(TagDecl *D, QualType can) 12680b7a158d120ac8d78c114a823e17eedfec6b6658Douglas Gregor : Type(Tagged, can, /*Dependent=*/false), decl(D, 0) {} 12692ce52f3fb95bf544db6bd3d91a72bce7d9cceb6cDouglas Gregor 12702ce52f3fb95bf544db6bd3d91a72bce7d9cceb6cDouglas Gregorpublic: 12710b7a158d120ac8d78c114a823e17eedfec6b6658Douglas Gregor TagDecl *getDecl() const { return decl.getPointer(); } 12725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 12730b7a158d120ac8d78c114a823e17eedfec6b6658Douglas Gregor /// @brief Determines whether this type is in the process of being 12740b7a158d120ac8d78c114a823e17eedfec6b6658Douglas Gregor /// defined. 12750b7a158d120ac8d78c114a823e17eedfec6b6658Douglas Gregor bool isBeingDefined() const { return decl.getInt(); } 12760b7a158d120ac8d78c114a823e17eedfec6b6658Douglas Gregor void setBeingDefined(bool Def) { decl.setInt(Def? 1 : 0); } 12770b7a158d120ac8d78c114a823e17eedfec6b6658Douglas Gregor 12785f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void getAsStringInternal(std::string &InnerString) const; 12795f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 12805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const Type *T) { return T->getTypeClass() == Tagged; } 12815f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const TagType *) { return true; } 1282a225400804cc53dd9cf6b28cf0e8e7f103a7522fTed Kremenek 1283a225400804cc53dd9cf6b28cf0e8e7f103a7522fTed Kremenekprotected: 1284a225400804cc53dd9cf6b28cf0e8e7f103a7522fTed Kremenek virtual void EmitImpl(llvm::Serializer& S) const; 128521d50e12c3c412d8457071dc419363b7a7e8b855Ted Kremenek static Type* CreateImpl(ASTContext& Context, llvm::Deserializer& D); 1286a225400804cc53dd9cf6b28cf0e8e7f103a7522fTed Kremenek friend class Type; 12875f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 12885f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 12895edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner/// RecordType - This is a helper class that allows the use of isa/cast/dyncast 12905edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner/// to detect TagType objects of structs/unions/classes. 12915edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattnerclass RecordType : public TagType { 129249aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidisprotected: 1293509447e7cb9c24a9f2bd149fe95030050b088622Argyrios Kyrtzidis explicit RecordType(RecordDecl *D) 1294509447e7cb9c24a9f2bd149fe95030050b088622Argyrios Kyrtzidis : TagType(reinterpret_cast<TagDecl*>(D), QualType()) { } 12952ce52f3fb95bf544db6bd3d91a72bce7d9cceb6cDouglas Gregor friend class ASTContext; // ASTContext creates these. 12965edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattnerpublic: 12975edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner 12985edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner RecordDecl *getDecl() const { 12995edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner return reinterpret_cast<RecordDecl*>(TagType::getDecl()); 13005edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner } 13015edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner 13025edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner // FIXME: This predicate is a helper to QualType/Type. It needs to 13035edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner // recursively check all fields for const-ness. If any field is declared 13045edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner // const, it needs to return false. 13055edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner bool hasConstFields() const { return false; } 13065edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner 13075edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner // FIXME: RecordType needs to check when it is created that all fields are in 13085edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner // the same address space, and return that. 13095edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner unsigned getAddressSpace() const { return 0; } 13105edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner 13112daa5df1b53f7ef745d724771384409f6f5df5c1Chris Lattner static bool classof(const TagType *T); 13122daa5df1b53f7ef745d724771384409f6f5df5c1Chris Lattner static bool classof(const Type *T) { 13132daa5df1b53f7ef745d724771384409f6f5df5c1Chris Lattner return isa<TagType>(T) && classof(cast<TagType>(T)); 13142daa5df1b53f7ef745d724771384409f6f5df5c1Chris Lattner } 13155edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner static bool classof(const RecordType *) { return true; } 13165edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner}; 13175edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner 131849aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis/// CXXRecordType - This is a helper class that allows the use of 131949aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis/// isa/cast/dyncast to detect TagType objects of C++ structs/unions/classes. 132049aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidisclass CXXRecordType : public RecordType { 132149aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis explicit CXXRecordType(CXXRecordDecl *D) 132249aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis : RecordType(reinterpret_cast<RecordDecl*>(D)) { } 132349aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis friend class ASTContext; // ASTContext creates these. 132449aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidispublic: 132549aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis 132649aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis CXXRecordDecl *getDecl() const { 132749aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis return reinterpret_cast<CXXRecordDecl*>(RecordType::getDecl()); 132849aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis } 132949aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis 133049aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis static bool classof(const TagType *T); 133149aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis static bool classof(const Type *T) { 133249aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis return isa<TagType>(T) && classof(cast<TagType>(T)); 133349aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis } 133449aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis static bool classof(const CXXRecordType *) { return true; } 133549aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis}; 133649aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis 13375edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner/// EnumType - This is a helper class that allows the use of isa/cast/dyncast 13385edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner/// to detect TagType objects of enums. 13395edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattnerclass EnumType : public TagType { 1340509447e7cb9c24a9f2bd149fe95030050b088622Argyrios Kyrtzidis explicit EnumType(EnumDecl *D) 1341509447e7cb9c24a9f2bd149fe95030050b088622Argyrios Kyrtzidis : TagType(reinterpret_cast<TagDecl*>(D), QualType()) { } 13422ce52f3fb95bf544db6bd3d91a72bce7d9cceb6cDouglas Gregor friend class ASTContext; // ASTContext creates these. 13435edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattnerpublic: 13445edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner 13455edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner EnumDecl *getDecl() const { 13465edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner return reinterpret_cast<EnumDecl*>(TagType::getDecl()); 13475edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner } 13485edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner 13492daa5df1b53f7ef745d724771384409f6f5df5c1Chris Lattner static bool classof(const TagType *T); 13502daa5df1b53f7ef745d724771384409f6f5df5c1Chris Lattner static bool classof(const Type *T) { 13512daa5df1b53f7ef745d724771384409f6f5df5c1Chris Lattner return isa<TagType>(T) && classof(cast<TagType>(T)); 13522daa5df1b53f7ef745d724771384409f6f5df5c1Chris Lattner } 13535edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner static bool classof(const EnumType *) { return true; } 13545edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner}; 13555edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner 1356fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregorclass TemplateTypeParmType : public Type, public llvm::FoldingSetNode { 1357fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor unsigned Depth : 16; 1358fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor unsigned Index : 16; 1359fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor IdentifierInfo *Name; 136072c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor 1361fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor TemplateTypeParmType(unsigned D, unsigned I, IdentifierInfo *N, 1362fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor QualType Canon) 1363fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor : Type(TemplateTypeParm, Canon, /*Dependent=*/true), 1364fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor Depth(D), Index(I), Name(N) { } 136572c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor 1366fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor TemplateTypeParmType(unsigned D, unsigned I) 1367fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor : Type(TemplateTypeParm, QualType(this, 0), /*Dependent=*/true), 1368fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor Depth(D), Index(I), Name(0) { } 136972c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor 1370fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor friend class ASTContext; // ASTContext creates these 137172c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor 1372fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregorpublic: 1373fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor unsigned getDepth() const { return Depth; } 1374fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor unsigned getIndex() const { return Index; } 1375fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor IdentifierInfo *getName() const { return Name; } 1376fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor 137772c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor virtual void getAsStringInternal(std::string &InnerString) const; 13785edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner 1379fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor void Profile(llvm::FoldingSetNodeID &ID) { 1380fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor Profile(ID, Depth, Index, Name); 1381fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor } 1382fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor 1383fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor static void Profile(llvm::FoldingSetNodeID &ID, unsigned Depth, 1384fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor unsigned Index, IdentifierInfo *Name) { 1385fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor ID.AddInteger(Depth); 1386fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor ID.AddInteger(Index); 1387fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor ID.AddPointer(Name); 1388fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor } 1389fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor 139072c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor static bool classof(const Type *T) { 139172c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor return T->getTypeClass() == TemplateTypeParm; 139272c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor } 139372c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor static bool classof(const TemplateTypeParmType *T) { return true; } 139472c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor 139572c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregorprotected: 139672c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor virtual void EmitImpl(llvm::Serializer& S) const; 139772c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor static Type* CreateImpl(ASTContext& Context, llvm::Deserializer& D); 139872c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor friend class Type; 139972c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor}; 1400fab9d67cebb87be968e7ae31a3b549a5279b5d51Douglas Gregor 140155f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor/// \brief Represents the type of a class template specialization as 140255f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor/// written in the source code. 140355f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor/// 140455f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor/// Class template specialization types represent the syntactic form 140555f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor/// of a template-id that refers to a type, e.g., @c vector<int>. All 140655f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor/// class template specialization types are syntactic sugar, whose 140755f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor/// canonical type will point to some other type node that represents 140855f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor/// the instantiation or class template specialization. For example, a 140955f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor/// class template specialization type of @c vector<int> will refer to 141055f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor/// a tag type for the instantiation 141155f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor/// @c std::vector<int, std::allocator<int>>. 141255f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregorclass ClassTemplateSpecializationType 141355f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor : public Type, public llvm::FoldingSetNode { 141455f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 141555f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor // FIXME: Do we want templates to have a representation in the type 141655f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor // system? It will probably help with dependent templates and 141755f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor // possibly with template-names preceded by a nested-name-specifier. 141855f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor TemplateDecl *Template; 141955f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 142055f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor unsigned NumArgs; 142155f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 142255f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor ClassTemplateSpecializationType(TemplateDecl *T, unsigned NumArgs, 142355f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor uintptr_t *Args, bool *ArgIsType, 142455f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor QualType Canon); 142555f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 142655f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// \brief Retrieve the number of packed words that precede the 142755f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// actual arguments. 142855f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// 142955f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// The flags that specify whether each argument is a type or an 143055f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// expression are packed into the 143155f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// ClassTemplateSpecializationType. This routine computes the 143255f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// number of pointer-sized words we need to store this information, 143355f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// based on the number of template arguments 143455f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor static unsigned getNumPackedWords(unsigned NumArgs) { 143555f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor const unsigned BitsPerWord = sizeof(uintptr_t) * CHAR_BIT; 143655f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor return NumArgs / BitsPerWord + (NumArgs % BitsPerWord > 0); 143755f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor } 143855f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 143955f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// \brief Pack the given boolean values into words. 144055f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor static void 144155f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor packBooleanValues(unsigned NumArgs, bool *Values, uintptr_t *Words); 144255f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 144355f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor friend class ASTContext; // ASTContext creates these 144455f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 144555f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregorpublic: 144655f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// \brief Retrieve the template that we are specializing. 144755f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor TemplateDecl *getTemplate() const { return Template; } 144855f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 144955f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// \briefe Retrieve the number of template arguments. 145055f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor unsigned getNumArgs() const { return NumArgs; } 145155f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 145255f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// \brief Retrieve a specific template argument as a type. 145355f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// \precondition @c isArgType(Arg) 145455f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor QualType getArgAsType(unsigned Arg) const { 145555f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor assert(isArgType(Arg) && "Argument is not a type"); 145655f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor return QualType::getFromOpaquePtr( 145755f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor reinterpret_cast<void *>(getArgAsOpaqueValue(Arg))); 145855f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor } 145955f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 146055f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// \brief Retrieve a specific template argument as an expression. 146155f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// \precondition @c !isArgType(Arg) 146255f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor Expr *getArgAsExpr(unsigned Arg) const { 146355f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor assert(!isArgType(Arg) && "Argument is not an expression"); 146455f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor return reinterpret_cast<Expr *>(getArgAsOpaqueValue(Arg)); 146555f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor } 146655f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 146755f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// \brief Retrieve the specified template argument as an opaque value. 146855f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor uintptr_t getArgAsOpaqueValue(unsigned Arg) const; 146955f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 147055f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor /// \brief Determine whether the given template argument is a type. 147155f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor bool isArgType(unsigned Arg) const; 147255f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 147355f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor virtual void getAsStringInternal(std::string &InnerString) const; 147455f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 147555f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor void Profile(llvm::FoldingSetNodeID &ID) { 147655f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor // Add the template 147755f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor ID.AddPointer(Template); 147855f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 147955f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor // Add the packed words describing what kind of template arguments 148055f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor // we have. 148155f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor uintptr_t *Data = reinterpret_cast<uintptr_t *>(this + 1); 148255f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor for (unsigned Packed = 0, NumPacked = getNumPackedWords(NumArgs); 148355f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor Packed != NumPacked; ++Packed) 148455f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor ID.AddInteger(Data[Packed]); 148555f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 148655f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor // Add the template arguments themselves. 148755f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor for (unsigned Arg = 0; Arg < NumArgs; ++Arg) 148855f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor ID.AddInteger(getArgAsOpaqueValue(Arg)); 148955f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor } 149055f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 149155f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor static void Profile(llvm::FoldingSetNodeID &ID, TemplateDecl *T, 149255f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor unsigned NumArgs, uintptr_t *Args, bool *ArgIsType) { 149355f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor // Add the template 149455f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor ID.AddPointer(T); 149555f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 149655f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor // Add the packed words describing what kind of template arguments 149755f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor // we have. 149855f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor unsigned NumPackedWords = getNumPackedWords(NumArgs); 149955f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor unsigned NumPackedBytes = NumPackedWords * sizeof(uintptr_t); 150055f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor uintptr_t *PackedWords 150155f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor = reinterpret_cast<uintptr_t *>(alloca(NumPackedBytes)); 150255f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor packBooleanValues(NumArgs, ArgIsType, PackedWords); 150355f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor for (unsigned Packed = 0; Packed != NumPackedWords; ++Packed) 150455f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor ID.AddInteger(PackedWords[Packed]); 150555f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 150655f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor // Add the template arguments themselves. 150755f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor for (unsigned Arg = 0; Arg < NumArgs; ++Arg) 150855f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor ID.AddInteger(Args[Arg]); 150955f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor } 151055f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 151155f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor static bool classof(const Type *T) { 151255f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor return T->getTypeClass() == ClassTemplateSpecialization; 151355f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor } 151455f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor static bool classof(const ClassTemplateSpecializationType *T) { return true; } 151555f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 151655f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregorprotected: 151755f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor virtual void EmitImpl(llvm::Serializer& S) const; 151855f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor static Type* CreateImpl(ASTContext& Context, llvm::Deserializer& D); 151955f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor friend class Type; 152055f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor}; 152155f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 1522fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner/// ObjCInterfaceType - Interfaces are the core concept in Objective-C for 1523fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner/// object oriented design. They basically correspond to C++ classes. There 1524fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner/// are two kinds of interface types, normal interfaces like "NSString" and 1525fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner/// qualified interfaces, which are qualified with a protocol list like 1526fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner/// "NSString<NSCopyable, NSAmazing>". Qualified interface types are instances 1527fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner/// of ObjCQualifiedInterfaceType, which is a subclass of ObjCInterfaceType. 1528a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCInterfaceType : public Type { 1529a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *Decl; 153006cef25d0b8c383217413f061441c7ea40d1052bFariborz Jahanianprotected: 1531a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceType(TypeClass tc, ObjCInterfaceDecl *D) : 1532898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor Type(tc, QualType(), /*Dependent=*/false), Decl(D) { } 15333536b443bc50d58a79f14fca9b6842541a434854Steve Naroff friend class ASTContext; // ASTContext creates these. 15343536b443bc50d58a79f14fca9b6842541a434854Steve Naroffpublic: 15353536b443bc50d58a79f14fca9b6842541a434854Steve Naroff 1536a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *getDecl() const { return Decl; } 15373536b443bc50d58a79f14fca9b6842541a434854Steve Naroff 1538fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner /// qual_iterator and friends: this provides access to the (potentially empty) 1539fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner /// list of protocols qualifying this interface. If this is an instance of 1540fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner /// ObjCQualifiedInterfaceType it returns the list, otherwise it returns an 1541fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner /// empty list if there are no qualifying protocols. 1542fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner typedef llvm::SmallVector<ObjCProtocolDecl*, 8>::const_iterator qual_iterator; 1543fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner inline qual_iterator qual_begin() const; 1544fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner inline qual_iterator qual_end() const; 1545fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner bool qual_empty() const { return getTypeClass() != ObjCQualifiedInterface; } 1546fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner 1547fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner /// getNumProtocols - Return the number of qualifying protocols in this 1548fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner /// interface type, or 0 if there are none. 1549fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner inline unsigned getNumProtocols() const; 1550fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner 15519baefc21bfe1bf49ab4a234e9f267f00abe0b1b1Chris Lattner /// getProtocol - Return the specified qualifying protocol. 15529baefc21bfe1bf49ab4a234e9f267f00abe0b1b1Chris Lattner inline ObjCProtocolDecl *getProtocol(unsigned i) const; 15534b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian 1554fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner 1555fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner virtual void getAsStringInternal(std::string &InnerString) const; 15563536b443bc50d58a79f14fca9b6842541a434854Steve Naroff static bool classof(const Type *T) { 1557368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner return T->getTypeClass() == ObjCInterface || 1558368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner T->getTypeClass() == ObjCQualifiedInterface; 15593536b443bc50d58a79f14fca9b6842541a434854Steve Naroff } 1560a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCInterfaceType *) { return true; } 15613536b443bc50d58a79f14fca9b6842541a434854Steve Naroff}; 15623536b443bc50d58a79f14fca9b6842541a434854Steve Naroff 1563a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCQualifiedInterfaceType - This class represents interface types 1564372bed091b6b1eca596130208e227e7077154de4Chris Lattner/// conforming to a list of protocols, such as INTF<Proto1, Proto2, Proto1>. 1565372bed091b6b1eca596130208e227e7077154de4Chris Lattner/// 1566878520b6413663a13b1b56c7e3f256b1ecbb8db4Fariborz Jahanian/// Duplicate protocols are removed and protocol list is canonicalized to be in 1567878520b6413663a13b1b56c7e3f256b1ecbb8db4Fariborz Jahanian/// alphabetical order. 1568a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCQualifiedInterfaceType : public ObjCInterfaceType, 156906cef25d0b8c383217413f061441c7ea40d1052bFariborz Jahanian public llvm::FoldingSetNode { 157006cef25d0b8c383217413f061441c7ea40d1052bFariborz Jahanian 1571e37882ad335896dedf345102bb425383e6221c37Fariborz Jahanian // List of protocols for this protocol conforming object type 1572e37882ad335896dedf345102bb425383e6221c37Fariborz Jahanian // List is sorted on protocol name. No protocol is enterred more than once. 1573fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner llvm::SmallVector<ObjCProtocolDecl*, 4> Protocols; 1574e37882ad335896dedf345102bb425383e6221c37Fariborz Jahanian 1575a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCQualifiedInterfaceType(ObjCInterfaceDecl *D, 1576065f0d7b00c3cd2b3139ebd105f50462fc778859Chris Lattner ObjCProtocolDecl **Protos, unsigned NumP) : 1577a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceType(ObjCQualifiedInterface, D), 157800bb283ecdfb1d5c69261c7663d166cee3f11a9bChris Lattner Protocols(Protos, Protos+NumP) { } 15794b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian friend class ASTContext; // ASTContext creates these. 1580e37882ad335896dedf345102bb425383e6221c37Fariborz Jahanianpublic: 1581e37882ad335896dedf345102bb425383e6221c37Fariborz Jahanian 15829baefc21bfe1bf49ab4a234e9f267f00abe0b1b1Chris Lattner ObjCProtocolDecl *getProtocol(unsigned i) const { 15834b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian return Protocols[i]; 15844b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian } 15854b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian unsigned getNumProtocols() const { 15864b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian return Protocols.size(); 15874b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian } 1588065f0d7b00c3cd2b3139ebd105f50462fc778859Chris Lattner 1589065f0d7b00c3cd2b3139ebd105f50462fc778859Chris Lattner qual_iterator qual_begin() const { return Protocols.begin(); } 1590065f0d7b00c3cd2b3139ebd105f50462fc778859Chris Lattner qual_iterator qual_end() const { return Protocols.end(); } 1591065f0d7b00c3cd2b3139ebd105f50462fc778859Chris Lattner 15924b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian virtual void getAsStringInternal(std::string &InnerString) const; 15934b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian 15944b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian void Profile(llvm::FoldingSetNodeID &ID); 15954b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian static void Profile(llvm::FoldingSetNodeID &ID, 15961ee0700c7dbe3554df09b4558e0b35a53d487ff2Chris Lattner const ObjCInterfaceDecl *Decl, 1597a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCProtocolDecl **protocols, unsigned NumProtocols); 15984b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian 1599e37882ad335896dedf345102bb425383e6221c37Fariborz Jahanian static bool classof(const Type *T) { 1600a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek return T->getTypeClass() == ObjCQualifiedInterface; 1601e37882ad335896dedf345102bb425383e6221c37Fariborz Jahanian } 1602a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCQualifiedInterfaceType *) { return true; } 1603e37882ad335896dedf345102bb425383e6221c37Fariborz Jahanian}; 1604fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner 1605fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattnerinline ObjCInterfaceType::qual_iterator ObjCInterfaceType::qual_begin() const { 1606fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner if (const ObjCQualifiedInterfaceType *QIT = 1607fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner dyn_cast<ObjCQualifiedInterfaceType>(this)) 1608fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner return QIT->qual_begin(); 1609fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner return 0; 1610fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner} 1611fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattnerinline ObjCInterfaceType::qual_iterator ObjCInterfaceType::qual_end() const { 1612fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner if (const ObjCQualifiedInterfaceType *QIT = 1613fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner dyn_cast<ObjCQualifiedInterfaceType>(this)) 1614fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner return QIT->qual_end(); 1615fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner return 0; 1616fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner} 1617fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner 1618fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner/// getNumProtocols - Return the number of qualifying protocols in this 1619fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner/// interface type, or 0 if there are none. 1620fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattnerinline unsigned ObjCInterfaceType::getNumProtocols() const { 1621fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner if (const ObjCQualifiedInterfaceType *QIT = 1622fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner dyn_cast<ObjCQualifiedInterfaceType>(this)) 1623fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner return QIT->getNumProtocols(); 1624fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner return 0; 1625fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner} 1626fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner 16279baefc21bfe1bf49ab4a234e9f267f00abe0b1b1Chris Lattner/// getProtocol - Return the specified qualifying protocol. 16289baefc21bfe1bf49ab4a234e9f267f00abe0b1b1Chris Lattnerinline ObjCProtocolDecl *ObjCInterfaceType::getProtocol(unsigned i) const { 16299baefc21bfe1bf49ab4a234e9f267f00abe0b1b1Chris Lattner return cast<ObjCQualifiedInterfaceType>(this)->getProtocol(i); 1630fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner} 1631fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner 1632fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner 1633c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian 1634372bed091b6b1eca596130208e227e7077154de4Chris Lattner/// ObjCQualifiedIdType - to represent id<protocol-list>. 1635372bed091b6b1eca596130208e227e7077154de4Chris Lattner/// 1636372bed091b6b1eca596130208e227e7077154de4Chris Lattner/// Duplicate protocols are removed and protocol list is canonicalized to be in 1637372bed091b6b1eca596130208e227e7077154de4Chris Lattner/// alphabetical order. 1638a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCQualifiedIdType : public Type, 1639c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian public llvm::FoldingSetNode { 1640c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian // List of protocols for this protocol conforming 'id' type 1641c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian // List is sorted on protocol name. No protocol is enterred more than once. 1642a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek llvm::SmallVector<ObjCProtocolDecl*, 8> Protocols; 1643c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian 164462f5f7ffad57e0c2af2b308af3735351505937cbChris Lattner ObjCQualifiedIdType(ObjCProtocolDecl **Protos, unsigned NumP) 1645898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor : Type(ObjCQualifiedId, QualType()/*these are always canonical*/, 16464b4218f48fef71a179c5a8287dae281580faf52fNate Begeman /*Dependent=*/false), 1647c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian Protocols(Protos, Protos+NumP) { } 1648c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian friend class ASTContext; // ASTContext creates these. 1649c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanianpublic: 1650c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian 1651a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCProtocolDecl *getProtocols(unsigned i) const { 1652c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian return Protocols[i]; 1653c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian } 1654c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian unsigned getNumProtocols() const { 1655c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian return Protocols.size(); 1656c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian } 1657a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCProtocolDecl **getReferencedProtocols() { 1658411f373abf5692a1bd90d35a139d955fa67ae82dFariborz Jahanian return &Protocols[0]; 1659065f0d7b00c3cd2b3139ebd105f50462fc778859Chris Lattner } 1660065f0d7b00c3cd2b3139ebd105f50462fc778859Chris Lattner 1661065f0d7b00c3cd2b3139ebd105f50462fc778859Chris Lattner typedef llvm::SmallVector<ObjCProtocolDecl*, 8>::const_iterator qual_iterator; 1662065f0d7b00c3cd2b3139ebd105f50462fc778859Chris Lattner qual_iterator qual_begin() const { return Protocols.begin(); } 1663065f0d7b00c3cd2b3139ebd105f50462fc778859Chris Lattner qual_iterator qual_end() const { return Protocols.end(); } 1664c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian 1665c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian virtual void getAsStringInternal(std::string &InnerString) const; 1666c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian 1667c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian void Profile(llvm::FoldingSetNodeID &ID); 166862f5f7ffad57e0c2af2b308af3735351505937cbChris Lattner static void Profile(llvm::FoldingSetNodeID &ID, 1669a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCProtocolDecl **protocols, unsigned NumProtocols); 1670c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian 1671c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian static bool classof(const Type *T) { 1672a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek return T->getTypeClass() == ObjCQualifiedId; 1673c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian } 1674a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCQualifiedIdType *) { return true; } 1675c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian 1676c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian}; 1677e37882ad335896dedf345102bb425383e6221c37Fariborz Jahanian 16785f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1679611c1fff195d32df97706e0920c92468b2509900Chris Lattner// Inline function definitions. 16805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1681ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb/// getUnqualifiedType - Return the type without any qualifiers. 1682ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lambinline QualType QualType::getUnqualifiedType() const { 1683f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner Type *TP = getTypePtr(); 1684f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner if (const ASQualType *ASQT = dyn_cast<ASQualType>(TP)) 1685f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner TP = ASQT->getBaseType(); 1686f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner return QualType(TP, 0); 1687ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb} 1688ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb 1689ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb/// getAddressSpace - Return the address space of this type. 1690ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lambinline unsigned QualType::getAddressSpace() const { 16914243a94b43ef6207938f3023dfcfb804dd545363Chris Lattner QualType CT = getTypePtr()->getCanonicalTypeInternal(); 16924243a94b43ef6207938f3023dfcfb804dd545363Chris Lattner if (const ArrayType *AT = dyn_cast<ArrayType>(CT)) 1693c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner return AT->getElementType().getAddressSpace(); 16944243a94b43ef6207938f3023dfcfb804dd545363Chris Lattner if (const RecordType *RT = dyn_cast<RecordType>(CT)) 16958e7dafec4b70303dfaff95151cd06bfc5532720cNate Begeman return RT->getAddressSpace(); 16964243a94b43ef6207938f3023dfcfb804dd545363Chris Lattner if (const ASQualType *ASQT = dyn_cast<ASQualType>(CT)) 1697ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb return ASQT->getAddressSpace(); 1698ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb return 0; 1699ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb} 1700611c1fff195d32df97706e0920c92468b2509900Chris Lattner 1701e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor/// isMoreQualifiedThan - Determine whether this type is more 1702e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor/// qualified than the Other type. For example, "const volatile int" 1703e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor/// is more qualified than "const int", "volatile int", and 1704e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor/// "int". However, it is not more qualified than "const volatile 1705e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor/// int". 1706e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregorinline bool QualType::isMoreQualifiedThan(QualType Other) const { 1707e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor // FIXME: Handle address spaces 1708e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor unsigned MyQuals = this->getCVRQualifiers(); 1709e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor unsigned OtherQuals = Other.getCVRQualifiers(); 1710ba7e210a999275695f58be03ef402758cfec3635Douglas Gregor assert(this->getAddressSpace() == 0 && "Address space not checked"); 1711ba7e210a999275695f58be03ef402758cfec3635Douglas Gregor assert(Other.getAddressSpace() == 0 && "Address space not checked"); 1712e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor return MyQuals != OtherQuals && (MyQuals | OtherQuals) == MyQuals; 1713e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor} 1714e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor 1715e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor/// isAtLeastAsQualifiedAs - Determine whether this type is at last 1716e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor/// as qualified as the Other type. For example, "const volatile 1717e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor/// int" is at least as qualified as "const int", "volatile int", 1718e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor/// "int", and "const volatile int". 1719e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregorinline bool QualType::isAtLeastAsQualifiedAs(QualType Other) const { 1720e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor // FIXME: Handle address spaces 1721e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor unsigned MyQuals = this->getCVRQualifiers(); 1722e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor unsigned OtherQuals = Other.getCVRQualifiers(); 1723ba7e210a999275695f58be03ef402758cfec3635Douglas Gregor assert(this->getAddressSpace() == 0 && "Address space not checked"); 1724ba7e210a999275695f58be03ef402758cfec3635Douglas Gregor assert(Other.getAddressSpace() == 0 && "Address space not checked"); 1725e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor return (MyQuals | OtherQuals) == MyQuals; 1726e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor} 1727e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor 1728e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor/// getNonReferenceType - If Type is a reference type (e.g., const 1729e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor/// int&), returns the type that the reference refers to ("const 1730e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor/// int"). Otherwise, returns the type itself. This routine is used 1731e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor/// throughout Sema to implement C++ 5p6: 1732e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor/// 1733e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor/// If an expression initially has the type "reference to T" (8.3.2, 1734e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor/// 8.5.3), the type is adjusted to "T" prior to any further 1735e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor/// analysis, the expression designates the object or function 1736e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor/// denoted by the reference, and the expression is an lvalue. 1737e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregorinline QualType QualType::getNonReferenceType() const { 1738e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor if (const ReferenceType *RefType = (*this)->getAsReferenceType()) 1739e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor return RefType->getPointeeType(); 1740e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor else 1741e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor return *this; 1742e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor} 1743e0a5d5fe8eab573f7764bf6d2ddb02bee8dceaf9Douglas Gregor 1744769c9cfc6e06bd9d8ffe7a4397b939f19b0e4dc3Ted Kremenekinline const TypedefType* Type::getAsTypedefType() const { 1745769c9cfc6e06bd9d8ffe7a4397b939f19b0e4dc3Ted Kremenek return dyn_cast<TypedefType>(this); 1746769c9cfc6e06bd9d8ffe7a4397b939f19b0e4dc3Ted Kremenek} 17472b1cc8be4dda4cd122485be0168b3c43d7dff15fChris Lattnerinline const ObjCInterfaceType *Type::getAsPointerToObjCInterfaceType() const { 17482b1cc8be4dda4cd122485be0168b3c43d7dff15fChris Lattner if (const PointerType *PT = getAsPointerType()) 17492b1cc8be4dda4cd122485be0168b3c43d7dff15fChris Lattner return PT->getPointeeType()->getAsObjCInterfaceType(); 17502b1cc8be4dda4cd122485be0168b3c43d7dff15fChris Lattner return 0; 17512b1cc8be4dda4cd122485be0168b3c43d7dff15fChris Lattner} 17522b1cc8be4dda4cd122485be0168b3c43d7dff15fChris Lattner 1753c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner// NOTE: All of these methods use "getUnqualifiedType" to strip off address 1754c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner// space qualifiers if present. 1755611c1fff195d32df97706e0920c92468b2509900Chris Lattnerinline bool Type::isFunctionType() const { 1756ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb return isa<FunctionType>(CanonicalType.getUnqualifiedType()); 1757611c1fff195d32df97706e0920c92468b2509900Chris Lattner} 1758611c1fff195d32df97706e0920c92468b2509900Chris Lattnerinline bool Type::isPointerType() const { 1759ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb return isa<PointerType>(CanonicalType.getUnqualifiedType()); 1760611c1fff195d32df97706e0920c92468b2509900Chris Lattner} 17615618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroffinline bool Type::isBlockPointerType() const { 17625618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff return isa<BlockPointerType>(CanonicalType); 17635618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff} 1764bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattnerinline bool Type::isReferenceType() const { 1765bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner return isa<ReferenceType>(CanonicalType.getUnqualifiedType()); 1766bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner} 1767bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattnerinline bool Type::isPointerLikeType() const { 1768bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner return isa<PointerLikeType>(CanonicalType.getUnqualifiedType()); 1769bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner} 1770498b0d1aba38f5ec64d566d1dd9e6be237ecc50fTed Kremenekinline bool Type::isFunctionPointerType() const { 177101c2c6e3c94a3fa2ac15851b4af5de6dc3ae2af8Ted Kremenek if (const PointerType* T = getAsPointerType()) 1772498b0d1aba38f5ec64d566d1dd9e6be237ecc50fTed Kremenek return T->getPointeeType()->isFunctionType(); 1773498b0d1aba38f5ec64d566d1dd9e6be237ecc50fTed Kremenek else 1774498b0d1aba38f5ec64d566d1dd9e6be237ecc50fTed Kremenek return false; 1775498b0d1aba38f5ec64d566d1dd9e6be237ecc50fTed Kremenek} 1776f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redlinline bool Type::isMemberPointerType() const { 1777f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl return isa<MemberPointerType>(CanonicalType.getUnqualifiedType()); 1778f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl} 1779f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redlinline bool Type::isMemberFunctionPointerType() const { 1780f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl if (const MemberPointerType* T = getAsMemberPointerType()) 1781f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl return T->getPointeeType()->isFunctionType(); 1782f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl else 1783f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl return false; 1784f30208ad5b334e93582e846a2a0c92f38a607b8aSebastian Redl} 1785611c1fff195d32df97706e0920c92468b2509900Chris Lattnerinline bool Type::isArrayType() const { 1786ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb return isa<ArrayType>(CanonicalType.getUnqualifiedType()); 1787611c1fff195d32df97706e0920c92468b2509900Chris Lattner} 1788c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattnerinline bool Type::isConstantArrayType() const { 1789c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner return isa<ConstantArrayType>(CanonicalType.getUnqualifiedType()); 1790c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner} 1791c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattnerinline bool Type::isIncompleteArrayType() const { 1792c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner return isa<IncompleteArrayType>(CanonicalType.getUnqualifiedType()); 1793c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner} 1794c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattnerinline bool Type::isVariableArrayType() const { 1795c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner return isa<VariableArrayType>(CanonicalType.getUnqualifiedType()); 1796c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner} 1797898574e7496ba8fd76290079d3a9d06954992734Douglas Gregorinline bool Type::isDependentSizedArrayType() const { 1798898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor return isa<DependentSizedArrayType>(CanonicalType.getUnqualifiedType()); 1799898574e7496ba8fd76290079d3a9d06954992734Douglas Gregor} 1800611c1fff195d32df97706e0920c92468b2509900Chris Lattnerinline bool Type::isRecordType() const { 1801ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb return isa<RecordType>(CanonicalType.getUnqualifiedType()); 1802611c1fff195d32df97706e0920c92468b2509900Chris Lattner} 1803f23d364084d1aabea688222780d6fc1dd8c7f78cChris Lattnerinline bool Type::isAnyComplexType() const { 1804c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner return isa<ComplexType>(CanonicalType.getUnqualifiedType()); 1805f23d364084d1aabea688222780d6fc1dd8c7f78cChris Lattner} 1806611c1fff195d32df97706e0920c92468b2509900Chris Lattnerinline bool Type::isVectorType() const { 1807ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb return isa<VectorType>(CanonicalType.getUnqualifiedType()); 1808611c1fff195d32df97706e0920c92468b2509900Chris Lattner} 1809213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begemaninline bool Type::isExtVectorType() const { 1810213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman return isa<ExtVectorType>(CanonicalType.getUnqualifiedType()); 1811611c1fff195d32df97706e0920c92468b2509900Chris Lattner} 1812a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekinline bool Type::isObjCInterfaceType() const { 1813c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner return isa<ObjCInterfaceType>(CanonicalType.getUnqualifiedType()); 1814368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner} 1815368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattnerinline bool Type::isObjCQualifiedInterfaceType() const { 1816c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner return isa<ObjCQualifiedInterfaceType>(CanonicalType.getUnqualifiedType()); 1817e7f64cc250245aa6c0e1ef6da7e9b6f62d5feddeFariborz Jahanian} 1818a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekinline bool Type::isObjCQualifiedIdType() const { 1819c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner return isa<ObjCQualifiedIdType>(CanonicalType.getUnqualifiedType()); 1820d58fabf7ed279be18a5e82617f809c9deff9be67Fariborz Jahanian} 182172c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregorinline bool Type::isTemplateTypeParmType() const { 182272c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor return isa<TemplateTypeParmType>(CanonicalType.getUnqualifiedType()); 182372c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor} 182472c3f314d92d65c050ee1c07b7753623c044d6c7Douglas Gregor 1825904eed3f6148758d39a2d3c88f3133274460d645Douglas Gregorinline bool Type::isOverloadType() const { 1826904eed3f6148758d39a2d3c88f3133274460d645Douglas Gregor if (const BuiltinType *BT = getAsBuiltinType()) 1827904eed3f6148758d39a2d3c88f3133274460d645Douglas Gregor return BT->getKind() == BuiltinType::Overload; 1828904eed3f6148758d39a2d3c88f3133274460d645Douglas Gregor else 1829904eed3f6148758d39a2d3c88f3133274460d645Douglas Gregor return false; 1830904eed3f6148758d39a2d3c88f3133274460d645Douglas Gregor} 1831904eed3f6148758d39a2d3c88f3133274460d645Douglas Gregor 183222caddc91d2f6186739c6b20ec58ed38cd68e595Chris Lattner/// Insertion operator for diagnostics. This allows sending QualType's into a 183322caddc91d2f6186739c6b20ec58ed38cd68e595Chris Lattner/// diagnostic with <<. 183422caddc91d2f6186739c6b20ec58ed38cd68e595Chris Lattnerinline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, 183522caddc91d2f6186739c6b20ec58ed38cd68e595Chris Lattner QualType T) { 183622caddc91d2f6186739c6b20ec58ed38cd68e595Chris Lattner DB.AddTaggedVal(reinterpret_cast<intptr_t>(T.getAsOpaquePtr()), 183722caddc91d2f6186739c6b20ec58ed38cd68e595Chris Lattner Diagnostic::ak_qualtype); 183822caddc91d2f6186739c6b20ec58ed38cd68e595Chris Lattner return DB; 183922caddc91d2f6186739c6b20ec58ed38cd68e595Chris Lattner} 184022caddc91d2f6186739c6b20ec58ed38cd68e595Chris Lattner 18415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end namespace clang 18425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 18435f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif 1844