ASTContext.h revision 72b2625aa67c8213acaf4bf6209b67859d60e2cf
1ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang//===--- ASTContext.h - Context to hold long-lived AST nodes ----*- C++ -*-===// 2ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang// 3ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang// The LLVM Compiler Infrastructure 4ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang// 5ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang// This file is distributed under the University of Illinois Open Source 6ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang// License. See LICENSE.TXT for details. 7ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang// 8ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang//===----------------------------------------------------------------------===// 9ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang// 10ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang// This file defines the ASTContext interface. 11ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang// 12b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian//===----------------------------------------------------------------------===// 13b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 14b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#ifndef LLVM_CLANG_AST_ASTCONTEXT_H 15ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#define LLVM_CLANG_AST_ASTCONTEXT_H 16b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 17b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#include "clang/Basic/AddressSpaces.h" 18b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#include "clang/Basic/IdentifierTable.h" 19b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#include "clang/Basic/LangOptions.h" 20b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#include "clang/Basic/OperatorKinds.h" 21b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#include "clang/Basic/PartialDiagnostic.h" 22ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#include "clang/Basic/VersionTuple.h" 23b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#include "clang/AST/Decl.h" 24b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#include "clang/AST/NestedNameSpecifier.h" 25b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#include "clang/AST/PrettyPrinter.h" 26b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#include "clang/AST/TemplateName.h" 27b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#include "clang/AST/Type.h" 28ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#include "clang/AST/CanonicalType.h" 29ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#include "clang/AST/UsuallyTinyPtrVector.h" 30b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#include "llvm/ADT/DenseMap.h" 31b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#include "llvm/ADT/FoldingSet.h" 32b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#include "llvm/ADT/IntrusiveRefCntPtr.h" 33b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#include "llvm/ADT/OwningPtr.h" 34ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#include "llvm/ADT/SmallPtrSet.h" 35b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#include "llvm/Support/Allocator.h" 36ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#include <vector> 37b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 38b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramaniannamespace llvm { 39ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang struct fltSemantics; 40b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian} 41b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 42b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramaniannamespace clang { 43ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang class FileManager; 44a72801d7d92ababb50eecf27a36bd222d031d2feVignesh Venkatasubramanian class ASTRecordLayout; 45a72801d7d92ababb50eecf27a36bd222d031d2feVignesh Venkatasubramanian class BlockExpr; 46a72801d7d92ababb50eecf27a36bd222d031d2feVignesh Venkatasubramanian class CharUnits; 47a72801d7d92ababb50eecf27a36bd222d031d2feVignesh Venkatasubramanian class DiagnosticsEngine; 48a72801d7d92ababb50eecf27a36bd222d031d2feVignesh Venkatasubramanian class Expr; 49ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang class ExternalASTSource; 50ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang class ASTMutationListener; 51ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang class IdentifierTable; 525ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang class SelectorTable; 535ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang class SourceManager; 545ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang class TargetInfo; 55ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang class CXXABI; 565ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang // Decls 57ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang class DeclContext; 58b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian class CXXMethodDecl; 59b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian class CXXRecordDecl; 60b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian class Decl; 61b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian class FieldDecl; 62b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian class MangleContext; 63b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian class ObjCIvarDecl; 64b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian class ObjCIvarRefExpr; 65b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian class ObjCPropertyDecl; 66b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian class ParmVarDecl; 67b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian class RecordDecl; 68b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian class StoredDeclsMap; 69b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian class TagDecl; 70b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian class TemplateTemplateParmDecl; 71b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian class TemplateTypeParmDecl; 72b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian class TranslationUnitDecl; 73b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian class TypeDecl; 74b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian class TypedefNameDecl; 75b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian class UsingDecl; 76b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian class UsingShadowDecl; 77b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian class UnresolvedSetIterator; 78b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 79b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian namespace Builtin { class Context; } 80b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 81b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian/// ASTContext - This class holds long-lived AST nodes (such as types and 82b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian/// decls) that can be referred to throughout the semantic analysis of a file. 83b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanianclass ASTContext : public llvm::RefCountedBase<ASTContext> { 84ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang ASTContext &this_() { return *this; } 85b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 86b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable std::vector<Type*> Types; 87b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<ExtQuals> ExtQualNodes; 88b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<ComplexType> ComplexTypes; 89b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<PointerType> PointerTypes; 90b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<BlockPointerType> BlockPointerTypes; 91b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<LValueReferenceType> LValueReferenceTypes; 92b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<RValueReferenceType> RValueReferenceTypes; 93b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<MemberPointerType> MemberPointerTypes; 94b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<ConstantArrayType> ConstantArrayTypes; 95b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<IncompleteArrayType> IncompleteArrayTypes; 96b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable std::vector<VariableArrayType*> VariableArrayTypes; 97b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<DependentSizedArrayType> DependentSizedArrayTypes; 98b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<DependentSizedExtVectorType> 99b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian DependentSizedExtVectorTypes; 100b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<VectorType> VectorTypes; 101b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<FunctionNoProtoType> FunctionNoProtoTypes; 102b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::ContextualFoldingSet<FunctionProtoType, ASTContext&> 103b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian FunctionProtoTypes; 104b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<DependentTypeOfExprType> DependentTypeOfExprTypes; 105b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<DependentDecltypeType> DependentDecltypeTypes; 106b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<TemplateTypeParmType> TemplateTypeParmTypes; 107b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<SubstTemplateTypeParmType> 108b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian SubstTemplateTypeParmTypes; 109b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<SubstTemplateTypeParmPackType> 110b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian SubstTemplateTypeParmPackTypes; 111b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::ContextualFoldingSet<TemplateSpecializationType, ASTContext&> 112b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian TemplateSpecializationTypes; 113b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<ParenType> ParenTypes; 114b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<ElaboratedType> ElaboratedTypes; 115b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<DependentNameType> DependentNameTypes; 116b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::ContextualFoldingSet<DependentTemplateSpecializationType, 117b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian ASTContext&> 118b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian DependentTemplateSpecializationTypes; 119b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian llvm::FoldingSet<PackExpansionType> PackExpansionTypes; 120b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<ObjCObjectTypeImpl> ObjCObjectTypes; 121b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<ObjCObjectPointerType> ObjCObjectPointerTypes; 1225ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang mutable llvm::FoldingSet<AutoType> AutoTypes; 1235ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang mutable llvm::FoldingSet<AtomicType> AtomicTypes; 1245ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang llvm::FoldingSet<AttributedType> AttributedTypes; 125b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 126b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<QualifiedTemplateName> QualifiedTemplateNames; 127b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<DependentTemplateName> DependentTemplateNames; 128b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<SubstTemplateTemplateParmStorage> 129b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian SubstTemplateTemplateParms; 130b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::ContextualFoldingSet<SubstTemplateTemplateParmPackStorage, 131ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang ASTContext&> 132ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang SubstTemplateTemplateParmPacks; 133ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 134ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \brief The set of nested name specifiers. 135ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// 136ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// This set is managed by the NestedNameSpecifier class. 1371184aebb761cbeac9124c37189a80a1a58f04b6bhkuang mutable llvm::FoldingSet<NestedNameSpecifier> NestedNameSpecifiers; 138ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang mutable NestedNameSpecifier *GlobalNestedNameSpecifier; 139ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang friend class NestedNameSpecifier; 140b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 141b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// ASTRecordLayouts - A cache mapping from RecordDecls to ASTRecordLayouts. 142b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// This is lazily created. This is intentionally not serialized. 143b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*> 144b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian ASTRecordLayouts; 145b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::DenseMap<const ObjCContainerDecl*, const ASTRecordLayout*> 146b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian ObjCLayouts; 147b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 148b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// KeyFunctions - A cache mapping from CXXRecordDecls to key functions. 149b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian llvm::DenseMap<const CXXRecordDecl*, const CXXMethodDecl*> KeyFunctions; 150b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 151b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Mapping from ObjCContainers to their ObjCImplementations. 152b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*> ObjCImpls; 153b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 154b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Mapping from ObjCMethod to its duplicate declaration in the same 155b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// interface. 156b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian llvm::DenseMap<const ObjCMethodDecl*,const ObjCMethodDecl*> ObjCMethodRedecls; 1575ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 158b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Mapping from __block VarDecls to their copy initialization expr. 159b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian llvm::DenseMap<const VarDecl*, Expr*> BlockVarCopyInits; 160b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 161b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Mapping from class scope functions specialization to their 162b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// template patterns. 163b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian llvm::DenseMap<const FunctionDecl*, FunctionDecl*> 164b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian ClassScopeSpecializationPattern; 165b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 166b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Representation of a "canonical" template template parameter that 167b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// is used in canonical template names. 168b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian class CanonicalTemplateTemplateParm : public llvm::FoldingSetNode { 169b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian TemplateTemplateParmDecl *Parm; 170b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 171b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian public: 172b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian CanonicalTemplateTemplateParm(TemplateTemplateParmDecl *Parm) 173b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian : Parm(Parm) { } 174ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 175f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang TemplateTemplateParmDecl *getParam() const { return Parm; } 176b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 177ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, Parm); } 178ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 179b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian static void Profile(llvm::FoldingSetNodeID &ID, 180b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian TemplateTemplateParmDecl *Parm); 181b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian }; 182b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::FoldingSet<CanonicalTemplateTemplateParm> 183b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian CanonTemplateTemplateParms; 184ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 185ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang TemplateTemplateParmDecl * 186f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const; 187ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 188f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// \brief The typedef for the __int128_t type. 189ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang mutable TypedefDecl *Int128Decl; 190b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 191b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief The typedef for the __uint128_t type. 192ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang mutable TypedefDecl *UInt128Decl; 193ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 194ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// BuiltinVaListType - built-in va list type. 19591037db265ecdd914a26e056cf69207b4f50924ehkuang /// This is initially null and set by Sema::LazilyCreateBuiltin when 19691037db265ecdd914a26e056cf69207b4f50924ehkuang /// a builtin that takes a valist is encountered. 19791037db265ecdd914a26e056cf69207b4f50924ehkuang QualType BuiltinVaListType; 19891037db265ecdd914a26e056cf69207b4f50924ehkuang 19991037db265ecdd914a26e056cf69207b4f50924ehkuang /// \brief The typedef for the predefined 'id' type. 20091037db265ecdd914a26e056cf69207b4f50924ehkuang mutable TypedefDecl *ObjCIdDecl; 201ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 202ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \brief The typedef for the predefined 'SEL' type. 203ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang mutable TypedefDecl *ObjCSelDecl; 204ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 205ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang QualType ObjCProtoType; 206ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const RecordType *ProtoStructType; 207ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 208ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \brief The typedef for the predefined 'Class' type. 209ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang mutable TypedefDecl *ObjCClassDecl; 210ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 211ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang // Typedefs which may be provided defining the structure of Objective-C 212ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang // pseudo-builtins 213ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang QualType ObjCIdRedefinitionType; 214ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang QualType ObjCClassRedefinitionType; 215b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType ObjCSelRedefinitionType; 216b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 217b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType ObjCConstantStringType; 218ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang mutable RecordDecl *CFConstantStringTypeDecl; 219ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 220ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \brief The typedef declaration for the Objective-C "instancetype" type. 221b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian TypedefDecl *ObjCInstanceTypeDecl; 222ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 2235ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// \brief The type for the C FILE type. 2245ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang TypeDecl *FILEDecl; 2255ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 2265ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// \brief The type for the C jmp_buf type. 2275ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang TypeDecl *jmp_bufDecl; 2285ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 2295ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// \brief The type for the C sigjmp_buf type. 2305ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang TypeDecl *sigjmp_bufDecl; 2315ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 232ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \brief Type for the Block descriptor for Blocks CodeGen. 233ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// 2345ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// Since this is only used for generation of debug info, it is not 2355ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// serialized. 236b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable RecordDecl *BlockDescriptorType; 237b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 2381184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// \brief Type for the Block descriptor for Blocks CodeGen. 2391184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// 240ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// Since this is only used for generation of debug info, it is not 241ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// serialized. 242ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang mutable RecordDecl *BlockDescriptorExtendedType; 243ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 244ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \brief Declaration for the CUDA cudaConfigureCall function. 2455ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang FunctionDecl *cudaConfigureCallDecl; 246b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 2475ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang TypeSourceInfo NullTypeSourceInfo; 248ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 2495ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// \brief Keeps track of all declaration attributes. 250b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// 251b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// Since so few decls have attrs, we keep them in a hash map instead of 252b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// wasting space in the Decl class. 253b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian llvm::DenseMap<const Decl*, AttrVec*> DeclAttrs; 254ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 2551184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// \brief Keeps track of the static data member templates from which 256b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// static data members of class template specializations were instantiated. 257b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// 258b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// This data structure stores the mapping from instantiations of static 259b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// data members to the static data member representations within the 260b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// class template from which they were instantiated along with the kind 261b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// of instantiation or specialization (a TemplateSpecializationKind - 1). 262b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// 2636ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// Given the following example: 264b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// 265ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \code 2665ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// template<typename T> 267b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// struct X { 2686ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// static T value; 2696ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// }; 270b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// 271ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// template<typename T> 272ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// T X<T>::value = T(17); 273ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// 2745ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// int *x = &X<int>::value; 2755ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// \endcode 2765ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// 277b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// This mapping will contain an entry that maps from the VarDecl for 278b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// X<int>::value to the corresponding VarDecl for X<T>::value (within the 279b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// class template X) and will be marked TSK_ImplicitInstantiation. 2805ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang llvm::DenseMap<const VarDecl *, MemberSpecializationInfo *> 281b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian InstantiatedFromStaticDataMember; 2825ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 2835ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// \brief Keeps track of the declaration from which a UsingDecl was 284b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// created during instantiation. The source declaration is always 285ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// a UsingDecl, an UnresolvedUsingValueDecl, or an 286b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// UnresolvedUsingTypenameDecl. 287b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// 2885ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// For example: 289b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \code 290b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// template<typename T> 2919b35249446b07f40ac5fcc3205f2c048616efacchkuang /// struct A { 2925ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// void f(); 293ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// }; 294b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// 295b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// template<typename T> 296ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// struct B : A<T> { 297b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// using A<T>::f; 298b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// }; 299b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// 300b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// template struct B<int>; 301ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \endcode 302b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// 303b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// This mapping will contain an entry that maps from the UsingDecl in 304b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// B<int> to the UnresolvedUsingDecl in B<T>. 30591037db265ecdd914a26e056cf69207b4f50924ehkuang llvm::DenseMap<UsingDecl *, NamedDecl *> InstantiatedFromUsingDecl; 306b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 307b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian llvm::DenseMap<UsingShadowDecl*, UsingShadowDecl*> 308b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian InstantiatedFromUsingShadowDecl; 309b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 310b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian llvm::DenseMap<FieldDecl *, FieldDecl *> InstantiatedFromUnnamedFieldDecl; 31191037db265ecdd914a26e056cf69207b4f50924ehkuang 312b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Mapping that stores the methods overridden by a given C++ 313b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// member function. 314b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// 31591037db265ecdd914a26e056cf69207b4f50924ehkuang /// Since most C++ member functions aren't virtual and therefore 31691037db265ecdd914a26e056cf69207b4f50924ehkuang /// don't override anything, we store the overridden functions in 31791037db265ecdd914a26e056cf69207b4f50924ehkuang /// this map on the side rather than within the CXXMethodDecl structure. 31891037db265ecdd914a26e056cf69207b4f50924ehkuang typedef UsuallyTinyPtrVector<const CXXMethodDecl> CXXMethodVector; 319b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector> OverriddenMethods; 32091037db265ecdd914a26e056cf69207b4f50924ehkuang 321b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Mapping that stores parameterIndex values for ParmVarDecls 32291037db265ecdd914a26e056cf69207b4f50924ehkuang /// when that value exceeds the bitfield size of 323b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// ParmVarDeclBits.ParameterIndex. 324b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian typedef llvm::DenseMap<const VarDecl *, unsigned> ParameterIndexTable; 325b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian ParameterIndexTable ParamIndices; 326b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 32791037db265ecdd914a26e056cf69207b4f50924ehkuang TranslationUnitDecl *TUDecl; 32891037db265ecdd914a26e056cf69207b4f50924ehkuang 32991037db265ecdd914a26e056cf69207b4f50924ehkuang /// SourceMgr - The associated SourceManager object. 33091037db265ecdd914a26e056cf69207b4f50924ehkuang SourceManager &SourceMgr; 33191037db265ecdd914a26e056cf69207b4f50924ehkuang 33291037db265ecdd914a26e056cf69207b4f50924ehkuang /// LangOpts - The language options used to create the AST associated with 33391037db265ecdd914a26e056cf69207b4f50924ehkuang /// this ASTContext object. 334b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian LangOptions &LangOpts; 335b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 336b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief The allocator used to create AST objects. 337b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// 338b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// AST objects are never destructed; rather, all memory associated with the 339b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// AST objects will be released when the ASTContext itself is destroyed. 340b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable llvm::BumpPtrAllocator BumpAlloc; 341b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 342b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Allocator for partial diagnostics. 343b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian PartialDiagnostic::StorageAllocator DiagAllocator; 344b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 345b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief The current C++ ABI. 346b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian llvm::OwningPtr<CXXABI> ABI; 347b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian CXXABI *createCXXABI(const TargetInfo &T); 34891037db265ecdd914a26e056cf69207b4f50924ehkuang 34991037db265ecdd914a26e056cf69207b4f50924ehkuang /// \brief The logical -> physical address space map. 35091037db265ecdd914a26e056cf69207b4f50924ehkuang const LangAS::Map *AddrSpaceMap; 35191037db265ecdd914a26e056cf69207b4f50924ehkuang 35291037db265ecdd914a26e056cf69207b4f50924ehkuang friend class ASTDeclReader; 35391037db265ecdd914a26e056cf69207b4f50924ehkuang friend class ASTReader; 35491037db265ecdd914a26e056cf69207b4f50924ehkuang friend class ASTWriter; 35591037db265ecdd914a26e056cf69207b4f50924ehkuang 356b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const TargetInfo *Target; 357b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian clang::PrintingPolicy PrintingPolicy; 358b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 359b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanianpublic: 360b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian IdentifierTable &Idents; 361b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian SelectorTable &Selectors; 362b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian Builtin::Context &BuiltinInfo; 363b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable DeclarationNameTable DeclarationNames; 364b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian llvm::OwningPtr<ExternalASTSource> ExternalSource; 365b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian ASTMutationListener *Listener; 366b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 367b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian clang::PrintingPolicy getPrintingPolicy() const { return PrintingPolicy; } 368b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 369b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian void setPrintingPolicy(clang::PrintingPolicy Policy) { 370b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian PrintingPolicy = Policy; 371b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian } 372b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 373b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian SourceManager& getSourceManager() { return SourceMgr; } 374b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const SourceManager& getSourceManager() const { return SourceMgr; } 375b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian void *Allocate(unsigned Size, unsigned Align = 8) const { 376b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian return BumpAlloc.Allocate(Size, Align); 377b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian } 378b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian void Deallocate(void *Ptr) const { } 379b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 380b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// Return the total amount of physical memory allocated for representing 381b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// AST nodes and type information. 382b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian size_t getASTAllocatedMemory() const { 383b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian return BumpAlloc.getTotalMemory(); 384b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian } 38591037db265ecdd914a26e056cf69207b4f50924ehkuang /// Return the total memory used for various side tables. 38691037db265ecdd914a26e056cf69207b4f50924ehkuang size_t getSideTableAllocatedMemory() const; 387b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 388b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian PartialDiagnostic::StorageAllocator &getDiagAllocator() { 389b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian return DiagAllocator; 390b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian } 39191037db265ecdd914a26e056cf69207b4f50924ehkuang 392b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const TargetInfo &getTargetInfo() const { return *Target; } 393b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 394b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const LangOptions& getLangOptions() const { return LangOpts; } 395b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 396b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian DiagnosticsEngine &getDiagnostics() const; 397b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 398b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian FullSourceLoc getFullLoc(SourceLocation Loc) const { 399b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian return FullSourceLoc(Loc,SourceMgr); 40091037db265ecdd914a26e056cf69207b4f50924ehkuang } 40191037db265ecdd914a26e056cf69207b4f50924ehkuang 402b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Retrieve the attributes for the given declaration. 403b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian AttrVec& getDeclAttrs(const Decl *D); 404b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 40591037db265ecdd914a26e056cf69207b4f50924ehkuang /// \brief Erase the attributes corresponding to the given declaration. 40691037db265ecdd914a26e056cf69207b4f50924ehkuang void eraseDeclAttrs(const Decl *D); 40791037db265ecdd914a26e056cf69207b4f50924ehkuang 40891037db265ecdd914a26e056cf69207b4f50924ehkuang /// \brief If this variable is an instantiated static data member of a 40991037db265ecdd914a26e056cf69207b4f50924ehkuang /// class template specialization, returns the templated static data member 41091037db265ecdd914a26e056cf69207b4f50924ehkuang /// from which it was instantiated. 411b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian MemberSpecializationInfo *getInstantiatedFromStaticDataMember( 41291037db265ecdd914a26e056cf69207b4f50924ehkuang const VarDecl *Var); 41391037db265ecdd914a26e056cf69207b4f50924ehkuang 41491037db265ecdd914a26e056cf69207b4f50924ehkuang FunctionDecl *getClassScopeSpecializationPattern(const FunctionDecl *FD); 415b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 416b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian void setClassScopeSpecializationPattern(FunctionDecl *FD, 417b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian FunctionDecl *Pattern); 418b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 419b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Note that the static data member \p Inst is an instantiation of 420b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// the static data member template \p Tmpl of a class template. 421b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl, 422b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian TemplateSpecializationKind TSK, 42391037db265ecdd914a26e056cf69207b4f50924ehkuang SourceLocation PointOfInstantiation = SourceLocation()); 42491037db265ecdd914a26e056cf69207b4f50924ehkuang 42591037db265ecdd914a26e056cf69207b4f50924ehkuang /// \brief If the given using decl is an instantiation of a 4261184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// (possibly unresolved) using decl from a template instantiation, 42791037db265ecdd914a26e056cf69207b4f50924ehkuang /// return it. 42891037db265ecdd914a26e056cf69207b4f50924ehkuang NamedDecl *getInstantiatedFromUsingDecl(UsingDecl *Inst); 42991037db265ecdd914a26e056cf69207b4f50924ehkuang 43091037db265ecdd914a26e056cf69207b4f50924ehkuang /// \brief Remember that the using decl \p Inst is an instantiation 43191037db265ecdd914a26e056cf69207b4f50924ehkuang /// of the using decl \p Pattern of a class template. 432b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian void setInstantiatedFromUsingDecl(UsingDecl *Inst, NamedDecl *Pattern); 433b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 434b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, 4356ac915abcdb404a00d927fe6308a47fcf09d9519hkuang UsingShadowDecl *Pattern); 436b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian UsingShadowDecl *getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst); 43791037db265ecdd914a26e056cf69207b4f50924ehkuang 43891037db265ecdd914a26e056cf69207b4f50924ehkuang FieldDecl *getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field); 43991037db265ecdd914a26e056cf69207b4f50924ehkuang 44091037db265ecdd914a26e056cf69207b4f50924ehkuang void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl); 4411184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 442b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// ZeroBitfieldFollowsNonBitfield - return 'true" if 'FD' is a zero-length 44391037db265ecdd914a26e056cf69207b4f50924ehkuang /// bitfield which follows the non-bitfield 'LastFD'. 44491037db265ecdd914a26e056cf69207b4f50924ehkuang bool ZeroBitfieldFollowsNonBitfield(const FieldDecl *FD, 44591037db265ecdd914a26e056cf69207b4f50924ehkuang const FieldDecl *LastFD) const; 446b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 447b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// ZeroBitfieldFollowsBitfield - return 'true" if 'FD' is a zero-length 448b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// bitfield which follows the bitfield 'LastFD'. 449b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian bool ZeroBitfieldFollowsBitfield(const FieldDecl *FD, 450b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const FieldDecl *LastFD) const; 451b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 452b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// BitfieldFollowsBitfield - return 'true" if 'FD' is a 453b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// bitfield which follows the bitfield 'LastFD'. 454b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian bool BitfieldFollowsBitfield(const FieldDecl *FD, 455b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const FieldDecl *LastFD) const; 456b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 457b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// NonBitfieldFollowsBitfield - return 'true" if 'FD' is not a 458b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// bitfield which follows the bitfield 'LastFD'. 459b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian bool NonBitfieldFollowsBitfield(const FieldDecl *FD, 460b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const FieldDecl *LastFD) const; 461b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 462b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// BitfieldFollowsNonBitfield - return 'true" if 'FD' is a 463b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// bitfield which follows the none bitfield 'LastFD'. 464b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian bool BitfieldFollowsNonBitfield(const FieldDecl *FD, 465b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const FieldDecl *LastFD) const; 466b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 467b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian // Access to the set of methods overridden by the given C++ method. 468b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian typedef CXXMethodVector::iterator overridden_cxx_method_iterator; 469b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian overridden_cxx_method_iterator 470b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian overridden_methods_begin(const CXXMethodDecl *Method) const; 47191037db265ecdd914a26e056cf69207b4f50924ehkuang 47291037db265ecdd914a26e056cf69207b4f50924ehkuang overridden_cxx_method_iterator 473b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian overridden_methods_end(const CXXMethodDecl *Method) const; 47491037db265ecdd914a26e056cf69207b4f50924ehkuang 47591037db265ecdd914a26e056cf69207b4f50924ehkuang unsigned overridden_methods_size(const CXXMethodDecl *Method) const; 47691037db265ecdd914a26e056cf69207b4f50924ehkuang 4771184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// \brief Note that the given C++ \p Method overrides the given \p 47891037db265ecdd914a26e056cf69207b4f50924ehkuang /// Overridden method. 47991037db265ecdd914a26e056cf69207b4f50924ehkuang void addOverriddenMethod(const CXXMethodDecl *Method, 48091037db265ecdd914a26e056cf69207b4f50924ehkuang const CXXMethodDecl *Overridden); 48191037db265ecdd914a26e056cf69207b4f50924ehkuang 4821184aebb761cbeac9124c37189a80a1a58f04b6bhkuang TranslationUnitDecl *getTranslationUnitDecl() const { return TUDecl; } 4831184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 484b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 485b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian // Builtin Types. 486b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian CanQualType VoidTy; 487b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian CanQualType BoolTy; 48891037db265ecdd914a26e056cf69207b4f50924ehkuang CanQualType CharTy; 48991037db265ecdd914a26e056cf69207b4f50924ehkuang CanQualType WCharTy; // [C++ 3.9.1p5], integer type in C99. 4901184aebb761cbeac9124c37189a80a1a58f04b6bhkuang CanQualType Char16Ty; // [C++0x 3.9.1p5], integer type in C99. 49191037db265ecdd914a26e056cf69207b4f50924ehkuang CanQualType Char32Ty; // [C++0x 3.9.1p5], integer type in C99. 49291037db265ecdd914a26e056cf69207b4f50924ehkuang CanQualType SignedCharTy, ShortTy, IntTy, LongTy, LongLongTy, Int128Ty; 49391037db265ecdd914a26e056cf69207b4f50924ehkuang CanQualType UnsignedCharTy, UnsignedShortTy, UnsignedIntTy, UnsignedLongTy; 49491037db265ecdd914a26e056cf69207b4f50924ehkuang CanQualType UnsignedLongLongTy, UnsignedInt128Ty; 49591037db265ecdd914a26e056cf69207b4f50924ehkuang CanQualType FloatTy, DoubleTy, LongDoubleTy; 49691037db265ecdd914a26e056cf69207b4f50924ehkuang CanQualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy; 49791037db265ecdd914a26e056cf69207b4f50924ehkuang CanQualType VoidPtrTy, NullPtrTy; 49891037db265ecdd914a26e056cf69207b4f50924ehkuang CanQualType DependentTy, OverloadTy, BoundMemberTy, UnknownAnyTy; 49991037db265ecdd914a26e056cf69207b4f50924ehkuang CanQualType ObjCBuiltinIdTy, ObjCBuiltinClassTy, ObjCBuiltinSelTy; 50091037db265ecdd914a26e056cf69207b4f50924ehkuang 50191037db265ecdd914a26e056cf69207b4f50924ehkuang // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. 50291037db265ecdd914a26e056cf69207b4f50924ehkuang mutable QualType AutoDeductTy; // Deduction against 'auto'. 5031184aebb761cbeac9124c37189a80a1a58f04b6bhkuang mutable QualType AutoRRefDeductTy; // Deduction against 'auto &&'. 50491037db265ecdd914a26e056cf69207b4f50924ehkuang 50591037db265ecdd914a26e056cf69207b4f50924ehkuang ASTContext(LangOptions& LOpts, SourceManager &SM, const TargetInfo *t, 50691037db265ecdd914a26e056cf69207b4f50924ehkuang IdentifierTable &idents, SelectorTable &sels, 50791037db265ecdd914a26e056cf69207b4f50924ehkuang Builtin::Context &builtins, 50891037db265ecdd914a26e056cf69207b4f50924ehkuang unsigned size_reserve, 50991037db265ecdd914a26e056cf69207b4f50924ehkuang bool DelayInitialization = false); 5101184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 5111184aebb761cbeac9124c37189a80a1a58f04b6bhkuang ~ASTContext(); 5121184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 51391037db265ecdd914a26e056cf69207b4f50924ehkuang /// \brief Attach an external AST source to the AST context. 514b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// 515b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// The external AST source provides the ability to load parts of 51691037db265ecdd914a26e056cf69207b4f50924ehkuang /// the abstract syntax tree as needed from some external storage, 51791037db265ecdd914a26e056cf69207b4f50924ehkuang /// e.g., a precompiled header. 51891037db265ecdd914a26e056cf69207b4f50924ehkuang void setExternalSource(llvm::OwningPtr<ExternalASTSource> &Source); 51991037db265ecdd914a26e056cf69207b4f50924ehkuang 520ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \brief Retrieve a pointer to the external AST source associated 5211184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// with this AST context, if any. 52291037db265ecdd914a26e056cf69207b4f50924ehkuang ExternalASTSource *getExternalSource() const { return ExternalSource.get(); } 5231184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 524ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \brief Attach an AST mutation listener to the AST context. 525ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// 526b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// The AST mutation listener provides the ability to track modifications to 52791037db265ecdd914a26e056cf69207b4f50924ehkuang /// the abstract syntax tree entities committed after they were initially 52891037db265ecdd914a26e056cf69207b4f50924ehkuang /// created. 52991037db265ecdd914a26e056cf69207b4f50924ehkuang void setASTMutationListener(ASTMutationListener *Listener) { 530ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang this->Listener = Listener; 531ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } 532b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 533b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Retrieve a pointer to the AST mutation listener associated 534b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// with this AST context, if any. 535ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang ASTMutationListener *getASTMutationListener() const { return Listener; } 536ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 53791037db265ecdd914a26e056cf69207b4f50924ehkuang void PrintStats() const; 538ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const std::vector<Type*>& getTypes() const { return Types; } 539ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 540ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \brief Retrieve the declaration for the 128-bit signed integer type. 541f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang TypedefDecl *getInt128Decl() const; 542f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang 543f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// \brief Retrieve the declaration for the 128-bit unsigned integer type. 544f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang TypedefDecl *getUInt128Decl() const; 545f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang 546f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang //===--------------------------------------------------------------------===// 547f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang // Type Constructors 548f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang //===--------------------------------------------------------------------===// 549f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang 550f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuangprivate: 55191037db265ecdd914a26e056cf69207b4f50924ehkuang /// getExtQualType - Return a type with extended qualifiers. 5525ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang QualType getExtQualType(const Type *Base, Qualifiers Quals) const; 5531184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 55491037db265ecdd914a26e056cf69207b4f50924ehkuang QualType getTypeDeclTypeSlow(const TypeDecl *Decl) const; 555ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 556b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanianpublic: 557b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getAddSpaceQualType - Return the uniqued reference to the type for an 5585ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// address space qualified type with the specified type and address space. 5596ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// The resulting type has a union of the qualifiers from T and the address 560b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// space. If T already has an address space specifier, it is silently 561b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// replaced. 5621184aebb761cbeac9124c37189a80a1a58f04b6bhkuang QualType getAddrSpaceQualType(QualType T, unsigned AddressSpace) const; 563f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang 564b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getObjCGCQualType - Returns the uniqued reference to the type for an 565b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// objc gc qualified type. The retulting type has a union of the qualifiers 566b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// from T and the gc attribute. 567b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const; 5686ac915abcdb404a00d927fe6308a47fcf09d9519hkuang 569b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getRestrictType - Returns the uniqued reference to the type for a 5701184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// 'restrict' qualified type. The resulting type has a union of the 571ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// qualifiers from T and 'restrict'. 572b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getRestrictType(QualType T) const { 573b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian return T.withFastQualifiers(Qualifiers::Restrict); 57491037db265ecdd914a26e056cf69207b4f50924ehkuang } 57591037db265ecdd914a26e056cf69207b4f50924ehkuang 57691037db265ecdd914a26e056cf69207b4f50924ehkuang /// getVolatileType - Returns the uniqued reference to the type for a 577b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// 'volatile' qualified type. The resulting type has a union of the 57891037db265ecdd914a26e056cf69207b4f50924ehkuang /// qualifiers from T and 'volatile'. 57991037db265ecdd914a26e056cf69207b4f50924ehkuang QualType getVolatileType(QualType T) const { 5801184aebb761cbeac9124c37189a80a1a58f04b6bhkuang return T.withFastQualifiers(Qualifiers::Volatile); 58191037db265ecdd914a26e056cf69207b4f50924ehkuang } 58291037db265ecdd914a26e056cf69207b4f50924ehkuang 583b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getConstType - Returns the uniqued reference to the type for a 5841184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// 'const' qualified type. The resulting type has a union of the 585f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// qualifiers from T and 'const'. 5866ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// 587f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// It can be reasonably expected that this will always be 58891037db265ecdd914a26e056cf69207b4f50924ehkuang /// equivalent to calling T.withConst(). 58991037db265ecdd914a26e056cf69207b4f50924ehkuang QualType getConstType(QualType T) const { return T.withConst(); } 59091037db265ecdd914a26e056cf69207b4f50924ehkuang 59191037db265ecdd914a26e056cf69207b4f50924ehkuang /// adjustFunctionType - Change the ExtInfo on a function type. 59291037db265ecdd914a26e056cf69207b4f50924ehkuang const FunctionType *adjustFunctionType(const FunctionType *Fn, 59391037db265ecdd914a26e056cf69207b4f50924ehkuang FunctionType::ExtInfo EInfo); 594b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 59591037db265ecdd914a26e056cf69207b4f50924ehkuang /// getComplexType - Return the uniqued reference to the type for a complex 596b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// number with the specified element type. 597b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getComplexType(QualType T) const; 598b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian CanQualType getComplexType(CanQualType T) const { 5996ac915abcdb404a00d927fe6308a47fcf09d9519hkuang return CanQualType::CreateUnsafe(getComplexType((QualType) T)); 600b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian } 6016ac915abcdb404a00d927fe6308a47fcf09d9519hkuang 602b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getPointerType - Return the uniqued reference to the type for a pointer to 60391037db265ecdd914a26e056cf69207b4f50924ehkuang /// the specified type. 60491037db265ecdd914a26e056cf69207b4f50924ehkuang QualType getPointerType(QualType T) const; 605f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang CanQualType getPointerType(CanQualType T) const { 606f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang return CanQualType::CreateUnsafe(getPointerType((QualType) T)); 60791037db265ecdd914a26e056cf69207b4f50924ehkuang } 60891037db265ecdd914a26e056cf69207b4f50924ehkuang 60991037db265ecdd914a26e056cf69207b4f50924ehkuang /// getAtomicType - Return the uniqued reference to the atomic type for 61091037db265ecdd914a26e056cf69207b4f50924ehkuang /// the specified type. 611f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang QualType getAtomicType(QualType T) const; 612b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 613b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getBlockPointerType - Return the uniqued reference to the type for a block 614b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// of the specified type. 6156ac915abcdb404a00d927fe6308a47fcf09d9519hkuang QualType getBlockPointerType(QualType T) const; 616b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 617b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// This gets the struct used to keep track of the descriptor for pointer to 61891037db265ecdd914a26e056cf69207b4f50924ehkuang /// blocks. 619ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang QualType getBlockDescriptorType() const; 620ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 62191037db265ecdd914a26e056cf69207b4f50924ehkuang /// This gets the struct used to keep track of the extended descriptor for 6221184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// pointer to blocks. 62391037db265ecdd914a26e056cf69207b4f50924ehkuang QualType getBlockDescriptorExtendedType() const; 62491037db265ecdd914a26e056cf69207b4f50924ehkuang 62591037db265ecdd914a26e056cf69207b4f50924ehkuang void setcudaConfigureCallDecl(FunctionDecl *FD) { 626b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian cudaConfigureCallDecl = FD; 627b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian } 6281184aebb761cbeac9124c37189a80a1a58f04b6bhkuang FunctionDecl *getcudaConfigureCallDecl() { 62991037db265ecdd914a26e056cf69207b4f50924ehkuang return cudaConfigureCallDecl; 63091037db265ecdd914a26e056cf69207b4f50924ehkuang } 631b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 632b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// This builds the struct used for __block variables. 63391037db265ecdd914a26e056cf69207b4f50924ehkuang QualType BuildByRefType(StringRef DeclName, QualType Ty) const; 634b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 6351184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// Returns true iff we need copy/dispose helpers for the given type. 6361184aebb761cbeac9124c37189a80a1a58f04b6bhkuang bool BlockRequiresCopying(QualType Ty) const; 6375ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 6385ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// getLValueReferenceType - Return the uniqued reference to the type for an 6395ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// lvalue reference to the specified type. 64091037db265ecdd914a26e056cf69207b4f50924ehkuang QualType getLValueReferenceType(QualType T, bool SpelledAsLValue = true) 6416ac915abcdb404a00d927fe6308a47fcf09d9519hkuang const; 64291037db265ecdd914a26e056cf69207b4f50924ehkuang 64391037db265ecdd914a26e056cf69207b4f50924ehkuang /// getRValueReferenceType - Return the uniqued reference to the type for an 6445ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// rvalue reference to the specified type. 6455ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang QualType getRValueReferenceType(QualType T) const; 64691037db265ecdd914a26e056cf69207b4f50924ehkuang 64791037db265ecdd914a26e056cf69207b4f50924ehkuang /// getMemberPointerType - Return the uniqued reference to the type for a 64891037db265ecdd914a26e056cf69207b4f50924ehkuang /// member pointer to the specified type in the specified class. The class 64991037db265ecdd914a26e056cf69207b4f50924ehkuang /// is a Type because it could be a dependent name. 6501184aebb761cbeac9124c37189a80a1a58f04b6bhkuang QualType getMemberPointerType(QualType T, const Type *Cls) const; 651b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 6521184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// getVariableArrayType - Returns a non-unique reference to the type for a 653b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// variable array of the specified element type. 65491037db265ecdd914a26e056cf69207b4f50924ehkuang QualType getVariableArrayType(QualType EltTy, Expr *NumElts, 6555ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang ArrayType::ArraySizeModifier ASM, 656b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian unsigned IndexTypeQuals, 657b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian SourceRange Brackets) const; 658b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 65991037db265ecdd914a26e056cf69207b4f50924ehkuang /// getDependentSizedArrayType - Returns a non-unique reference to 66091037db265ecdd914a26e056cf69207b4f50924ehkuang /// the type for a dependently-sized array of the specified element 661b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// type. FIXME: We will need these to be uniqued, or at least 662b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// comparable, at some point. 66391037db265ecdd914a26e056cf69207b4f50924ehkuang QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, 66491037db265ecdd914a26e056cf69207b4f50924ehkuang ArrayType::ArraySizeModifier ASM, 66591037db265ecdd914a26e056cf69207b4f50924ehkuang unsigned IndexTypeQuals, 6666ac915abcdb404a00d927fe6308a47fcf09d9519hkuang SourceRange Brackets) const; 66791037db265ecdd914a26e056cf69207b4f50924ehkuang 66891037db265ecdd914a26e056cf69207b4f50924ehkuang /// getIncompleteArrayType - Returns a unique reference to the type for a 66991037db265ecdd914a26e056cf69207b4f50924ehkuang /// incomplete array of the specified element type. 67091037db265ecdd914a26e056cf69207b4f50924ehkuang QualType getIncompleteArrayType(QualType EltTy, 67191037db265ecdd914a26e056cf69207b4f50924ehkuang ArrayType::ArraySizeModifier ASM, 672b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian unsigned IndexTypeQuals) const; 673b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 67491037db265ecdd914a26e056cf69207b4f50924ehkuang /// getConstantArrayType - Return the unique reference to the type for a 675b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// constant array of the specified element type. 67691037db265ecdd914a26e056cf69207b4f50924ehkuang QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, 6771184aebb761cbeac9124c37189a80a1a58f04b6bhkuang ArrayType::ArraySizeModifier ASM, 6781184aebb761cbeac9124c37189a80a1a58f04b6bhkuang unsigned IndexTypeQuals) const; 6795ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 6805ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// getVariableArrayDecayedType - Returns a vla type where known sizes 68191037db265ecdd914a26e056cf69207b4f50924ehkuang /// are replaced with [*]. 6825ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang QualType getVariableArrayDecayedType(QualType Ty) const; 6835ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 684b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getVectorType - Return the unique reference to a vector type of 685b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// the specified element type and size. VectorType must be a built-in type. 686b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getVectorType(QualType VectorType, unsigned NumElts, 6875ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang VectorType::VectorKind VecKind) const; 6885ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 6895ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// getExtVectorType - Return the unique reference to an extended vector type 6905ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// of the specified element type and size. VectorType must be a built-in 6915ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// type. 6925ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang QualType getExtVectorType(QualType VectorType, unsigned NumElts) const; 6935ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 6945ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// getDependentSizedExtVectorType - Returns a non-unique reference to 6955ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// the type for a dependently-sized vector of the specified element 6965ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// type. FIXME: We will need these to be uniqued, or at least 6975ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// comparable, at some point. 6981184aebb761cbeac9124c37189a80a1a58f04b6bhkuang QualType getDependentSizedExtVectorType(QualType VectorType, 699b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian Expr *SizeExpr, 700b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian SourceLocation AttrLoc) const; 701b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 702b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getFunctionNoProtoType - Return a K&R style C function type like 'int()'. 703b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// 704b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getFunctionNoProtoType(QualType ResultTy, 705b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const FunctionType::ExtInfo &Info) const; 706b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 707b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getFunctionNoProtoType(QualType ResultTy) const { 708b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian return getFunctionNoProtoType(ResultTy, FunctionType::ExtInfo()); 7095ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang } 71091037db265ecdd914a26e056cf69207b4f50924ehkuang 71191037db265ecdd914a26e056cf69207b4f50924ehkuang /// getFunctionType - Return a normal function type with a typed 7125ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// argument list. 7135ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang QualType getFunctionType(QualType ResultTy, 71491037db265ecdd914a26e056cf69207b4f50924ehkuang const QualType *Args, unsigned NumArgs, 71591037db265ecdd914a26e056cf69207b4f50924ehkuang const FunctionProtoType::ExtProtoInfo &EPI) const; 7165ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 7175ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// getTypeDeclType - Return the unique reference to the type for 7185ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// the specified type declaration. 7195ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang QualType getTypeDeclType(const TypeDecl *Decl, 72091037db265ecdd914a26e056cf69207b4f50924ehkuang const TypeDecl *PrevDecl = 0) const { 72191037db265ecdd914a26e056cf69207b4f50924ehkuang assert(Decl && "Passed null for Decl param"); 7225ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0); 7235ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 7245ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang if (PrevDecl) { 7255ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang assert(PrevDecl->TypeForDecl && "previous decl has no TypeForDecl"); 72691037db265ecdd914a26e056cf69207b4f50924ehkuang Decl->TypeForDecl = PrevDecl->TypeForDecl; 72791037db265ecdd914a26e056cf69207b4f50924ehkuang return QualType(PrevDecl->TypeForDecl, 0); 7285ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang } 7295ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 7305ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang return getTypeDeclTypeSlow(Decl); 7315ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang } 73291037db265ecdd914a26e056cf69207b4f50924ehkuang 73391037db265ecdd914a26e056cf69207b4f50924ehkuang /// getTypedefType - Return the unique reference to the type for the 734b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// specified typedef-name decl. 73591037db265ecdd914a26e056cf69207b4f50924ehkuang QualType getTypedefType(const TypedefNameDecl *Decl, 7365ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang QualType Canon = QualType()) const; 7375ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 7385ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang QualType getRecordType(const RecordDecl *Decl) const; 7395ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 7405ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang QualType getEnumType(const EnumDecl *Decl) const; 7415ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 742b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const; 743b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 7445ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang QualType getAttributedType(AttributedType::Kind attrKind, 745b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType modifiedType, 746b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType equivalentType); 747b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 748b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getSubstTemplateTypeParmType(const TemplateTypeParmType *Replaced, 749b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType Replacement) const; 75091037db265ecdd914a26e056cf69207b4f50924ehkuang QualType getSubstTemplateTypeParmPackType( 7515ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang const TemplateTypeParmType *Replaced, 7526ac915abcdb404a00d927fe6308a47fcf09d9519hkuang const TemplateArgument &ArgPack); 7535ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 754b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getTemplateTypeParmType(unsigned Depth, unsigned Index, 7555ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang bool ParameterPack, 756b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian TemplateTypeParmDecl *ParmDecl = 0) const; 7575ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 758b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getTemplateSpecializationType(TemplateName T, 759b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const TemplateArgument *Args, 760b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian unsigned NumArgs, 7615ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang QualType Canon = QualType()) const; 7625ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 7635ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang QualType getCanonicalTemplateSpecializationType(TemplateName T, 7645ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang const TemplateArgument *Args, 7655ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang unsigned NumArgs) const; 766b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 767b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getTemplateSpecializationType(TemplateName T, 768b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const TemplateArgumentListInfo &Args, 769b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType Canon = QualType()) const; 7705ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 77191037db265ecdd914a26e056cf69207b4f50924ehkuang TypeSourceInfo * 77291037db265ecdd914a26e056cf69207b4f50924ehkuang getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc, 77391037db265ecdd914a26e056cf69207b4f50924ehkuang const TemplateArgumentListInfo &Args, 77491037db265ecdd914a26e056cf69207b4f50924ehkuang QualType Canon = QualType()) const; 77591037db265ecdd914a26e056cf69207b4f50924ehkuang 77691037db265ecdd914a26e056cf69207b4f50924ehkuang QualType getParenType(QualType NamedType) const; 7771184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 7785ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang QualType getElaboratedType(ElaboratedTypeKeyword Keyword, 77991037db265ecdd914a26e056cf69207b4f50924ehkuang NestedNameSpecifier *NNS, 7805ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang QualType NamedType) const; 78191037db265ecdd914a26e056cf69207b4f50924ehkuang QualType getDependentNameType(ElaboratedTypeKeyword Keyword, 7826ac915abcdb404a00d927fe6308a47fcf09d9519hkuang NestedNameSpecifier *NNS, 7835ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang const IdentifierInfo *Name, 7845ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang QualType Canon = QualType()) const; 7855ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 786b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, 7871184aebb761cbeac9124c37189a80a1a58f04b6bhkuang NestedNameSpecifier *NNS, 788b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const IdentifierInfo *Name, 7895ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang const TemplateArgumentListInfo &Args) const; 790ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, 791ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang NestedNameSpecifier *NNS, 792ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const IdentifierInfo *Name, 793ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned NumArgs, 79491037db265ecdd914a26e056cf69207b4f50924ehkuang const TemplateArgument *Args) const; 795ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 796f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang QualType getPackExpansionType(QualType Pattern, 7971184aebb761cbeac9124c37189a80a1a58f04b6bhkuang llvm::Optional<unsigned> NumExpansions); 7981184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 799ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl) const; 800ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 8016ac915abcdb404a00d927fe6308a47fcf09d9519hkuang QualType getObjCObjectType(QualType Base, 802b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian ObjCProtocolDecl * const *Protocols, 803b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian unsigned NumProtocols) const; 804b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 805b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getObjCObjectPointerType - Return a ObjCObjectPointerType type 806b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// for the given ObjCObjectType. 807ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang QualType getObjCObjectPointerType(QualType OIT) const; 808ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 809b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getTypeOfType - GCC extension. 810b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getTypeOfExprType(Expr *e) const; 811b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getTypeOfType(QualType t) const; 812ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 8139b35249446b07f40ac5fcc3205f2c048616efacchkuang /// getDecltypeType - C++0x decltype. 814ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang QualType getDecltypeType(Expr *e) const; 815ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 816ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// getUnaryTransformType - unary type transforms 817ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, 818f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang UnaryTransformType::UTTKind UKind) const; 819b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 820b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getAutoType - C++0x deduced auto type. 821b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getAutoType(QualType DeducedType) const; 822b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 823b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getAutoDeductType - C++0x deduction pattern for 'auto' type. 824b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getAutoDeductType() const; 825b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 826b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getAutoRRefDeductType - C++0x deduction pattern for 'auto &&' type. 827b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getAutoRRefDeductType() const; 82891037db265ecdd914a26e056cf69207b4f50924ehkuang 82991037db265ecdd914a26e056cf69207b4f50924ehkuang /// getTagDeclType - Return the unique reference to the type for the 830b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// specified TagDecl (struct/union/class/enum) decl. 831ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang QualType getTagDeclType(const TagDecl *Decl) const; 832ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 833ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// getSizeType - Return the unique type for "size_t" (C99 7.17), defined 834ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// in <stddef.h>. The sizeof operator requires this (C99 6.5.3.4p4). 835ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang CanQualType getSizeType() const; 836ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 837b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getWCharType - In C++, this returns the unique wchar_t type. In C99, this 838b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// returns a type compatible with the type defined in <stddef.h> as defined 839b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// by the target. 840b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getWCharType() const { return WCharTy; } 841ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 842b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getSignedWCharType - Return the type of "signed wchar_t". 843b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// Used when in C++, as a GCC extension. 844b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getSignedWCharType() const; 845ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 8461184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// getUnsignedWCharType - Return the type of "unsigned wchar_t". 8471184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// Used when in C++, as a GCC extension. 8481184aebb761cbeac9124c37189a80a1a58f04b6bhkuang QualType getUnsignedWCharType() const; 849ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 850f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// getPointerDiffType - Return the unique type for "ptrdiff_t" (ref?) 851f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// defined in <stddef.h>. Pointer - pointer requires this (C99 6.5.6p9). 852f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang QualType getPointerDiffType() const; 853f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang 854ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang // getCFConstantStringType - Return the C structure type used to represent 855b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian // constant CFStrings. 856b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getCFConstantStringType() const; 8575ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 858b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// Get the structure type used to representation CFStrings, or NULL 859b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// if it hasn't yet been built. 8605ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang QualType getRawCFConstantStringType() const { 86191037db265ecdd914a26e056cf69207b4f50924ehkuang if (CFConstantStringTypeDecl) 862b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian return getTagDeclType(CFConstantStringTypeDecl); 8635ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang return QualType(); 86491037db265ecdd914a26e056cf69207b4f50924ehkuang } 865b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian void setCFConstantStringType(QualType T); 8665ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 867ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang // This setter/getter represents the ObjC type for an NSConstantString. 868ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang void setObjCConstantStringInterface(ObjCInterfaceDecl *Decl); 869ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang QualType getObjCConstantStringInterface() const { 870b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian return ObjCConstantStringType; 871b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian } 872b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 873b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Retrieve the type that 'id' has been defined to, which may be 874b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// different from the built-in 'id' if 'id' has been typedef'd. 87591037db265ecdd914a26e056cf69207b4f50924ehkuang QualType getObjCIdRedefinitionType() const { 87691037db265ecdd914a26e056cf69207b4f50924ehkuang if (ObjCIdRedefinitionType.isNull()) 87791037db265ecdd914a26e056cf69207b4f50924ehkuang return getObjCIdType(); 87891037db265ecdd914a26e056cf69207b4f50924ehkuang return ObjCIdRedefinitionType; 87991037db265ecdd914a26e056cf69207b4f50924ehkuang } 8801184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 8815ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// \brief Set the user-written type that redefines 'id'. 88291037db265ecdd914a26e056cf69207b4f50924ehkuang void setObjCIdRedefinitionType(QualType RedefType) { 88391037db265ecdd914a26e056cf69207b4f50924ehkuang ObjCIdRedefinitionType = RedefType; 8846ac915abcdb404a00d927fe6308a47fcf09d9519hkuang } 885b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 886b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Retrieve the type that 'Class' has been defined to, which may be 887b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// different from the built-in 'Class' if 'Class' has been typedef'd. 888b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getObjCClassRedefinitionType() const { 889b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian if (ObjCClassRedefinitionType.isNull()) 89091037db265ecdd914a26e056cf69207b4f50924ehkuang return getObjCClassType(); 89191037db265ecdd914a26e056cf69207b4f50924ehkuang return ObjCClassRedefinitionType; 892f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang } 893b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 894b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Set the user-written type that redefines 'SEL'. 895b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian void setObjCClassRedefinitionType(QualType RedefType) { 896ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang ObjCClassRedefinitionType = RedefType; 8979b35249446b07f40ac5fcc3205f2c048616efacchkuang } 898b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 899b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Retrieve the type that 'SEL' has been defined to, which may be 900b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// different from the built-in 'SEL' if 'SEL' has been typedef'd. 901ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang QualType getObjCSelRedefinitionType() const { 9025ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang if (ObjCSelRedefinitionType.isNull()) 903b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian return getObjCSelType(); 90491037db265ecdd914a26e056cf69207b4f50924ehkuang return ObjCSelRedefinitionType; 9055ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang } 90691037db265ecdd914a26e056cf69207b4f50924ehkuang 90791037db265ecdd914a26e056cf69207b4f50924ehkuang 90891037db265ecdd914a26e056cf69207b4f50924ehkuang /// \brief Set the user-written type that redefines 'SEL'. 90991037db265ecdd914a26e056cf69207b4f50924ehkuang void setObjCSelRedefinitionType(QualType RedefType) { 91091037db265ecdd914a26e056cf69207b4f50924ehkuang ObjCSelRedefinitionType = RedefType; 91191037db265ecdd914a26e056cf69207b4f50924ehkuang } 912b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 913b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Retrieve the Objective-C "instancetype" type, if already known; 91491037db265ecdd914a26e056cf69207b4f50924ehkuang /// otherwise, returns a NULL type; 915b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getObjCInstanceType() { 916b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian return getTypeDeclType(getObjCInstanceTypeDecl()); 917b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian } 918b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 919b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Retrieve the typedef declaration corresponding to the Objective-C 920b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// "instancetype" type. 921b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian TypedefDecl *getObjCInstanceTypeDecl(); 922b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 92391037db265ecdd914a26e056cf69207b4f50924ehkuang /// \brief Set the type for the C FILE type. 924ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang void setFILEDecl(TypeDecl *FILEDecl) { this->FILEDecl = FILEDecl; } 925ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 926b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Retrieve the C FILE type. 927b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getFILEType() const { 928ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang if (FILEDecl) 9291184aebb761cbeac9124c37189a80a1a58f04b6bhkuang return getTypeDeclType(FILEDecl); 9301184aebb761cbeac9124c37189a80a1a58f04b6bhkuang return QualType(); 931b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian } 932b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 933b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Set the type for the C jmp_buf type. 934ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang void setjmp_bufDecl(TypeDecl *jmp_bufDecl) { 935b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian this->jmp_bufDecl = jmp_bufDecl; 9365ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang } 937b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 9385ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// \brief Retrieve the C jmp_buf type. 93991037db265ecdd914a26e056cf69207b4f50924ehkuang QualType getjmp_bufType() const { 9405ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang if (jmp_bufDecl) 94191037db265ecdd914a26e056cf69207b4f50924ehkuang return getTypeDeclType(jmp_bufDecl); 9425ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang return QualType(); 94391037db265ecdd914a26e056cf69207b4f50924ehkuang } 944ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 945ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \brief Set the type for the C sigjmp_buf type. 946b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl) { 947b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian this->sigjmp_bufDecl = sigjmp_bufDecl; 948b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian } 949b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 950b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Retrieve the C sigjmp_buf type. 951f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang QualType getsigjmp_bufType() const { 952f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang if (sigjmp_bufDecl) 953ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang return getTypeDeclType(sigjmp_bufDecl); 9546ac915abcdb404a00d927fe6308a47fcf09d9519hkuang return QualType(); 955b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian } 956b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 957ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \brief The result type of logical operations, '<', '>', '!=', etc. 958ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang QualType getLogicalOperationType() const { 959ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang return getLangOptions().CPlusPlus ? BoolTy : IntTy; 960b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian } 961b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 962b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getObjCEncodingForType - Emit the ObjC type encoding for the 963f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// given type into \arg S. If \arg NameFields is specified then 96491037db265ecdd914a26e056cf69207b4f50924ehkuang /// record field names are also encoded. 96591037db265ecdd914a26e056cf69207b4f50924ehkuang void getObjCEncodingForType(QualType t, std::string &S, 96691037db265ecdd914a26e056cf69207b4f50924ehkuang const FieldDecl *Field=0) const; 9671184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 96891037db265ecdd914a26e056cf69207b4f50924ehkuang void getLegacyIntegralTypeEncoding(QualType &t) const; 96991037db265ecdd914a26e056cf69207b4f50924ehkuang 97091037db265ecdd914a26e056cf69207b4f50924ehkuang // Put the string version of type qualifiers into S. 971b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian void getObjCEncodingForTypeQualifier(Decl::ObjCDeclQualifier QT, 972b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian std::string &S) const; 973b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 974b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getObjCEncodingForFunctionDecl - Returns the encoded type for this 97591037db265ecdd914a26e056cf69207b4f50924ehkuang /// function. This is in the same format as Objective-C method encodings. 9761184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// 97791037db265ecdd914a26e056cf69207b4f50924ehkuang /// \returns true if an error occurred (e.g., because one of the parameter 978b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// types is incomplete), false otherwise. 979b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian bool getObjCEncodingForFunctionDecl(const FunctionDecl *Decl, std::string& S); 980b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 981b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getObjCEncodingForMethodDecl - Return the encoded type for this method 982b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// declaration. 983b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// 984b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \returns true if an error occurred (e.g., because one of the parameter 985b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// types is incomplete), false otherwise. 986b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian bool getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl, std::string &S) 987b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const; 988b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 989b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getObjCEncodingForBlock - Return the encoded type for this block 990b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// declaration. 991b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian std::string getObjCEncodingForBlock(const BlockExpr *blockExpr) const; 992b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 993b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getObjCEncodingForPropertyDecl - Return the encoded type for 994b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// this method declaration. If non-NULL, Container must be either 995b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// an ObjCCategoryImplDecl or ObjCImplementationDecl; it should 996b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// only be NULL when getting encodings for protocol properties. 9976ac915abcdb404a00d927fe6308a47fcf09d9519hkuang void getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD, 998b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const Decl *Container, 999b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian std::string &S) const; 1000b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1001b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian bool ProtocolCompatibleWithProtocol(ObjCProtocolDecl *lProto, 1002b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian ObjCProtocolDecl *rProto) const; 1003b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1004b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getObjCEncodingTypeSize returns size of type for objective-c encoding 1005b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// purpose in characters. 1006b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian CharUnits getObjCEncodingTypeSize(QualType t) const; 1007b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1008b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Retrieve the typedef corresponding to the predefined 'id' type 1009b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// in Objective-C. 1010b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian TypedefDecl *getObjCIdDecl() const; 1011b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1012b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// This setter/getter represents the ObjC 'id' type. It is setup lazily, by 101391037db265ecdd914a26e056cf69207b4f50924ehkuang /// Sema. id is always a (typedef for a) pointer type, a pointer to a struct. 101491037db265ecdd914a26e056cf69207b4f50924ehkuang QualType getObjCIdType() const { 1015ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang return getTypeDeclType(getObjCIdDecl()); 101691037db265ecdd914a26e056cf69207b4f50924ehkuang } 10171184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 101891037db265ecdd914a26e056cf69207b4f50924ehkuang /// \brief Retrieve the typedef corresponding to the predefined 'SEL' type 101991037db265ecdd914a26e056cf69207b4f50924ehkuang /// in Objective-C. 1020b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian TypedefDecl *getObjCSelDecl() const; 102191037db265ecdd914a26e056cf69207b4f50924ehkuang 102291037db265ecdd914a26e056cf69207b4f50924ehkuang /// \brief Retrieve the type that corresponds to the predefined Objective-C 102391037db265ecdd914a26e056cf69207b4f50924ehkuang /// 'SEL' type. 102491037db265ecdd914a26e056cf69207b4f50924ehkuang QualType getObjCSelType() const { 102591037db265ecdd914a26e056cf69207b4f50924ehkuang return getTypeDeclType(getObjCSelDecl()); 102691037db265ecdd914a26e056cf69207b4f50924ehkuang } 102791037db265ecdd914a26e056cf69207b4f50924ehkuang 102891037db265ecdd914a26e056cf69207b4f50924ehkuang void setObjCProtoType(QualType QT); 102991037db265ecdd914a26e056cf69207b4f50924ehkuang QualType getObjCProtoType() const { return ObjCProtoType; } 103091037db265ecdd914a26e056cf69207b4f50924ehkuang 10311184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// \brief Retrieve the typedef declaration corresponding to the predefined 103291037db265ecdd914a26e056cf69207b4f50924ehkuang /// Objective-C 'Class' type. 103391037db265ecdd914a26e056cf69207b4f50924ehkuang TypedefDecl *getObjCClassDecl() const; 103491037db265ecdd914a26e056cf69207b4f50924ehkuang 103591037db265ecdd914a26e056cf69207b4f50924ehkuang /// This setter/getter repreents the ObjC 'Class' type. It is setup lazily, by 103691037db265ecdd914a26e056cf69207b4f50924ehkuang /// Sema. 'Class' is always a (typedef for a) pointer type, a pointer to a 103791037db265ecdd914a26e056cf69207b4f50924ehkuang /// struct. 103891037db265ecdd914a26e056cf69207b4f50924ehkuang QualType getObjCClassType() const { 103991037db265ecdd914a26e056cf69207b4f50924ehkuang return getTypeDeclType(getObjCClassDecl()); 1040ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } 1041ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1042ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang void setBuiltinVaListType(QualType T); 1043ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang QualType getBuiltinVaListType() const { return BuiltinVaListType; } 1044b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1045ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// getCVRQualifiedType - Returns a type with additional const, 1046ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// volatile, or restrict qualifiers. 104791037db265ecdd914a26e056cf69207b4f50924ehkuang QualType getCVRQualifiedType(QualType T, unsigned CVR) const { 10481184aebb761cbeac9124c37189a80a1a58f04b6bhkuang return getQualifiedType(T, Qualifiers::fromCVRMask(CVR)); 1049ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } 1050b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1051f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// getQualifiedType - Returns a type with additional qualifiers. 1052b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getQualifiedType(QualType T, Qualifiers Qs) const { 105391037db265ecdd914a26e056cf69207b4f50924ehkuang if (!Qs.hasNonFastQualifiers()) 105491037db265ecdd914a26e056cf69207b4f50924ehkuang return T.withFastQualifiers(Qs.getFastQualifiers()); 105591037db265ecdd914a26e056cf69207b4f50924ehkuang QualifierCollector Qc(Qs); 105691037db265ecdd914a26e056cf69207b4f50924ehkuang const Type *Ptr = Qc.strip(T); 1057b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian return getExtQualType(Ptr, Qc); 1058b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian } 1059b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1060b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getQualifiedType - Returns a type with additional qualifiers. 1061ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang QualType getQualifiedType(const Type *T, Qualifiers Qs) const { 1062ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang if (!Qs.hasNonFastQualifiers()) 10635ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang return QualType(T, Qs.getFastQualifiers()); 1064f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang return getExtQualType(T, Qs); 1065f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang } 10665ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 1067f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// getLifetimeQualifiedType - Returns a type with the given 1068ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// lifetime qualifier. 1069ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang QualType getLifetimeQualifiedType(QualType type, 1070ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang Qualifiers::ObjCLifetime lifetime) { 1071ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang assert(type.getObjCLifetime() == Qualifiers::OCL_None); 1072ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang assert(lifetime != Qualifiers::OCL_None); 10736ac915abcdb404a00d927fe6308a47fcf09d9519hkuang 1074ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang Qualifiers qs; 1075ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang qs.addObjCLifetime(lifetime); 1076ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang return getQualifiedType(type, qs); 1077ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } 1078b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1079b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian DeclarationNameInfo getNameForTemplate(TemplateName Name, 10801184aebb761cbeac9124c37189a80a1a58f04b6bhkuang SourceLocation NameLoc) const; 10815ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 10821184aebb761cbeac9124c37189a80a1a58f04b6bhkuang TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, 10831184aebb761cbeac9124c37189a80a1a58f04b6bhkuang UnresolvedSetIterator End) const; 108491037db265ecdd914a26e056cf69207b4f50924ehkuang 108591037db265ecdd914a26e056cf69207b4f50924ehkuang TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, 108691037db265ecdd914a26e056cf69207b4f50924ehkuang bool TemplateKeyword, 108791037db265ecdd914a26e056cf69207b4f50924ehkuang TemplateDecl *Template) const; 108891037db265ecdd914a26e056cf69207b4f50924ehkuang 108991037db265ecdd914a26e056cf69207b4f50924ehkuang TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, 1090ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const IdentifierInfo *Name) const; 1091ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, 1092ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang OverloadedOperatorKind Operator) const; 1093ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang TemplateName getSubstTemplateTemplateParm(TemplateTemplateParmDecl *param, 109491037db265ecdd914a26e056cf69207b4f50924ehkuang TemplateName replacement) const; 109591037db265ecdd914a26e056cf69207b4f50924ehkuang TemplateName getSubstTemplateTemplateParmPack(TemplateTemplateParmDecl *Param, 10965ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang const TemplateArgument &ArgPack) const; 1097b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1098b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian enum GetBuiltinTypeError { 1099b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian GE_None, //< No error 1100b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian GE_Missing_stdio, //< Missing a type from <stdio.h> 1101b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian GE_Missing_setjmp //< Missing a type from <setjmp.h> 11026ac915abcdb404a00d927fe6308a47fcf09d9519hkuang }; 1103f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang 110491037db265ecdd914a26e056cf69207b4f50924ehkuang /// GetBuiltinType - Return the type for the specified builtin. If 110591037db265ecdd914a26e056cf69207b4f50924ehkuang /// IntegerConstantArgs is non-null, it is filled in with a bitmask of 110691037db265ecdd914a26e056cf69207b4f50924ehkuang /// arguments to the builtin that are required to be integer constant 1107b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// expressions. 1108b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, 1109b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian unsigned *IntegerConstantArgs = 0) const; 1110b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1111b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanianprivate: 1112b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian CanQualType getFromTargetType(unsigned Type) const; 1113b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1114b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian //===--------------------------------------------------------------------===// 1115b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian // Type Predicates. 1116b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian //===--------------------------------------------------------------------===// 1117b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1118b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanianpublic: 1119b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getObjCGCAttr - Returns one of GCNone, Weak or Strong objc's 1120b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// garbage collection attribute. 1121b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// 1122b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian Qualifiers::GC getObjCGCAttrKind(QualType Ty) const; 1123b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1124b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// areCompatibleVectorTypes - Return true if the given vector types 1125b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// are of the same unqualified type or if they are equivalent to the same 1126b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// GCC vector type, ignoring whether they are target-specific (AltiVec or 1127b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// Neon) types. 1128b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec); 1129b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1130b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// isObjCNSObjectType - Return true if this is an NSObject object with 1131b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// its NSObject attribute set. 1132b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian static bool isObjCNSObjectType(QualType Ty) { 1133b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian return Ty->isObjCNSObjectType(); 1134b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian } 1135b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1136b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian //===--------------------------------------------------------------------===// 1137ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang // Type Sizing and Analysis 1138ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang //===--------------------------------------------------------------------===// 1139ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1140ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// getFloatTypeSemantics - Return the APFloat 'semantics' for the specified 1141ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// scalar floating point type. 1142ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const llvm::fltSemantics &getFloatTypeSemantics(QualType T) const; 1143ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1144ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// getTypeInfo - Get the size and alignment of the specified complete type in 1145ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// bits. 1146ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang std::pair<uint64_t, unsigned> getTypeInfo(const Type *T) const; 1147ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang std::pair<uint64_t, unsigned> getTypeInfo(QualType T) const { 1148ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang return getTypeInfo(T.getTypePtr()); 1149ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } 1150ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1151f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// getTypeSize - Return the size of the specified type, in bits. This method 1152f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// does not work on incomplete types. 1153f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang uint64_t getTypeSize(QualType T) const { 1154ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang return getTypeInfo(T).first; 1155f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang } 1156f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang uint64_t getTypeSize(const Type *T) const { 1157ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang return getTypeInfo(T).first; 1158ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } 1159f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang 116091037db265ecdd914a26e056cf69207b4f50924ehkuang /// getCharWidth - Return the size of the character type, in bits 116191037db265ecdd914a26e056cf69207b4f50924ehkuang uint64_t getCharWidth() const { 1162f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang return getTypeSize(CharTy); 1163f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang } 1164f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang 1165ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// toCharUnitsFromBits - Convert a size in bits to a size in characters. 1166ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang CharUnits toCharUnitsFromBits(int64_t BitSize) const; 1167ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1168ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// toBits - Convert a size in characters to a size in bits. 1169b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian int64_t toBits(CharUnits CharSize) const; 1170b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1171b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getTypeSizeInChars - Return the size of the specified type, in characters. 1172f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// This method does not work on incomplete types. 1173ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang CharUnits getTypeSizeInChars(QualType T) const; 1174b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian CharUnits getTypeSizeInChars(const Type *T) const; 11756ac915abcdb404a00d927fe6308a47fcf09d9519hkuang 11766ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// getTypeAlign - Return the ABI-specified alignment of a type, in bits. 11776ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// This method does not work on incomplete types. 11786ac915abcdb404a00d927fe6308a47fcf09d9519hkuang unsigned getTypeAlign(QualType T) const { 1179f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang return getTypeInfo(T).second; 1180f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang } 1181ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned getTypeAlign(const Type *T) const { 1182ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang return getTypeInfo(T).second; 1183f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang } 1184ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1185ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// getTypeAlignInChars - Return the ABI-specified alignment of a type, in 1186ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// characters. This method does not work on incomplete types. 1187b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian CharUnits getTypeAlignInChars(QualType T) const; 1188ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang CharUnits getTypeAlignInChars(const Type *T) const; 1189ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1190ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang std::pair<CharUnits, CharUnits> getTypeInfoInChars(const Type *T) const; 1191ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang std::pair<CharUnits, CharUnits> getTypeInfoInChars(QualType T) const; 1192f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang 119391037db265ecdd914a26e056cf69207b4f50924ehkuang /// getPreferredTypeAlign - Return the "preferred" alignment of the specified 119491037db265ecdd914a26e056cf69207b4f50924ehkuang /// type for the current target in bits. This can be different than the ABI 11951184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// alignment in cases where it is beneficial for performance to overalign 11961184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// a data type. 11971184aebb761cbeac9124c37189a80a1a58f04b6bhkuang unsigned getPreferredTypeAlign(const Type *T) const; 1198ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 119991037db265ecdd914a26e056cf69207b4f50924ehkuang /// getDeclAlign - Return a conservative estimate of the alignment of 1200b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// the specified decl. Note that bitfields do not have a valid alignment, so 1201b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// this method will assert on them. 1202ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// If @p RefAsPointee, references are treated like their underlying type 1203ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// (for alignof), else they're treated like pointers (for CodeGen). 1204ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang CharUnits getDeclAlign(const Decl *D, bool RefAsPointee = false) const; 1205ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1206f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// getASTRecordLayout - Get or compute information about the layout of the 12071184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// specified record (struct/union/class), which indicates its size and field 12081184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// position information. 1209f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang const ASTRecordLayout &getASTRecordLayout(const RecordDecl *D) const; 1210f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang 1211f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// getASTObjCInterfaceLayout - Get or compute information about the 1212f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// layout of the specified Objective-C interface. 1213ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const ASTRecordLayout &getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) 1214f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang const; 1215ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1216ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang void DumpRecordLayout(const RecordDecl *RD, raw_ostream &OS) const; 121791037db265ecdd914a26e056cf69207b4f50924ehkuang 121891037db265ecdd914a26e056cf69207b4f50924ehkuang /// getASTObjCImplementationLayout - Get or compute information about 121991037db265ecdd914a26e056cf69207b4f50924ehkuang /// the layout of the specified Objective-C implementation. This may 122091037db265ecdd914a26e056cf69207b4f50924ehkuang /// differ from the interface if synthesized ivars are present. 122191037db265ecdd914a26e056cf69207b4f50924ehkuang const ASTRecordLayout & 1222ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang getASTObjCImplementationLayout(const ObjCImplementationDecl *D) const; 1223ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 122491037db265ecdd914a26e056cf69207b4f50924ehkuang /// getKeyFunction - Get the key function for the given record decl, or NULL 1225ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// if there isn't one. The key function is, according to the Itanium C++ ABI 1226ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// section 5.2.3: 1227ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// 1228f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// ...the first non-pure virtual function that is not inline at the point 1229ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// of class definition. 1230f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang const CXXMethodDecl *getKeyFunction(const CXXRecordDecl *RD); 12311184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 1232ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang bool isNearlyEmpty(const CXXRecordDecl *RD) const; 1233f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang 1234ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang MangleContext *createMangleContext(); 1235ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1236ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass, 1237ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang SmallVectorImpl<const ObjCIvarDecl*> &Ivars) const; 123891037db265ecdd914a26e056cf69207b4f50924ehkuang 12391184aebb761cbeac9124c37189a80a1a58f04b6bhkuang unsigned CountNonClassIvars(const ObjCInterfaceDecl *OI) const; 1240f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang void CollectInheritedProtocols(const Decl *CDecl, 124191037db265ecdd914a26e056cf69207b4f50924ehkuang llvm::SmallPtrSet<ObjCProtocolDecl*, 8> &Protocols); 1242ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 12431184aebb761cbeac9124c37189a80a1a58f04b6bhkuang //===--------------------------------------------------------------------===// 1244ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang // Type Operators 12456ac915abcdb404a00d927fe6308a47fcf09d9519hkuang //===--------------------------------------------------------------------===// 124691037db265ecdd914a26e056cf69207b4f50924ehkuang 124791037db265ecdd914a26e056cf69207b4f50924ehkuang /// getCanonicalType - Return the canonical (structural) type corresponding to 12481184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// the specified potentially non-canonical type. The non-canonical version 1249ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// of a type may have many "decorated" versions of types. Decorators can 1250ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// include typedefs, 'typeof' operators, etc. The returned type is guaranteed 1251ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// to be free of any of these, allowing two canonical types to be compared 1252f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// for exact equality with a simple pointer comparison. 1253f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang CanQualType getCanonicalType(QualType T) const { 1254f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang return CanQualType::CreateUnsafe(T.getCanonicalType()); 1255ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } 1256f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang 1257ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const Type *getCanonicalType(const Type *T) const { 1258f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang return T->getCanonicalTypeInternal().getTypePtr(); 12596ac915abcdb404a00d927fe6308a47fcf09d9519hkuang } 12606ac915abcdb404a00d927fe6308a47fcf09d9519hkuang 12611184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// getCanonicalParamType - Return the canonical parameter type 12625ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// corresponding to the specific potentially non-canonical one. 12631184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// Qualifiers are stripped off, functions are turned into function 1264ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// pointers, and arrays decay one level into pointers. 1265ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang CanQualType getCanonicalParamType(QualType T) const; 1266b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1267b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Determine whether the given types are equivalent. 1268ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang bool hasSameType(QualType T1, QualType T2) { 1269ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang return getCanonicalType(T1) == getCanonicalType(T2); 1270ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } 12711184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 1272ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \brief Returns this type as a completely-unqualified array type, 1273b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// capturing the qualifiers in Quals. This will remove the minimal amount of 1274b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// sugaring from the types, similar to the behavior of 127591037db265ecdd914a26e056cf69207b4f50924ehkuang /// QualType::getUnqualifiedType(). 127691037db265ecdd914a26e056cf69207b4f50924ehkuang /// 127791037db265ecdd914a26e056cf69207b4f50924ehkuang /// \param T is the qualified type, which may be an ArrayType 1278ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// 1279ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \param Quals will receive the full set of qualifiers that were 1280ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// applied to the array. 1281ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// 1282ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \returns if this is an array type, the completely unqualified array type 1283ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// that corresponds to it. Otherwise, returns T.getUnqualifiedType(). 1284ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals); 12851184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 1286ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \brief Determine whether the given types are equivalent after 1287ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// cvr-qualifiers have been removed. 1288ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang bool hasSameUnqualifiedType(QualType T1, QualType T2) { 1289ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang return getCanonicalType(T1).getTypePtr() == 1290ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang getCanonicalType(T2).getTypePtr(); 1291ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } 129291037db265ecdd914a26e056cf69207b4f50924ehkuang 12931184aebb761cbeac9124c37189a80a1a58f04b6bhkuang bool UnwrapSimilarPointerTypes(QualType &T1, QualType &T2); 1294f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang 1295f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// \brief Retrieves the "canonical" nested name specifier for a 1296f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// given nested name specifier. 1297f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// 129891037db265ecdd914a26e056cf69207b4f50924ehkuang /// The canonical nested name specifier is a nested name specifier 1299ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// that uniquely identifies a type or namespace within the type 1300ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// system. For example, given: 1301ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// 1302ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \code 13031184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// namespace N { 13041184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// struct S { 1305ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// template<typename T> struct X { typename T* type; }; 1306ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// }; 1307ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// } 1308ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// 1309b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// template<typename T> struct Y { 131091037db265ecdd914a26e056cf69207b4f50924ehkuang /// typename N::S::X<T>::type member; 13111184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// }; 13121184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// \endcode 1313ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// 13146ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// Here, the nested-name-specifier for N::S::X<T>:: will be 131591037db265ecdd914a26e056cf69207b4f50924ehkuang /// S::X<template-param-0-0>, since 'S' and 'X' are uniquely defined 13161184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// by declarations in the type system and the canonical type for 13171184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// the template type parameter 'T' is template-param-0-0. 13181184aebb761cbeac9124c37189a80a1a58f04b6bhkuang NestedNameSpecifier * 1319ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const; 13201184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 13211184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// \brief Retrieves the default calling convention to use for 13221184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// C++ instance methods. 1323b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian CallingConv getDefaultMethodCallConv(); 1324b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1325b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Retrieves the canonical representation of the given 1326b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// calling convention. 1327b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian CallingConv getCanonicalCallConv(CallingConv CC) const { 1328ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang if (!LangOpts.MRTD && CC == CC_C) 13291184aebb761cbeac9124c37189a80a1a58f04b6bhkuang return CC_Default; 13301184aebb761cbeac9124c37189a80a1a58f04b6bhkuang return CC; 13311184aebb761cbeac9124c37189a80a1a58f04b6bhkuang } 13321184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 13331184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// \brief Determines whether two calling conventions name the same 13341184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// calling convention. 1335b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian bool isSameCallConv(CallingConv lcc, CallingConv rcc) { 1336b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian return (getCanonicalCallConv(lcc) == getCanonicalCallConv(rcc)); 1337b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian } 13381184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 13391184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// \brief Retrieves the "canonical" template name that refers to a 13401184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// given template. 13411184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// 13421184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// The canonical template name is the simplest expression that can 13431184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// be used to refer to a given template. For most templates, this 13441184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// expression is just the template declaration itself. For example, 13451184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// the template std::vector can be referred to via a variety of 13461184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// names---std::vector, ::std::vector, vector (if vector is in 13471184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// scope), etc.---but all of these names map down to the same 13481184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// TemplateDecl, which is used to form the canonical template name. 13491184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// 13501184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// Dependent template names are more interesting. Here, the 13511184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// template name could be something like T::template apply or 13521184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// std::allocator<T>::template rebind, where the nested name 1353ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// specifier itself is dependent. In this case, the canonical 1354ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// template name uses the shortest form of the dependent 1355ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// nested-name-specifier, which itself contains all canonical 13569b35249446b07f40ac5fcc3205f2c048616efacchkuang /// types, values, and templates. 1357ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang TemplateName getCanonicalTemplateName(TemplateName Name) const; 135891037db265ecdd914a26e056cf69207b4f50924ehkuang 1359b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Determine whether the given template names refer to the same 1360b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// template. 1361ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang bool hasSameTemplateName(TemplateName X, TemplateName Y); 13621184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 1363ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \brief Retrieve the "canonical" template argument. 136491037db265ecdd914a26e056cf69207b4f50924ehkuang /// 13651184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// The canonical template argument is the simplest template argument 13661184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// (which may be a type, value, expression, or declaration) that 1367b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// expresses the value of the argument. 1368b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) 13691184aebb761cbeac9124c37189a80a1a58f04b6bhkuang const; 1370ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 13716ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// Type Query functions. If the type is an instance of the specified class, 137291037db265ecdd914a26e056cf69207b4f50924ehkuang /// return the Type pointer for the underlying maximally pretty type. This 13735ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// is a member of ASTContext because this may need to do some amount of 13741184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// canonicalization, e.g. to move type qualifiers into the element type. 13751184aebb761cbeac9124c37189a80a1a58f04b6bhkuang const ArrayType *getAsArrayType(QualType T) const; 13761184aebb761cbeac9124c37189a80a1a58f04b6bhkuang const ConstantArrayType *getAsConstantArrayType(QualType T) const { 1377ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang return dyn_cast_or_null<ConstantArrayType>(getAsArrayType(T)); 137891037db265ecdd914a26e056cf69207b4f50924ehkuang } 1379ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const VariableArrayType *getAsVariableArrayType(QualType T) const { 1380ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang return dyn_cast_or_null<VariableArrayType>(getAsArrayType(T)); 1381ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } 1382ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const IncompleteArrayType *getAsIncompleteArrayType(QualType T) const { 1383ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang return dyn_cast_or_null<IncompleteArrayType>(getAsArrayType(T)); 1384ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } 1385ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const DependentSizedArrayType *getAsDependentSizedArrayType(QualType T) 1386ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const { 1387ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang return dyn_cast_or_null<DependentSizedArrayType>(getAsArrayType(T)); 13889b35249446b07f40ac5fcc3205f2c048616efacchkuang } 13899b35249446b07f40ac5fcc3205f2c048616efacchkuang 13909b35249446b07f40ac5fcc3205f2c048616efacchkuang /// getBaseElementType - Returns the innermost element type of an array type. 1391b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// For example, will return "int" for int[m][n] 13929b35249446b07f40ac5fcc3205f2c048616efacchkuang QualType getBaseElementType(const ArrayType *VAT) const; 13939b35249446b07f40ac5fcc3205f2c048616efacchkuang 1394b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getBaseElementType - Returns the innermost element type of a type 13959b35249446b07f40ac5fcc3205f2c048616efacchkuang /// (which needn't actually be an array type). 1396b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getBaseElementType(QualType QT) const; 13979b35249446b07f40ac5fcc3205f2c048616efacchkuang 13989b35249446b07f40ac5fcc3205f2c048616efacchkuang /// getConstantArrayElementCount - Returns number of constant array elements. 13999b35249446b07f40ac5fcc3205f2c048616efacchkuang uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const; 14009b35249446b07f40ac5fcc3205f2c048616efacchkuang 14019b35249446b07f40ac5fcc3205f2c048616efacchkuang /// \brief Perform adjustment on the parameter type of a function. 14029b35249446b07f40ac5fcc3205f2c048616efacchkuang /// 14039b35249446b07f40ac5fcc3205f2c048616efacchkuang /// This routine adjusts the given parameter type @p T to the actual 1404b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// parameter type used by semantic analysis (C99 6.7.5.3p[7,8], 14059b35249446b07f40ac5fcc3205f2c048616efacchkuang /// C++ [dcl.fct]p3). The adjusted parameter type is returned. 1406b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getAdjustedParameterType(QualType T); 14079b35249446b07f40ac5fcc3205f2c048616efacchkuang 14089b35249446b07f40ac5fcc3205f2c048616efacchkuang /// \brief Retrieve the parameter type as adjusted for use in the signature 1409ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// of a function, decaying array and function types and removing top-level 1410ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// cv-qualifiers. 1411ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang QualType getSignatureParameterType(QualType T); 14126ac915abcdb404a00d927fe6308a47fcf09d9519hkuang 1413ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// getArrayDecayedType - Return the properly qualified result of decaying the 1414ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// specified array type to a pointer. This operation is non-trivial when 1415ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// handling typedefs etc. The canonical type of "T" must be an array type, 1416b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// this returns a pointer to a properly qualified element of the array. 141791037db265ecdd914a26e056cf69207b4f50924ehkuang /// 141891037db265ecdd914a26e056cf69207b4f50924ehkuang /// See C99 6.7.5.3p7 and C99 6.3.2.1p3. 14191184aebb761cbeac9124c37189a80a1a58f04b6bhkuang QualType getArrayDecayedType(QualType T) const; 1420b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1421b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// getPromotedIntegerType - Returns the type that Promotable will 142291037db265ecdd914a26e056cf69207b4f50924ehkuang /// promote to: C99 6.3.1.1p2, assuming that Promotable is a promotable 14236ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// integer type. 14245ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang QualType getPromotedIntegerType(QualType PromotableType) const; 1425b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1426b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Recurses in pointer/array types until it finds an objc retainable 1427b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// type and returns its ownership. 142891037db265ecdd914a26e056cf69207b4f50924ehkuang Qualifiers::ObjCLifetime getInnerObjCOwnership(QualType T) const; 142991037db265ecdd914a26e056cf69207b4f50924ehkuang 14309b35249446b07f40ac5fcc3205f2c048616efacchkuang /// \brief Whether this is a promotable bitfield reference according 1431b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// to C99 6.3.1.1p2, bullet 2 (and GCC extensions). 1432b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// 143391037db265ecdd914a26e056cf69207b4f50924ehkuang /// \returns the type this bit-field will promote to, or NULL if no 143491037db265ecdd914a26e056cf69207b4f50924ehkuang /// promotion occurs. 143591037db265ecdd914a26e056cf69207b4f50924ehkuang QualType isPromotableBitField(Expr *E) const; 143691037db265ecdd914a26e056cf69207b4f50924ehkuang 143791037db265ecdd914a26e056cf69207b4f50924ehkuang /// getIntegerTypeOrder - Returns the highest ranked integer type: 143891037db265ecdd914a26e056cf69207b4f50924ehkuang /// C99 6.3.1.8p1. If LHS > RHS, return 1. If LHS == RHS, return 0. If 143991037db265ecdd914a26e056cf69207b4f50924ehkuang /// LHS < RHS, return -1. 1440b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian int getIntegerTypeOrder(QualType LHS, QualType RHS) const; 1441b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 144291037db265ecdd914a26e056cf69207b4f50924ehkuang /// getFloatingTypeOrder - Compare the rank of the two specified floating 144391037db265ecdd914a26e056cf69207b4f50924ehkuang /// point types, ignoring the domain of the type (i.e. 'double' == 144491037db265ecdd914a26e056cf69207b4f50924ehkuang /// '_Complex double'). If LHS > RHS, return 1. If LHS == RHS, return 0. If 14459b35249446b07f40ac5fcc3205f2c048616efacchkuang /// LHS < RHS, return -1. 144691037db265ecdd914a26e056cf69207b4f50924ehkuang int getFloatingTypeOrder(QualType LHS, QualType RHS) const; 1447b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 144891037db265ecdd914a26e056cf69207b4f50924ehkuang /// getFloatingTypeOfSizeWithinDomain - Returns a real floating 14496ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// point or a complex type (based on typeDomain/typeSize). 145091037db265ecdd914a26e056cf69207b4f50924ehkuang /// 'typeDomain' is a real floating point or complex type. 145191037db265ecdd914a26e056cf69207b4f50924ehkuang /// 'typeSize' is a real floating point or complex type. 14526ac915abcdb404a00d927fe6308a47fcf09d9519hkuang QualType getFloatingTypeOfSizeWithinDomain(QualType typeSize, 145391037db265ecdd914a26e056cf69207b4f50924ehkuang QualType typeDomain) const; 14546ac915abcdb404a00d927fe6308a47fcf09d9519hkuang 14556ac915abcdb404a00d927fe6308a47fcf09d9519hkuang unsigned getTargetAddressSpace(QualType T) const { 145691037db265ecdd914a26e056cf69207b4f50924ehkuang return getTargetAddressSpace(T.getQualifiers()); 145791037db265ecdd914a26e056cf69207b4f50924ehkuang } 14581184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 145991037db265ecdd914a26e056cf69207b4f50924ehkuang unsigned getTargetAddressSpace(Qualifiers Q) const { 14609b35249446b07f40ac5fcc3205f2c048616efacchkuang return getTargetAddressSpace(Q.getAddressSpace()); 146191037db265ecdd914a26e056cf69207b4f50924ehkuang } 1462ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 146391037db265ecdd914a26e056cf69207b4f50924ehkuang unsigned getTargetAddressSpace(unsigned AS) const { 1464ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang if (AS < LangAS::Offset || AS >= LangAS::Offset + LangAS::Count) 1465ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang return AS; 1466ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang else 14671184aebb761cbeac9124c37189a80a1a58f04b6bhkuang return (*AddrSpaceMap)[AS - LangAS::Offset]; 1468ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } 1469ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1470ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuangprivate: 1471ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang // Helper for integer ordering 1472ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned getIntegerRank(const Type *T) const; 1473b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1474b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanianpublic: 1475b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1476ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang //===--------------------------------------------------------------------===// 1477ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang // Type Compatibility Predicates 1478b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian //===--------------------------------------------------------------------===// 1479b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 14806ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// Compatibility predicates used to check assignment expressions. 1481b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian bool typesAreCompatible(QualType T1, QualType T2, 1482b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian bool CompareUnqualified = false); // C99 6.2.7p1 1483ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1484f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang bool propertyTypesAreCompatible(QualType, QualType); 1485f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang bool typesAreBlockPointerCompatible(QualType, QualType); 1486b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1487ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang bool isObjCIdType(QualType T) const { 1488ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang return T == getObjCIdType(); 1489ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } 1490b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian bool isObjCClassType(QualType T) const { 1491ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang return T == getObjCClassType(); 1492b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian } 1493b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian bool isObjCSelType(QualType T) const { 14945ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang return T == getObjCSelType(); 1495b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian } 1496b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian bool QualifiedIdConformsQualifiedId(QualType LHS, QualType RHS); 1497b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian bool ObjCQualifiedIdTypesAreCompatible(QualType LHS, QualType RHS, 14985ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang bool ForCompare); 1499ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1500ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang bool ObjCQualifiedClassTypesAreCompatible(QualType LHS, QualType RHS); 1501ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1502b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian // Check the safety of assignment from LHS to RHS 1503b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, 1504b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const ObjCObjectPointerType *RHSOPT); 1505ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang bool canAssignObjCInterfaces(const ObjCObjectType *LHS, 1506ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const ObjCObjectType *RHS); 1507b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian bool canAssignObjCInterfacesInBlockPointer( 1508b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const ObjCObjectPointerType *LHSOPT, 1509b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const ObjCObjectPointerType *RHSOPT, 1510ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang bool BlockReturnType); 1511ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang bool areComparableObjCPointerTypes(QualType LHS, QualType RHS); 1512b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType areCommonBaseCompatible(const ObjCObjectPointerType *LHSOPT, 1513b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const ObjCObjectPointerType *RHSOPT); 1514b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian bool canBindObjCObjectType(QualType To, QualType From); 1515ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1516ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang // Functions for calculating composite types 1517ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, 1518ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang bool Unqualified = false, bool BlockReturnType = false); 1519ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer=false, 1520b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian bool Unqualified = false); 1521b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType mergeFunctionArgumentTypes(QualType, QualType, 1522b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian bool OfBlockPointer=false, 1523ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang bool Unqualified = false); 1524b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType mergeTransparentUnionType(QualType, QualType, 15255ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang bool OfBlockPointer=false, 152691037db265ecdd914a26e056cf69207b4f50924ehkuang bool Unqualified = false); 152791037db265ecdd914a26e056cf69207b4f50924ehkuang 1528ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang QualType mergeObjCGCQualifiers(QualType, QualType); 1529ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1530ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang bool FunctionTypesMatchOnNSConsumedAttrs( 1531b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const FunctionProtoType *FromFunctionType, 1532b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const FunctionProtoType *ToFunctionType); 1533ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1534ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang void ResetObjCLayout(const ObjCContainerDecl *CD) { 153591037db265ecdd914a26e056cf69207b4f50924ehkuang ObjCLayouts[CD] = 0; 1536ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } 153791037db265ecdd914a26e056cf69207b4f50924ehkuang 1538ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang //===--------------------------------------------------------------------===// 1539ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang // Integer Predicates 154091037db265ecdd914a26e056cf69207b4f50924ehkuang //===--------------------------------------------------------------------===// 1541ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1542b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian // The width of an integer, as defined in C99 6.2.6.2. This is the number 1543b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian // of bits in an integer type excluding any padding bits. 1544ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned getIntWidth(QualType T) const; 1545ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1546f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang // Per C99 6.2.5p6, for every signed integer type, there is a corresponding 15475ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang // unsigned integer type. This method takes a signed type, and returns the 15486ac915abcdb404a00d927fe6308a47fcf09d9519hkuang // corresponding unsigned integer type. 1549b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian QualType getCorrespondingUnsignedType(QualType T); 1550b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1551b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian //===--------------------------------------------------------------------===// 1552ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang // Type Iterators. 15535ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang //===--------------------------------------------------------------------===// 1554b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1555b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian typedef std::vector<Type*>::iterator type_iterator; 1556b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian typedef std::vector<Type*>::const_iterator const_type_iterator; 1557b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 155891037db265ecdd914a26e056cf69207b4f50924ehkuang type_iterator types_begin() { return Types.begin(); } 15595ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang type_iterator types_end() { return Types.end(); } 1560b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const_type_iterator types_begin() const { return Types.begin(); } 15615ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang const_type_iterator types_end() const { return Types.end(); } 15626ac915abcdb404a00d927fe6308a47fcf09d9519hkuang 15636ac915abcdb404a00d927fe6308a47fcf09d9519hkuang //===--------------------------------------------------------------------===// 15645ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang // Integer Values 1565b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian //===--------------------------------------------------------------------===// 1566b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 15671184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// MakeIntValue - Make an APSInt of the appropriate width and 1568f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// signedness for the given \arg Value and integer \arg Type. 15691184aebb761cbeac9124c37189a80a1a58f04b6bhkuang llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const { 1570b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian llvm::APSInt Res(getIntWidth(Type), 15716ac915abcdb404a00d927fe6308a47fcf09d9519hkuang !Type->isSignedIntegerOrEnumerationType()); 1572b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian Res = Value; 1573b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian return Res; 1574ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang } 1575ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 15765ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// \brief Get the implementation of ObjCInterfaceDecl,or NULL if none exists. 15775ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang ObjCImplementationDecl *getObjCImplementation(ObjCInterfaceDecl *D); 15785ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// \brief Get the implementation of ObjCCategoryDecl, or NULL if none exists. 1579f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang ObjCCategoryImplDecl *getObjCImplementation(ObjCCategoryDecl *D); 1580ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1581ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \brief returns true if there is at lease one @implementation in TU. 158291037db265ecdd914a26e056cf69207b4f50924ehkuang bool AnyObjCImplementation() { 158391037db265ecdd914a26e056cf69207b4f50924ehkuang return !ObjCImpls.empty(); 158491037db265ecdd914a26e056cf69207b4f50924ehkuang } 15855ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 158691037db265ecdd914a26e056cf69207b4f50924ehkuang /// \brief Set the implementation of ObjCInterfaceDecl. 1587ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang void setObjCImplementation(ObjCInterfaceDecl *IFaceD, 15885ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang ObjCImplementationDecl *ImplD); 15895ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang /// \brief Set the implementation of ObjCCategoryDecl. 15905ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang void setObjCImplementation(ObjCCategoryDecl *CatD, 1591b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian ObjCCategoryImplDecl *ImplD); 15921184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 1593f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang /// \brief Get the duplicate declaration of a ObjCMethod in the same 159491037db265ecdd914a26e056cf69207b4f50924ehkuang /// interface, or null if non exists. 1595b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const ObjCMethodDecl *getObjCMethodRedeclaration( 1596b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian const ObjCMethodDecl *MD) const { 1597b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian llvm::DenseMap<const ObjCMethodDecl*, const ObjCMethodDecl*>::const_iterator 159891037db265ecdd914a26e056cf69207b4f50924ehkuang I = ObjCMethodRedecls.find(MD); 159991037db265ecdd914a26e056cf69207b4f50924ehkuang if (I == ObjCMethodRedecls.end()) 160091037db265ecdd914a26e056cf69207b4f50924ehkuang return 0; 160191037db265ecdd914a26e056cf69207b4f50924ehkuang return I->second; 160291037db265ecdd914a26e056cf69207b4f50924ehkuang } 1603ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1604ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang void setObjCMethodRedeclaration(const ObjCMethodDecl *MD, 16055ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang const ObjCMethodDecl *Redecl) { 160691037db265ecdd914a26e056cf69207b4f50924ehkuang ObjCMethodRedecls[MD] = Redecl; 160791037db265ecdd914a26e056cf69207b4f50924ehkuang } 160891037db265ecdd914a26e056cf69207b4f50924ehkuang 1609ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \brief Set the copy inialization expression of a block var decl. 1610ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang void setBlockVarCopyInits(VarDecl*VD, Expr* Init); 1611ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \brief Get the copy initialization expression of VarDecl,or NULL if 1612ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// none exists. 1613ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang Expr *getBlockVarCopyInits(const VarDecl*VD); 161491037db265ecdd914a26e056cf69207b4f50924ehkuang 161591037db265ecdd914a26e056cf69207b4f50924ehkuang /// \brief Allocate an uninitialized TypeSourceInfo. 161691037db265ecdd914a26e056cf69207b4f50924ehkuang /// 161791037db265ecdd914a26e056cf69207b4f50924ehkuang /// The caller should initialize the memory held by TypeSourceInfo using 161891037db265ecdd914a26e056cf69207b4f50924ehkuang /// the TypeLoc wrappers. 161991037db265ecdd914a26e056cf69207b4f50924ehkuang /// 162091037db265ecdd914a26e056cf69207b4f50924ehkuang /// \param T the type that will be the basis for type source info. This type 162191037db265ecdd914a26e056cf69207b4f50924ehkuang /// should refer to how the declarator was written in source code, not to 162291037db265ecdd914a26e056cf69207b4f50924ehkuang /// what type semantic analysis resolved the declarator to. 162391037db265ecdd914a26e056cf69207b4f50924ehkuang /// 162491037db265ecdd914a26e056cf69207b4f50924ehkuang /// \param Size the size of the type info to create, or 0 if the size 162591037db265ecdd914a26e056cf69207b4f50924ehkuang /// should be calculated based on the type. 1626b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian TypeSourceInfo *CreateTypeSourceInfo(QualType T, unsigned Size = 0) const; 1627ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1628ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \brief Allocate a TypeSourceInfo where all locations have been 1629ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// initialized to a given location, which defaults to the empty 1630ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// location. 163191037db265ecdd914a26e056cf69207b4f50924ehkuang TypeSourceInfo * 163291037db265ecdd914a26e056cf69207b4f50924ehkuang getTrivialTypeSourceInfo(QualType T, 1633ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang SourceLocation Loc = SourceLocation()) const; 1634ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 16351184aebb761cbeac9124c37189a80a1a58f04b6bhkuang TypeSourceInfo *getNullTypeSourceInfo() { return &NullTypeSourceInfo; } 1636ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1637ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \brief Add a deallocation callback that will be invoked when the 1638ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// ASTContext is destroyed. 1639b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// 1640b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Callback A callback function that will be invoked on destruction. 1641b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// 1642b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Data Pointer data that will be provided to the callback function 1643b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// when it is called. 1644ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang void AddDeallocation(void (*Callback)(void*), void *Data); 1645ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1646ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD); 16476ac915abcdb404a00d927fe6308a47fcf09d9519hkuang GVALinkage GetGVALinkageForVariable(const VarDecl *VD); 16481184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 16491184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// \brief Determines if the decl can be CodeGen'ed or deserialized from PCH 16501184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// lazily, only when used; this is only relevant for function or file scoped 1651b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// var definitions. 16521184aebb761cbeac9124c37189a80a1a58f04b6bhkuang /// 1653b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \returns true if the function/var must be CodeGen'ed/deserialized even if 1654b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// it is not used. 16555ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang bool DeclMustBeEmitted(const Decl *D); 1656b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1657b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1658ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \brief Used by ParmVarDecl to store on the side the 1659ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// index of the parameter when it exceeds the size of the normal bitfield. 1660ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang void setParameterIndex(const ParmVarDecl *D, unsigned index); 1661ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 16626ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// \brief Used by ParmVarDecl to retrieve on the side the 1663ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// index of the parameter when it exceeds the size of the normal bitfield. 1664ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang unsigned getParameterIndex(const ParmVarDecl *D) const; 16655ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 1666ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang //===--------------------------------------------------------------------===// 1667ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang // Statistics 1668ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang //===--------------------------------------------------------------------===// 1669b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1670b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief The number of implicitly-declared default constructors. 1671b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian static unsigned NumImplicitDefaultConstructors; 1672b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 16736ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// \brief The number of implicitly-declared default constructors for 16746ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// which declarations were built. 16756ac915abcdb404a00d927fe6308a47fcf09d9519hkuang static unsigned NumImplicitDefaultConstructorsDeclared; 16766ac915abcdb404a00d927fe6308a47fcf09d9519hkuang 16776ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// \brief The number of implicitly-declared copy constructors. 16786ac915abcdb404a00d927fe6308a47fcf09d9519hkuang static unsigned NumImplicitCopyConstructors; 16796ac915abcdb404a00d927fe6308a47fcf09d9519hkuang 16806ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// \brief The number of implicitly-declared copy constructors for 16816ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// which declarations were built. 16826ac915abcdb404a00d927fe6308a47fcf09d9519hkuang static unsigned NumImplicitCopyConstructorsDeclared; 16836ac915abcdb404a00d927fe6308a47fcf09d9519hkuang 16846ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// \brief The number of implicitly-declared move constructors. 16856ac915abcdb404a00d927fe6308a47fcf09d9519hkuang static unsigned NumImplicitMoveConstructors; 16866ac915abcdb404a00d927fe6308a47fcf09d9519hkuang 16876ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// \brief The number of implicitly-declared move constructors for 16886ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// which declarations were built. 16896ac915abcdb404a00d927fe6308a47fcf09d9519hkuang static unsigned NumImplicitMoveConstructorsDeclared; 16906ac915abcdb404a00d927fe6308a47fcf09d9519hkuang 16916ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// \brief The number of implicitly-declared copy assignment operators. 16926ac915abcdb404a00d927fe6308a47fcf09d9519hkuang static unsigned NumImplicitCopyAssignmentOperators; 16936ac915abcdb404a00d927fe6308a47fcf09d9519hkuang 16946ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// \brief The number of implicitly-declared copy assignment operators for 16956ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// which declarations were built. 16966ac915abcdb404a00d927fe6308a47fcf09d9519hkuang static unsigned NumImplicitCopyAssignmentOperatorsDeclared; 16976ac915abcdb404a00d927fe6308a47fcf09d9519hkuang 16986ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// \brief The number of implicitly-declared move assignment operators. 16996ac915abcdb404a00d927fe6308a47fcf09d9519hkuang static unsigned NumImplicitMoveAssignmentOperators; 17006ac915abcdb404a00d927fe6308a47fcf09d9519hkuang 17016ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// \brief The number of implicitly-declared move assignment operators for 17026ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// which declarations were built. 17036ac915abcdb404a00d927fe6308a47fcf09d9519hkuang static unsigned NumImplicitMoveAssignmentOperatorsDeclared; 17046ac915abcdb404a00d927fe6308a47fcf09d9519hkuang 17056ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// \brief The number of implicitly-declared destructors. 17066ac915abcdb404a00d927fe6308a47fcf09d9519hkuang static unsigned NumImplicitDestructors; 17076ac915abcdb404a00d927fe6308a47fcf09d9519hkuang 17086ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// \brief The number of implicitly-declared destructors for which 17096ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// declarations were built. 17106ac915abcdb404a00d927fe6308a47fcf09d9519hkuang static unsigned NumImplicitDestructorsDeclared; 17116ac915abcdb404a00d927fe6308a47fcf09d9519hkuang 1712ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuangprivate: 17135ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang ASTContext(const ASTContext&); // DO NOT IMPLEMENT 171491037db265ecdd914a26e056cf69207b4f50924ehkuang void operator=(const ASTContext&); // DO NOT IMPLEMENT 1715ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1716ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuangpublic: 1717b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \brief Initialize built-in types. 171891037db265ecdd914a26e056cf69207b4f50924ehkuang /// 1719ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// This routine may only be invoked once for a given ASTContext object. 1720b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// It is normally invoked by the ASTContext constructor. However, the 1721b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// constructor can be asked to delay initialization, which places the burden 17226ac915abcdb404a00d927fe6308a47fcf09d9519hkuang /// of calling this function on the user of that object. 172391037db265ecdd914a26e056cf69207b4f50924ehkuang /// 1724b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian /// \param Target The target 1725b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian void InitBuiltinTypes(const TargetInfo &Target); 1726ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 172791037db265ecdd914a26e056cf69207b4f50924ehkuangprivate: 1728ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang void InitBuiltinType(CanQualType &R, BuiltinType::Kind K); 1729ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 17301184aebb761cbeac9124c37189a80a1a58f04b6bhkuang // Return the ObjC type encoding for a given type. 1731f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang void getObjCEncodingForTypeImpl(QualType t, std::string &S, 1732f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang bool ExpandPointedToStructures, 1733b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian bool ExpandStructures, 173491037db265ecdd914a26e056cf69207b4f50924ehkuang const FieldDecl *Field, 173591037db265ecdd914a26e056cf69207b4f50924ehkuang bool OutermostType = false, 173691037db265ecdd914a26e056cf69207b4f50924ehkuang bool EncodingProperty = false, 173791037db265ecdd914a26e056cf69207b4f50924ehkuang bool StructField = false) const; 17385ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang 1739b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian // Adds the encoding of the structure's members. 1740ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang void getObjCEncodingForStructureImpl(RecordDecl *RD, std::string &S, 17415ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang const FieldDecl *Field, 17425ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang bool includeVBases = true) const; 1743ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1744ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const ASTRecordLayout & 1745ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang getObjCLayout(const ObjCInterfaceDecl *D, 1746ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang const ObjCImplementationDecl *Impl) const; 1747ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1748ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuangprivate: 1749ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// \brief A set of deallocations that should be performed when the 1750ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang /// ASTContext is destroyed. 175191037db265ecdd914a26e056cf69207b4f50924ehkuang SmallVector<std::pair<void (*)(void*), void *>, 16> Deallocations; 175291037db265ecdd914a26e056cf69207b4f50924ehkuang 1753ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang // FIXME: This currently contains the set of StoredDeclMaps used 1754ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang // by DeclContext objects. This probably should not be in ASTContext, 1755b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian // but we include it here so that ASTContext can quickly deallocate them. 1756ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang llvm::PointerIntPair<StoredDeclsMap*,1> LastSDM; 1757ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 175891037db265ecdd914a26e056cf69207b4f50924ehkuang /// \brief A counter used to uniquely identify "blocks". 1759b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian mutable unsigned int UniqueBlockByRefTypeID; 1760b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1761b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian friend class DeclContext; 1762b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian friend class DeclarationNameTable; 1763b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian void ReleaseDeclContextMaps(); 1764b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian}; 1765b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1766b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian/// @brief Utility function for constructing a nullary selector. 1767b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanianstatic inline Selector GetNullarySelector(StringRef name, ASTContext& Ctx) { 17685ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang IdentifierInfo* II = &Ctx.Idents.get(name); 1769b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian return Ctx.Selectors.getSelector(0, &II); 1770ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang} 1771ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1772ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang/// @brief Utility function for constructing an unary selector. 1773ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuangstatic inline Selector GetUnarySelector(StringRef name, ASTContext& Ctx) { 1774ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang IdentifierInfo* II = &Ctx.Idents.get(name); 17759b35249446b07f40ac5fcc3205f2c048616efacchkuang return Ctx.Selectors.getSelector(1, &II); 177691037db265ecdd914a26e056cf69207b4f50924ehkuang} 1777b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1778b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian} // end namespace clang 177991037db265ecdd914a26e056cf69207b4f50924ehkuang 17806ac915abcdb404a00d927fe6308a47fcf09d9519hkuang// operator new and delete aren't allowed inside namespaces. 17816ac915abcdb404a00d927fe6308a47fcf09d9519hkuang// The throw specifications are mandated by the standard. 17826ac915abcdb404a00d927fe6308a47fcf09d9519hkuang/// @brief Placement new for using the ASTContext's allocator. 17836ac915abcdb404a00d927fe6308a47fcf09d9519hkuang/// 17846ac915abcdb404a00d927fe6308a47fcf09d9519hkuang/// This placement form of operator new uses the ASTContext's allocator for 178591037db265ecdd914a26e056cf69207b4f50924ehkuang/// obtaining memory. It is a non-throwing new, which means that it returns 17865ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang/// null on error. (If that is what the allocator does. The current does, so if 178791037db265ecdd914a26e056cf69207b4f50924ehkuang/// this ever changes, this operator will have to be changed, too.) 178891037db265ecdd914a26e056cf69207b4f50924ehkuang/// Usage looks like this (assuming there's an ASTContext 'Context' in scope): 178991037db265ecdd914a26e056cf69207b4f50924ehkuang/// @code 179091037db265ecdd914a26e056cf69207b4f50924ehkuang/// // Default alignment (8) 1791ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang/// IntegerLiteral *Ex = new (Context) IntegerLiteral(arguments); 1792ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang/// // Specific alignment 17935ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang/// IntegerLiteral *Ex2 = new (Context, 4) IntegerLiteral(arguments); 179491037db265ecdd914a26e056cf69207b4f50924ehkuang/// @endcode 1795b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian/// Please note that you cannot use delete on the pointer; it must be 1796ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang/// deallocated using an explicit destructor call followed by 1797ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang/// @c Context.Deallocate(Ptr). 1798ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang/// 1799ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang/// @param Bytes The number of bytes to allocate. Calculated by the compiler. 1800b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian/// @param C The ASTContext that provides the allocator. 18011184aebb761cbeac9124c37189a80a1a58f04b6bhkuang/// @param Alignment The alignment of the allocated memory (if the underlying 1802ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang/// allocator supports it). 1803ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang/// @return The allocated memory. Could be NULL. 1804ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuanginline void *operator new(size_t Bytes, const clang::ASTContext &C, 180591037db265ecdd914a26e056cf69207b4f50924ehkuang size_t Alignment) throw () { 1806ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang return C.Allocate(Bytes, Alignment); 1807ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang} 1808b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian/// @brief Placement delete companion to the new above. 1809b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian/// 1810ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang/// This operator is just a companion to the new above. There is no way of 1811ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang/// invoking it directly; see the new operator for more details. This operator 18121184aebb761cbeac9124c37189a80a1a58f04b6bhkuang/// is called implicitly by the compiler if a placement new expression using 1813ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang/// the ASTContext throws in the object constructor. 18141184aebb761cbeac9124c37189a80a1a58f04b6bhkuanginline void operator delete(void *Ptr, const clang::ASTContext &C, size_t) 1815ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang throw () { 1816ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang C.Deallocate(Ptr); 18171184aebb761cbeac9124c37189a80a1a58f04b6bhkuang} 18181184aebb761cbeac9124c37189a80a1a58f04b6bhkuang 18191184aebb761cbeac9124c37189a80a1a58f04b6bhkuang/// This placement form of operator new[] uses the ASTContext's allocator for 18201184aebb761cbeac9124c37189a80a1a58f04b6bhkuang/// obtaining memory. It is a non-throwing new[], which means that it returns 18211184aebb761cbeac9124c37189a80a1a58f04b6bhkuang/// null on error. 1822b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian/// Usage looks like this (assuming there's an ASTContext 'Context' in scope): 182391037db265ecdd914a26e056cf69207b4f50924ehkuang/// @code 182491037db265ecdd914a26e056cf69207b4f50924ehkuang/// // Default alignment (8) 182591037db265ecdd914a26e056cf69207b4f50924ehkuang/// char *data = new (Context) char[10]; 18261184aebb761cbeac9124c37189a80a1a58f04b6bhkuang/// // Specific alignment 18271184aebb761cbeac9124c37189a80a1a58f04b6bhkuang/// char *data = new (Context, 4) char[10]; 182891037db265ecdd914a26e056cf69207b4f50924ehkuang/// @endcode 182991037db265ecdd914a26e056cf69207b4f50924ehkuang/// Please note that you cannot use delete on the pointer; it must be 183091037db265ecdd914a26e056cf69207b4f50924ehkuang/// deallocated using an explicit destructor call followed by 1831ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang/// @c Context.Deallocate(Ptr). 1832b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian/// 1833b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian/// @param Bytes The number of bytes to allocate. Calculated by the compiler. 1834ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang/// @param C The ASTContext that provides the allocator. 1835b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian/// @param Alignment The alignment of the allocated memory (if the underlying 1836b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian/// allocator supports it). 1837b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian/// @return The allocated memory. Could be NULL. 18381184aebb761cbeac9124c37189a80a1a58f04b6bhkuanginline void *operator new[](size_t Bytes, const clang::ASTContext& C, 18391184aebb761cbeac9124c37189a80a1a58f04b6bhkuang size_t Alignment = 8) throw () { 18401184aebb761cbeac9124c37189a80a1a58f04b6bhkuang return C.Allocate(Bytes, Alignment); 18411184aebb761cbeac9124c37189a80a1a58f04b6bhkuang} 1842ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang 1843ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang/// @brief Placement delete[] companion to the new[] above. 1844b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian/// 1845b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian/// This operator is just a companion to the new[] above. There is no way of 1846b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian/// invoking it directly; see the new[] operator for more details. This operator 18471184aebb761cbeac9124c37189a80a1a58f04b6bhkuang/// is called implicitly by the compiler if a placement new[] expression using 1848b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian/// the ASTContext throws in the object constructor. 18491184aebb761cbeac9124c37189a80a1a58f04b6bhkuanginline void operator delete[](void *Ptr, const clang::ASTContext &C, size_t) 18501184aebb761cbeac9124c37189a80a1a58f04b6bhkuang throw () { 1851b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian C.Deallocate(Ptr); 1852b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian} 1853b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian 1854b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#endif 1855b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian