ASTContext.h revision b62f6813406a03bf8a371c4e46c9fad51d102121
15f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===--- ASTContext.h - Context to hold long-lived AST nodes ----*- C++ -*-===// 25f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 35f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// The LLVM Compiler Infrastructure 45f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 55f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// This file was developed by Chris Lattner and is distributed under 65f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// the University of Illinois Open Source License. See LICENSE.TXT for details. 75f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 85f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===// 95f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// This file defines the ASTContext interface. 115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===// 135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#ifndef LLVM_CLANG_AST_ASTCONTEXT_H 155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#define LLVM_CLANG_AST_ASTCONTEXT_H 165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "clang/AST/Builtins.h" 185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "clang/AST/Expr.h" 19464175bba1318bef7905122e9fda20cff926df78Chris Lattner#include "clang/AST/RecordLayout.h" 20464175bba1318bef7905122e9fda20cff926df78Chris Lattner#include "clang/AST/Type.h" 21464175bba1318bef7905122e9fda20cff926df78Chris Lattner#include "llvm/ADT/DenseMap.h" 22a9aa5e69d8253e196be90c070738ab5bd9813730Steve Naroff#include "llvm/ADT/StringMap.h" 2368d331a78e655d97294e94fcfa63f92cc1f40578Steve Naroff#include "llvm/ADT/FoldingSet.h" 245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include <vector> 255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang { 275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer class TargetInfo; 28c7229c338c21ef26b01ef3ecf9eec4fd373fa9ecChris Lattner class IdentifierTable; 29980e508ca70d6de75d2abfd96b4681fc98bb2698Steve Naroff 305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// ASTContext - This class holds long-lived AST nodes (such as types and 315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// decls) that can be referred to throughout the semantic analysis of a file. 325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass ASTContext { 335f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer std::vector<Type*> Types; 345f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer llvm::FoldingSet<ComplexType> ComplexTypes; 355f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer llvm::FoldingSet<PointerType> PointerTypes; 365f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer llvm::FoldingSet<ReferenceType> ReferenceTypes; 37fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff llvm::FoldingSet<ConstantArrayType> ArrayTypes; 385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer llvm::FoldingSet<VectorType> VectorTypes; 395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer llvm::FoldingSet<FunctionTypeNoProto> FunctionTypeNoProtos; 405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer llvm::FoldingSet<FunctionTypeProto> FunctionTypeProtos; 414b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian llvm::FoldingSet<ObjcQualifiedInterfaceType> ObjcQualifiedInterfaceTypes; 42464175bba1318bef7905122e9fda20cff926df78Chris Lattner llvm::DenseMap<const RecordDecl*, const RecordLayout*> RecordLayoutInfo; 43b2cf3573d7351094f6247fcca94703ce88eb9ee0Anders Carlsson 44b2cf3573d7351094f6247fcca94703ce88eb9ee0Anders Carlsson /// BuiltinVaListType - built-in va list type. 45b2cf3573d7351094f6247fcca94703ce88eb9ee0Anders Carlsson /// This is initially null and set by Sema::LazilyCreateBuiltin when 46b2cf3573d7351094f6247fcca94703ce88eb9ee0Anders Carlsson /// a builtin that takes a valist is encountered. 47b2cf3573d7351094f6247fcca94703ce88eb9ee0Anders Carlsson QualType BuiltinVaListType; 487e219e47de26346885d667131977bd9ca2d7662aSteve Naroff 497e219e47de26346885d667131977bd9ca2d7662aSteve Naroff /// ObjcIdType - a psuedo built-in typedef type (set by Sema). 507e219e47de26346885d667131977bd9ca2d7662aSteve Naroff QualType ObjcIdType; 517e219e47de26346885d667131977bd9ca2d7662aSteve Naroff const RecordType *IdStructType; 522198891824c38d45b2279de5d5e3ef9394eb457cSteve Naroff 53b62f6813406a03bf8a371c4e46c9fad51d102121Fariborz Jahanian /// ObjcSelType - another psuedo built-in typedef type (set by Sema). 54b62f6813406a03bf8a371c4e46c9fad51d102121Fariborz Jahanian QualType ObjcSelType; 55b62f6813406a03bf8a371c4e46c9fad51d102121Fariborz Jahanian const RecordType *SelStructType; 56b62f6813406a03bf8a371c4e46c9fad51d102121Fariborz Jahanian 572198891824c38d45b2279de5d5e3ef9394eb457cSteve Naroff QualType ObjcConstantStringType; 582198891824c38d45b2279de5d5e3ef9394eb457cSteve Naroff RecordDecl *CFConstantStringTypeDecl; 595f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 601d5b0e37cd569f3d1ddfc5cabff649ef7e42f3c6Fariborz Jahanian 61b800dc2d5e27ec60f567567b623cdc61152b8fb8Chris Lattner SourceManager &SourceMgr; 625f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer TargetInfo &Target; 6371993dd85eed9cc42c6b2fa61ee5c53026b74817Anders Carlsson IdentifierTable &Idents; 6429238a0bf7cbf5b396efb451a0adb5fe4aa037caSteve Naroff SelectorTable &Selectors; 655f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer Builtin::Context BuiltinInfo; 665f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 675f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer // Builtin Types. 685f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType VoidTy; 695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType BoolTy; 705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType CharTy; 715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType SignedCharTy, ShortTy, IntTy, LongTy, LongLongTy; 725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType UnsignedCharTy, UnsignedShortTy, UnsignedIntTy, UnsignedLongTy; 735f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType UnsignedLongLongTy; 745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType FloatTy, DoubleTy, LongDoubleTy; 755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy; 765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 7768d331a78e655d97294e94fcfa63f92cc1f40578Steve Naroff ASTContext(SourceManager &SM, TargetInfo &t, IdentifierTable &idents, 7829238a0bf7cbf5b396efb451a0adb5fe4aa037caSteve Naroff SelectorTable &sels) : 7968d331a78e655d97294e94fcfa63f92cc1f40578Steve Naroff CFConstantStringTypeDecl(0), SourceMgr(SM), Target(t), 8068d331a78e655d97294e94fcfa63f92cc1f40578Steve Naroff Idents(idents), Selectors(sels) { 815f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer InitBuiltinTypes(); 825f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer BuiltinInfo.InitializeBuiltins(idents, Target); 835f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ~ASTContext(); 855f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 865f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void PrintStats() const; 87d2d2a11a91d7ddf468bfb70f66362d24806ed601Chris Lattner 88464175bba1318bef7905122e9fda20cff926df78Chris Lattner //===--------------------------------------------------------------------===// 89464175bba1318bef7905122e9fda20cff926df78Chris Lattner // Type Constructors 90464175bba1318bef7905122e9fda20cff926df78Chris Lattner //===--------------------------------------------------------------------===// 91d2d2a11a91d7ddf468bfb70f66362d24806ed601Chris Lattner 925f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// getComplexType - Return the uniqued reference to the type for a complex 935f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// number with the specified element type. 945f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType getComplexType(QualType T); 955f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 965f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// getPointerType - Return the uniqued reference to the type for a pointer to 975f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// the specified type. 985f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType getPointerType(QualType T); 995f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1005f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// getReferenceType - Return the uniqued reference to the type for a 1015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// reference to the specified type. 1025f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType getReferenceType(QualType T); 1035f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 104bdbf7b030a3e0ddb95240076683830e6f78c79a5Steve Naroff /// getVariableArrayType - Returns a non-unique reference to the type for a 105bdbf7b030a3e0ddb95240076683830e6f78c79a5Steve Naroff /// variable array of the specified element type. 106c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff QualType getVariableArrayType(QualType EltTy, Expr *NumElts, 107c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff ArrayType::ArraySizeModifier ASM, 108c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff unsigned EltTypeQuals); 109fb22d96692c5240fb8d611290dbf7eeed3759c73Steve Naroff 110bdbf7b030a3e0ddb95240076683830e6f78c79a5Steve Naroff /// getConstantArrayType - Return the unique reference to the type for a 111bdbf7b030a3e0ddb95240076683830e6f78c79a5Steve Naroff /// constant array of the specified element type. 112c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, 113c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff ArrayType::ArraySizeModifier ASM, 114c9406125e2cac9208098655ac8058c095c2c3a65Steve Naroff unsigned EltTypeQuals); 1155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 11673322924127c873c13101b705dd823f5539ffa5fSteve Naroff /// getVectorType - Return the unique reference to a vector type of 11773322924127c873c13101b705dd823f5539ffa5fSteve Naroff /// the specified element type and size. VectorType must be a built-in type. 11873322924127c873c13101b705dd823f5539ffa5fSteve Naroff QualType getVectorType(QualType VectorType, unsigned NumElts); 11973322924127c873c13101b705dd823f5539ffa5fSteve Naroff 12073322924127c873c13101b705dd823f5539ffa5fSteve Naroff /// getOCUVectorType - Return the unique reference to an OCU vector type of 12173322924127c873c13101b705dd823f5539ffa5fSteve Naroff /// the specified element type and size. VectorType must be a built-in type. 12273322924127c873c13101b705dd823f5539ffa5fSteve Naroff QualType getOCUVectorType(QualType VectorType, unsigned NumElts); 1235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// getFunctionTypeNoProto - Return a K&R style C function type like 'int()'. 1255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// 1265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType getFunctionTypeNoProto(QualType ResultTy); 1275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// getFunctionType - Return a normal function type with a typed argument 1295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// list. isVariadic indicates whether the argument list includes '...'. 1305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType getFunctionType(QualType ResultTy, QualType *ArgArray, 1315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer unsigned NumArgs, bool isVariadic); 1325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1335f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// getTypedefType - Return the unique reference to the type for the 1345f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// specified typename decl. 1355f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType getTypedefType(TypedefDecl *Decl); 1363536b443bc50d58a79f14fca9b6842541a434854Steve Naroff QualType getObjcInterfaceType(ObjcInterfaceDecl *Decl); 1374b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian 1384b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian /// getObjcQualifiedInterfaceType - Return a 1394b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian /// ObjcQualifiedInterfaceType type for the given interface decl and 1404b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian /// the conforming protocol list. 1414b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian QualType getObjcQualifiedInterfaceType(ObjcInterfaceDecl *Decl, 1424b6c9051c6522894978c9ba6a819a659d102db36Fariborz Jahanian ObjcProtocolDecl **ProtocolList, unsigned NumProtocols); 1435f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 144d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff /// getTypeOfType - GCC extension. 1458d1a3b8ca1e5fcc4567b5a6f51d82be2e460de1cSteve Naroff QualType getTypeOfExpr(Expr *e); 146d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff QualType getTypeOfType(QualType t); 147d1861fd633d5096a00777c918eb8575ea7162fe7Steve Naroff 1485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// getTagDeclType - Return the unique reference to the type for the 1495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// specified TagDecl (struct/union/class/enum) decl. 1505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType getTagDeclType(TagDecl *Decl); 1515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// getSizeType - Return the unique type for "size_t" (C99 7.17), defined 1535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// in <stddef.h>. The sizeof operator requires this (C99 6.5.3.4p4). 1545f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer QualType getSizeType() const; 1555f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1568b9023ba35a86838789e2c9034a6128728c547aaChris Lattner /// getPointerDiffType - Return the unique type for "ptrdiff_t" (ref?) 1578b9023ba35a86838789e2c9034a6128728c547aaChris Lattner /// defined in <stddef.h>. Pointer - pointer requires this (C99 6.5.6p9). 1588b9023ba35a86838789e2c9034a6128728c547aaChris Lattner QualType getPointerDiffType() const; 1598b9023ba35a86838789e2c9034a6128728c547aaChris Lattner 1602198891824c38d45b2279de5d5e3ef9394eb457cSteve Naroff // getCFConstantStringType - Return the type used for constant CFStrings. 1612198891824c38d45b2279de5d5e3ef9394eb457cSteve Naroff // CURRENTLY UNUSED (10/15/07). ObjCStringLiteral now uses the hook below. 16271993dd85eed9cc42c6b2fa61ee5c53026b74817Anders Carlsson QualType getCFConstantStringType(); 16371993dd85eed9cc42c6b2fa61ee5c53026b74817Anders Carlsson 164983df5b2280980e59b0b062bcc2882230465a61eSteve Naroff // This setter/getter represents the ObjC type for an NSConstantString. 1652198891824c38d45b2279de5d5e3ef9394eb457cSteve Naroff void setObjcConstantStringInterface(ObjcInterfaceDecl *Decl); 1662198891824c38d45b2279de5d5e3ef9394eb457cSteve Naroff QualType getObjcConstantStringInterface() const { 1672198891824c38d45b2279de5d5e3ef9394eb457cSteve Naroff return ObjcConstantStringType; 1682198891824c38d45b2279de5d5e3ef9394eb457cSteve Naroff } 169b62f6813406a03bf8a371c4e46c9fad51d102121Fariborz Jahanian 170983df5b2280980e59b0b062bcc2882230465a61eSteve Naroff // This setter/getter repreents the ObjC 'id' type. It is setup lazily, by 171983df5b2280980e59b0b062bcc2882230465a61eSteve Naroff // Sema. 1727e219e47de26346885d667131977bd9ca2d7662aSteve Naroff void setObjcIdType(TypedefDecl *Decl); 1737e219e47de26346885d667131977bd9ca2d7662aSteve Naroff QualType getObjcIdType() const { return ObjcIdType; } 174b62f6813406a03bf8a371c4e46c9fad51d102121Fariborz Jahanian 175b62f6813406a03bf8a371c4e46c9fad51d102121Fariborz Jahanian void setObjcSelType(TypedefDecl *Decl); 176b62f6813406a03bf8a371c4e46c9fad51d102121Fariborz Jahanian QualType getObjcSelType() const { return ObjcSelType; } 177b62f6813406a03bf8a371c4e46c9fad51d102121Fariborz Jahanian 178b2cf3573d7351094f6247fcca94703ce88eb9ee0Anders Carlsson void setBuiltinVaListType(QualType T); 179b2cf3573d7351094f6247fcca94703ce88eb9ee0Anders Carlsson QualType getBuiltinVaListType() const { return BuiltinVaListType; } 180b2cf3573d7351094f6247fcca94703ce88eb9ee0Anders Carlsson 181464175bba1318bef7905122e9fda20cff926df78Chris Lattner //===--------------------------------------------------------------------===// 182464175bba1318bef7905122e9fda20cff926df78Chris Lattner // Type Sizing and Analysis 183464175bba1318bef7905122e9fda20cff926df78Chris Lattner //===--------------------------------------------------------------------===// 184464175bba1318bef7905122e9fda20cff926df78Chris Lattner 185464175bba1318bef7905122e9fda20cff926df78Chris Lattner /// getTypeInfo - Get the size and alignment of the specified complete type in 186464175bba1318bef7905122e9fda20cff926df78Chris Lattner /// bits. 187464175bba1318bef7905122e9fda20cff926df78Chris Lattner std::pair<uint64_t, unsigned> getTypeInfo(QualType T, SourceLocation L); 188464175bba1318bef7905122e9fda20cff926df78Chris Lattner 189464175bba1318bef7905122e9fda20cff926df78Chris Lattner /// getTypeSize - Return the size of the specified type, in bits. This method 190464175bba1318bef7905122e9fda20cff926df78Chris Lattner /// does not work on incomplete types. 191464175bba1318bef7905122e9fda20cff926df78Chris Lattner uint64_t getTypeSize(QualType T, SourceLocation L) { 192464175bba1318bef7905122e9fda20cff926df78Chris Lattner return getTypeInfo(T, L).first; 193464175bba1318bef7905122e9fda20cff926df78Chris Lattner } 194464175bba1318bef7905122e9fda20cff926df78Chris Lattner 195464175bba1318bef7905122e9fda20cff926df78Chris Lattner /// getTypeAlign - Return the alignment of the specified type, in bits. This 196464175bba1318bef7905122e9fda20cff926df78Chris Lattner /// method does not work on incomplete types. 197464175bba1318bef7905122e9fda20cff926df78Chris Lattner unsigned getTypeAlign(QualType T, SourceLocation L) { 198464175bba1318bef7905122e9fda20cff926df78Chris Lattner return getTypeInfo(T, L).second; 199464175bba1318bef7905122e9fda20cff926df78Chris Lattner } 200464175bba1318bef7905122e9fda20cff926df78Chris Lattner 201464175bba1318bef7905122e9fda20cff926df78Chris Lattner /// getRecordLayout - Get or compute information about the layout of the 202464175bba1318bef7905122e9fda20cff926df78Chris Lattner /// specified record (struct/union/class), which indicates its size and field 203464175bba1318bef7905122e9fda20cff926df78Chris Lattner /// position information. 204464175bba1318bef7905122e9fda20cff926df78Chris Lattner const RecordLayout &getRecordLayout(const RecordDecl *D, SourceLocation L); 205464175bba1318bef7905122e9fda20cff926df78Chris Lattner 206464175bba1318bef7905122e9fda20cff926df78Chris Lattner //===--------------------------------------------------------------------===// 207464175bba1318bef7905122e9fda20cff926df78Chris Lattner // Type Operators 208464175bba1318bef7905122e9fda20cff926df78Chris Lattner //===--------------------------------------------------------------------===// 209464175bba1318bef7905122e9fda20cff926df78Chris Lattner 210464175bba1318bef7905122e9fda20cff926df78Chris Lattner /// maxIntegerType - Returns the highest ranked integer type. Handles 3 211464175bba1318bef7905122e9fda20cff926df78Chris Lattner /// different type combos: unsigned/unsigned, signed/signed, signed/unsigned. 2125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer static QualType maxIntegerType(QualType lhs, QualType rhs); 2135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 214fb0d49669aa370b4c0993c5cee60275ef9fd6518Steve Naroff /// compareFloatingType - Handles 3 different combos: 215fb0d49669aa370b4c0993c5cee60275ef9fd6518Steve Naroff /// float/float, float/complex, complex/complex. 216fb0d49669aa370b4c0993c5cee60275ef9fd6518Steve Naroff /// If lt > rt, return 1. If lt == rt, return 0. If lt < rt, return -1. 217fb0d49669aa370b4c0993c5cee60275ef9fd6518Steve Naroff static int compareFloatingType(QualType lt, QualType rt); 2185f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 219716c7304ff5d27a95e1e7823acd1d09d5ec3e37fSteve Naroff /// getFloatingTypeOfSizeWithinDomain - Returns a real floating 220716c7304ff5d27a95e1e7823acd1d09d5ec3e37fSteve Naroff /// point or a complex type (based on typeDomain/typeSize). 221716c7304ff5d27a95e1e7823acd1d09d5ec3e37fSteve Naroff /// 'typeDomain' is a real floating point or complex type. 222716c7304ff5d27a95e1e7823acd1d09d5ec3e37fSteve Naroff /// 'typeSize' is a real floating point or complex type. 223f1448a0e4a1e868ff873a8530a61a09cb68666ccSteve Naroff QualType getFloatingTypeOfSizeWithinDomain(QualType typeSize, 224f1448a0e4a1e868ff873a8530a61a09cb68666ccSteve Naroff QualType typeDomain) const; 225ec0550fa3653d46560bf4484a2e988329c228e39Steve Naroff 226ec0550fa3653d46560bf4484a2e988329c228e39Steve Naroff //===--------------------------------------------------------------------===// 227ec0550fa3653d46560bf4484a2e988329c228e39Steve Naroff // Type Compatibility Predicates 228ec0550fa3653d46560bf4484a2e988329c228e39Steve Naroff //===--------------------------------------------------------------------===// 229ec0550fa3653d46560bf4484a2e988329c228e39Steve Naroff 230ec0550fa3653d46560bf4484a2e988329c228e39Steve Naroff /// Compatibility predicates used to check assignment expressions. 231ec0550fa3653d46560bf4484a2e988329c228e39Steve Naroff bool typesAreCompatible(QualType, QualType); // C99 6.2.7p1 232ec0550fa3653d46560bf4484a2e988329c228e39Steve Naroff bool tagTypesAreCompatible(QualType, QualType); // C99 6.2.7p1 233ec0550fa3653d46560bf4484a2e988329c228e39Steve Naroff bool pointerTypesAreCompatible(QualType, QualType); // C99 6.7.5.1p2 234ec0550fa3653d46560bf4484a2e988329c228e39Steve Naroff bool referenceTypesAreCompatible(QualType, QualType); // C++ 5.17p6 235ec0550fa3653d46560bf4484a2e988329c228e39Steve Naroff bool functionTypesAreCompatible(QualType, QualType); // C99 6.7.5.3p15 236ec0550fa3653d46560bf4484a2e988329c228e39Steve Naroff bool arrayTypesAreCompatible(QualType, QualType); // C99 6.7.5.2p6 237ec0550fa3653d46560bf4484a2e988329c228e39Steve Naroff bool builtinTypesAreCompatible(QualType, QualType); 238ec0550fa3653d46560bf4484a2e988329c228e39Steve Naroff 239ec0550fa3653d46560bf4484a2e988329c228e39Steve Naroff /// Objective-C specific type checking. 240ec0550fa3653d46560bf4484a2e988329c228e39Steve Naroff bool interfaceTypesAreCompatible(QualType, QualType); 241ec0550fa3653d46560bf4484a2e988329c228e39Steve Naroff bool objcTypesAreCompatible(QualType, QualType); 242ec0550fa3653d46560bf4484a2e988329c228e39Steve Naroff bool isObjcIdType(QualType T) const { 243ec0550fa3653d46560bf4484a2e988329c228e39Steve Naroff return T->getAsStructureType() == IdStructType; 244ec0550fa3653d46560bf4484a2e988329c228e39Steve Naroff } 2455f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerprivate: 2465f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer ASTContext(const ASTContext&); // DO NOT IMPLEMENT 2475f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void operator=(const ASTContext&); // DO NOT IMPLEMENT 2485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void InitBuiltinTypes(); 2505f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer void InitBuiltinType(QualType &R, BuiltinType::Kind K); 2515f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 2525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2535f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end namespace clang 2545f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 2555f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif 256