Type.h revision 98cd599ee8a9b259ed7388ee2921a20d97658864
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 175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "llvm/Support/Casting.h" 185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "llvm/ADT/FoldingSet.h" 19fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff#include "llvm/ADT/APSInt.h" 2073af669633e13c813f80cd15ecf3e6414778aee4Ted Kremenek#include "llvm/Bitcode/SerializationFwd.h" 215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerusing llvm::isa; 235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerusing llvm::cast; 245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerusing llvm::cast_or_null; 255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerusing llvm::dyn_cast; 265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerusing llvm::dyn_cast_or_null; 275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang { 295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer class ASTContext; 305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer class Type; 315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer class TypedefDecl; 325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer class TagDecl; 335f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer class RecordDecl; 3449aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis class CXXRecordDecl; 355f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer class EnumDecl; 3621d50e12c3c412d8457071dc419363b7a7e8b855Ted Kremenek class FieldDecl; 37a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek class ObjCInterfaceDecl; 38a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek class ObjCProtocolDecl; 39a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek class ObjCMethodDecl; 405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer class Expr; 41b3064041583eb134fbf56906728bf752bc65b572Ted Kremenek class Stmt; 425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer class SourceLocation; 43bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner class PointerLikeType; 443acb13805673d47be95829bd5a4b1707952c0b6fChris Lattner class PointerType; 455618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff class BlockPointerType; 46251dcaf8616c6f04051e214f35cadb7de42aef7eBill Wendling class ReferenceType; 473acb13805673d47be95829bd5a4b1707952c0b6fChris Lattner class VectorType; 48700204c74b455746752e851b25565ebf932f5340Steve Naroff class ArrayType; 49d7444aac1af1c2c1d5e5b7467ecf6006ee2d8abeSteve Naroff class ConstantArrayType; 50d7444aac1af1c2c1d5e5b7467ecf6006ee2d8abeSteve Naroff class VariableArrayType; 51c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman class IncompleteArrayType; 52dfa6aae5a119a527e537c35566ba3272fd8c5d74Steve Naroff class RecordType; 53ad74a758189180b8ab8faea648e4766c3bfd7fcbEli Friedman class EnumType; 54c6fb90a7246c2d5d3233e70107bf9d8c7c9e535bChris Lattner class ComplexType; 557064f5c95bbdb17680d0ea658d4090898c2592d3Steve Naroff class TagType; 56769c9cfc6e06bd9d8ffe7a4397b939f19b0e4dc3Ted Kremenek class TypedefType; 577064f5c95bbdb17680d0ea658d4090898c2592d3Steve Naroff class FunctionType; 58b77792eabf5882cf9af8cc810599b20432fda6c2Chris Lattner class FunctionTypeProto; 59213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman class ExtVectorType; 6077878cc5aa6ad01fc0c91bac1a61819dbf3bf691Steve Naroff class BuiltinType; 61368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner class ObjCInterfaceType; 62368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner class ObjCQualifiedIdType; 63a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek class ObjCQualifiedInterfaceType; 6492866e2e90f6d93fb95e25a7ac4438e239d89ce6Ted Kremenek class StmtIteratorBase; 655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 665f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// QualType - For efficiency, we don't store CVR-qualified types as nodes on 675f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// their own: instead each reference to a type stores the qualifiers. This 685f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// greatly reduces the number of nodes we need to allocate for types (for 695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// example we only need one for 'int', 'const int', 'volatile int', 705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 'const volatile int', etc). 715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// As an added efficiency bonus, instead of making this a pair, we just store 735f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// the three bits we care about in the low bits of the pointer. To handle the 745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// packing/unpacking, we make QualType be a simple wrapper class that acts like 755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// a smart pointer. 765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass QualType { 775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer uintptr_t ThePtr; 785f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 795f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer enum TQ { // NOTE: These flags must be kept in sync with DeclSpec::TQ. 805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Const = 0x1, 815f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Restrict = 0x2, 825f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Volatile = 0x4, 835f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer CVRFlags = Const|Restrict|Volatile 845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer }; 855f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 865f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType() : ThePtr(0) {} 875f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 885f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType(Type *Ptr, unsigned Quals) { 895f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer assert((Quals & ~CVRFlags) == 0 && "Invalid type qualifiers!"); 9083ba14e260193a67bba3772134d1d428a1b1c394Steve Naroff ThePtr = reinterpret_cast<uintptr_t>(Ptr); 9183ba14e260193a67bba3772134d1d428a1b1c394Steve Naroff assert((ThePtr & CVRFlags) == 0 && "Type pointer not 8-byte aligned?"); 9283ba14e260193a67bba3772134d1d428a1b1c394Steve Naroff ThePtr |= Quals; 9383ba14e260193a67bba3772134d1d428a1b1c394Steve Naroff } 9483ba14e260193a67bba3772134d1d428a1b1c394Steve Naroff 9583ba14e260193a67bba3772134d1d428a1b1c394Steve Naroff QualType(const Type *Ptr, unsigned Quals) { 9683ba14e260193a67bba3772134d1d428a1b1c394Steve Naroff assert((Quals & ~CVRFlags) == 0 && "Invalid type qualifiers!"); 975f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ThePtr = reinterpret_cast<uintptr_t>(Ptr); 985f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer assert((ThePtr & CVRFlags) == 0 && "Type pointer not 8-byte aligned?"); 995f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ThePtr |= Quals; 1005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1025f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static QualType getFromOpaquePtr(void *Ptr) { 1035f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType T; 1045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer T.ThePtr = reinterpret_cast<uintptr_t>(Ptr); 1055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return T; 1065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 108f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner unsigned getCVRQualifiers() const { 1095f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return ThePtr & CVRFlags; 1105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Type *getTypePtr() const { 1125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return reinterpret_cast<Type*>(ThePtr & ~CVRFlags); 1135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void *getAsOpaquePtr() const { 1165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return reinterpret_cast<void*>(ThePtr); 1175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1195f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Type &operator*() const { 1205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return *getTypePtr(); 1215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Type *operator->() const { 1245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return getTypePtr(); 1255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// isNull - Return true if this QualType doesn't point to a type yet. 1285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isNull() const { 1295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return ThePtr == 0; 1305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isConstQualified() const { 133b8128140956c6f8f0ab143818775a81f4b4aa477Chris Lattner return (ThePtr & Const) ? true : false; 1345f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1355f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isVolatileQualified() const { 136b8128140956c6f8f0ab143818775a81f4b4aa477Chris Lattner return (ThePtr & Volatile) ? true : false; 1375f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isRestrictQualified() const { 139b8128140956c6f8f0ab143818775a81f4b4aa477Chris Lattner return (ThePtr & Restrict) ? true : false; 1405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 141b381aac9bae6d608c72267dd0ed08ec6369e94e4Nuno Lopes 142b381aac9bae6d608c72267dd0ed08ec6369e94e4Nuno Lopes bool isConstant(ASTContext& Ctx) const; 1437effa1aceac1219529af23c776835f855b8d905cChris Lattner 1447effa1aceac1219529af23c776835f855b8d905cChris Lattner /// addConst/addVolatile/addRestrict - add the specified type qual to this 1457effa1aceac1219529af23c776835f855b8d905cChris Lattner /// QualType. 1467effa1aceac1219529af23c776835f855b8d905cChris Lattner void addConst() { ThePtr |= Const; } 1477effa1aceac1219529af23c776835f855b8d905cChris Lattner void addVolatile() { ThePtr |= Volatile; } 1487effa1aceac1219529af23c776835f855b8d905cChris Lattner void addRestrict() { ThePtr |= Restrict; } 1495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1501c6a38bcea17801e9a4738753aee845381af2b6cSanjiv Gupta void removeConst() { ThePtr &= ~Const; } 1511c6a38bcea17801e9a4738753aee845381af2b6cSanjiv Gupta void removeVolatile() { ThePtr &= ~Volatile; } 1521c6a38bcea17801e9a4738753aee845381af2b6cSanjiv Gupta void removeRestrict() { ThePtr &= ~Restrict; } 1531c6a38bcea17801e9a4738753aee845381af2b6cSanjiv Gupta 1545f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType getQualifiedType(unsigned TQs) const { 1555f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return QualType(getTypePtr(), TQs); 1565f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 157c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner QualType getWithAdditionalQualifiers(unsigned TQs) const { 158c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner return QualType(getTypePtr(), TQs|getCVRQualifiers()); 159c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner } 1605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 161ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb inline QualType getUnqualifiedType() const; 1625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 16398cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor /// isMoreQualifiedThan - Determine whether this type is more 16498cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor /// qualified than the Other type. For example, "const volatile int" 16598cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor /// is more qualified than "const int", "volatile int", and 16698cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor /// "int". However, it is not more qualified than "const volatile 16798cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor /// int". 16898cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor bool isMoreQualifiedThan(QualType Other) const { 16998cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor unsigned MyQuals = this->getCVRQualifiers(); 17098cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor unsigned OtherQuals = Other.getCVRQualifiers(); 17198cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor return MyQuals != OtherQuals && (MyQuals | OtherQuals) == MyQuals; 17298cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor } 17398cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor 17498cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor /// isAtLeastAsQualifiedAs - Determine whether this type is at last 17598cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor /// as qualified as the Other type. For example, "const volatile 17698cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor /// int" is at least as qualified as "const int", "volatile int", 17798cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor /// "int", and "const volatile int". 17898cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor bool isAtLeastAsQualifiedAs(QualType Other) const { 17998cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor unsigned MyQuals = this->getCVRQualifiers(); 18098cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor unsigned OtherQuals = Other.getCVRQualifiers(); 18198cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor return MyQuals | OtherQuals == MyQuals; 18298cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor } 18398cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor 1845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// operator==/!= - Indicate whether the specified types and qualifiers are 1855f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// identical. 1865f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool operator==(const QualType &RHS) const { 1875f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return ThePtr == RHS.ThePtr; 1885f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1895f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool operator!=(const QualType &RHS) const { 1905f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return ThePtr != RHS.ThePtr; 1915f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1925f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer std::string getAsString() const { 1935f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer std::string S; 1945f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer getAsStringInternal(S); 1955f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return S; 1965f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1975f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void getAsStringInternal(std::string &Str) const; 1985f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 199c36d405a02fab41f6c45cb2bc750d64949742903Chris Lattner void dump(const char *s) const; 200c36d405a02fab41f6c45cb2bc750d64949742903Chris Lattner void dump() const; 2013f2dcb1ca8bd2d5d3ccc5c80f4ab06f949d88a89Ted Kremenek 2023f2dcb1ca8bd2d5d3ccc5c80f4ab06f949d88a89Ted Kremenek void Profile(llvm::FoldingSetNodeID &ID) const { 2033f2dcb1ca8bd2d5d3ccc5c80f4ab06f949d88a89Ted Kremenek ID.AddPointer(getAsOpaquePtr()); 2043f2dcb1ca8bd2d5d3ccc5c80f4ab06f949d88a89Ted Kremenek } 2055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 206368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattnerpublic: 2075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 208ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb /// getAddressSpace - Return the address space of this type. 209ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb inline unsigned getAddressSpace() const; 210ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb 21103ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek /// Emit - Serialize a QualType to Bitcode. 21273af669633e13c813f80cd15ecf3e6414778aee4Ted Kremenek void Emit(llvm::Serializer& S) const; 21373af669633e13c813f80cd15ecf3e6414778aee4Ted Kremenek 21403ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek /// Read - Deserialize a QualType from Bitcode. 21503ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek static QualType ReadVal(llvm::Deserializer& D); 21621d50e12c3c412d8457071dc419363b7a7e8b855Ted Kremenek 21721d50e12c3c412d8457071dc419363b7a7e8b855Ted Kremenek void ReadBackpatch(llvm::Deserializer& D); 2185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 2195f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end clang. 2215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace llvm { 2235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// Implement simplify_type for QualType, so that we can dyn_cast from QualType 2245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// to a specific Type class. 2255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencertemplate<> struct simplify_type<const ::clang::QualType> { 2265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer typedef ::clang::Type* SimpleType; 2275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static SimpleType getSimplifiedValue(const ::clang::QualType &Val) { 2285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return Val.getTypePtr(); 2295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 2305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 2315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencertemplate<> struct simplify_type< ::clang::QualType> 2325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer : public simplify_type<const ::clang::QualType> {}; 23373af669633e13c813f80cd15ecf3e6414778aee4Ted Kremenek 23473af669633e13c813f80cd15ecf3e6414778aee4Ted Kremenek} // end namespace llvm 2355f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang { 2375f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// Type - This is the base class of the type hierarchy. A central concept 2395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// with types is that each type always has a canonical type. A canonical type 2405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// is the type with any typedef names stripped out of it or the types it 2415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// references. For example, consider: 2425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 2435f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// typedef int foo; 2445f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// typedef foo* bar; 2455f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 'int *' 'foo *' 'bar' 2465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 2475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// There will be a Type object created for 'int'. Since int is canonical, its 2485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// canonicaltype pointer points to itself. There is also a Type for 'foo' (a 2495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// TypeNameType). Its CanonicalType pointer points to the 'int' Type. Next 2505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// there is a PointerType that represents 'int*', which, like 'int', is 2515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// canonical. Finally, there is a PointerType type for 'foo*' whose canonical 2525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// type is 'int*', and there is a TypeNameType for 'bar', whose canonical type 2535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// is also 'int*'. 2545f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 2555f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// Non-canonical types are useful for emitting diagnostics, without losing 2565f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// information about typedefs being used. Canonical types are useful for type 2575f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// comparisons (they allow by-pointer equality tests) and useful for reasoning 2585f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// about whether something has a particular form (e.g. is a function type), 2595f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// because they implicitly, recursively, strip all typedefs out of a type. 2605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 2615f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// Types, once created, are immutable. 2625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 2635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass Type { 2645f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 2655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer enum TypeClass { 266fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff Builtin, Complex, Pointer, Reference, 267c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman ConstantArray, VariableArray, IncompleteArray, 268213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman Vector, ExtVector, 2695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer FunctionNoProto, FunctionProto, 270ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb TypeName, Tagged, ASQual, 271a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterface, ObjCQualifiedInterface, 272a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCQualifiedId, 2735618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff TypeOfExp, TypeOfTyp, // GNU typeof extension. 2745618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff BlockPointer // C extension 2755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer }; 2765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerprivate: 2775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType CanonicalType; 2785f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2795f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// TypeClass bitfield - Enum that specifies what subclass this belongs to. 2805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// Note that this should stay at the end of the ivars for Type so that 2815f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// subclasses can pack their bitfields into the same word. 282ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb unsigned TC : 5; 2835f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerprotected: 284124dd7b5777e29ecac006822bd4d4623f0dc4264Hartmut Kaiser // silence VC++ warning C4355: 'this' : used in base member initializer list 285124dd7b5777e29ecac006822bd4d4623f0dc4264Hartmut Kaiser Type *this_() { return this; } 2865f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Type(TypeClass tc, QualType Canonical) 287f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner : CanonicalType(Canonical.isNull() ? QualType(this_(), 0) : Canonical), 288f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner TC(tc) {} 2894b05b1dee6cc65ae61d93dab7edff72710f24589Ted Kremenek virtual ~Type() {}; 2904b05b1dee6cc65ae61d93dab7edff72710f24589Ted Kremenek virtual void Destroy(ASTContext& C); 2915f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer friend class ASTContext; 29273af669633e13c813f80cd15ecf3e6414778aee4Ted Kremenek 29373af669633e13c813f80cd15ecf3e6414778aee4Ted Kremenek void EmitTypeInternal(llvm::Serializer& S) const; 29473af669633e13c813f80cd15ecf3e6414778aee4Ted Kremenek void ReadTypeInternal(llvm::Deserializer& D); 29573af669633e13c813f80cd15ecf3e6414778aee4Ted Kremenek 2968b9023ba35a86838789e2c9034a6128728c547aaChris Lattnerpublic: 297a8ae51f79d35b7c1822ba4a086176b4a8c862862Hartmut Kaiser TypeClass getTypeClass() const { return static_cast<TypeClass>(TC); } 2985f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2995f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isCanonical() const { return CanonicalType.getTypePtr() == this; } 3005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 3015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// Types are partitioned into 3 broad categories (C99 6.2.5p1): 3025f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// object types, function types, and incomplete types. 3035f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 3045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// isObjectType - types that fully describe objects. An object is a region 3055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// of memory that can be examined and stored into (H&S). 3065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isObjectType() const; 3075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 3085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// isIncompleteType - Return true if this is an incomplete type. 3095f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// A type that can describe objects, but which lacks information needed to 3105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// determine its size (e.g. void, or a fwd declared struct). Clients of this 3115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// routine will need to determine if the size is actually required. 3125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isIncompleteType() const; 313d805bec0fbb98aa10abbb41bfdcb2e2fab1bac96Chris Lattner 314d805bec0fbb98aa10abbb41bfdcb2e2fab1bac96Chris Lattner /// isIncompleteOrObjectType - Return true if this is an incomplete or object 315d805bec0fbb98aa10abbb41bfdcb2e2fab1bac96Chris Lattner /// type, in other words, not a function type. 316d805bec0fbb98aa10abbb41bfdcb2e2fab1bac96Chris Lattner bool isIncompleteOrObjectType() const { 317d805bec0fbb98aa10abbb41bfdcb2e2fab1bac96Chris Lattner return !isFunctionType(); 318d805bec0fbb98aa10abbb41bfdcb2e2fab1bac96Chris Lattner } 3195f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 320d7444aac1af1c2c1d5e5b7467ecf6006ee2d8abeSteve Naroff /// isVariablyModifiedType (C99 6.7.5.2p2) - Return true for variable array 321d7444aac1af1c2c1d5e5b7467ecf6006ee2d8abeSteve Naroff /// types that have a non-constant expression. This does not include "[]". 322d7444aac1af1c2c1d5e5b7467ecf6006ee2d8abeSteve Naroff bool isVariablyModifiedType() const; 323d7444aac1af1c2c1d5e5b7467ecf6006ee2d8abeSteve Naroff 3245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// Helper methods to distinguish type categories. All type predicates 325ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb /// operate on the canonical type, ignoring typedefs and qualifiers. 32696d2c438f5c9ada8229f7f2ac049d2e9957bc954Steve Naroff 32796d2c438f5c9ada8229f7f2ac049d2e9957bc954Steve Naroff /// isIntegerType() does *not* include complex integers (a GCC extension). 32896d2c438f5c9ada8229f7f2ac049d2e9957bc954Steve Naroff /// isComplexIntegerType() can be used to test for complex integers. 3295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isIntegerType() const; // C99 6.2.5p17 (int, char, bool, enum) 33013b7c5ff42d6077a8d59e2c9ec9e7fedd0150ae6Steve Naroff bool isEnumeralType() const; 33113b7c5ff42d6077a8d59e2c9ec9e7fedd0150ae6Steve Naroff bool isBooleanType() const; 33213b7c5ff42d6077a8d59e2c9ec9e7fedd0150ae6Steve Naroff bool isCharType() const; 33377a52233f7c0f162672652051bfe78b65ad4f789Douglas Gregor bool isWideCharType() const; 33433e1d64ab5cd5d27f8530ccd056191fe2c9f3f2eFariborz Jahanian bool isIntegralType() const; 3355f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 3365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// Floating point categories. 3375f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isRealFloatingType() const; // C99 6.2.5p10 (float, double, long double) 33802f62a9fedbc370fba081303399410a3afdde29fSteve Naroff /// isComplexType() does *not* include complex integers (a GCC extension). 33902f62a9fedbc370fba081303399410a3afdde29fSteve Naroff /// isComplexIntegerType() can be used to test for complex integers. 3405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isComplexType() const; // C99 6.2.5p11 (complex) 341f23d364084d1aabea688222780d6fc1dd8c7f78cChris Lattner bool isAnyComplexType() const; // C99 6.2.5p11 (complex) + Complex Int. 3425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isFloatingType() const; // C99 6.2.5p11 (real floating + complex) 3435f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isRealType() const; // C99 6.2.5p17 (real floating + integer) 3445f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isArithmeticType() const; // C99 6.2.5p18 (integer + floating) 345c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner bool isVoidType() const; // C99 6.2.5p19 346c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner bool isDerivedType() const; // C99 6.2.5p20 347c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner bool isScalarType() const; // C99 6.2.5p21 (arithmetic + pointers) 348c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner bool isAggregateType() const; // C99 6.2.5p21 (arrays, structures) 3495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 350c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner // Type Predicates: Check to see if this type is structurally the specified 351ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb // type, ignoring typedefs and qualifiers. 352c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner bool isFunctionType() const; 353bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner bool isPointerLikeType() const; // Pointer or Reference. 354befee48ff2a1dab236c5700f00ecca1cfdcd5837Chris Lattner bool isPointerType() const; 3555618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff bool isBlockPointerType() const; 356a1d9fdea79ba7bbd71862b9f9f78f5f117331fc7Chris Lattner bool isReferenceType() const; 357bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner bool isFunctionPointerType() const; 358c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner bool isArrayType() const; 359c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner bool isConstantArrayType() const; 360c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner bool isIncompleteArrayType() const; 361c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner bool isVariableArrayType() const; 362c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner bool isRecordType() const; 36399dc91422144483c20d1c7381bc9ac634b646b04Chris Lattner bool isClassType() const; 364c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner bool isStructureType() const; 3654cdec1c3ca80124024a787ce32833fd5b20cbb15Steve Naroff bool isUnionType() const; 366368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner bool isComplexIntegerType() const; // GCC _Complex integer type. 367368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner bool isVectorType() const; // GCC vector type. 368213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman bool isExtVectorType() const; // Extended vector type. 369368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner bool isObjCInterfaceType() const; // NSString or NSString<foo> 370368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner bool isObjCQualifiedInterfaceType() const; // NSString<foo> 371368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner bool isObjCQualifiedIdType() const; // id<foo> 372c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner 373c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner // Type Checking Functions: Check to see if this type is structurally the 374f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner // specified type, ignoring typedefs and qualifiers, and return a pointer to 375f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner // the best type we can. 37677878cc5aa6ad01fc0c91bac1a61819dbf3bf691Steve Naroff const BuiltinType *getAsBuiltinType() const; 377c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner const FunctionType *getAsFunctionType() const; 378b77792eabf5882cf9af8cc810599b20432fda6c2Chris Lattner const FunctionTypeProto *getAsFunctionTypeProto() const; 379bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner const PointerLikeType *getAsPointerLikeType() const; // Pointer or Reference. 380befee48ff2a1dab236c5700f00ecca1cfdcd5837Chris Lattner const PointerType *getAsPointerType() const; 3815618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff const BlockPointerType *getAsBlockPointerType() const; 382a1d9fdea79ba7bbd71862b9f9f78f5f117331fc7Chris Lattner const ReferenceType *getAsReferenceType() const; 383c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner const RecordType *getAsRecordType() const; 384769c9cfc6e06bd9d8ffe7a4397b939f19b0e4dc3Ted Kremenek const RecordType *getAsStructureType() const; 385c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner /// NOTE: getAsArrayType* are methods on ASTContext. 386769c9cfc6e06bd9d8ffe7a4397b939f19b0e4dc3Ted Kremenek const TypedefType *getAsTypedefType() const; 387c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner const RecordType *getAsUnionType() const; 388ad74a758189180b8ab8faea648e4766c3bfd7fcbEli Friedman const EnumType *getAsEnumType() const; 389c8629630ce3e7f0da231bf10a4b39240caaac68aChris Lattner const VectorType *getAsVectorType() const; // GCC vector type. 390c6fb90a7246c2d5d3233e70107bf9d8c7c9e535bChris Lattner const ComplexType *getAsComplexType() const; 3914cdec1c3ca80124024a787ce32833fd5b20cbb15Steve Naroff const ComplexType *getAsComplexIntegerType() const; // GCC complex int type. 392213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman const ExtVectorType *getAsExtVectorType() const; // Extended vector type. 393368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner const ObjCInterfaceType *getAsObjCInterfaceType() const; 394368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner const ObjCQualifiedInterfaceType *getAsObjCQualifiedInterfaceType() const; 395368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner const ObjCQualifiedIdType *getAsObjCQualifiedIdType() const; 396c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner 3972b1cc8be4dda4cd122485be0168b3c43d7dff15fChris Lattner /// getAsPointerToObjCInterfaceType - If this is a pointer to an ObjC 3982b1cc8be4dda4cd122485be0168b3c43d7dff15fChris Lattner /// interface, return the interface type, otherwise return null. 3992b1cc8be4dda4cd122485be0168b3c43d7dff15fChris Lattner const ObjCInterfaceType *getAsPointerToObjCInterfaceType() const; 4002b1cc8be4dda4cd122485be0168b3c43d7dff15fChris Lattner 401c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner /// getArrayElementTypeNoTypeQual - If this is an array type, return the 402c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner /// element type of the array, potentially with type qualifiers missing. 403c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner /// This method should never be used when type qualifiers are meaningful. 404c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner const Type *getArrayElementTypeNoTypeQual() const; 405c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner 406c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner 4075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 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) : 467ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb Type(ASQual, CanonicalPtr), BaseType(Base), AddressSpace(AddrSpace) { 468ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb } 469ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb friend class ASTContext; // ASTContext creates these. 470ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lambpublic: 471f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner Type *getBaseType() const { return BaseType; } 472ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb unsigned getAddressSpace() const { return AddressSpace; } 473ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb 474ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb virtual void getAsStringInternal(std::string &InnerString) const; 475ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb 476ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb void Profile(llvm::FoldingSetNodeID &ID) { 477ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb Profile(ID, getBaseType(), AddressSpace); 478ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb } 479f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner static void Profile(llvm::FoldingSetNodeID &ID, Type *Base, 480ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb unsigned AddrSpace) { 481f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner ID.AddPointer(Base); 482ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb ID.AddInteger(AddrSpace); 483ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb } 484ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb 485ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb static bool classof(const Type *T) { return T->getTypeClass() == ASQual; } 486ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb static bool classof(const ASQualType *) { return true; } 487ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb 488ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lambprotected: 489ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb virtual void EmitImpl(llvm::Serializer& S) const; 490ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D); 491ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb friend class Type; 492ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb}; 493ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb 494ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb 4955f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// BuiltinType - This class is used for builtin types like 'int'. Builtin 4965f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// types are always canonical and have a literal name field. 4975f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass BuiltinType : public Type { 4985f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 4995f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer enum Kind { 5005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Void, 5015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5025f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Bool, // This is bool and/or _Bool. 5035f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Char_U, // This is 'char' for targets where char is unsigned. 5045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer UChar, // This is explicitly qualified unsigned char. 5055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer UShort, 5065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer UInt, 5075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ULong, 5085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ULongLong, 5095f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Char_S, // This is 'char' for targets where char is signed. 5115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer SChar, // This is explicitly qualified signed char. 5122ff9b4c7c8fed9233a0b8de2e9507368c451aab6Argyrios Kyrtzidis WChar, // This is 'wchar_t' for C++. 5135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Short, 5145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Int, 5155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Long, 5165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer LongLong, 5175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5188e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregor Float, Double, LongDouble, 5198e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregor 5208e9bebdea69c590dedfbf27374114cb76fe12fbdDouglas Gregor Overload // This represents the type of an overloaded function declaration. 5215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer }; 5225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerprivate: 5235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Kind TypeKind; 5245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 5255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer BuiltinType(Kind K) : Type(Builtin, QualType()), TypeKind(K) {} 5265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Kind getKind() const { return TypeKind; } 5285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer const char *getName() const; 5295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void getAsStringInternal(std::string &InnerString) const; 5315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const Type *T) { return T->getTypeClass() == Builtin; } 5335f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const BuiltinType *) { return true; } 5345f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 5355f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// ComplexType - C99 6.2.5p11 - Complex values. This supports the C99 complex 5375f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// types (_Complex float etc) as well as the GCC integer complex extensions. 5385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 5395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass ComplexType : public Type, public llvm::FoldingSetNode { 5405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType ElementType; 5415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ComplexType(QualType Element, QualType CanonicalPtr) : 5425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Type(Complex, CanonicalPtr), ElementType(Element) { 5435f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 5445f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer friend class ASTContext; // ASTContext creates these. 5455f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 5465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType getElementType() const { return ElementType; } 5475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void getAsStringInternal(std::string &InnerString) const; 54903ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek 5505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void Profile(llvm::FoldingSetNodeID &ID) { 5515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Profile(ID, getElementType()); 5525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 5535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static void Profile(llvm::FoldingSetNodeID &ID, QualType Element) { 5545f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ID.AddPointer(Element.getAsOpaquePtr()); 5555f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 5565f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5575f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const Type *T) { return T->getTypeClass() == Complex; } 5585f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const ComplexType *) { return true; } 55973af669633e13c813f80cd15ecf3e6414778aee4Ted Kremenek 56003ed44061df258e74a40383bda849e14b892a8c6Ted Kremenekprotected: 56103ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek virtual void EmitImpl(llvm::Serializer& S) const; 56203ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D); 56303ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek friend class Type; 5645f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 5655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 566bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner/// PointerLikeType - Common base class for pointers and references. 56739218dfef550ad1cd7b7ece83a715996a113ffd1Steve Naroff/// FIXME: Add more documentation on this classes design point. For example, 56839218dfef550ad1cd7b7ece83a715996a113ffd1Steve Naroff/// should BlockPointerType inherit from it? Is the concept of a PointerLikeType 56939218dfef550ad1cd7b7ece83a715996a113ffd1Steve Naroff/// in the C++ standard? 570bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner/// 571bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattnerclass PointerLikeType : public Type { 572bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner QualType PointeeType; 573bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattnerprotected: 574bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner PointerLikeType(TypeClass K, QualType Pointee, QualType CanonicalPtr) : 575bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner Type(K, CanonicalPtr), PointeeType(Pointee) { 576bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner } 577bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattnerpublic: 578bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner 579bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner QualType getPointeeType() const { return PointeeType; } 580bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner 581bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner static bool classof(const Type *T) { 582bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner return T->getTypeClass() == Pointer || T->getTypeClass() == Reference; 583bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner } 584bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner static bool classof(const PointerLikeType *) { return true; } 585bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner}; 5865f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5875f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// PointerType - C99 6.7.5.1 - Pointer Declarators. 5885f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 589bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattnerclass PointerType : public PointerLikeType, public llvm::FoldingSetNode { 5905f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer PointerType(QualType Pointee, QualType CanonicalPtr) : 591bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner PointerLikeType(Pointer, Pointee, CanonicalPtr) { 5925f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 5935f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer friend class ASTContext; // ASTContext creates these. 5945f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 5955f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5965f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void getAsStringInternal(std::string &InnerString) const; 5975f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5985f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void Profile(llvm::FoldingSetNodeID &ID) { 5995f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Profile(ID, getPointeeType()); 6005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 6015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static void Profile(llvm::FoldingSetNodeID &ID, QualType Pointee) { 6025f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ID.AddPointer(Pointee.getAsOpaquePtr()); 6035f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 6045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 6055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const Type *T) { return T->getTypeClass() == Pointer; } 6065f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const PointerType *) { return true; } 60703ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek 60803ed44061df258e74a40383bda849e14b892a8c6Ted Kremenekprotected: 60903ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek virtual void EmitImpl(llvm::Serializer& S) const; 61003ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D); 61103ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek friend class Type; 6125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 6135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 6145618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff/// BlockPointerType - pointer to a block type. 6155618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff/// This type is to represent types syntactically represented as 6165618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff/// "void (^)(int)", etc. Pointee is required to always be a function type. 61739218dfef550ad1cd7b7ece83a715996a113ffd1Steve Naroff/// FIXME: Should BlockPointerType inherit from PointerLikeType? It could 61839218dfef550ad1cd7b7ece83a715996a113ffd1Steve Naroff/// simplfy some type checking code, however PointerLikeType doesn't appear 61939218dfef550ad1cd7b7ece83a715996a113ffd1Steve Naroff/// to be used by the type checker. 6205618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff/// 6215618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroffclass BlockPointerType : public Type, public llvm::FoldingSetNode { 6225618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff QualType PointeeType; // Block is some kind of pointer type 6235618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff BlockPointerType(QualType Pointee, QualType CanonicalCls) : 6245618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff Type(BlockPointer, CanonicalCls), PointeeType(Pointee) { 6255618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff } 6265618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff friend class ASTContext; // ASTContext creates these. 6275618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroffpublic: 6285618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff 6295618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff // Get the pointee type. Pointee is required to always be a function type. 6305618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff QualType getPointeeType() const { return PointeeType; } 6315618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff 6325618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff virtual void getAsStringInternal(std::string &InnerString) const; 6335618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff 6345618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff void Profile(llvm::FoldingSetNodeID &ID) { 6355618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff Profile(ID, getPointeeType()); 6365618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff } 6375618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff static void Profile(llvm::FoldingSetNodeID &ID, QualType Pointee) { 6385618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff ID.AddPointer(Pointee.getAsOpaquePtr()); 6395618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff } 6405618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff 6415618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff static bool classof(const Type *T) { 6425618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff return T->getTypeClass() == BlockPointer; 6435618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff } 6445618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff static bool classof(const BlockPointerType *) { return true; } 6455618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff 6465618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff protected: 6475618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff virtual void EmitImpl(llvm::Serializer& S) const; 6485618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D); 6495618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff friend class Type; 6505618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff}; 6515618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff 6525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// ReferenceType - C++ 8.3.2 - Reference Declarators. 6535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 654bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattnerclass ReferenceType : public PointerLikeType, public llvm::FoldingSetNode { 6555f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ReferenceType(QualType Referencee, QualType CanonicalRef) : 656bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner PointerLikeType(Reference, Referencee, CanonicalRef) { 6575f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 6585f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer friend class ASTContext; // ASTContext creates these. 6595f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 6605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void getAsStringInternal(std::string &InnerString) const; 6615f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 6625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void Profile(llvm::FoldingSetNodeID &ID) { 663bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner Profile(ID, getPointeeType()); 6645f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 6655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static void Profile(llvm::FoldingSetNodeID &ID, QualType Referencee) { 6665f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ID.AddPointer(Referencee.getAsOpaquePtr()); 6675f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 6685f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 6695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const Type *T) { return T->getTypeClass() == Reference; } 6705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const ReferenceType *) { return true; } 6715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 6725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 6735f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// ArrayType - C99 6.7.5.2 - Array Declarators. 6745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 6752e7d352dbec06755105237afba183492d31d03cbTed Kremenekclass ArrayType : public Type, public llvm::FoldingSetNode { 6765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 6775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ArraySizeModifier - Capture whether this is a normal array (e.g. int X[4]) 6785f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// an array with a static size (e.g. int X[static 4]), or with a star size 679c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff /// (e.g. int X[*]). 'static' is only allowed on function parameters. 6805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer enum ArraySizeModifier { 6815f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Normal, Static, Star 6825f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer }; 6835f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerprivate: 684fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff /// ElementType - The element type of the array. 685fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff QualType ElementType; 686c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff 687ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek // NOTE: VC++ treats enums as signed, avoid using the ArraySizeModifier enum 688c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff /// NOTE: These fields are packed into the bitfields space in the Type class. 689ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek unsigned SizeModifier : 2; 690c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff 691c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff /// IndexTypeQuals - Capture qualifiers in declarations like: 692c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff /// 'int X[static restrict 4]'. For function parameters only. 693c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff unsigned IndexTypeQuals : 3; 694c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff 695fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroffprotected: 696c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff ArrayType(TypeClass tc, QualType et, QualType can, 697c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff ArraySizeModifier sm, unsigned tq) 698c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff : Type(tc, can), ElementType(et), SizeModifier(sm), IndexTypeQuals(tq) {} 699fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff friend class ASTContext; // ASTContext creates these. 700fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroffpublic: 701fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff QualType getElementType() const { return ElementType; } 702ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek ArraySizeModifier getSizeModifier() const { 703ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek return ArraySizeModifier(SizeModifier); 704ca63fa00786e51c207c829f4182f11a6c6b552beTed Kremenek } 705c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff unsigned getIndexTypeQualifier() const { return IndexTypeQuals; } 706fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff 707fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff static bool classof(const Type *T) { 708fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff return T->getTypeClass() == ConstantArray || 709c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman T->getTypeClass() == VariableArray || 710c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman T->getTypeClass() == IncompleteArray; 711fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff } 712fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff static bool classof(const ArrayType *) { return true; } 713fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff}; 714fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff 715da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// ConstantArrayType - This class represents C arrays with a specified constant 716da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// size. For example 'int A[100]' has ConstantArrayType where the element type 717da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// is 'int' and the size is 100. 7182e7d352dbec06755105237afba183492d31d03cbTed Kremenekclass ConstantArrayType : public ArrayType { 719fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff llvm::APInt Size; // Allows us to unique the type. 720fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff 721c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff ConstantArrayType(QualType et, QualType can, llvm::APInt sz, 722c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff ArraySizeModifier sm, unsigned tq) 723c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff : ArrayType(ConstantArray, et, can, sm, tq), Size(sz) {} 724fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff friend class ASTContext; // ASTContext creates these. 725fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroffpublic: 726c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner const llvm::APInt &getSize() const { return Size; } 727fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff virtual void getAsStringInternal(std::string &InnerString) const; 728fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff 729fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff void Profile(llvm::FoldingSetNodeID &ID) { 730fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff Profile(ID, getElementType(), getSize()); 731fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff } 732fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff static void Profile(llvm::FoldingSetNodeID &ID, QualType ET, 733fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff llvm::APInt ArraySize) { 734fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff ID.AddPointer(ET.getAsOpaquePtr()); 735fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff ID.AddInteger(ArraySize.getZExtValue()); 736fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff } 737fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff static bool classof(const Type *T) { 738fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff return T->getTypeClass() == ConstantArray; 739fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff } 740fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff static bool classof(const ConstantArrayType *) { return true; } 741da5dbb4a0ad091791bdb0dad1b9ceba3c04a7f5cTed Kremenek 742da5dbb4a0ad091791bdb0dad1b9ceba3c04a7f5cTed Kremenekprotected: 743da5dbb4a0ad091791bdb0dad1b9ceba3c04a7f5cTed Kremenek virtual void EmitImpl(llvm::Serializer& S) const; 744da5dbb4a0ad091791bdb0dad1b9ceba3c04a7f5cTed Kremenek static Type* CreateImpl(ASTContext& Context, llvm::Deserializer& D); 745da5dbb4a0ad091791bdb0dad1b9ceba3c04a7f5cTed Kremenek friend class Type; 746fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff}; 747fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff 748da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// IncompleteArrayType - This class represents C arrays with an unspecified 749da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// size. For example 'int A[]' has an IncompleteArrayType where the element 750da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// type is 'int' and the size is unspecified. 751c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedmanclass IncompleteArrayType : public ArrayType { 752c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman IncompleteArrayType(QualType et, QualType can, 753c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman ArraySizeModifier sm, unsigned tq) 754c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman : ArrayType(IncompleteArray, et, can, sm, tq) {} 755c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman friend class ASTContext; // ASTContext creates these. 756c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedmanpublic: 757c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman 758c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman virtual void getAsStringInternal(std::string &InnerString) const; 759c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman 760c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman static bool classof(const Type *T) { 761c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman return T->getTypeClass() == IncompleteArray; 762c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman } 763c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman static bool classof(const IncompleteArrayType *) { return true; } 764c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman 765c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman friend class StmtIteratorBase; 766c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman 767c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman void Profile(llvm::FoldingSetNodeID &ID) { 768c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman Profile(ID, getElementType()); 769c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman } 770c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman 771c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman static void Profile(llvm::FoldingSetNodeID &ID, QualType ET) { 772c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman ID.AddPointer(ET.getAsOpaquePtr()); 773c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman } 774c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman 775c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedmanprotected: 776c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman virtual void EmitImpl(llvm::Serializer& S) const; 777c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D); 778c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman friend class Type; 779c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman}; 780c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman 781da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// VariableArrayType - This class represents C arrays with a specified size 782da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// which is not an integer-constant-expression. For example, 'int s[x+foo()]'. 783da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// Since the size expression is an arbitrary expression, we store it as such. 784da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// 785da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// Note: VariableArrayType's aren't uniqued (since the expressions aren't) and 786da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// should not be: two lexically equivalent variable array types could mean 787da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// different things, for example, these variables do not have the same type 788da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// dynamically: 789da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// 790da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// void foo(int x) { 791da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// int Y[x]; 792da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// ++x; 793da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// int Z[x]; 794da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// } 795da2d71a50fe724c881b148fcc2c05a5e9b56e3a5Chris Lattner/// 7962e7d352dbec06755105237afba183492d31d03cbTed Kremenekclass VariableArrayType : public ArrayType { 797fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff /// SizeExpr - An assignment expression. VLA's are only permitted within 798fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff /// a function block. 799b3064041583eb134fbf56906728bf752bc65b572Ted Kremenek Stmt *SizeExpr; 8005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 801c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff VariableArrayType(QualType et, QualType can, Expr *e, 802c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff ArraySizeModifier sm, unsigned tq) 803b3064041583eb134fbf56906728bf752bc65b572Ted Kremenek : ArrayType(VariableArray, et, can, sm, tq), SizeExpr((Stmt*) e) {} 8045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer friend class ASTContext; // ASTContext creates these. 8054b05b1dee6cc65ae61d93dab7edff72710f24589Ted Kremenek virtual void Destroy(ASTContext& C); 8064b05b1dee6cc65ae61d93dab7edff72710f24589Ted Kremenek 8075f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 808c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner Expr *getSizeExpr() const { 809b3064041583eb134fbf56906728bf752bc65b572Ted Kremenek // We use C-style casts instead of cast<> here because we do not wish 810b3064041583eb134fbf56906728bf752bc65b572Ted Kremenek // to have a dependency of Type.h on Stmt.h/Expr.h. 811b3064041583eb134fbf56906728bf752bc65b572Ted Kremenek return (Expr*) SizeExpr; 812b3064041583eb134fbf56906728bf752bc65b572Ted Kremenek } 8135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 8145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void getAsStringInternal(std::string &InnerString) const; 8155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 816fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff static bool classof(const Type *T) { 817fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff return T->getTypeClass() == VariableArray; 8185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 819fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff static bool classof(const VariableArrayType *) { return true; } 820a4cb4525cf4bf8f61299147f22ffc187ed1eac9eTed Kremenek 82192866e2e90f6d93fb95e25a7ac4438e239d89ce6Ted Kremenek friend class StmtIteratorBase; 8222bd24ba6d10f8c811c8e2a57c8397e07082ba497Ted Kremenek 8232bd24ba6d10f8c811c8e2a57c8397e07082ba497Ted Kremenek void Profile(llvm::FoldingSetNodeID &ID) { 824c5773c4b8ce1ed6ed5c7112c9020c954a47dce96Eli Friedman assert (0 && "Cannnot unique VariableArrayTypes."); 8252bd24ba6d10f8c811c8e2a57c8397e07082ba497Ted Kremenek } 826ed1a01d4d0ee773eb6478ff9701b46d2f0c06952Ted Kremenek 827ed1a01d4d0ee773eb6478ff9701b46d2f0c06952Ted Kremenekprotected: 828ed1a01d4d0ee773eb6478ff9701b46d2f0c06952Ted Kremenek virtual void EmitImpl(llvm::Serializer& S) const; 829ed1a01d4d0ee773eb6478ff9701b46d2f0c06952Ted Kremenek static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D); 830ed1a01d4d0ee773eb6478ff9701b46d2f0c06952Ted Kremenek friend class Type; 8315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 8325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 83373322924127c873c13101b705dd823f5539ffa5fSteve Naroff/// VectorType - GCC generic vector type. This type is created using 83473322924127c873c13101b705dd823f5539ffa5fSteve Naroff/// __attribute__((vector_size(n)), where "n" specifies the vector size in 83573322924127c873c13101b705dd823f5539ffa5fSteve Naroff/// bytes. Since the constructor takes the number of vector elements, the 83673322924127c873c13101b705dd823f5539ffa5fSteve Naroff/// client is responsible for converting the size into the number of elements. 8375f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass VectorType : public Type, public llvm::FoldingSetNode { 83873322924127c873c13101b705dd823f5539ffa5fSteve Naroffprotected: 8395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// ElementType - The element type of the vector. 8405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType ElementType; 8415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 8425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// NumElements - The number of elements in the vector. 8435f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer unsigned NumElements; 8445f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 84573322924127c873c13101b705dd823f5539ffa5fSteve Naroff VectorType(QualType vecType, unsigned nElements, QualType canonType) : 84673322924127c873c13101b705dd823f5539ffa5fSteve Naroff Type(Vector, canonType), ElementType(vecType), NumElements(nElements) {} 84773322924127c873c13101b705dd823f5539ffa5fSteve Naroff VectorType(TypeClass tc, QualType vecType, unsigned nElements, 84873322924127c873c13101b705dd823f5539ffa5fSteve Naroff QualType canonType) : Type(tc, canonType), ElementType(vecType), 84973322924127c873c13101b705dd823f5539ffa5fSteve Naroff NumElements(nElements) {} 8505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer friend class ASTContext; // ASTContext creates these. 8515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 8525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 8535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType getElementType() const { return ElementType; } 8545f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer unsigned getNumElements() const { return NumElements; } 8555f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 8565f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void getAsStringInternal(std::string &InnerString) const; 8575f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 8585f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void Profile(llvm::FoldingSetNodeID &ID) { 85973322924127c873c13101b705dd823f5539ffa5fSteve Naroff Profile(ID, getElementType(), getNumElements(), getTypeClass()); 8605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 86173322924127c873c13101b705dd823f5539ffa5fSteve Naroff static void Profile(llvm::FoldingSetNodeID &ID, QualType ElementType, 86273322924127c873c13101b705dd823f5539ffa5fSteve Naroff unsigned NumElements, TypeClass TypeClass) { 8635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ID.AddPointer(ElementType.getAsOpaquePtr()); 8645f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ID.AddInteger(NumElements); 86573322924127c873c13101b705dd823f5539ffa5fSteve Naroff ID.AddInteger(TypeClass); 86673322924127c873c13101b705dd823f5539ffa5fSteve Naroff } 86773322924127c873c13101b705dd823f5539ffa5fSteve Naroff static bool classof(const Type *T) { 868213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman return T->getTypeClass() == Vector || T->getTypeClass() == ExtVector; 8695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 8705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const VectorType *) { return true; } 8715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 8725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 873213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman/// ExtVectorType - Extended vector type. This type is created using 874213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman/// __attribute__((ext_vector_type(n)), where "n" is the number of elements. 875213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman/// Unlike vector_size, ext_vector_type is only allowed on typedef's. This 876fcac0fff877a461bc5d5a57e6c6727a4c819d95aSteve Naroff/// class enables syntactic extensions, like Vector Components for accessing 877fcac0fff877a461bc5d5a57e6c6727a4c819d95aSteve Naroff/// points, colors, and textures (modeled after OpenGL Shading Language). 878213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begemanclass ExtVectorType : public VectorType { 879213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman ExtVectorType(QualType vecType, unsigned nElements, QualType canonType) : 880213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman VectorType(ExtVector, vecType, nElements, canonType) {} 88173322924127c873c13101b705dd823f5539ffa5fSteve Naroff friend class ASTContext; // ASTContext creates these. 88273322924127c873c13101b705dd823f5539ffa5fSteve Naroffpublic: 88388dca0464804b8b26ae605f89784c927e8493dddChris Lattner static int getPointAccessorIdx(char c) { 88488dca0464804b8b26ae605f89784c927e8493dddChris Lattner switch (c) { 88588dca0464804b8b26ae605f89784c927e8493dddChris Lattner default: return -1; 88688dca0464804b8b26ae605f89784c927e8493dddChris Lattner case 'x': return 0; 88788dca0464804b8b26ae605f89784c927e8493dddChris Lattner case 'y': return 1; 88888dca0464804b8b26ae605f89784c927e8493dddChris Lattner case 'z': return 2; 88988dca0464804b8b26ae605f89784c927e8493dddChris Lattner case 'w': return 3; 89088dca0464804b8b26ae605f89784c927e8493dddChris Lattner } 891e1b31fedbc006e6e4071bbb4f74c6116b56cfa9fSteve Naroff } 89288dca0464804b8b26ae605f89784c927e8493dddChris Lattner static int getColorAccessorIdx(char c) { 89388dca0464804b8b26ae605f89784c927e8493dddChris Lattner switch (c) { 89488dca0464804b8b26ae605f89784c927e8493dddChris Lattner default: return -1; 89588dca0464804b8b26ae605f89784c927e8493dddChris Lattner case 'r': return 0; 89688dca0464804b8b26ae605f89784c927e8493dddChris Lattner case 'g': return 1; 89788dca0464804b8b26ae605f89784c927e8493dddChris Lattner case 'b': return 2; 89888dca0464804b8b26ae605f89784c927e8493dddChris Lattner case 'a': return 3; 89988dca0464804b8b26ae605f89784c927e8493dddChris Lattner } 900e1b31fedbc006e6e4071bbb4f74c6116b56cfa9fSteve Naroff } 90188dca0464804b8b26ae605f89784c927e8493dddChris Lattner static int getTextureAccessorIdx(char c) { 90288dca0464804b8b26ae605f89784c927e8493dddChris Lattner switch (c) { 90388dca0464804b8b26ae605f89784c927e8493dddChris Lattner default: return -1; 90488dca0464804b8b26ae605f89784c927e8493dddChris Lattner case 's': return 0; 90588dca0464804b8b26ae605f89784c927e8493dddChris Lattner case 't': return 1; 90688dca0464804b8b26ae605f89784c927e8493dddChris Lattner case 'p': return 2; 90788dca0464804b8b26ae605f89784c927e8493dddChris Lattner case 'q': return 3; 908e1b31fedbc006e6e4071bbb4f74c6116b56cfa9fSteve Naroff } 90988dca0464804b8b26ae605f89784c927e8493dddChris Lattner }; 910b8f849da3cedee2f61ad98389115ddd04e439d60Chris Lattner 911b8f849da3cedee2f61ad98389115ddd04e439d60Chris Lattner static int getAccessorIdx(char c) { 912b8f849da3cedee2f61ad98389115ddd04e439d60Chris Lattner if (int idx = getPointAccessorIdx(c)+1) return idx-1; 913b8f849da3cedee2f61ad98389115ddd04e439d60Chris Lattner if (int idx = getColorAccessorIdx(c)+1) return idx-1; 914b8f849da3cedee2f61ad98389115ddd04e439d60Chris Lattner return getTextureAccessorIdx(c); 915b8f849da3cedee2f61ad98389115ddd04e439d60Chris Lattner } 916b8f849da3cedee2f61ad98389115ddd04e439d60Chris Lattner 91788dca0464804b8b26ae605f89784c927e8493dddChris Lattner bool isAccessorWithinNumElements(char c) const { 918b8f849da3cedee2f61ad98389115ddd04e439d60Chris Lattner if (int idx = getAccessorIdx(c)+1) 91988dca0464804b8b26ae605f89784c927e8493dddChris Lattner return unsigned(idx-1) < NumElements; 92088dca0464804b8b26ae605f89784c927e8493dddChris Lattner return false; 921e1b31fedbc006e6e4071bbb4f74c6116b56cfa9fSteve Naroff } 92231a458462c6cf417a84e0c47852b18fb22d79acbSteve Naroff virtual void getAsStringInternal(std::string &InnerString) const; 92331a458462c6cf417a84e0c47852b18fb22d79acbSteve Naroff 9247064f5c95bbdb17680d0ea658d4090898c2592d3Steve Naroff static bool classof(const Type *T) { 925213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman return T->getTypeClass() == ExtVector; 92673322924127c873c13101b705dd823f5539ffa5fSteve Naroff } 927213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman static bool classof(const ExtVectorType *) { return true; } 92873322924127c873c13101b705dd823f5539ffa5fSteve Naroff}; 92973322924127c873c13101b705dd823f5539ffa5fSteve Naroff 9305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// FunctionType - C99 6.7.5.3 - Function Declarators. This is the common base 9315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// class of FunctionTypeNoProto and FunctionTypeProto. 9325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 9335f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass FunctionType : public Type { 9345f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// SubClassData - This field is owned by the subclass, put here to pack 9355f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// tightly with the ivars in Type. 9365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool SubClassData : 1; 9375f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 9385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // The type returned by the function. 9395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType ResultType; 9405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerprotected: 9415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer FunctionType(TypeClass tc, QualType res, bool SubclassInfo,QualType Canonical) 9425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer : Type(tc, Canonical), SubClassData(SubclassInfo), ResultType(res) {} 9435f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool getSubClassData() const { return SubClassData; } 9445f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 9455f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 9465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType getResultType() const { return ResultType; } 9475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 9485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 9495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const Type *T) { 9505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return T->getTypeClass() == FunctionNoProto || 9515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer T->getTypeClass() == FunctionProto; 9525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 9535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const FunctionType *) { return true; } 9545f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 9555f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 9565f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// FunctionTypeNoProto - Represents a K&R-style 'int foo()' function, which has 9575f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// no information available about its arguments. 9585f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass FunctionTypeNoProto : public FunctionType, public llvm::FoldingSetNode { 9595f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer FunctionTypeNoProto(QualType Result, QualType Canonical) 9605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer : FunctionType(FunctionNoProto, Result, false, Canonical) {} 9615f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer friend class ASTContext; // ASTContext creates these. 9625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 9635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // No additional state past what FunctionType provides. 9645f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 9655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void getAsStringInternal(std::string &InnerString) const; 9665f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 9675f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void Profile(llvm::FoldingSetNodeID &ID) { 9685f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Profile(ID, getResultType()); 9695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 9705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static void Profile(llvm::FoldingSetNodeID &ID, QualType ResultType) { 9715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ID.AddPointer(ResultType.getAsOpaquePtr()); 9725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 9735f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 9745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const Type *T) { 9755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return T->getTypeClass() == FunctionNoProto; 9765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 9775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const FunctionTypeNoProto *) { return true; } 9782b14d46231fd75ad1e58043e9fab029c54c817cbTed Kremenek 9792b14d46231fd75ad1e58043e9fab029c54c817cbTed Kremenekprotected: 9802b14d46231fd75ad1e58043e9fab029c54c817cbTed Kremenek virtual void EmitImpl(llvm::Serializer& S) const; 9812b14d46231fd75ad1e58043e9fab029c54c817cbTed Kremenek static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D); 9822b14d46231fd75ad1e58043e9fab029c54c817cbTed Kremenek friend class Type; 9835f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 9845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 9855f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// FunctionTypeProto - Represents a prototype with argument type info, e.g. 9865f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 'int foo(int)' or 'int foo(void)'. 'void' is represented as having no 9875f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// arguments, not as having a single void argument. 9885f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass FunctionTypeProto : public FunctionType, public llvm::FoldingSetNode { 98986da77fdaf4c0237eafb9670f54eee20b08635bfEli Friedman FunctionTypeProto(QualType Result, const QualType *ArgArray, unsigned numArgs, 9905f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isVariadic, QualType Canonical) 9915f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer : FunctionType(FunctionProto, Result, isVariadic, Canonical), 9925f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer NumArgs(numArgs) { 993942cfd37297528918616d06cd6e4e8bd6e4915a2Chris Lattner // Fill in the trailing argument array. 994942cfd37297528918616d06cd6e4e8bd6e4915a2Chris Lattner QualType *ArgInfo = reinterpret_cast<QualType *>(this+1);; 9955f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer for (unsigned i = 0; i != numArgs; ++i) 9965f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ArgInfo[i] = ArgArray[i]; 9975f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 9985f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 9995f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// NumArgs - The number of arguments this function has, not counting '...'. 10005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer unsigned NumArgs; 10015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1002942cfd37297528918616d06cd6e4e8bd6e4915a2Chris Lattner /// ArgInfo - There is an variable size array after the class in memory that 1003942cfd37297528918616d06cd6e4e8bd6e4915a2Chris Lattner /// holds the argument types. 10044b05b1dee6cc65ae61d93dab7edff72710f24589Ted Kremenek 10055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer friend class ASTContext; // ASTContext creates these. 10064b05b1dee6cc65ae61d93dab7edff72710f24589Ted Kremenek virtual void Destroy(ASTContext& C); 10074b05b1dee6cc65ae61d93dab7edff72710f24589Ted Kremenek 10085f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 10095f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer unsigned getNumArgs() const { return NumArgs; } 10105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType getArgType(unsigned i) const { 10115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer assert(i < NumArgs && "Invalid argument number!"); 1012942cfd37297528918616d06cd6e4e8bd6e4915a2Chris Lattner return arg_type_begin()[i]; 10135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 10145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 10155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer bool isVariadic() const { return getSubClassData(); } 10165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 10175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer typedef const QualType *arg_type_iterator; 1018942cfd37297528918616d06cd6e4e8bd6e4915a2Chris Lattner arg_type_iterator arg_type_begin() const { 1019942cfd37297528918616d06cd6e4e8bd6e4915a2Chris Lattner return reinterpret_cast<const QualType *>(this+1); 1020942cfd37297528918616d06cd6e4e8bd6e4915a2Chris Lattner } 1021942cfd37297528918616d06cd6e4e8bd6e4915a2Chris Lattner arg_type_iterator arg_type_end() const { return arg_type_begin()+NumArgs; } 10225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 10235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void getAsStringInternal(std::string &InnerString) const; 10245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 10255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const Type *T) { 10265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer return T->getTypeClass() == FunctionProto; 10275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 10285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const FunctionTypeProto *) { return true; } 10295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 10305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void Profile(llvm::FoldingSetNodeID &ID); 10315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static void Profile(llvm::FoldingSetNodeID &ID, QualType Result, 1032942cfd37297528918616d06cd6e4e8bd6e4915a2Chris Lattner arg_type_iterator ArgTys, unsigned NumArgs, 1033942cfd37297528918616d06cd6e4e8bd6e4915a2Chris Lattner bool isVariadic); 103403ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek 103503ed44061df258e74a40383bda849e14b892a8c6Ted Kremenekprotected: 103603ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek virtual void EmitImpl(llvm::Serializer& S) const; 103703ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D); 103803ed44061df258e74a40383bda849e14b892a8c6Ted Kremenek friend class Type; 10395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 10405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 10415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 10425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass TypedefType : public Type { 10435f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer TypedefDecl *Decl; 1044c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanianprotected: 1045c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian TypedefType(TypeClass tc, TypedefDecl *D, QualType can) 1046c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian : Type(tc, can), Decl(D) { 10475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer assert(!isa<TypedefType>(can) && "Invalid canonical type"); 10485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 10495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer friend class ASTContext; // ASTContext creates these. 10505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 10515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 10525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer TypedefDecl *getDecl() const { return Decl; } 1053a2c7767ce7d8feb10253f4b650826a20f3324c6fChris Lattner 1054a2c7767ce7d8feb10253f4b650826a20f3324c6fChris Lattner /// LookThroughTypedefs - Return the ultimate type this typedef corresponds to 1055a2c7767ce7d8feb10253f4b650826a20f3324c6fChris Lattner /// potentially looking through *all* consequtive typedefs. This returns the 1056a2c7767ce7d8feb10253f4b650826a20f3324c6fChris Lattner /// sum of the type qualifiers, so if you have: 1057a2c7767ce7d8feb10253f4b650826a20f3324c6fChris Lattner /// typedef const int A; 1058a2c7767ce7d8feb10253f4b650826a20f3324c6fChris Lattner /// typedef volatile A B; 1059a2c7767ce7d8feb10253f4b650826a20f3324c6fChris Lattner /// looking through the typedefs for B will give you "const volatile A". 1060a2c7767ce7d8feb10253f4b650826a20f3324c6fChris Lattner QualType LookThroughTypedefs() const; 10615f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 10625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void getAsStringInternal(std::string &InnerString) const; 10635f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 10645f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const Type *T) { return T->getTypeClass() == TypeName; } 10655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const TypedefType *) { return true; } 1066b28166d11e788bc99fd5cd47c4f649ea0195c3b1Ted Kremenek 1067b28166d11e788bc99fd5cd47c4f649ea0195c3b1Ted Kremenekprotected: 1068b28166d11e788bc99fd5cd47c4f649ea0195c3b1Ted Kremenek virtual void EmitImpl(llvm::Serializer& S) const; 1069b28166d11e788bc99fd5cd47c4f649ea0195c3b1Ted Kremenek static Type* CreateImpl(ASTContext& Context,llvm::Deserializer& D); 1070b28166d11e788bc99fd5cd47c4f649ea0195c3b1Ted Kremenek friend class Type; 10715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 10725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1073d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff/// TypeOfExpr (GCC extension). 1074d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroffclass TypeOfExpr : public Type { 1075d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff Expr *TOExpr; 1076d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff TypeOfExpr(Expr *E, QualType can) : Type(TypeOfExp, can), TOExpr(E) { 1077d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff assert(!isa<TypedefType>(can) && "Invalid canonical type"); 1078d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff } 1079d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff friend class ASTContext; // ASTContext creates these. 1080d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroffpublic: 1081d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff Expr *getUnderlyingExpr() const { return TOExpr; } 1082d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff 1083d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff virtual void getAsStringInternal(std::string &InnerString) const; 1084d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff 1085d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff static bool classof(const Type *T) { return T->getTypeClass() == TypeOfExp; } 1086d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff static bool classof(const TypeOfExpr *) { return true; } 1087d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff}; 1088d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff 1089d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff/// TypeOfType (GCC extension). 1090d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroffclass TypeOfType : public Type { 1091d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff QualType TOType; 1092d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff TypeOfType(QualType T, QualType can) : Type(TypeOfTyp, can), TOType(T) { 1093d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff assert(!isa<TypedefType>(can) && "Invalid canonical type"); 1094d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff } 1095d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff friend class ASTContext; // ASTContext creates these. 1096d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroffpublic: 1097d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff QualType getUnderlyingType() const { return TOType; } 1098d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff 1099d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff virtual void getAsStringInternal(std::string &InnerString) const; 1100d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff 1101d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff static bool classof(const Type *T) { return T->getTypeClass() == TypeOfTyp; } 1102d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff static bool classof(const TypeOfType *) { return true; } 1103d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff}; 11045f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 11055f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass TagType : public Type { 1106aad48b6b2dfc81ad36a05d161c775cd6aab5b339Ted Kremenek TagDecl *decl; 11074b7c98378ae0c1a3635f0b7756848b4a9923f8bcTed Kremenek friend class ASTContext; 11082ce52f3fb95bf544db6bd3d91a72bce7d9cceb6cDouglas Gregor 11092ce52f3fb95bf544db6bd3d91a72bce7d9cceb6cDouglas Gregorprotected: 1110aad48b6b2dfc81ad36a05d161c775cd6aab5b339Ted Kremenek TagType(TagDecl *D, QualType can) : Type(Tagged, can), decl(D) {} 11112ce52f3fb95bf544db6bd3d91a72bce7d9cceb6cDouglas Gregor 11122ce52f3fb95bf544db6bd3d91a72bce7d9cceb6cDouglas Gregorpublic: 1113aad48b6b2dfc81ad36a05d161c775cd6aab5b339Ted Kremenek TagDecl *getDecl() const { return decl; } 11145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 11155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void getAsStringInternal(std::string &InnerString) const; 11165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 11175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const Type *T) { return T->getTypeClass() == Tagged; } 11185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static bool classof(const TagType *) { return true; } 1119a225400804cc53dd9cf6b28cf0e8e7f103a7522fTed Kremenek 1120a225400804cc53dd9cf6b28cf0e8e7f103a7522fTed Kremenekprotected: 1121a225400804cc53dd9cf6b28cf0e8e7f103a7522fTed Kremenek virtual void EmitImpl(llvm::Serializer& S) const; 112221d50e12c3c412d8457071dc419363b7a7e8b855Ted Kremenek static Type* CreateImpl(ASTContext& Context, llvm::Deserializer& D); 1123a225400804cc53dd9cf6b28cf0e8e7f103a7522fTed Kremenek friend class Type; 11245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 11255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 11265edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner/// RecordType - This is a helper class that allows the use of isa/cast/dyncast 11275edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner/// to detect TagType objects of structs/unions/classes. 11285edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattnerclass RecordType : public TagType { 112949aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidisprotected: 1130509447e7cb9c24a9f2bd149fe95030050b088622Argyrios Kyrtzidis explicit RecordType(RecordDecl *D) 1131509447e7cb9c24a9f2bd149fe95030050b088622Argyrios Kyrtzidis : TagType(reinterpret_cast<TagDecl*>(D), QualType()) { } 11322ce52f3fb95bf544db6bd3d91a72bce7d9cceb6cDouglas Gregor friend class ASTContext; // ASTContext creates these. 11335edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattnerpublic: 11345edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner 11355edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner RecordDecl *getDecl() const { 11365edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner return reinterpret_cast<RecordDecl*>(TagType::getDecl()); 11375edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner } 11385edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner 11395edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner // FIXME: This predicate is a helper to QualType/Type. It needs to 11405edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner // recursively check all fields for const-ness. If any field is declared 11415edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner // const, it needs to return false. 11425edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner bool hasConstFields() const { return false; } 11435edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner 11445edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner // FIXME: RecordType needs to check when it is created that all fields are in 11455edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner // the same address space, and return that. 11465edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner unsigned getAddressSpace() const { return 0; } 11475edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner 11482daa5df1b53f7ef745d724771384409f6f5df5c1Chris Lattner static bool classof(const TagType *T); 11492daa5df1b53f7ef745d724771384409f6f5df5c1Chris Lattner static bool classof(const Type *T) { 11502daa5df1b53f7ef745d724771384409f6f5df5c1Chris Lattner return isa<TagType>(T) && classof(cast<TagType>(T)); 11512daa5df1b53f7ef745d724771384409f6f5df5c1Chris Lattner } 11525edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner static bool classof(const RecordType *) { return true; } 11535edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner}; 11545edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner 115549aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis/// CXXRecordType - This is a helper class that allows the use of 115649aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis/// isa/cast/dyncast to detect TagType objects of C++ structs/unions/classes. 115749aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidisclass CXXRecordType : public RecordType { 115849aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis explicit CXXRecordType(CXXRecordDecl *D) 115949aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis : RecordType(reinterpret_cast<RecordDecl*>(D)) { } 116049aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis friend class ASTContext; // ASTContext creates these. 116149aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidispublic: 116249aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis 116349aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis CXXRecordDecl *getDecl() const { 116449aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis return reinterpret_cast<CXXRecordDecl*>(RecordType::getDecl()); 116549aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis } 116649aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis 116749aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis static bool classof(const TagType *T); 116849aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis static bool classof(const Type *T) { 116949aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis return isa<TagType>(T) && classof(cast<TagType>(T)); 117049aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis } 117149aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis static bool classof(const CXXRecordType *) { return true; } 117249aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis}; 117349aa7ff1245abd03e6e998e01302df31e4c6f8f6Argyrios Kyrtzidis 11745edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner/// EnumType - This is a helper class that allows the use of isa/cast/dyncast 11755edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner/// to detect TagType objects of enums. 11765edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattnerclass EnumType : public TagType { 1177509447e7cb9c24a9f2bd149fe95030050b088622Argyrios Kyrtzidis explicit EnumType(EnumDecl *D) 1178509447e7cb9c24a9f2bd149fe95030050b088622Argyrios Kyrtzidis : TagType(reinterpret_cast<TagDecl*>(D), QualType()) { } 11792ce52f3fb95bf544db6bd3d91a72bce7d9cceb6cDouglas Gregor friend class ASTContext; // ASTContext creates these. 11805edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattnerpublic: 11815edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner 11825edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner EnumDecl *getDecl() const { 11835edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner return reinterpret_cast<EnumDecl*>(TagType::getDecl()); 11845edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner } 11855edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner 11862daa5df1b53f7ef745d724771384409f6f5df5c1Chris Lattner static bool classof(const TagType *T); 11872daa5df1b53f7ef745d724771384409f6f5df5c1Chris Lattner static bool classof(const Type *T) { 11882daa5df1b53f7ef745d724771384409f6f5df5c1Chris Lattner return isa<TagType>(T) && classof(cast<TagType>(T)); 11892daa5df1b53f7ef745d724771384409f6f5df5c1Chris Lattner } 11905edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner static bool classof(const EnumType *) { return true; } 11915edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner}; 11925edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner 11935edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner 11945edb8bfe8472e7d7bf6a82386394ef27359eb846Chris Lattner 1195fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner/// ObjCInterfaceType - Interfaces are the core concept in Objective-C for 1196fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner/// object oriented design. They basically correspond to C++ classes. There 1197fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner/// are two kinds of interface types, normal interfaces like "NSString" and 1198fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner/// qualified interfaces, which are qualified with a protocol list like 1199fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner/// "NSString<NSCopyable, NSAmazing>". Qualified interface types are instances 1200fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner/// of ObjCQualifiedInterfaceType, which is a subclass of ObjCInterfaceType. 1201a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCInterfaceType : public Type { 1202a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *Decl; 120306cef25d0b8c383217413f061441c7ea40d1052bFariborz Jahanianprotected: 1204a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceType(TypeClass tc, ObjCInterfaceDecl *D) : 120506cef25d0b8c383217413f061441c7ea40d1052bFariborz Jahanian Type(tc, QualType()), Decl(D) { } 12063536b443bc50d58a79f14fca9b6842541a434854Steve Naroff friend class ASTContext; // ASTContext creates these. 12073536b443bc50d58a79f14fca9b6842541a434854Steve Naroffpublic: 12083536b443bc50d58a79f14fca9b6842541a434854Steve Naroff 1209a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceDecl *getDecl() const { return Decl; } 12103536b443bc50d58a79f14fca9b6842541a434854Steve Naroff 1211fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner /// qual_iterator and friends: this provides access to the (potentially empty) 1212fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner /// list of protocols qualifying this interface. If this is an instance of 1213fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner /// ObjCQualifiedInterfaceType it returns the list, otherwise it returns an 1214fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner /// empty list if there are no qualifying protocols. 1215fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner typedef llvm::SmallVector<ObjCProtocolDecl*, 8>::const_iterator qual_iterator; 1216fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner inline qual_iterator qual_begin() const; 1217fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner inline qual_iterator qual_end() const; 1218fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner bool qual_empty() const { return getTypeClass() != ObjCQualifiedInterface; } 1219fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner 1220fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner /// getNumProtocols - Return the number of qualifying protocols in this 1221fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner /// interface type, or 0 if there are none. 1222fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner inline unsigned getNumProtocols() const; 1223fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner 12249baefc21bfe1bf49ab4a234e9f267f00abe0b1b1Chris Lattner /// getProtocol - Return the specified qualifying protocol. 12259baefc21bfe1bf49ab4a234e9f267f00abe0b1b1Chris Lattner inline ObjCProtocolDecl *getProtocol(unsigned i) const; 12264b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian 1227fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner 1228fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner virtual void getAsStringInternal(std::string &InnerString) const; 12293536b443bc50d58a79f14fca9b6842541a434854Steve Naroff static bool classof(const Type *T) { 1230368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner return T->getTypeClass() == ObjCInterface || 1231368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner T->getTypeClass() == ObjCQualifiedInterface; 12323536b443bc50d58a79f14fca9b6842541a434854Steve Naroff } 1233a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCInterfaceType *) { return true; } 12343536b443bc50d58a79f14fca9b6842541a434854Steve Naroff}; 12353536b443bc50d58a79f14fca9b6842541a434854Steve Naroff 1236a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek/// ObjCQualifiedInterfaceType - This class represents interface types 1237372bed091b6b1eca596130208e227e7077154de4Chris Lattner/// conforming to a list of protocols, such as INTF<Proto1, Proto2, Proto1>. 1238372bed091b6b1eca596130208e227e7077154de4Chris Lattner/// 1239878520b6413663a13b1b56c7e3f256b1ecbb8db4Fariborz Jahanian/// Duplicate protocols are removed and protocol list is canonicalized to be in 1240878520b6413663a13b1b56c7e3f256b1ecbb8db4Fariborz Jahanian/// alphabetical order. 1241a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCQualifiedInterfaceType : public ObjCInterfaceType, 124206cef25d0b8c383217413f061441c7ea40d1052bFariborz Jahanian public llvm::FoldingSetNode { 124306cef25d0b8c383217413f061441c7ea40d1052bFariborz Jahanian 1244e37882ad335896dedf345102bb425383e6221c37Fariborz Jahanian // List of protocols for this protocol conforming object type 1245e37882ad335896dedf345102bb425383e6221c37Fariborz Jahanian // List is sorted on protocol name. No protocol is enterred more than once. 1246fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner llvm::SmallVector<ObjCProtocolDecl*, 4> Protocols; 1247e37882ad335896dedf345102bb425383e6221c37Fariborz Jahanian 1248a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCQualifiedInterfaceType(ObjCInterfaceDecl *D, 1249065f0d7b00c3cd2b3139ebd105f50462fc778859Chris Lattner ObjCProtocolDecl **Protos, unsigned NumP) : 1250a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCInterfaceType(ObjCQualifiedInterface, D), 125100bb283ecdfb1d5c69261c7663d166cee3f11a9bChris Lattner Protocols(Protos, Protos+NumP) { } 12524b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian friend class ASTContext; // ASTContext creates these. 1253e37882ad335896dedf345102bb425383e6221c37Fariborz Jahanianpublic: 1254e37882ad335896dedf345102bb425383e6221c37Fariborz Jahanian 12559baefc21bfe1bf49ab4a234e9f267f00abe0b1b1Chris Lattner ObjCProtocolDecl *getProtocol(unsigned i) const { 12564b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian return Protocols[i]; 12574b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian } 12584b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian unsigned getNumProtocols() const { 12594b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian return Protocols.size(); 12604b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian } 1261065f0d7b00c3cd2b3139ebd105f50462fc778859Chris Lattner 1262065f0d7b00c3cd2b3139ebd105f50462fc778859Chris Lattner qual_iterator qual_begin() const { return Protocols.begin(); } 1263065f0d7b00c3cd2b3139ebd105f50462fc778859Chris Lattner qual_iterator qual_end() const { return Protocols.end(); } 1264065f0d7b00c3cd2b3139ebd105f50462fc778859Chris Lattner 12654b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian virtual void getAsStringInternal(std::string &InnerString) const; 12664b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian 12674b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian void Profile(llvm::FoldingSetNodeID &ID); 12684b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian static void Profile(llvm::FoldingSetNodeID &ID, 12691ee0700c7dbe3554df09b4558e0b35a53d487ff2Chris Lattner const ObjCInterfaceDecl *Decl, 1270a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCProtocolDecl **protocols, unsigned NumProtocols); 12714b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian 1272e37882ad335896dedf345102bb425383e6221c37Fariborz Jahanian static bool classof(const Type *T) { 1273a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek return T->getTypeClass() == ObjCQualifiedInterface; 1274e37882ad335896dedf345102bb425383e6221c37Fariborz Jahanian } 1275a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCQualifiedInterfaceType *) { return true; } 1276e37882ad335896dedf345102bb425383e6221c37Fariborz Jahanian}; 1277fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner 1278fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattnerinline ObjCInterfaceType::qual_iterator ObjCInterfaceType::qual_begin() const { 1279fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner if (const ObjCQualifiedInterfaceType *QIT = 1280fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner dyn_cast<ObjCQualifiedInterfaceType>(this)) 1281fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner return QIT->qual_begin(); 1282fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner return 0; 1283fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner} 1284fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattnerinline ObjCInterfaceType::qual_iterator ObjCInterfaceType::qual_end() const { 1285fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner if (const ObjCQualifiedInterfaceType *QIT = 1286fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner dyn_cast<ObjCQualifiedInterfaceType>(this)) 1287fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner return QIT->qual_end(); 1288fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner return 0; 1289fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner} 1290fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner 1291fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner/// getNumProtocols - Return the number of qualifying protocols in this 1292fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner/// interface type, or 0 if there are none. 1293fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattnerinline unsigned ObjCInterfaceType::getNumProtocols() const { 1294fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner if (const ObjCQualifiedInterfaceType *QIT = 1295fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner dyn_cast<ObjCQualifiedInterfaceType>(this)) 1296fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner return QIT->getNumProtocols(); 1297fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner return 0; 1298fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner} 1299fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner 13009baefc21bfe1bf49ab4a234e9f267f00abe0b1b1Chris Lattner/// getProtocol - Return the specified qualifying protocol. 13019baefc21bfe1bf49ab4a234e9f267f00abe0b1b1Chris Lattnerinline ObjCProtocolDecl *ObjCInterfaceType::getProtocol(unsigned i) const { 13029baefc21bfe1bf49ab4a234e9f267f00abe0b1b1Chris Lattner return cast<ObjCQualifiedInterfaceType>(this)->getProtocol(i); 1303fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner} 1304fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner 1305fb7701df5401fa1f5b3396d269fb33e731a00089Chris Lattner 1306c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian 1307372bed091b6b1eca596130208e227e7077154de4Chris Lattner/// ObjCQualifiedIdType - to represent id<protocol-list>. 1308372bed091b6b1eca596130208e227e7077154de4Chris Lattner/// 1309372bed091b6b1eca596130208e227e7077154de4Chris Lattner/// Duplicate protocols are removed and protocol list is canonicalized to be in 1310372bed091b6b1eca596130208e227e7077154de4Chris Lattner/// alphabetical order. 1311a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekclass ObjCQualifiedIdType : public Type, 1312c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian public llvm::FoldingSetNode { 1313c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian // List of protocols for this protocol conforming 'id' type 1314c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian // List is sorted on protocol name. No protocol is enterred more than once. 1315a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek llvm::SmallVector<ObjCProtocolDecl*, 8> Protocols; 1316c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian 131762f5f7ffad57e0c2af2b308af3735351505937cbChris Lattner ObjCQualifiedIdType(ObjCProtocolDecl **Protos, unsigned NumP) 131862f5f7ffad57e0c2af2b308af3735351505937cbChris Lattner : Type(ObjCQualifiedId, QualType()/*these are always canonical*/), 1319c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian Protocols(Protos, Protos+NumP) { } 1320c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian friend class ASTContext; // ASTContext creates these. 1321c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanianpublic: 1322c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian 1323a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCProtocolDecl *getProtocols(unsigned i) const { 1324c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian return Protocols[i]; 1325c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian } 1326c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian unsigned getNumProtocols() const { 1327c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian return Protocols.size(); 1328c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian } 1329a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCProtocolDecl **getReferencedProtocols() { 1330411f373abf5692a1bd90d35a139d955fa67ae82dFariborz Jahanian return &Protocols[0]; 1331065f0d7b00c3cd2b3139ebd105f50462fc778859Chris Lattner } 1332065f0d7b00c3cd2b3139ebd105f50462fc778859Chris Lattner 1333065f0d7b00c3cd2b3139ebd105f50462fc778859Chris Lattner typedef llvm::SmallVector<ObjCProtocolDecl*, 8>::const_iterator qual_iterator; 1334065f0d7b00c3cd2b3139ebd105f50462fc778859Chris Lattner qual_iterator qual_begin() const { return Protocols.begin(); } 1335065f0d7b00c3cd2b3139ebd105f50462fc778859Chris Lattner qual_iterator qual_end() const { return Protocols.end(); } 1336c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian 1337c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian virtual void getAsStringInternal(std::string &InnerString) const; 1338c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian 1339c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian void Profile(llvm::FoldingSetNodeID &ID); 134062f5f7ffad57e0c2af2b308af3735351505937cbChris Lattner static void Profile(llvm::FoldingSetNodeID &ID, 1341a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek ObjCProtocolDecl **protocols, unsigned NumProtocols); 1342c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian 1343c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian static bool classof(const Type *T) { 1344a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek return T->getTypeClass() == ObjCQualifiedId; 1345c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian } 1346a526c5c67e5a0473c340903ee542ce570119665fTed Kremenek static bool classof(const ObjCQualifiedIdType *) { return true; } 1347c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian 1348c569249ca0ab755ac79d8cbbfcb2bcae19743624Fariborz Jahanian}; 1349e37882ad335896dedf345102bb425383e6221c37Fariborz Jahanian 13505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1351611c1fff195d32df97706e0920c92468b2509900Chris Lattner// Inline function definitions. 13525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1353ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb/// getUnqualifiedType - Return the type without any qualifiers. 1354ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lambinline QualType QualType::getUnqualifiedType() const { 1355f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner Type *TP = getTypePtr(); 1356f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner if (const ASQualType *ASQT = dyn_cast<ASQualType>(TP)) 1357f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner TP = ASQT->getBaseType(); 1358f46699ce225811d8d9dbab9d00189a0e54469457Chris Lattner return QualType(TP, 0); 1359ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb} 1360ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb 1361ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb/// getAddressSpace - Return the address space of this type. 1362ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lambinline unsigned QualType::getAddressSpace() const { 13634243a94b43ef6207938f3023dfcfb804dd545363Chris Lattner QualType CT = getTypePtr()->getCanonicalTypeInternal(); 13644243a94b43ef6207938f3023dfcfb804dd545363Chris Lattner if (const ArrayType *AT = dyn_cast<ArrayType>(CT)) 1365c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner return AT->getElementType().getAddressSpace(); 13664243a94b43ef6207938f3023dfcfb804dd545363Chris Lattner if (const RecordType *RT = dyn_cast<RecordType>(CT)) 13678e7dafec4b70303dfaff95151cd06bfc5532720cNate Begeman return RT->getAddressSpace(); 13684243a94b43ef6207938f3023dfcfb804dd545363Chris Lattner if (const ASQualType *ASQT = dyn_cast<ASQualType>(CT)) 1369ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb return ASQT->getAddressSpace(); 1370ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb return 0; 1371ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb} 1372611c1fff195d32df97706e0920c92468b2509900Chris Lattner 1373769c9cfc6e06bd9d8ffe7a4397b939f19b0e4dc3Ted Kremenekinline const TypedefType* Type::getAsTypedefType() const { 1374769c9cfc6e06bd9d8ffe7a4397b939f19b0e4dc3Ted Kremenek return dyn_cast<TypedefType>(this); 1375769c9cfc6e06bd9d8ffe7a4397b939f19b0e4dc3Ted Kremenek} 13762b1cc8be4dda4cd122485be0168b3c43d7dff15fChris Lattnerinline const ObjCInterfaceType *Type::getAsPointerToObjCInterfaceType() const { 13772b1cc8be4dda4cd122485be0168b3c43d7dff15fChris Lattner if (const PointerType *PT = getAsPointerType()) 13782b1cc8be4dda4cd122485be0168b3c43d7dff15fChris Lattner return PT->getPointeeType()->getAsObjCInterfaceType(); 13792b1cc8be4dda4cd122485be0168b3c43d7dff15fChris Lattner return 0; 13802b1cc8be4dda4cd122485be0168b3c43d7dff15fChris Lattner} 13812b1cc8be4dda4cd122485be0168b3c43d7dff15fChris Lattner 1382c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner// NOTE: All of these methods use "getUnqualifiedType" to strip off address 1383c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner// space qualifiers if present. 1384611c1fff195d32df97706e0920c92468b2509900Chris Lattnerinline bool Type::isFunctionType() const { 1385ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb return isa<FunctionType>(CanonicalType.getUnqualifiedType()); 1386611c1fff195d32df97706e0920c92468b2509900Chris Lattner} 1387611c1fff195d32df97706e0920c92468b2509900Chris Lattnerinline bool Type::isPointerType() const { 1388ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb return isa<PointerType>(CanonicalType.getUnqualifiedType()); 1389611c1fff195d32df97706e0920c92468b2509900Chris Lattner} 13905618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroffinline bool Type::isBlockPointerType() const { 13915618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff return isa<BlockPointerType>(CanonicalType); 13925618bd4a52c45fbbb605e3ba885663b2164db8a3Steve Naroff} 1393bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattnerinline bool Type::isReferenceType() const { 1394bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner return isa<ReferenceType>(CanonicalType.getUnqualifiedType()); 1395bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner} 1396bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattnerinline bool Type::isPointerLikeType() const { 1397bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner return isa<PointerLikeType>(CanonicalType.getUnqualifiedType()); 1398bdcd637c29ec1540f912ea6860c88b910e78c329Chris Lattner} 1399498b0d1aba38f5ec64d566d1dd9e6be237ecc50fTed Kremenekinline bool Type::isFunctionPointerType() const { 140001c2c6e3c94a3fa2ac15851b4af5de6dc3ae2af8Ted Kremenek if (const PointerType* T = getAsPointerType()) 1401498b0d1aba38f5ec64d566d1dd9e6be237ecc50fTed Kremenek return T->getPointeeType()->isFunctionType(); 1402498b0d1aba38f5ec64d566d1dd9e6be237ecc50fTed Kremenek else 1403498b0d1aba38f5ec64d566d1dd9e6be237ecc50fTed Kremenek return false; 1404498b0d1aba38f5ec64d566d1dd9e6be237ecc50fTed Kremenek} 1405611c1fff195d32df97706e0920c92468b2509900Chris Lattnerinline bool Type::isArrayType() const { 1406ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb return isa<ArrayType>(CanonicalType.getUnqualifiedType()); 1407611c1fff195d32df97706e0920c92468b2509900Chris Lattner} 1408c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattnerinline bool Type::isConstantArrayType() const { 1409c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner return isa<ConstantArrayType>(CanonicalType.getUnqualifiedType()); 1410c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner} 1411c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattnerinline bool Type::isIncompleteArrayType() const { 1412c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner return isa<IncompleteArrayType>(CanonicalType.getUnqualifiedType()); 1413c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner} 1414c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattnerinline bool Type::isVariableArrayType() const { 1415c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner return isa<VariableArrayType>(CanonicalType.getUnqualifiedType()); 1416c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner} 1417611c1fff195d32df97706e0920c92468b2509900Chris Lattnerinline bool Type::isRecordType() const { 1418ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb return isa<RecordType>(CanonicalType.getUnqualifiedType()); 1419611c1fff195d32df97706e0920c92468b2509900Chris Lattner} 1420f23d364084d1aabea688222780d6fc1dd8c7f78cChris Lattnerinline bool Type::isAnyComplexType() const { 1421c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner return isa<ComplexType>(CanonicalType.getUnqualifiedType()); 1422f23d364084d1aabea688222780d6fc1dd8c7f78cChris Lattner} 1423611c1fff195d32df97706e0920c92468b2509900Chris Lattnerinline bool Type::isVectorType() const { 1424ebb97e98c03f8d7034bd3748a10e35f39a95c289Christopher Lamb return isa<VectorType>(CanonicalType.getUnqualifiedType()); 1425611c1fff195d32df97706e0920c92468b2509900Chris Lattner} 1426213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begemaninline bool Type::isExtVectorType() const { 1427213541a68a3e137d11d2cefb612c6cdb410d7e8eNate Begeman return isa<ExtVectorType>(CanonicalType.getUnqualifiedType()); 1428611c1fff195d32df97706e0920c92468b2509900Chris Lattner} 1429a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekinline bool Type::isObjCInterfaceType() const { 1430c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner return isa<ObjCInterfaceType>(CanonicalType.getUnqualifiedType()); 1431368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattner} 1432368eefa081d12f0a265ee90ee8ec61b54168d57dChris Lattnerinline bool Type::isObjCQualifiedInterfaceType() const { 1433c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner return isa<ObjCQualifiedInterfaceType>(CanonicalType.getUnqualifiedType()); 1434e7f64cc250245aa6c0e1ef6da7e9b6f62d5feddeFariborz Jahanian} 1435a526c5c67e5a0473c340903ee542ce570119665fTed Kremenekinline bool Type::isObjCQualifiedIdType() const { 1436c63a1f276f7b324fd9a4be82098b1c8f7bf30733Chris Lattner return isa<ObjCQualifiedIdType>(CanonicalType.getUnqualifiedType()); 1437d58fabf7ed279be18a5e82617f809c9deff9be67Fariborz Jahanian} 14385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end namespace clang 14395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 14405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif 1441