ASTContext.h revision dd7fddb5b6883326e52b278a9b7e9cefea29aae0
1fa458e413c3e5b8d479e49258d060b7bb4567c57danno@chromium.org//===--- ASTContext.h - Context to hold long-lived AST nodes ----*- C++ -*-===//
243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen//
343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen//                     The LLVM Compiler Infrastructure
443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen//
543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// This file is distributed under the University of Illinois Open Source
643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen// License. See LICENSE.TXT for details.
743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen//
843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen//===----------------------------------------------------------------------===//
943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen//
1043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen//  This file defines the ASTContext interface.
1143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen//
1243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen//===----------------------------------------------------------------------===//
1343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
1443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen#ifndef LLVM_CLANG_AST_ASTCONTEXT_H
1543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen#define LLVM_CLANG_AST_ASTCONTEXT_H
1643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
1743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen#include "clang/Basic/AddressSpaces.h"
1843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen#include "clang/Basic/IdentifierTable.h"
1943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen#include "clang/Basic/LangOptions.h"
2043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen#include "clang/Basic/OperatorKinds.h"
2143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen#include "clang/Basic/PartialDiagnostic.h"
2243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen#include "clang/Basic/VersionTuple.h"
2343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen#include "clang/AST/Decl.h"
2443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen#include "clang/AST/NestedNameSpecifier.h"
2543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen#include "clang/AST/PrettyPrinter.h"
2643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen#include "clang/AST/TemplateName.h"
2743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen#include "clang/AST/Type.h"
2843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen#include "clang/AST/CanonicalType.h"
2943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen#include "clang/AST/UsuallyTinyPtrVector.h"
3043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen#include "llvm/ADT/DenseMap.h"
31c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org#include "llvm/ADT/FoldingSet.h"
3243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen#include "llvm/ADT/IntrusiveRefCntPtr.h"
331805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org#include "llvm/ADT/OwningPtr.h"
34f837290e142d49c9e1332841ec2c49ee2f09584avegorov@chromium.org#include "llvm/ADT/SmallPtrSet.h"
35b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org#include "llvm/Support/Allocator.h"
3665fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org#include <vector>
37ce5e87bd905d592a8bd612b3dedf7a994177c13aager@chromium.org
38dff694e8cc18aa9640e92962de2699b9d07a7690vegorov@chromium.orgnamespace llvm {
3943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  struct fltSemantics;
40fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org}
4143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
4255ee80713569ab0324fc8dcedcb5518501daa6a6ricow@chromium.orgnamespace clang {
43b5737496145078e47f3d28f19ed8d918e2254738ager@chromium.org  class FileManager;
44a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  class ASTRecordLayout;
4543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  class BlockExpr;
4671affb54842da76b24f0bb3184e9f0960523f89dkasperl@chromium.org  class CharUnits;
4771affb54842da76b24f0bb3184e9f0960523f89dkasperl@chromium.org  class Diagnostic;
4843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  class Expr;
49b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class ExternalASTSource;
50b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class ASTMutationListener;
51b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class IdentifierTable;
52b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class SelectorTable;
53b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class SourceManager;
54b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class TargetInfo;
55068ea0a6ea115c058d1d9798029bd7fa1eaaa955mstarzinger@chromium.org  class CXXABI;
56068ea0a6ea115c058d1d9798029bd7fa1eaaa955mstarzinger@chromium.org  // Decls
57068ea0a6ea115c058d1d9798029bd7fa1eaaa955mstarzinger@chromium.org  class DeclContext;
58068ea0a6ea115c058d1d9798029bd7fa1eaaa955mstarzinger@chromium.org  class CXXMethodDecl;
59b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class CXXRecordDecl;
60b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class Decl;
61b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class FieldDecl;
62b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class MangleContext;
63b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class ObjCIvarDecl;
64b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class ObjCIvarRefExpr;
65b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class ObjCPropertyDecl;
66b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class RecordDecl;
67b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class StoredDeclsMap;
68b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class TagDecl;
69b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class TemplateTemplateParmDecl;
70b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class TemplateTypeParmDecl;
71b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class TranslationUnitDecl;
72b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class TypeDecl;
73b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class TypedefNameDecl;
74b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class UsingDecl;
75b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class UsingShadowDecl;
76b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  class UnresolvedSetIterator;
77b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org
78b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  namespace Builtin { class Context; }
79b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org
80b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org/// ASTContext - This class holds long-lived AST nodes (such as types and
81b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org/// decls) that can be referred to throughout the semantic analysis of a file.
82b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.orgclass ASTContext : public llvm::RefCountedBase<ASTContext> {
83b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  ASTContext &this_() { return *this; }
84b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org
85b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  mutable std::vector<Type*> Types;
86b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  mutable llvm::FoldingSet<ExtQuals> ExtQualNodes;
87b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  mutable llvm::FoldingSet<ComplexType> ComplexTypes;
88b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  mutable llvm::FoldingSet<PointerType> PointerTypes;
89b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  mutable llvm::FoldingSet<BlockPointerType> BlockPointerTypes;
90b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  mutable llvm::FoldingSet<LValueReferenceType> LValueReferenceTypes;
91b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  mutable llvm::FoldingSet<RValueReferenceType> RValueReferenceTypes;
92400388edd471bd4d4a97b21c52c1024cd1cc5708rossberg@chromium.org  mutable llvm::FoldingSet<MemberPointerType> MemberPointerTypes;
93400388edd471bd4d4a97b21c52c1024cd1cc5708rossberg@chromium.org  mutable llvm::FoldingSet<ConstantArrayType> ConstantArrayTypes;
94c36ce6e8979bbbd43539f0a0effc87ea20dd65cckmillikin@chromium.org  mutable llvm::FoldingSet<IncompleteArrayType> IncompleteArrayTypes;
95c36ce6e8979bbbd43539f0a0effc87ea20dd65cckmillikin@chromium.org  mutable std::vector<VariableArrayType*> VariableArrayTypes;
96c36ce6e8979bbbd43539f0a0effc87ea20dd65cckmillikin@chromium.org  mutable llvm::FoldingSet<DependentSizedArrayType> DependentSizedArrayTypes;
97c36ce6e8979bbbd43539f0a0effc87ea20dd65cckmillikin@chromium.org  mutable llvm::FoldingSet<DependentSizedExtVectorType>
98a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org    DependentSizedExtVectorTypes;
99c36ce6e8979bbbd43539f0a0effc87ea20dd65cckmillikin@chromium.org  mutable llvm::FoldingSet<VectorType> VectorTypes;
100a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable llvm::FoldingSet<FunctionNoProtoType> FunctionNoProtoTypes;
101a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable llvm::ContextualFoldingSet<FunctionProtoType, ASTContext&>
102a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org    FunctionProtoTypes;
103a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable llvm::FoldingSet<DependentTypeOfExprType> DependentTypeOfExprTypes;
104a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable llvm::FoldingSet<DependentDecltypeType> DependentDecltypeTypes;
105a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable llvm::FoldingSet<TemplateTypeParmType> TemplateTypeParmTypes;
106a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable llvm::FoldingSet<SubstTemplateTypeParmType>
107c36ce6e8979bbbd43539f0a0effc87ea20dd65cckmillikin@chromium.org    SubstTemplateTypeParmTypes;
108a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable llvm::FoldingSet<SubstTemplateTypeParmPackType>
1097028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org    SubstTemplateTypeParmPackTypes;
110a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable llvm::ContextualFoldingSet<TemplateSpecializationType, ASTContext&>
111a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org    TemplateSpecializationTypes;
112a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable llvm::FoldingSet<ParenType> ParenTypes;
113a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable llvm::FoldingSet<ElaboratedType> ElaboratedTypes;
114a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable llvm::FoldingSet<DependentNameType> DependentNameTypes;
115a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable llvm::ContextualFoldingSet<DependentTemplateSpecializationType,
116a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org                                     ASTContext&>
117a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org    DependentTemplateSpecializationTypes;
118a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  llvm::FoldingSet<PackExpansionType> PackExpansionTypes;
119a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable llvm::FoldingSet<ObjCObjectTypeImpl> ObjCObjectTypes;
120a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable llvm::FoldingSet<ObjCObjectPointerType> ObjCObjectPointerTypes;
1217028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  mutable llvm::FoldingSet<AutoType> AutoTypes;
122a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  llvm::FoldingSet<AttributedType> AttributedTypes;
1237028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org
124a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable llvm::FoldingSet<QualifiedTemplateName> QualifiedTemplateNames;
1257028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  mutable llvm::FoldingSet<DependentTemplateName> DependentTemplateNames;
1267028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  mutable llvm::FoldingSet<SubstTemplateTemplateParmStorage>
127a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org    SubstTemplateTemplateParms;
128a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable llvm::ContextualFoldingSet<SubstTemplateTemplateParmPackStorage,
129a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org                                     ASTContext&>
130a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org    SubstTemplateTemplateParmPacks;
131a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
132a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// \brief The set of nested name specifiers.
133a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  ///
134a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// This set is managed by the NestedNameSpecifier class.
1357028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  mutable llvm::FoldingSet<NestedNameSpecifier> NestedNameSpecifiers;
136a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable NestedNameSpecifier *GlobalNestedNameSpecifier;
1377028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  friend class NestedNameSpecifier;
138a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
139a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// ASTRecordLayouts - A cache mapping from RecordDecls to ASTRecordLayouts.
140a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  ///  This is lazily created.  This is intentionally not serialized.
141a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*>
142a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org    ASTRecordLayouts;
143a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable llvm::DenseMap<const ObjCContainerDecl*, const ASTRecordLayout*>
144a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org    ObjCLayouts;
145a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
146a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// KeyFunctions - A cache mapping from CXXRecordDecls to key functions.
147a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  llvm::DenseMap<const CXXRecordDecl*, const CXXMethodDecl*> KeyFunctions;
148a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
149a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// \brief Mapping from ObjCContainers to their ObjCImplementations.
150a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*> ObjCImpls;
151a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
152a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// \brief Mapping from __block VarDecls to their copy initialization expr.
153a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  llvm::DenseMap<const VarDecl*, Expr*> BlockVarCopyInits;
1547028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org
155a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// \brief Representation of a "canonical" template template parameter that
156a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// is used in canonical template names.
1577028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  class CanonicalTemplateTemplateParm : public llvm::FoldingSetNode {
158a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org    TemplateTemplateParmDecl *Parm;
159a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
160a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  public:
161a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org    CanonicalTemplateTemplateParm(TemplateTemplateParmDecl *Parm)
162a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org      : Parm(Parm) { }
163a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
164a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org    TemplateTemplateParmDecl *getParam() const { return Parm; }
1657028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org
166a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org    void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, Parm); }
167a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
168a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org    static void Profile(llvm::FoldingSetNodeID &ID,
169a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org                        TemplateTemplateParmDecl *Parm);
170a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  };
171a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable llvm::FoldingSet<CanonicalTemplateTemplateParm>
172a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org    CanonTemplateTemplateParms;
173a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
174a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  TemplateTemplateParmDecl *
175a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org    getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const;
176a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
177a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// \brief Whether __[u]int128_t identifier is installed.
178a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  bool IsInt128Installed;
179a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
180a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// BuiltinVaListType - built-in va list type.
181a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// This is initially null and set by Sema::LazilyCreateBuiltin when
182a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// a builtin that takes a valist is encountered.
183a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  QualType BuiltinVaListType;
1847028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org
185a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// ObjCIdType - a pseudo built-in typedef type (set by Sema).
1867028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  QualType ObjCIdTypedefType;
187a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
188a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// ObjCSelType - another pseudo built-in typedef type (set by Sema).
189a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  QualType ObjCSelTypedefType;
190a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
191a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// ObjCProtoType - another pseudo built-in typedef type (set by Sema).
192a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  QualType ObjCProtoType;
193a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  const RecordType *ProtoStructType;
194a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
195a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// ObjCClassType - another pseudo built-in typedef type (set by Sema).
196a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  QualType ObjCClassTypedefType;
197a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
198a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  QualType ObjCConstantStringType;
199a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable RecordDecl *CFConstantStringTypeDecl;
200a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
2017028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  mutable RecordDecl *NSConstantStringTypeDecl;
202a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
203a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable RecordDecl *ObjCFastEnumerationStateTypeDecl;
204a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
205dfe53073738bbf16023d96fce5118358a1037fd3ulan@chromium.org  /// \brief The type for the C FILE type.
206dfe53073738bbf16023d96fce5118358a1037fd3ulan@chromium.org  TypeDecl *FILEDecl;
207a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
208a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// \brief The type for the C jmp_buf type.
209a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  TypeDecl *jmp_bufDecl;
210a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
211a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// \brief The type for the C sigjmp_buf type.
212a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  TypeDecl *sigjmp_bufDecl;
213a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
214a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// \brief Type for the Block descriptor for Blocks CodeGen.
215a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable RecordDecl *BlockDescriptorType;
216a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
217a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// \brief Type for the Block descriptor for Blocks CodeGen.
218a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  mutable RecordDecl *BlockDescriptorExtendedType;
2197028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org
220a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// \brief Declaration for the CUDA cudaConfigureCall function.
221a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  FunctionDecl *cudaConfigureCallDecl;
222a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
223c36ce6e8979bbbd43539f0a0effc87ea20dd65cckmillikin@chromium.org  TypeSourceInfo NullTypeSourceInfo;
224a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
225a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// \brief Keeps track of all declaration attributes.
226a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  ///
227a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// Since so few decls have attrs, we keep them in a hash map instead of
228a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// wasting space in the Decl class.
229a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  llvm::DenseMap<const Decl*, AttrVec*> DeclAttrs;
230a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org
231a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// \brief Keeps track of the static data member templates from which
23237abdec9cad6edeba05b5c7a9ff73c25f5df2b70christian.plesner.hansen@gmail.com  /// static data members of class template specializations were instantiated.
23337abdec9cad6edeba05b5c7a9ff73c25f5df2b70christian.plesner.hansen@gmail.com  ///
234a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// This data structure stores the mapping from instantiations of static
235a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// data members to the static data member representations within the
236a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// class template from which they were instantiated along with the kind
237a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// of instantiation or specialization (a TemplateSpecializationKind - 1).
2387028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  ///
239a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// Given the following example:
240a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  ///
241a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// \code
242a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// template<typename T>
243a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// struct X {
244a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  ///   static T value;
245a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// };
246dfe53073738bbf16023d96fce5118358a1037fd3ulan@chromium.org  ///
247dfe53073738bbf16023d96fce5118358a1037fd3ulan@chromium.org  /// template<typename T>
248a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  ///   T X<T>::value = T(17);
249a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  ///
250a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// int *x = &X<int>::value;
251a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// \endcode
2529e3e0b618a14a05efd7d66f20bac4423dd3a1a2ffschneider@chromium.org  ///
253fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  /// This mapping will contain an entry that maps from the VarDecl for
254fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  /// X<int>::value to the corresponding VarDecl for X<T>::value (within the
255fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  /// class template X) and will be marked TSK_ImplicitInstantiation.
256fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  llvm::DenseMap<const VarDecl *, MemberSpecializationInfo *>
257fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org    InstantiatedFromStaticDataMember;
258fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org
2599e3e0b618a14a05efd7d66f20bac4423dd3a1a2ffschneider@chromium.org  /// \brief Keeps track of the declaration from which a UsingDecl was
2604a9f6553038df6b893b3d3ccae351723f4cbbae7yangguo@chromium.org  /// created during instantiation.  The source declaration is always
26159297c735ad2a41156ae9c723a39ff259ad061e0jkummerow@chromium.org  /// a UsingDecl, an UnresolvedUsingValueDecl, or an
2629e3e0b618a14a05efd7d66f20bac4423dd3a1a2ffschneider@chromium.org  /// UnresolvedUsingTypenameDecl.
2634a9f6553038df6b893b3d3ccae351723f4cbbae7yangguo@chromium.org  ///
264154ff99473e866f5eb00a44045e27866a7fdce29yangguo@chromium.org  /// For example:
2659e3e0b618a14a05efd7d66f20bac4423dd3a1a2ffschneider@chromium.org  /// \code
266fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  /// template<typename T>
2679e3e0b618a14a05efd7d66f20bac4423dd3a1a2ffschneider@chromium.org  /// struct A {
268fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  ///   void f();
269fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  /// };
270fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  ///
2719e3e0b618a14a05efd7d66f20bac4423dd3a1a2ffschneider@chromium.org  /// template<typename T>
272fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  /// struct B : A<T> {
273fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  ///   using A<T>::f;
274fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  /// };
275fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  ///
2767028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  /// template struct B<int>;
277fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  /// \endcode
278fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  ///
279fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  /// This mapping will contain an entry that maps from the UsingDecl in
2809e3e0b618a14a05efd7d66f20bac4423dd3a1a2ffschneider@chromium.org  /// B<int> to the UnresolvedUsingDecl in B<T>.
2814a9f6553038df6b893b3d3ccae351723f4cbbae7yangguo@chromium.org  llvm::DenseMap<UsingDecl *, NamedDecl *> InstantiatedFromUsingDecl;
28259297c735ad2a41156ae9c723a39ff259ad061e0jkummerow@chromium.org
2839e3e0b618a14a05efd7d66f20bac4423dd3a1a2ffschneider@chromium.org  llvm::DenseMap<UsingShadowDecl*, UsingShadowDecl*>
2844a9f6553038df6b893b3d3ccae351723f4cbbae7yangguo@chromium.org    InstantiatedFromUsingShadowDecl;
285154ff99473e866f5eb00a44045e27866a7fdce29yangguo@chromium.org
2869e3e0b618a14a05efd7d66f20bac4423dd3a1a2ffschneider@chromium.org  llvm::DenseMap<FieldDecl *, FieldDecl *> InstantiatedFromUnnamedFieldDecl;
287fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org
2885b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  /// \brief Mapping that stores the methods overridden by a given C++
28943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// member function.
2907979bbb1df2eaff193e85d44c8da1ffa1525b7fcfschneider@chromium.org  ///
291fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  /// Since most C++ member functions aren't virtual and therefore
292fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  /// don't override anything, we store the overridden functions in
29343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// this map on the side rather than within the CXXMethodDecl structure.
29443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  typedef UsuallyTinyPtrVector<const CXXMethodDecl> CXXMethodVector;
295d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org  llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector> OverriddenMethods;
296d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org
297d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org  TranslationUnitDecl *TUDecl;
2985b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org
2995b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  /// SourceMgr - The associated SourceManager object.
3005b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  SourceManager &SourceMgr;
3015b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org
302d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org  /// LangOpts - The language options used to create the AST associated with
303d236f4d96b5dd21acc5ec57f4e50fa97cdd97bb6ricow@chromium.org  ///  this ASTContext object.
30443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  LangOptions LangOpts;
30543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
30643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief The allocator used to create AST objects.
30743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  ///
30843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// AST objects are never destructed; rather, all memory associated with the
309d88afa260e45de10e729b05a20146184a488aff7erik.corry@gmail.com  /// AST objects will be released when the ASTContext itself is destroyed.
310d88afa260e45de10e729b05a20146184a488aff7erik.corry@gmail.com  mutable llvm::BumpPtrAllocator BumpAlloc;
3115b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org
3125b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  /// \brief Allocator for partial diagnostics.
3135b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  PartialDiagnostic::StorageAllocator DiagAllocator;
3145b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org
3155b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  /// \brief The current C++ ABI.
3165b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  llvm::OwningPtr<CXXABI> ABI;
317beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org  CXXABI *createCXXABI(const TargetInfo &T);
318beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org
319beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org  /// \brief The logical -> physical address space map.
3205b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  const LangAS::Map &AddrSpaceMap;
3215b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org
322beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org  friend class ASTDeclReader;
323beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org
324beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.orgpublic:
325beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org  const TargetInfo &Target;
326beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org  IdentifierTable &Idents;
327beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org  SelectorTable &Selectors;
328beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org  Builtin::Context &BuiltinInfo;
329beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org  mutable DeclarationNameTable DeclarationNames;
330beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org  llvm::OwningPtr<ExternalASTSource> ExternalSource;
331beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org  ASTMutationListener *Listener;
3325b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  clang::PrintingPolicy PrintingPolicy;
333beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org
334beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org  // Typedefs which may be provided defining the structure of Objective-C
335beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org  // pseudo-builtins
3365b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  QualType ObjCIdRedefinitionType;
3375b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  QualType ObjCClassRedefinitionType;
3385b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  QualType ObjCSelRedefinitionType;
3395b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org
340beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org  SourceManager& getSourceManager() { return SourceMgr; }
341beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org  const SourceManager& getSourceManager() const { return SourceMgr; }
342beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org  void *Allocate(unsigned Size, unsigned Align = 8) const {
3435b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org    return BumpAlloc.Allocate(Size, Align);
3445b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  }
3455b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  void Deallocate(void *Ptr) const { }
3465b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org
347beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org  /// Return the total amount of physical memory allocated for representing
3485b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  /// AST nodes and type information.
3495b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  size_t getASTAllocatedMemory() const {
3505b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org    return BumpAlloc.getTotalMemory();
3515b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  }
352beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org  /// Return the total memory used for various side tables.
3535b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  size_t getSideTableAllocatedMemory() const;
354d88afa260e45de10e729b05a20146184a488aff7erik.corry@gmail.com
3555b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  PartialDiagnostic::StorageAllocator &getDiagAllocator() {
356beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org    return DiagAllocator;
3575b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  }
35843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
35943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  const LangOptions& getLangOptions() const { return LangOpts; }
36043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
36143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  Diagnostic &getDiagnostics() const;
3622ec107fe650fe56eed094ca017940f26af46644bsgjesse@chromium.org
36365fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org  FullSourceLoc getFullLoc(SourceLocation Loc) const {
36443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen    return FullSourceLoc(Loc,SourceMgr);
36543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  }
36665fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org
36743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief Retrieve the attributes for the given declaration.
36865fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org  AttrVec& getDeclAttrs(const Decl *D);
36943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
37043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief Erase the attributes corresponding to the given declaration.
37143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  void eraseDeclAttrs(const Decl *D);
37243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
37343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief If this variable is an instantiated static data member of a
374e0e1b0d3e70c933d36ed381d511e9fda39f2a751mstarzinger@chromium.org  /// class template specialization, returns the templated static data member
37543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// from which it was instantiated.
376beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org  MemberSpecializationInfo *getInstantiatedFromStaticDataMember(
377beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org                                                           const VarDecl *Var);
37843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
37943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief Note that the static data member \p Inst is an instantiation of
38043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// the static data member template \p Tmpl of a class template.
38143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl,
38243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen                                           TemplateSpecializationKind TSK,
383beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org                        SourceLocation PointOfInstantiation = SourceLocation());
38465fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org
38543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief If the given using decl is an instantiation of a
38643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// (possibly unresolved) using decl from a template instantiation,
38743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// return it.
38843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  NamedDecl *getInstantiatedFromUsingDecl(UsingDecl *Inst);
389beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org
39043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief Remember that the using decl \p Inst is an instantiation
391d88afa260e45de10e729b05a20146184a488aff7erik.corry@gmail.com  /// of the using decl \p Pattern of a class template.
392d88afa260e45de10e729b05a20146184a488aff7erik.corry@gmail.com  void setInstantiatedFromUsingDecl(UsingDecl *Inst, NamedDecl *Pattern);
393beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org
394beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org  void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst,
39543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen                                          UsingShadowDecl *Pattern);
39643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  UsingShadowDecl *getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst);
39765fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org
39843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  FieldDecl *getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field);
39943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
40043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl);
40143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
40243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// ZeroBitfieldFollowsNonBitfield - return 'true" if 'FD' is a zero-length
40343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// bitfield which follows the non-bitfield 'LastFD'.
40443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  bool ZeroBitfieldFollowsNonBitfield(const FieldDecl *FD,
405beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org                                      const FieldDecl *LastFD) const;
40643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
40743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// ZeroBitfieldFollowsBitfield - return 'true" if 'FD' is a zero-length
40843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// bitfield which follows the bitfield 'LastFD'.
40943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  bool ZeroBitfieldFollowsBitfield(const FieldDecl *FD,
410beb2571dca14508fbbbb47a2f606327d5968ee92ager@chromium.org                                   const FieldDecl *LastFD) const;
41143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
41243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// BitfieldFollowsBitfield - return 'true" if 'FD' is a
41343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// bitfield which follows the bitfield 'LastFD'.
414dfe53073738bbf16023d96fce5118358a1037fd3ulan@chromium.org  bool BitfieldFollowsBitfield(const FieldDecl *FD,
415dfe53073738bbf16023d96fce5118358a1037fd3ulan@chromium.org                               const FieldDecl *LastFD) const;
416394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
41743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// NonBitfieldFollowsBitfield - return 'true" if 'FD' is not a
41843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// bitfield which follows the bitfield 'LastFD'.
41943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  bool NonBitfieldFollowsBitfield(const FieldDecl *FD,
4204f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org                                  const FieldDecl *LastFD) const;
42143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
42243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// BitfieldFollowsNonBitfield - return 'true" if 'FD' is a
42343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// bitfield which follows the none bitfield 'LastFD'.
42443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  bool BitfieldFollowsNonBitfield(const FieldDecl *FD,
42543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen                                  const FieldDecl *LastFD) const;
42643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
42743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  // Access to the set of methods overridden by the given C++ method.
42843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  typedef CXXMethodVector::iterator overridden_cxx_method_iterator;
429e03fb64ef23331755b7986d2560bc4c00ba3e67bfschneider@chromium.org  overridden_cxx_method_iterator
430e03fb64ef23331755b7986d2560bc4c00ba3e67bfschneider@chromium.org  overridden_methods_begin(const CXXMethodDecl *Method) const;
431e03fb64ef23331755b7986d2560bc4c00ba3e67bfschneider@chromium.org
43243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  overridden_cxx_method_iterator
43343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  overridden_methods_end(const CXXMethodDecl *Method) const;
43443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
435e03fb64ef23331755b7986d2560bc4c00ba3e67bfschneider@chromium.org  unsigned overridden_methods_size(const CXXMethodDecl *Method) const;
43643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
43743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief Note that the given C++ \p Method overrides the given \p
438b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  /// Overridden method.
4390b6db5975a9d1ebcf3de7b18603380d99f789e66sgjesse@chromium.org  void addOverriddenMethod(const CXXMethodDecl *Method,
440b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org                           const CXXMethodDecl *Overridden);
44143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
442e03fb64ef23331755b7986d2560bc4c00ba3e67bfschneider@chromium.org  TranslationUnitDecl *getTranslationUnitDecl() const { return TUDecl; }
4430b6db5975a9d1ebcf3de7b18603380d99f789e66sgjesse@chromium.org
444b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org
44543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  // Builtin Types.
44643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  CanQualType VoidTy;
44743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  CanQualType BoolTy;
44843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  CanQualType CharTy;
44943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  CanQualType WCharTy;  // [C++ 3.9.1p5], integer type in C99.
450e03fb64ef23331755b7986d2560bc4c00ba3e67bfschneider@chromium.org  CanQualType Char16Ty; // [C++0x 3.9.1p5], integer type in C99.
451e03fb64ef23331755b7986d2560bc4c00ba3e67bfschneider@chromium.org  CanQualType Char32Ty; // [C++0x 3.9.1p5], integer type in C99.
452e03fb64ef23331755b7986d2560bc4c00ba3e67bfschneider@chromium.org  CanQualType SignedCharTy, ShortTy, IntTy, LongTy, LongLongTy, Int128Ty;
45343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  CanQualType UnsignedCharTy, UnsignedShortTy, UnsignedIntTy, UnsignedLongTy;
45443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  CanQualType UnsignedLongLongTy, UnsignedInt128Ty;
45543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  CanQualType FloatTy, DoubleTy, LongDoubleTy;
456e03fb64ef23331755b7986d2560bc4c00ba3e67bfschneider@chromium.org  CanQualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy;
45743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  CanQualType VoidPtrTy, NullPtrTy;
45843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  CanQualType DependentTy, OverloadTy, BoundMemberTy, UnknownAnyTy;
45943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  CanQualType ObjCBuiltinIdTy, ObjCBuiltinClassTy, ObjCBuiltinSelTy;
460e03fb64ef23331755b7986d2560bc4c00ba3e67bfschneider@chromium.org
461b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org  // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.
46243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  mutable QualType AutoDeductTy;     // Deduction against 'auto'.
46343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  mutable QualType AutoRRefDeductTy; // Deduction against 'auto &&'.
46443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
46543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  ASTContext(const LangOptions& LOpts, SourceManager &SM, const TargetInfo &t,
466c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org             IdentifierTable &idents, SelectorTable &sels,
467c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org             Builtin::Context &builtins,
468c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org             unsigned size_reserve);
469c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org
470c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org  ~ASTContext();
471394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
472c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org  /// \brief Attach an external AST source to the AST context.
473394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  ///
474c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org  /// The external AST source provides the ability to load parts of
475394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  /// the abstract syntax tree as needed from some external storage,
476c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org  /// e.g., a precompiled header.
477394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  void setExternalSource(llvm::OwningPtr<ExternalASTSource> &Source);
478394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
479394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  /// \brief Retrieve a pointer to the external AST source associated
480c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org  /// with this AST context, if any.
481394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  ExternalASTSource *getExternalSource() const { return ExternalSource.get(); }
482394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
483394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  /// \brief Attach an AST mutation listener to the AST context.
484c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org  ///
485394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  /// The AST mutation listener provides the ability to track modifications to
486394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  /// the abstract syntax tree entities committed after they were initially
48743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// created.
488c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org  void setASTMutationListener(ASTMutationListener *Listener) {
489c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org    this->Listener = Listener;
490c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org  }
491c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org
49204e4f1e9e1291ac270e1cb7d8384b2af2fd2d685jkummerow@chromium.org  /// \brief Retrieve a pointer to the AST mutation listener associated
493c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org  /// with this AST context, if any.
494e27d617298263725e8a48c2aa14029759b952623mstarzinger@chromium.org  ASTMutationListener *getASTMutationListener() const { return Listener; }
495c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org
496c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org  void PrintStats() const;
497c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org  const std::vector<Type*>& getTypes() const { return Types; }
498b1df11df5b7bdcc201852bfcdce0a8eace33b011svenpanne@chromium.org
4995a11aaf63fdb7843c9b116fdb84ee35b0a980ea6yangguo@chromium.org  //===--------------------------------------------------------------------===//
500ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org  //                           Type Constructors
501c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org  //===--------------------------------------------------------------------===//
502471f2f1d24adb4bad1edc3bf0ee35092486de187mstarzinger@chromium.org
503ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.orgprivate:
504ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org  /// getExtQualType - Return a type with extended qualifiers.
505ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org  QualType getExtQualType(const Type *Base, Qualifiers Quals) const;
506c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org
507c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org  QualType getTypeDeclTypeSlow(const TypeDecl *Decl) const;
508c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org
50956454717593e7552d6846198b8e0f661fa36a3cayangguo@chromium.orgpublic:
51056454717593e7552d6846198b8e0f661fa36a3cayangguo@chromium.org  /// getAddSpaceQualType - Return the uniqued reference to the type for an
51156454717593e7552d6846198b8e0f661fa36a3cayangguo@chromium.org  /// address space qualified type with the specified type and address space.
512ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org  /// The resulting type has a union of the qualifiers from T and the address
513ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org  /// space. If T already has an address space specifier, it is silently
514ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org  /// replaced.
51543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  QualType getAddrSpaceQualType(QualType T, unsigned AddressSpace) const;
51643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
51743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// getObjCGCQualType - Returns the uniqued reference to the type for an
51843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// objc gc qualified type. The retulting type has a union of the qualifiers
51943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// from T and the gc attribute.
52043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const;
52143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
52243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// getRestrictType - Returns the uniqued reference to the type for a
52343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// 'restrict' qualified type.  The resulting type has a union of the
52443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// qualifiers from T and 'restrict'.
52543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  QualType getRestrictType(QualType T) const {
52643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen    return T.withFastQualifiers(Qualifiers::Restrict);
52743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  }
52843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
529a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// getVolatileType - Returns the uniqued reference to the type for a
530a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// 'volatile' qualified type.  The resulting type has a union of the
531a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  /// qualifiers from T and 'volatile'.
532a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org  QualType getVolatileType(QualType T) const {
533a74f0daeb278665869b4b6a3bc2739e88fed93b1ager@chromium.org    return T.withFastQualifiers(Qualifiers::Volatile);
53443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  }
53543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
53643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// getConstType - Returns the uniqued reference to the type for a
53743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// 'const' qualified type.  The resulting type has a union of the
538e27d617298263725e8a48c2aa14029759b952623mstarzinger@chromium.org  /// qualifiers from T and 'const'.
539a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  ///
540a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  /// It can be reasonably expected that this will always be
541e27d617298263725e8a48c2aa14029759b952623mstarzinger@chromium.org  /// equivalent to calling T.withConst().
5425a11aaf63fdb7843c9b116fdb84ee35b0a980ea6yangguo@chromium.org  QualType getConstType(QualType T) const { return T.withConst(); }
543a9aa5fa8ae2a2b43a94e6462ded2cd51445e9ee3ager@chromium.org
5441b3afd1cab9087ca3c4e585d3da77d374d65c082mstarzinger@chromium.org  /// adjustFunctionType - Change the ExtInfo on a function type.
54543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  const FunctionType *adjustFunctionType(const FunctionType *Fn,
5461e8da746019f818a22dfdc6f691dbc0447048cadjkummerow@chromium.org                                         FunctionType::ExtInfo EInfo);
547c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org
54843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// getComplexType - Return the uniqued reference to the type for a complex
549e27d617298263725e8a48c2aa14029759b952623mstarzinger@chromium.org  /// number with the specified element type.
550e27d617298263725e8a48c2aa14029759b952623mstarzinger@chromium.org  QualType getComplexType(QualType T) const;
551a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org  CanQualType getComplexType(CanQualType T) const {
552400388edd471bd4d4a97b21c52c1024cd1cc5708rossberg@chromium.org    return CanQualType::CreateUnsafe(getComplexType((QualType) T));
5535a11aaf63fdb7843c9b116fdb84ee35b0a980ea6yangguo@chromium.org  }
5545a11aaf63fdb7843c9b116fdb84ee35b0a980ea6yangguo@chromium.org
5555a11aaf63fdb7843c9b116fdb84ee35b0a980ea6yangguo@chromium.org  /// getPointerType - Return the uniqued reference to the type for a pointer to
55656454717593e7552d6846198b8e0f661fa36a3cayangguo@chromium.org  /// the specified type.
557e27d617298263725e8a48c2aa14029759b952623mstarzinger@chromium.org  QualType getPointerType(QualType T) const;
558e27d617298263725e8a48c2aa14029759b952623mstarzinger@chromium.org  CanQualType getPointerType(CanQualType T) const {
559e27d617298263725e8a48c2aa14029759b952623mstarzinger@chromium.org    return CanQualType::CreateUnsafe(getPointerType((QualType) T));
560e27d617298263725e8a48c2aa14029759b952623mstarzinger@chromium.org  }
561e27d617298263725e8a48c2aa14029759b952623mstarzinger@chromium.org
5621fd77d58ca66b2711f09cdea32c0c2d1a01b3ae5danno@chromium.org  /// getBlockPointerType - Return the uniqued reference to the type for a block
563ba72ec861b69b67139c93fc6dd56f4a73c9b3135jkummerow@chromium.org  /// of the specified type.
56443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  QualType getBlockPointerType(QualType T) const;
56543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
56643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// This gets the struct used to keep track of the descriptor for pointer to
5675a11aaf63fdb7843c9b116fdb84ee35b0a980ea6yangguo@chromium.org  /// blocks.
5684000f228dd279f96628ed845f1e81d01ba7e14d8jkummerow@chromium.org  QualType getBlockDescriptorType() const;
5694000f228dd279f96628ed845f1e81d01ba7e14d8jkummerow@chromium.org
5704000f228dd279f96628ed845f1e81d01ba7e14d8jkummerow@chromium.org  // Set the type for a Block descriptor type.
57127bf28851c1fa362a3f7c709871c21dcc9c23ce7ricow@chromium.org  void setBlockDescriptorType(QualType T);
5727979bbb1df2eaff193e85d44c8da1ffa1525b7fcfschneider@chromium.org  /// Get the BlockDescriptorType type, or NULL if it hasn't yet been built.
573dc94e19484d1700cb0ec22365444223e49a3ac1ejkummerow@chromium.org  QualType getRawBlockdescriptorType() {
574dc94e19484d1700cb0ec22365444223e49a3ac1ejkummerow@chromium.org    if (BlockDescriptorType)
575dc94e19484d1700cb0ec22365444223e49a3ac1ejkummerow@chromium.org      return getTagDeclType(BlockDescriptorType);
576dc94e19484d1700cb0ec22365444223e49a3ac1ejkummerow@chromium.org    return QualType();
5777028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  }
57843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
57943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// This gets the struct used to keep track of the extended descriptor for
580ce5e87bd905d592a8bd612b3dedf7a994177c13aager@chromium.org  /// pointer to blocks.
581304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org  QualType getBlockDescriptorExtendedType() const;
5825f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org
5835f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org  // Set the type for a Block descriptor extended type.
5845f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org  void setBlockDescriptorExtendedType(QualType T);
5855f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org  /// Get the BlockDescriptorExtendedType type, or NULL if it hasn't yet been
586154ff99473e866f5eb00a44045e27866a7fdce29yangguo@chromium.org  /// built.
5875f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org  QualType getRawBlockdescriptorExtendedType() const {
5889e3e0b618a14a05efd7d66f20bac4423dd3a1a2ffschneider@chromium.org    if (BlockDescriptorExtendedType)
5891510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org      return getTagDeclType(BlockDescriptorExtendedType);
5905f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org    return QualType();
591154ff99473e866f5eb00a44045e27866a7fdce29yangguo@chromium.org  }
5929e3e0b618a14a05efd7d66f20bac4423dd3a1a2ffschneider@chromium.org
5931510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org  void setcudaConfigureCallDecl(FunctionDecl *FD) {
5945f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org    cudaConfigureCallDecl = FD;
595304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org  }
596304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org  FunctionDecl *getcudaConfigureCallDecl() {
597dc94e19484d1700cb0ec22365444223e49a3ac1ejkummerow@chromium.org    return cudaConfigureCallDecl;
598304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org  }
599304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org
600304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org  /// This builds the struct used for __block variables.
601304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org  QualType BuildByRefType(StringRef DeclName, QualType Ty) const;
602304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org
603304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org  /// Returns true iff we need copy/dispose helpers for the given type.
604304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org  bool BlockRequiresCopying(QualType Ty) const;
605304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org
606304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org  /// getLValueReferenceType - Return the uniqued reference to the type for an
607304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org  /// lvalue reference to the specified type.
608304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org  QualType getLValueReferenceType(QualType T, bool SpelledAsLValue = true)
609304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org    const;
6105f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org
6115f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org  /// getRValueReferenceType - Return the uniqued reference to the type for an
6125f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org  /// rvalue reference to the specified type.
61327bf28851c1fa362a3f7c709871c21dcc9c23ce7ricow@chromium.org  QualType getRValueReferenceType(QualType T) const;
6141510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org
615394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  /// getMemberPointerType - Return the uniqued reference to the type for a
61643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// member pointer to the specified type in the specified class. The class
617e27d617298263725e8a48c2aa14029759b952623mstarzinger@chromium.org  /// is a Type because it could be a dependent name.
61843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  QualType getMemberPointerType(QualType T, const Type *Cls) const;
6194a9f6553038df6b893b3d3ccae351723f4cbbae7yangguo@chromium.org
62043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// getVariableArrayType - Returns a non-unique reference to the type for a
62143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// variable array of the specified element type.
62227bf28851c1fa362a3f7c709871c21dcc9c23ce7ricow@chromium.org  QualType getVariableArrayType(QualType EltTy, Expr *NumElts,
62327bf28851c1fa362a3f7c709871c21dcc9c23ce7ricow@chromium.org                                ArrayType::ArraySizeModifier ASM,
624355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org                                unsigned IndexTypeQuals,
625355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org                                SourceRange Brackets) const;
626355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org
6271e8da746019f818a22dfdc6f691dbc0447048cadjkummerow@chromium.org  /// getDependentSizedArrayType - Returns a non-unique reference to
6282c067b150f65db3e076b6b5a813e7f6f2492f770rossberg@chromium.org  /// the type for a dependently-sized array of the specified element
6292c067b150f65db3e076b6b5a813e7f6f2492f770rossberg@chromium.org  /// type. FIXME: We will need these to be uniqued, or at least
6302c067b150f65db3e076b6b5a813e7f6f2492f770rossberg@chromium.org  /// comparable, at some point.
6312c067b150f65db3e076b6b5a813e7f6f2492f770rossberg@chromium.org  QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts,
632355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org                                      ArrayType::ArraySizeModifier ASM,
633355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org                                      unsigned IndexTypeQuals,
63427bf28851c1fa362a3f7c709871c21dcc9c23ce7ricow@chromium.org                                      SourceRange Brackets) const;
635394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
636394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  /// getIncompleteArrayType - Returns a unique reference to the type for a
637355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  /// incomplete array of the specified element type.
638cddc71f18a46e6117cc765b1c53ca122e7aaa318rossberg@chromium.org  QualType getIncompleteArrayType(QualType EltTy,
639e27d617298263725e8a48c2aa14029759b952623mstarzinger@chromium.org                                  ArrayType::ArraySizeModifier ASM,
640e27d617298263725e8a48c2aa14029759b952623mstarzinger@chromium.org                                  unsigned IndexTypeQuals) const;
641e27d617298263725e8a48c2aa14029759b952623mstarzinger@chromium.org
642e27d617298263725e8a48c2aa14029759b952623mstarzinger@chromium.org  /// getConstantArrayType - Return the unique reference to the type for a
643cddc71f18a46e6117cc765b1c53ca122e7aaa318rossberg@chromium.org  /// constant array of the specified element type.
644cddc71f18a46e6117cc765b1c53ca122e7aaa318rossberg@chromium.org  QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize,
645cddc71f18a46e6117cc765b1c53ca122e7aaa318rossberg@chromium.org                                ArrayType::ArraySizeModifier ASM,
646cddc71f18a46e6117cc765b1c53ca122e7aaa318rossberg@chromium.org                                unsigned IndexTypeQuals) const;
647f705b5034dc5bc422ac1019b591469a7d0534772mstarzinger@chromium.org
648e27d617298263725e8a48c2aa14029759b952623mstarzinger@chromium.org  /// getVariableArrayDecayedType - Returns a vla type where known sizes
649f705b5034dc5bc422ac1019b591469a7d0534772mstarzinger@chromium.org  /// are replaced with [*].
6501b3afd1cab9087ca3c4e585d3da77d374d65c082mstarzinger@chromium.org  QualType getVariableArrayDecayedType(QualType Ty) const;
6517028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org
65243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// getVectorType - Return the unique reference to a vector type of
653a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  /// the specified element type and size. VectorType must be a built-in type.
65433e09c8efd078308de3c77a88301566f65c07befverwaest@chromium.org  QualType getVectorType(QualType VectorType, unsigned NumElts,
6551b3afd1cab9087ca3c4e585d3da77d374d65c082mstarzinger@chromium.org                         VectorType::VectorKind VecKind) const;
656a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org
6570ee099beef2c2b38743d657b84a30b626d9178ecager@chromium.org  /// getExtVectorType - Return the unique reference to an extended vector type
6581805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org  /// of the specified element type and size.  VectorType must be a built-in
6591b3afd1cab9087ca3c4e585d3da77d374d65c082mstarzinger@chromium.org  /// type.
6602c067b150f65db3e076b6b5a813e7f6f2492f770rossberg@chromium.org  QualType getExtVectorType(QualType VectorType, unsigned NumElts) const;
6611805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org
6621805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org  /// getDependentSizedExtVectorType - Returns a non-unique reference to
6639faefa4670e0c454c6e56bb87b4410d73828e84fsvenpanne@chromium.org  /// the type for a dependently-sized vector of the specified element
6649faefa4670e0c454c6e56bb87b4410d73828e84fsvenpanne@chromium.org  /// type. FIXME: We will need these to be uniqued, or at least
6659faefa4670e0c454c6e56bb87b4410d73828e84fsvenpanne@chromium.org  /// comparable, at some point.
6669faefa4670e0c454c6e56bb87b4410d73828e84fsvenpanne@chromium.org  QualType getDependentSizedExtVectorType(QualType VectorType,
6679faefa4670e0c454c6e56bb87b4410d73828e84fsvenpanne@chromium.org                                          Expr *SizeExpr,
668f005df6c3232e65028420519fbab7284bc9b33aedanno@chromium.org                                          SourceLocation AttrLoc) const;
6699faefa4670e0c454c6e56bb87b4410d73828e84fsvenpanne@chromium.org
6709faefa4670e0c454c6e56bb87b4410d73828e84fsvenpanne@chromium.org  /// getFunctionNoProtoType - Return a K&R style C function type like 'int()'.
6719faefa4670e0c454c6e56bb87b4410d73828e84fsvenpanne@chromium.org  ///
6729faefa4670e0c454c6e56bb87b4410d73828e84fsvenpanne@chromium.org  QualType getFunctionNoProtoType(QualType ResultTy,
67343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen                                  const FunctionType::ExtInfo &Info) const;
674b1df11df5b7bdcc201852bfcdce0a8eace33b011svenpanne@chromium.org
675911335cff40a2630bbe1dfb77b1897be991241bfsgjesse@chromium.org  QualType getFunctionNoProtoType(QualType ResultTy) const {
676911335cff40a2630bbe1dfb77b1897be991241bfsgjesse@chromium.org    return getFunctionNoProtoType(ResultTy, FunctionType::ExtInfo());
677fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  }
678c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org
679c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org  /// getFunctionType - Return a normal function type with a typed
68004e4f1e9e1291ac270e1cb7d8384b2af2fd2d685jkummerow@chromium.org  /// argument list.
681911335cff40a2630bbe1dfb77b1897be991241bfsgjesse@chromium.org  QualType getFunctionType(QualType ResultTy,
68256454717593e7552d6846198b8e0f661fa36a3cayangguo@chromium.org                           const QualType *Args, unsigned NumArgs,
6837c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.org                           const FunctionProtoType::ExtProtoInfo &EPI) const;
684471f2f1d24adb4bad1edc3bf0ee35092486de187mstarzinger@chromium.org
685f705b5034dc5bc422ac1019b591469a7d0534772mstarzinger@chromium.org  /// getTypeDeclType - Return the unique reference to the type for
686a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  /// the specified type declaration.
687a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  QualType getTypeDeclType(const TypeDecl *Decl,
688b1df11df5b7bdcc201852bfcdce0a8eace33b011svenpanne@chromium.org                           const TypeDecl *PrevDecl = 0) const {
6892c9426bdda5e95459527292063d885c98180cb0fjkummerow@chromium.org    assert(Decl && "Passed null for Decl param");
6902c9426bdda5e95459527292063d885c98180cb0fjkummerow@chromium.org    if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0);
691a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org
692ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org    if (PrevDecl) {
69343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen      assert(PrevDecl->TypeForDecl && "previous decl has no TypeForDecl");
69443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen      Decl->TypeForDecl = PrevDecl->TypeForDecl;
69543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen      return QualType(PrevDecl->TypeForDecl, 0);
69643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen    }
69743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
69843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen    return getTypeDeclTypeSlow(Decl);
69943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  }
70043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
70143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// getTypedefType - Return the unique reference to the type for the
702f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// specified typedef-name decl.
7035a11aaf63fdb7843c9b116fdb84ee35b0a980ea6yangguo@chromium.org  QualType getTypedefType(const TypedefNameDecl *Decl,
704dc94e19484d1700cb0ec22365444223e49a3ac1ejkummerow@chromium.org                          QualType Canon = QualType()) const;
705f05f2913e034b9332e55c02c9395e701725c02c1kmillikin@chromium.org
7067979bbb1df2eaff193e85d44c8da1ffa1525b7fcfschneider@chromium.org  QualType getRecordType(const RecordDecl *Decl) const;
707dc94e19484d1700cb0ec22365444223e49a3ac1ejkummerow@chromium.org
708dc94e19484d1700cb0ec22365444223e49a3ac1ejkummerow@chromium.org  QualType getEnumType(const EnumDecl *Decl) const;
709dc94e19484d1700cb0ec22365444223e49a3ac1ejkummerow@chromium.org
710dc94e19484d1700cb0ec22365444223e49a3ac1ejkummerow@chromium.org  QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const;
7115a11aaf63fdb7843c9b116fdb84ee35b0a980ea6yangguo@chromium.org
712304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org  QualType getAttributedType(AttributedType::Kind attrKind,
7135f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org                             QualType modifiedType,
7145f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org                             QualType equivalentType);
715304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org
7165f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org  QualType getSubstTemplateTypeParmType(const TemplateTypeParmType *Replaced,
717154ff99473e866f5eb00a44045e27866a7fdce29yangguo@chromium.org                                        QualType Replacement) const;
7185f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org  QualType getSubstTemplateTypeParmPackType(
7194d3fe4e246b0312eba361689f288ddf8dd516960danno@chromium.org                                          const TemplateTypeParmType *Replaced,
7204d3fe4e246b0312eba361689f288ddf8dd516960danno@chromium.org                                            const TemplateArgument &ArgPack);
7211510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org
7225f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org  QualType getTemplateTypeParmType(unsigned Depth, unsigned Index,
723154ff99473e866f5eb00a44045e27866a7fdce29yangguo@chromium.org                                   bool ParameterPack,
724154ff99473e866f5eb00a44045e27866a7fdce29yangguo@chromium.org                                   TemplateTypeParmDecl *ParmDecl = 0) const;
725154ff99473e866f5eb00a44045e27866a7fdce29yangguo@chromium.org
7261510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org  QualType getTemplateSpecializationType(TemplateName T,
7275f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org                                         const TemplateArgument *Args,
728304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org                                         unsigned NumArgs,
729304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org                                         QualType Canon = QualType()) const;
730dc94e19484d1700cb0ec22365444223e49a3ac1ejkummerow@chromium.org
731de64f721c489207a7b9018406d39c7fb04bb9424verwaest@chromium.org  QualType getCanonicalTemplateSpecializationType(TemplateName T,
732304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org                                                  const TemplateArgument *Args,
733304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org                                                  unsigned NumArgs) const;
734304cc33f8259ef467e8e3c79f448d0bae0e8cd85yangguo@chromium.org
7355f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org  QualType getTemplateSpecializationType(TemplateName T,
7365f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org                                         const TemplateArgumentListInfo &Args,
7375f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org                                         QualType Canon = QualType()) const;
7381510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org
7395a11aaf63fdb7843c9b116fdb84ee35b0a980ea6yangguo@chromium.org  TypeSourceInfo *
7409e3e0b618a14a05efd7d66f20bac4423dd3a1a2ffschneider@chromium.org  getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc,
741394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com                                    const TemplateArgumentListInfo &Args,
7425f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org                                    QualType Canon = QualType()) const;
7435f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org
7444d3fe4e246b0312eba361689f288ddf8dd516960danno@chromium.org  QualType getParenType(QualType NamedType) const;
7457028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org
74665fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org  QualType getElaboratedType(ElaboratedTypeKeyword Keyword,
74765fae84840520e9ce49a78bf542abf073b49ac3fricow@chromium.org                             NestedNameSpecifier *NNS,
748471f2f1d24adb4bad1edc3bf0ee35092486de187mstarzinger@chromium.org                             QualType NamedType) const;
74943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  QualType getDependentNameType(ElaboratedTypeKeyword Keyword,
75043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen                                NestedNameSpecifier *NNS,
75143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen                                const IdentifierInfo *Name,
75243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen                                QualType Canon = QualType()) const;
75343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
75443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword,
755394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com                                                  NestedNameSpecifier *NNS,
7565a11aaf63fdb7843c9b116fdb84ee35b0a980ea6yangguo@chromium.org                                                  const IdentifierInfo *Name,
7575a11aaf63fdb7843c9b116fdb84ee35b0a980ea6yangguo@chromium.org                                    const TemplateArgumentListInfo &Args) const;
7585a11aaf63fdb7843c9b116fdb84ee35b0a980ea6yangguo@chromium.org  QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword,
7597028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org                                                  NestedNameSpecifier *NNS,
7604d3fe4e246b0312eba361689f288ddf8dd516960danno@chromium.org                                                  const IdentifierInfo *Name,
7611e8da746019f818a22dfdc6f691dbc0447048cadjkummerow@chromium.org                                                  unsigned NumArgs,
762e27d617298263725e8a48c2aa14029759b952623mstarzinger@chromium.org                                            const TemplateArgument *Args) const;
7635a11aaf63fdb7843c9b116fdb84ee35b0a980ea6yangguo@chromium.org
7641b3afd1cab9087ca3c4e585d3da77d374d65c082mstarzinger@chromium.org  QualType getPackExpansionType(QualType Pattern,
7655a11aaf63fdb7843c9b116fdb84ee35b0a980ea6yangguo@chromium.org                                llvm::Optional<unsigned> NumExpansions);
7665a11aaf63fdb7843c9b116fdb84ee35b0a980ea6yangguo@chromium.org
7671b3afd1cab9087ca3c4e585d3da77d374d65c082mstarzinger@chromium.org  QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl) const;
768dfe53073738bbf16023d96fce5118358a1037fd3ulan@chromium.org
7697c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.org  QualType getObjCObjectType(QualType Base,
7707c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.org                             ObjCProtocolDecl * const *Protocols,
7717c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.org                             unsigned NumProtocols) const;
7727c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.org
77343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// getObjCObjectPointerType - Return a ObjCObjectPointerType type
77483aa54905e559090bea7771b83f188762cfcf082ricow@chromium.org  /// for the given ObjCObjectType.
7757c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.org  QualType getObjCObjectPointerType(QualType OIT) const;
776f705b5034dc5bc422ac1019b591469a7d0534772mstarzinger@chromium.org
7777c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.org  /// getTypeOfType - GCC extension.
778dfe53073738bbf16023d96fce5118358a1037fd3ulan@chromium.org  QualType getTypeOfExprType(Expr *e) const;
7797c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.org  QualType getTypeOfType(QualType t) const;
78043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
78143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// getDecltypeType - C++0x decltype.
78243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  QualType getDecltypeType(Expr *e) const;
78343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
78443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// getUnaryTransformType - unary type transforms
78543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType,
78643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen                                 UnaryTransformType::UTTKind UKind) const;
78743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
788a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  /// getAutoType - C++0x deduced auto type.
789a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org  QualType getAutoType(QualType DeducedType) const;
7904d3fe4e246b0312eba361689f288ddf8dd516960danno@chromium.org
791a55512615f5adc085d23bc8589d155c4b579fb7bkasperl@chromium.org  /// getAutoDeductType - C++0x deduction pattern for 'auto' type.
79243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  QualType getAutoDeductType() const;
79343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
79443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// getAutoRRefDeductType - C++0x deduction pattern for 'auto &&' type.
79543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  QualType getAutoRRefDeductType() const;
796f05f2913e034b9332e55c02c9395e701725c02c1kmillikin@chromium.org
797bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  /// getTagDeclType - Return the unique reference to the type for the
798d88afa260e45de10e729b05a20146184a488aff7erik.corry@gmail.com  /// specified TagDecl (struct/union/class/enum) decl.
799e27d617298263725e8a48c2aa14029759b952623mstarzinger@chromium.org  QualType getTagDeclType(const TagDecl *Decl) const;
800e27d617298263725e8a48c2aa14029759b952623mstarzinger@chromium.org
8015b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  /// getSizeType - Return the unique type for "size_t" (C99 7.17), defined
8029e3e0b618a14a05efd7d66f20bac4423dd3a1a2ffschneider@chromium.org  /// in <stddef.h>. The sizeof operator requires this (C99 6.5.3.4p4).
8035b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  CanQualType getSizeType() const;
8045b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org
8055b2fbee8f0b54371d42843c8fd90249a24093678ager@chromium.org  /// getWCharType - In C++, this returns the unique wchar_t type.  In C99, this
806dfe53073738bbf16023d96fce5118358a1037fd3ulan@chromium.org  /// returns a type compatible with the type defined in <stddef.h> as defined
8075f0c45f2cacb31d36a8f80c31f17bda7751a3644ager@chromium.org  /// by the target.
808dfe53073738bbf16023d96fce5118358a1037fd3ulan@chromium.org  QualType getWCharType() const { return WCharTy; }
809fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org
810fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  /// getSignedWCharType - Return the type of "signed wchar_t".
811fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  /// Used when in C++, as a GCC extension.
812dfe53073738bbf16023d96fce5118358a1037fd3ulan@chromium.org  QualType getSignedWCharType() const;
813bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
814dfe53073738bbf16023d96fce5118358a1037fd3ulan@chromium.org  /// getUnsignedWCharType - Return the type of "unsigned wchar_t".
815bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// Used when in C++, as a GCC extension.
816bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  QualType getUnsignedWCharType() const;
817bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
818fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  /// getPointerDiffType - Return the unique type for "ptrdiff_t" (ref?)
819dfe53073738bbf16023d96fce5118358a1037fd3ulan@chromium.org  /// defined in <stddef.h>. Pointer - pointer requires this (C99 6.5.6p9).
820fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  QualType getPointerDiffType() const;
82143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
822c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org  // getCFConstantStringType - Return the C structure type used to represent
823c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org  // constant CFStrings.
824ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org  QualType getCFConstantStringType() const;
825ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org
82643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  // getNSConstantStringType - Return the C structure type used to represent
827ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org  // constant NSStrings.
8288f806e8b8f108ca2c8899c5d31861ef1273dcd4akarlklose@chromium.org  QualType getNSConstantStringType() const;
82943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// Get the structure type used to representation NSStrings, or NULL
830ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org  /// if it hasn't yet been built.
831dfe53073738bbf16023d96fce5118358a1037fd3ulan@chromium.org  QualType getRawNSConstantStringType() const {
832ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org    if (NSConstantStringTypeDecl)
83343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen      return getTagDeclType(NSConstantStringTypeDecl);
83443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen    return QualType();
83543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  }
836c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org  void setNSConstantStringType(QualType T);
837dfe53073738bbf16023d96fce5118358a1037fd3ulan@chromium.org
838c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org
839c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org  /// Get the structure type used to representation CFStrings, or NULL
840c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org  /// if it hasn't yet been built.
841c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org  QualType getRawCFConstantStringType() const {
842ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org    if (CFConstantStringTypeDecl)
843ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org      return getTagDeclType(CFConstantStringTypeDecl);
844c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org    return QualType();
8458f806e8b8f108ca2c8899c5d31861ef1273dcd4akarlklose@chromium.org  }
846c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org  void setCFConstantStringType(QualType T);
847ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org
848dfe53073738bbf16023d96fce5118358a1037fd3ulan@chromium.org  // This setter/getter represents the ObjC type for an NSConstantString.
849ea88ce93dcb41a9200ec8747ae7642a5db1f4ce7sgjesse@chromium.org  void setObjCConstantStringInterface(ObjCInterfaceDecl *Decl);
850c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org  QualType getObjCConstantStringInterface() const {
851c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org    return ObjCConstantStringType;
852c6c5718277d4047fad1e034396228ce15571b5a4sgjesse@chromium.org  }
853fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org
85443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  //// This gets the struct used to keep track of fast enumerations.
8552c067b150f65db3e076b6b5a813e7f6f2492f770rossberg@chromium.org  QualType getObjCFastEnumerationStateType() const;
85633e09c8efd078308de3c77a88301566f65c07befverwaest@chromium.org
85743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// Get the ObjCFastEnumerationState type, or NULL if it hasn't yet
85843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// been built.
859f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  QualType getRawObjCFastEnumerationStateType() const {
86043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen    if (ObjCFastEnumerationStateTypeDecl)
86143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen      return getTagDeclType(ObjCFastEnumerationStateTypeDecl);
86243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen    return QualType();
86343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  }
86443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
865e03fb64ef23331755b7986d2560bc4c00ba3e67bfschneider@chromium.org  void setObjCFastEnumerationStateType(QualType T);
86643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
86743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief Set the type for the C FILE type.
8680a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org  void setFILEDecl(TypeDecl *FILEDecl) { this->FILEDecl = FILEDecl; }
8690a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org
87043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief Retrieve the C FILE type.
8710a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org  QualType getFILEType() const {
8720a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org    if (FILEDecl)
8730a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org      return getTypeDeclType(FILEDecl);
8740a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org    return QualType();
8750a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org  }
87633e09c8efd078308de3c77a88301566f65c07befverwaest@chromium.org
87733e09c8efd078308de3c77a88301566f65c07befverwaest@chromium.org  /// \brief Set the type for the C jmp_buf type.
87833e09c8efd078308de3c77a88301566f65c07befverwaest@chromium.org  void setjmp_bufDecl(TypeDecl *jmp_bufDecl) {
87933e09c8efd078308de3c77a88301566f65c07befverwaest@chromium.org    this->jmp_bufDecl = jmp_bufDecl;
88033e09c8efd078308de3c77a88301566f65c07befverwaest@chromium.org  }
88133e09c8efd078308de3c77a88301566f65c07befverwaest@chromium.org
8820a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org  /// \brief Retrieve the C jmp_buf type.
8830a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org  QualType getjmp_bufType() const {
8840a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org    if (jmp_bufDecl)
8850a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org      return getTypeDeclType(jmp_bufDecl);
8860a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org    return QualType();
8870a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org  }
8880a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org
889f2038fb01417bcf7698b87a5dfaa4a861539618aerik.corry@gmail.com  /// \brief Set the type for the C sigjmp_buf type.
890f2038fb01417bcf7698b87a5dfaa4a861539618aerik.corry@gmail.com  void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl) {
8910a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org    this->sigjmp_bufDecl = sigjmp_bufDecl;
8920a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org  }
8930a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org
8941510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org  /// \brief Retrieve the C sigjmp_buf type.
8951510d58cbcf57c82a10e7d390bfe21a7ae68ba43mstarzinger@chromium.org  QualType getsigjmp_bufType() const {
8960a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org    if (sigjmp_bufDecl)
8970a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org      return getTypeDeclType(sigjmp_bufDecl);
8981b3afd1cab9087ca3c4e585d3da77d374d65c082mstarzinger@chromium.org    return QualType();
8994a9f6553038df6b893b3d3ccae351723f4cbbae7yangguo@chromium.org  }
9000a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org
9014a9f6553038df6b893b3d3ccae351723f4cbbae7yangguo@chromium.org  /// \brief The result type of logical operations, '<', '>', '!=', etc.
9022c067b150f65db3e076b6b5a813e7f6f2492f770rossberg@chromium.org  QualType getLogicalOperationType() const {
9032c067b150f65db3e076b6b5a813e7f6f2492f770rossberg@chromium.org    return getLangOptions().CPlusPlus ? BoolTy : IntTy;
9042c067b150f65db3e076b6b5a813e7f6f2492f770rossberg@chromium.org  }
9052c067b150f65db3e076b6b5a813e7f6f2492f770rossberg@chromium.org
906cddc71f18a46e6117cc765b1c53ca122e7aaa318rossberg@chromium.org  /// getObjCEncodingForType - Emit the ObjC type encoding for the
9072c067b150f65db3e076b6b5a813e7f6f2492f770rossberg@chromium.org  /// given type into \arg S. If \arg NameFields is specified then
9082c067b150f65db3e076b6b5a813e7f6f2492f770rossberg@chromium.org  /// record field names are also encoded.
9092c067b150f65db3e076b6b5a813e7f6f2492f770rossberg@chromium.org  void getObjCEncodingForType(QualType t, std::string &S,
9102c067b150f65db3e076b6b5a813e7f6f2492f770rossberg@chromium.org                              const FieldDecl *Field=0) const;
9112c067b150f65db3e076b6b5a813e7f6f2492f770rossberg@chromium.org
9122c067b150f65db3e076b6b5a813e7f6f2492f770rossberg@chromium.org  void getLegacyIntegralTypeEncoding(QualType &t) const;
913cddc71f18a46e6117cc765b1c53ca122e7aaa318rossberg@chromium.org
9142c067b150f65db3e076b6b5a813e7f6f2492f770rossberg@chromium.org  // Put the string version of type qualifiers into S.
9151b3afd1cab9087ca3c4e585d3da77d374d65c082mstarzinger@chromium.org  void getObjCEncodingForTypeQualifier(Decl::ObjCDeclQualifier QT,
916e27d617298263725e8a48c2aa14029759b952623mstarzinger@chromium.org                                       std::string &S) const;
9171b3afd1cab9087ca3c4e585d3da77d374d65c082mstarzinger@chromium.org
9180a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org  /// getObjCEncodingForFunctionDecl - Returns the encoded type for this
9190a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org  /// function.  This is in the same format as Objective-C method encodings.
9200a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org  ///
9210a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org  /// \returns true if an error occurred (e.g., because one of the parameter
9220a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org  /// types is incomplete), false otherwise.
9230a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org  bool getObjCEncodingForFunctionDecl(const FunctionDecl *Decl, std::string& S);
9240a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org
9250a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org  /// getObjCEncodingForMethodDecl - Return the encoded type for this method
9260a4e901cdfb5505a896d30aa8c2e04fce0fbe069vegorov@chromium.org  /// declaration.
9277028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  ///
92843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \returns true if an error occurred (e.g., because one of the parameter
929911335cff40a2630bbe1dfb77b1897be991241bfsgjesse@chromium.org  /// types is incomplete), false otherwise.
93043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  bool getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl, std::string &S)
93143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen    const;
93243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
93343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// getObjCEncodingForBlock - Return the encoded type for this block
934f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// declaration.
935f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  std::string getObjCEncodingForBlock(const BlockExpr *blockExpr) const;
936f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
937f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// getObjCEncodingForPropertyDecl - Return the encoded type for
938f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// this method declaration. If non-NULL, Container must be either
939f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// an ObjCCategoryImplDecl or ObjCImplementationDecl; it should
940f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// only be NULL when getting encodings for protocol properties.
941f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  void getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD,
942f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org                                      const Decl *Container,
943f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org                                      std::string &S) const;
944f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
945f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  bool ProtocolCompatibleWithProtocol(ObjCProtocolDecl *lProto,
946f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org                                      ObjCProtocolDecl *rProto) const;
947f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
948f705b5034dc5bc422ac1019b591469a7d0534772mstarzinger@chromium.org  /// getObjCEncodingTypeSize returns size of type for objective-c encoding
949f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// purpose in characters.
950f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  CharUnits getObjCEncodingTypeSize(QualType t) const;
951f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
952812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// \brief Whether __[u]int128_t identifier is installed.
953f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  bool isInt128Installed() const { return IsInt128Installed; }
954f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  void setInt128Installed() { IsInt128Installed = true; }
955812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org
956f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// This setter/getter represents the ObjC 'id' type. It is setup lazily, by
957f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// Sema.  id is always a (typedef for a) pointer type, a pointer to a struct.
958f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  QualType getObjCIdType() const { return ObjCIdTypedefType; }
959f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  void setObjCIdType(QualType T);
960a7d3df915ae6a29cd392dba32a26049d7b9b008fyangguo@chromium.org
961a7d3df915ae6a29cd392dba32a26049d7b9b008fyangguo@chromium.org  void setObjCSelType(QualType T);
962a7d3df915ae6a29cd392dba32a26049d7b9b008fyangguo@chromium.org  QualType getObjCSelType() const { return ObjCSelTypedefType; }
963a7d3df915ae6a29cd392dba32a26049d7b9b008fyangguo@chromium.org
964a7d3df915ae6a29cd392dba32a26049d7b9b008fyangguo@chromium.org  void setObjCProtoType(QualType QT);
965a7d3df915ae6a29cd392dba32a26049d7b9b008fyangguo@chromium.org  QualType getObjCProtoType() const { return ObjCProtoType; }
966a7d3df915ae6a29cd392dba32a26049d7b9b008fyangguo@chromium.org
967a7d3df915ae6a29cd392dba32a26049d7b9b008fyangguo@chromium.org  /// This setter/getter repreents the ObjC 'Class' type. It is setup lazily, by
968a7d3df915ae6a29cd392dba32a26049d7b9b008fyangguo@chromium.org  /// Sema.  'Class' is always a (typedef for a) pointer type, a pointer to a
969a7d3df915ae6a29cd392dba32a26049d7b9b008fyangguo@chromium.org  /// struct.
970a7d3df915ae6a29cd392dba32a26049d7b9b008fyangguo@chromium.org  QualType getObjCClassType() const { return ObjCClassTypedefType; }
9714a9f6553038df6b893b3d3ccae351723f4cbbae7yangguo@chromium.org  void setObjCClassType(QualType T);
972a7d3df915ae6a29cd392dba32a26049d7b9b008fyangguo@chromium.org
973812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  void setBuiltinVaListType(QualType T);
974a7d3df915ae6a29cd392dba32a26049d7b9b008fyangguo@chromium.org  QualType getBuiltinVaListType() const { return BuiltinVaListType; }
975a7d3df915ae6a29cd392dba32a26049d7b9b008fyangguo@chromium.org
976a7d3df915ae6a29cd392dba32a26049d7b9b008fyangguo@chromium.org  /// getCVRQualifiedType - Returns a type with additional const,
977a7d3df915ae6a29cd392dba32a26049d7b9b008fyangguo@chromium.org  /// volatile, or restrict qualifiers.
978f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  QualType getCVRQualifiedType(QualType T, unsigned CVR) const {
979f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org    return getQualifiedType(T, Qualifiers::fromCVRMask(CVR));
980f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  }
981f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
98281cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org  /// getQualifiedType - Returns a type with additional qualifiers.
983f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  QualType getQualifiedType(QualType T, Qualifiers Qs) const {
984f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org    if (!Qs.hasNonFastQualifiers())
985f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org      return T.withFastQualifiers(Qs.getFastQualifiers());
986a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org    QualifierCollector Qc(Qs);
987f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org    const Type *Ptr = Qc.strip(T);
988bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com    return getExtQualType(Ptr, Qc);
989bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  }
990bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
991bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// getQualifiedType - Returns a type with additional qualifiers.
992bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  QualType getQualifiedType(const Type *T, Qualifiers Qs) const {
993bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com    if (!Qs.hasNonFastQualifiers())
994812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org      return QualType(T, Qs.getFastQualifiers());
9958e8d8825f97138de12985f8e0d3163074dff5258ulan@chromium.org    return getExtQualType(T, Qs);
996812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  }
997a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org
998812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// getLifetimeQualifiedType - Returns a type with the given
999812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// lifetime qualifier.
1000bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  QualType getLifetimeQualifiedType(QualType type,
1001bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com                                    Qualifiers::ObjCLifetime lifetime) {
1002bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com    assert(type.getObjCLifetime() == Qualifiers::OCL_None);
1003bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com    assert(lifetime != Qualifiers::OCL_None);
1004bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
1005bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com    Qualifiers qs;
1006bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com    qs.addObjCLifetime(lifetime);
1007bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com    return getQualifiedType(type, qs);
1008bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  }
1009bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
10107028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  DeclarationNameInfo getNameForTemplate(TemplateName Name,
101181cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org                                         SourceLocation NameLoc) const;
1012a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org
101381cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org  TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin,
1014a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org                                         UnresolvedSetIterator End) const;
1015f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
1016f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS,
1017f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org                                        bool TemplateKeyword,
1018f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org                                        TemplateDecl *Template) const;
1019f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
1020f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  TemplateName getDependentTemplateName(NestedNameSpecifier *NNS,
1021812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org                                        const IdentifierInfo *Name) const;
1022812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  TemplateName getDependentTemplateName(NestedNameSpecifier *NNS,
1023f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org                                        OverloadedOperatorKind Operator) const;
1024f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  TemplateName getSubstTemplateTemplateParm(TemplateTemplateParmDecl *param,
1025f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org                                            TemplateName replacement) const;
1026f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  TemplateName getSubstTemplateTemplateParmPack(TemplateTemplateParmDecl *Param,
1027f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org                                        const TemplateArgument &ArgPack) const;
1028812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org
1029f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  enum GetBuiltinTypeError {
1030812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org    GE_None,              //< No error
1031812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org    GE_Missing_stdio,     //< Missing a type from <stdio.h>
1032812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org    GE_Missing_setjmp     //< Missing a type from <setjmp.h>
1033812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  };
1034f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
1035812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// GetBuiltinType - Return the type for the specified builtin.  If
10361fd77d58ca66b2711f09cdea32c0c2d1a01b3ae5danno@chromium.org  /// IntegerConstantArgs is non-null, it is filled in with a bitmask of
1037812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// arguments to the builtin that are required to be integer constant
1038812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// expressions.
1039812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error,
1040812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org                          unsigned *IntegerConstantArgs = 0) const;
1041f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
1042f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.orgprivate:
1043f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  CanQualType getFromTargetType(unsigned Type) const;
1044f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
1045f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  //===--------------------------------------------------------------------===//
1046f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  //                         Type Predicates.
1047f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  //===--------------------------------------------------------------------===//
1048f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
1049a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.orgpublic:
1050f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// getObjCGCAttr - Returns one of GCNone, Weak or Strong objc's
1051a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  /// garbage collection attribute.
1052bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  ///
1053bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  Qualifiers::GC getObjCGCAttrKind(QualType Ty) const;
1054bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
1055f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// areCompatibleVectorTypes - Return true if the given vector types
1056f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// are of the same unqualified type or if they are equivalent to the same
1057f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// GCC vector type, ignoring whether they are target-specific (AltiVec or
1058f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// Neon) types.
1059f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec);
1060f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
1061f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// isObjCNSObjectType - Return true if this is an NSObject object with
1062f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// its NSObject attribute set.
10637028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  static bool isObjCNSObjectType(QualType Ty) {
1064f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org    return Ty->isObjCNSObjectType();
1065f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  }
1066f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
1067f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  //===--------------------------------------------------------------------===//
1068f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  //                         Type Sizing and Analysis
1069f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  //===--------------------------------------------------------------------===//
1070400388edd471bd4d4a97b21c52c1024cd1cc5708rossberg@chromium.org
1071f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// getFloatTypeSemantics - Return the APFloat 'semantics' for the specified
1072f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// scalar floating point type.
1073f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  const llvm::fltSemantics &getFloatTypeSemantics(QualType T) const;
1074f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
1075f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// getTypeInfo - Get the size and alignment of the specified complete type in
1076f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// bits.
1077ed49e965b5cafa35395084dbfb79f4e07930f10ferik.corry@gmail.com  std::pair<uint64_t, unsigned> getTypeInfo(const Type *T) const;
1078bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  std::pair<uint64_t, unsigned> getTypeInfo(QualType T) const {
107981cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org    return getTypeInfo(T.getTypePtr());
1080ed49e965b5cafa35395084dbfb79f4e07930f10ferik.corry@gmail.com  }
108181cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org
108281cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org  /// getTypeSize - Return the size of the specified type, in bits.  This method
108381cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org  /// does not work on incomplete types.
108481cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org  uint64_t getTypeSize(QualType T) const {
108581cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org    return getTypeInfo(T).first;
108681cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org  }
108781cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org  uint64_t getTypeSize(const Type *T) const {
108881cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org    return getTypeInfo(T).first;
108981cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org  }
109081cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org
109181cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org  /// getCharWidth - Return the size of the character type, in bits
1092ed49e965b5cafa35395084dbfb79f4e07930f10ferik.corry@gmail.com  uint64_t getCharWidth() const {
109381cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org    return getTypeSize(CharTy);
1094ed49e965b5cafa35395084dbfb79f4e07930f10ferik.corry@gmail.com  }
109581cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org
1096a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  /// toCharUnitsFromBits - Convert a size in bits to a size in characters.
1097f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  CharUnits toCharUnitsFromBits(int64_t BitSize) const;
1098f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
1099f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// toBits - Convert a size in characters to a size in bits.
1100f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  int64_t toBits(CharUnits CharSize) const;
1101f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
1102f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// getTypeSizeInChars - Return the size of the specified type, in characters.
1103f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// This method does not work on incomplete types.
1104f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  CharUnits getTypeSizeInChars(QualType T) const;
1105a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  CharUnits getTypeSizeInChars(const Type *T) const;
1106f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
1107f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// getTypeAlign - Return the ABI-specified alignment of a type, in bits.
1108f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// This method does not work on incomplete types.
1109bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  unsigned getTypeAlign(QualType T) const {
1110bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com    return getTypeInfo(T).second;
1111bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  }
1112bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  unsigned getTypeAlign(const Type *T) const {
1113a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org    return getTypeInfo(T).second;
11147028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  }
1115bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
1116bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// getTypeAlignInChars - Return the ABI-specified alignment of a type, in
1117bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// characters. This method does not work on incomplete types.
1118bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  CharUnits getTypeAlignInChars(QualType T) const;
1119bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  CharUnits getTypeAlignInChars(const Type *T) const;
1120bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
1121bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  std::pair<CharUnits, CharUnits> getTypeInfoInChars(const Type *T) const;
1122bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  std::pair<CharUnits, CharUnits> getTypeInfoInChars(QualType T) const;
1123bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
1124bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// getPreferredTypeAlign - Return the "preferred" alignment of the specified
1125bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// type for the current target in bits.  This can be different than the ABI
1126bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// alignment in cases where it is beneficial for performance to overalign
1127bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// a data type.
1128bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  unsigned getPreferredTypeAlign(const Type *T) const;
1129f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
1130f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// getDeclAlign - Return a conservative estimate of the alignment of
1131f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// the specified decl.  Note that bitfields do not have a valid alignment, so
1132f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// this method will assert on them.
1133f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// If @p RefAsPointee, references are treated like their underlying type
1134f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// (for alignof), else they're treated like pointers (for CodeGen).
1135f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  CharUnits getDeclAlign(const Decl *D, bool RefAsPointee = false) const;
1136f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
1137f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// getASTRecordLayout - Get or compute information about the layout of the
1138f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// specified record (struct/union/class), which indicates its size and field
1139a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  /// position information.
1140f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  const ASTRecordLayout &getASTRecordLayout(const RecordDecl *D) const;
1141bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
1142bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// getASTObjCInterfaceLayout - Get or compute information about the
1143bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// layout of the specified Objective-C interface.
1144bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  const ASTRecordLayout &getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D)
1145f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org    const;
114628583c92ca8f528df625800519088ac88996d504jkummerow@chromium.org
114728583c92ca8f528df625800519088ac88996d504jkummerow@chromium.org  void DumpRecordLayout(const RecordDecl *RD, raw_ostream &OS) const;
1148bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
1149a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  /// getASTObjCImplementationLayout - Get or compute information about
1150f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// the layout of the specified Objective-C implementation. This may
1151f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// differ from the interface if synthesized ivars are present.
1152f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  const ASTRecordLayout &
1153f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  getASTObjCImplementationLayout(const ObjCImplementationDecl *D) const;
1154f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
1155812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// getKeyFunction - Get the key function for the given record decl, or NULL
1156f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// if there isn't one.  The key function is, according to the Itanium C++ ABI
1157a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  /// section 5.2.3:
1158f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  ///
1159bf9432e3965b385e2e8df3701b710c105f5b3eb7ulan@chromium.org  /// ...the first non-pure virtual function that is not inline at the point
1160f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// of class definition.
1161bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  const CXXMethodDecl *getKeyFunction(const CXXRecordDecl *RD);
1162bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
1163bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  bool isNearlyEmpty(const CXXRecordDecl *RD) const;
1164bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
1165bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  MangleContext *createMangleContext();
1166ed49e965b5cafa35395084dbfb79f4e07930f10ferik.corry@gmail.com
11678e8d8825f97138de12985f8e0d3163074dff5258ulan@chromium.org  void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass,
11688e8d8825f97138de12985f8e0d3163074dff5258ulan@chromium.org                            SmallVectorImpl<const ObjCIvarDecl*> &Ivars) const;
11698e8d8825f97138de12985f8e0d3163074dff5258ulan@chromium.org
1170a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  unsigned CountNonClassIvars(const ObjCInterfaceDecl *OI) const;
11718e8d8825f97138de12985f8e0d3163074dff5258ulan@chromium.org  void CollectInheritedProtocols(const Decl *CDecl,
11728e8d8825f97138de12985f8e0d3163074dff5258ulan@chromium.org                          llvm::SmallPtrSet<ObjCProtocolDecl*, 8> &Protocols);
1173a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org
1174ed49e965b5cafa35395084dbfb79f4e07930f10ferik.corry@gmail.com  //===--------------------------------------------------------------------===//
117581cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org  //                            Type Operators
117681cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org  //===--------------------------------------------------------------------===//
117781cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org
1178ed49e965b5cafa35395084dbfb79f4e07930f10ferik.corry@gmail.com  /// getCanonicalType - Return the canonical (structural) type corresponding to
1179f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// the specified potentially non-canonical type.  The non-canonical version
1180f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// of a type may have many "decorated" versions of types.  Decorators can
1181f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// include typedefs, 'typeof' operators, etc. The returned type is guaranteed
1182812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// to be free of any of these, allowing two canonical types to be compared
1183812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// for exact equality with a simple pointer comparison.
1184812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  CanQualType getCanonicalType(QualType T) const {
1185812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org    return CanQualType::CreateUnsafe(T.getCanonicalType());
1186812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  }
1187812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org
1188812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  const Type *getCanonicalType(const Type *T) const {
1189812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org    return T->getCanonicalTypeInternal().getTypePtr();
1190812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  }
1191812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org
1192812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// getCanonicalParamType - Return the canonical parameter type
1193812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// corresponding to the specific potentially non-canonical one.
1194812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// Qualifiers are stripped off, functions are turned into function
1195f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// pointers, and arrays decay one level into pointers.
1196812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  CanQualType getCanonicalParamType(QualType T) const;
1197812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org
1198812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// \brief Determine whether the given types are equivalent.
1199812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  bool hasSameType(QualType T1, QualType T2) {
1200812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org    return getCanonicalType(T1) == getCanonicalType(T2);
1201a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  }
1202812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org
12037028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  /// \brief Returns this type as a completely-unqualified array type,
1204812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// capturing the qualifiers in Quals. This will remove the minimal amount of
1205812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// sugaring from the types, similar to the behavior of
12067028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  /// QualType::getUnqualifiedType().
1207812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  ///
1208812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// \param T is the qualified type, which may be an ArrayType
1209812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  ///
12107028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  /// \param Quals will receive the full set of qualifiers that were
1211812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// applied to the array.
1212812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  ///
12131fd77d58ca66b2711f09cdea32c0c2d1a01b3ae5danno@chromium.org  /// \returns if this is an array type, the completely unqualified array type
1214812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// that corresponds to it. Otherwise, returns T.getUnqualifiedType().
1215812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals);
1216812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org
1217812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// \brief Determine whether the given types are equivalent after
1218812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// cvr-qualifiers have been removed.
1219a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  bool hasSameUnqualifiedType(QualType T1, QualType T2) {
1220812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org    return getCanonicalType(T1).getTypePtr() ==
1221bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com           getCanonicalType(T2).getTypePtr();
1222bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  }
1223bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
1224bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  bool UnwrapSimilarPointerTypes(QualType &T1, QualType &T2);
12257028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org
12267028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  /// \brief Retrieves the "canonical" nested name specifier for a
1227bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// given nested name specifier.
1228bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  ///
1229bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// The canonical nested name specifier is a nested name specifier
1230bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// that uniquely identifies a type or namespace within the type
1231bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// system. For example, given:
1232bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  ///
1233bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// \code
1234bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// namespace N {
1235bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  ///   struct S {
1236bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  ///     template<typename T> struct X { typename T* type; };
1237bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  ///   };
1238bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// }
1239812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  ///
1240a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  /// template<typename T> struct Y {
1241812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  ///   typename N::S::X<T>::type member;
1242812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// };
1243812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// \endcode
1244812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  ///
1245f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// Here, the nested-name-specifier for N::S::X<T>:: will be
1246f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// S::X<template-param-0-0>, since 'S' and 'X' are uniquely defined
1247f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// by declarations in the type system and the canonical type for
1248812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// the template type parameter 'T' is template-param-0-0.
1249812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  NestedNameSpecifier *
1250812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const;
1251812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org
1252812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// \brief Retrieves the default calling convention to use for
1253f705b5034dc5bc422ac1019b591469a7d0534772mstarzinger@chromium.org  /// C++ instance methods.
1254812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  CallingConv getDefaultMethodCallConv();
1255812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org
1256812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// \brief Retrieves the canonical representation of the given
1257812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// calling convention.
1258812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  CallingConv getCanonicalCallConv(CallingConv CC) const {
1259812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org    if (CC == CC_C)
1260812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org      return CC_Default;
12617028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org    return CC;
1262812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  }
1263812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org
1264a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  /// \brief Determines whether two calling conventions name the same
1265812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// calling convention.
1266812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  bool isSameCallConv(CallingConv lcc, CallingConv rcc) {
126759297c735ad2a41156ae9c723a39ff259ad061e0jkummerow@chromium.org    return (getCanonicalCallConv(lcc) == getCanonicalCallConv(rcc));
12687028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  }
1269812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org
1270812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// \brief Retrieves the "canonical" template name that refers to a
1271812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// given template.
12727028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  ///
1273812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// The canonical template name is the simplest expression that can
1274812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// be used to refer to a given template. For most templates, this
1275a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  /// expression is just the template declaration itself. For example,
1276812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// the template std::vector can be referred to via a variety of
1277812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// names---std::vector, ::std::vector, vector (if vector is in
1278812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// scope), etc.---but all of these names map down to the same
1279812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// TemplateDecl, which is used to form the canonical template name.
1280812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  ///
1281812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// Dependent template names are more interesting. Here, the
1282812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// template name could be something like T::template apply or
1283812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// std::allocator<T>::template rebind, where the nested name
1284812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// specifier itself is dependent. In this case, the canonical
1285812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// template name uses the shortest form of the dependent
1286812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// nested-name-specifier, which itself contains all canonical
1287812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// types, values, and templates.
1288812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  TemplateName getCanonicalTemplateName(TemplateName Name) const;
1289812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org
1290812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// \brief Determine whether the given template names refer to the same
1291812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// template.
1292812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  bool hasSameTemplateName(TemplateName X, TemplateName Y);
1293812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org
1294812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// \brief Retrieve the "canonical" template argument.
1295812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  ///
1296812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// The canonical template argument is the simplest template argument
1297812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// (which may be a type, value, expression, or declaration) that
1298bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// expresses the value of the argument.
1299bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg)
1300812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org    const;
1301bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
1302bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// Type Query functions.  If the type is an instance of the specified class,
1303bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// return the Type pointer for the underlying maximally pretty type.  This
1304bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// is a member of ASTContext because this may need to do some amount of
13057028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  /// canonicalization, e.g. to move type qualifiers into the element type.
13067028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  const ArrayType *getAsArrayType(QualType T) const;
13077028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  const ConstantArrayType *getAsConstantArrayType(QualType T) const {
13087028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org    return dyn_cast_or_null<ConstantArrayType>(getAsArrayType(T));
1309bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  }
1310bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  const VariableArrayType *getAsVariableArrayType(QualType T) const {
1311bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com    return dyn_cast_or_null<VariableArrayType>(getAsArrayType(T));
1312bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  }
1313bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  const IncompleteArrayType *getAsIncompleteArrayType(QualType T) const {
1314a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org    return dyn_cast_or_null<IncompleteArrayType>(getAsArrayType(T));
1315bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  }
1316812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  const DependentSizedArrayType *getAsDependentSizedArrayType(QualType T)
1317812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org    const {
1318812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org    return dyn_cast_or_null<DependentSizedArrayType>(getAsArrayType(T));
1319812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  }
1320f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
1321f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// getBaseElementType - Returns the innermost element type of an array type.
1322f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// For example, will return "int" for int[m][n]
1323f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  QualType getBaseElementType(const ArrayType *VAT) const;
1324f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
1325f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// getBaseElementType - Returns the innermost element type of a type
1326f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// (which needn't actually be an array type).
1327f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  QualType getBaseElementType(QualType QT) const;
1328f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
1329f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// getConstantArrayElementCount - Returns number of constant array elements.
1330f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const;
1331f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
1332f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// \brief Perform adjustment on the parameter type of a function.
1333f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  ///
1334f705b5034dc5bc422ac1019b591469a7d0534772mstarzinger@chromium.org  /// This routine adjusts the given parameter type @p T to the actual
1335f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// parameter type used by semantic analysis (C99 6.7.5.3p[7,8],
1336f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// C++ [dcl.fct]p3). The adjusted parameter type is returned.
1337f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  QualType getAdjustedParameterType(QualType T);
1338812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org
1339f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// \brief Retrieve the parameter type as adjusted for use in the signature
1340f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// of a function, decaying array and function types and removing top-level
1341812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  /// cv-qualifiers.
1342f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  QualType getSignatureParameterType(QualType T);
1343f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org
1344f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// getArrayDecayedType - Return the properly qualified result of decaying the
1345f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// specified array type to a pointer.  This operation is non-trivial when
1346f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// handling typedefs etc.  The canonical type of "T" must be an array type,
1347f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  /// this returns a pointer to a properly qualified element of the array.
134843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  ///
134943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// See C99 6.7.5.3p7 and C99 6.3.2.1p3.
135043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  QualType getArrayDecayedType(QualType T) const;
135143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
135243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// getPromotedIntegerType - Returns the type that Promotable will
135343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// promote to: C99 6.3.1.1p2, assuming that Promotable is a promotable
135443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// integer type.
135543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  QualType getPromotedIntegerType(QualType PromotableType) const;
135643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
135743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief Recurses in pointer/array types until it finds an objc retainable
135843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// type and returns its ownership.
135943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  Qualifiers::ObjCLifetime getInnerObjCOwnership(QualType T) const;
136043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
136143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief Whether this is a promotable bitfield reference according
136243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// to C99 6.3.1.1p2, bullet 2 (and GCC extensions).
136343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  ///
136443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \returns the type this bit-field will promote to, or NULL if no
136543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// promotion occurs.
136643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  QualType isPromotableBitField(Expr *E) const;
136743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
136843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// getIntegerTypeOrder - Returns the highest ranked integer type:
136943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// C99 6.3.1.8p1.  If LHS > RHS, return 1.  If LHS == RHS, return 0. If
13703291210ab99f306b74430ebbc4b7d939629e699fager@chromium.org  /// LHS < RHS, return -1.
137143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  int getIntegerTypeOrder(QualType LHS, QualType RHS) const;
137243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
137343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// getFloatingTypeOrder - Compare the rank of the two specified floating
137443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// point types, ignoring the domain of the type (i.e. 'double' ==
137543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// '_Complex double').  If LHS > RHS, return 1.  If LHS == RHS, return 0. If
137643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// LHS < RHS, return -1.
13771b3afd1cab9087ca3c4e585d3da77d374d65c082mstarzinger@chromium.org  int getFloatingTypeOrder(QualType LHS, QualType RHS) const;
137843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
1379a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  /// getFloatingTypeOfSizeWithinDomain - Returns a real floating
138043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// point or a complex type (based on typeDomain/typeSize).
138143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// 'typeDomain' is a real floating point or complex type.
138243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// 'typeSize' is a real floating point or complex type.
1383a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  QualType getFloatingTypeOfSizeWithinDomain(QualType typeSize,
138443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen                                             QualType typeDomain) const;
138543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
1386a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  unsigned getTargetAddressSpace(QualType T) const {
138743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen    return getTargetAddressSpace(T.getQualifiers());
138843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  }
1389a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org
139043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  unsigned getTargetAddressSpace(Qualifiers Q) const {
139143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen    return getTargetAddressSpace(Q.getAddressSpace());
1392a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  }
139343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
139443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  unsigned getTargetAddressSpace(unsigned AS) const {
1395a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org    if (AS < LangAS::Offset || AS >= LangAS::Offset + LangAS::Count)
139643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen      return AS;
139743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen    else
1398a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org      return AddrSpaceMap[AS - LangAS::Offset];
139943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  }
140043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
1401a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.orgprivate:
140243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  // Helper for integer ordering
140343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  unsigned getIntegerRank(const Type *T) const;
1404a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org
140543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansenpublic:
140643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
1407a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  //===--------------------------------------------------------------------===//
140843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  //                    Type Compatibility Predicates
140943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  //===--------------------------------------------------------------------===//
1410a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org
141143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// Compatibility predicates used to check assignment expressions.
141243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  bool typesAreCompatible(QualType T1, QualType T2,
1413a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org                          bool CompareUnqualified = false); // C99 6.2.7p1
141443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
141543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  bool propertyTypesAreCompatible(QualType, QualType);
141643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  bool typesAreBlockPointerCompatible(QualType, QualType);
141743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
141843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  bool isObjCIdType(QualType T) const {
141943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen    return T == ObjCIdTypedefType;
142043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  }
1421a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  bool isObjCClassType(QualType T) const {
1422a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org    return T == ObjCClassTypedefType;
1423e03fb64ef23331755b7986d2560bc4c00ba3e67bfschneider@chromium.org  }
142443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  bool isObjCSelType(QualType T) const {
1425400388edd471bd4d4a97b21c52c1024cd1cc5708rossberg@chromium.org    return T == ObjCSelTypedefType;
142643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  }
142743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  bool QualifiedIdConformsQualifiedId(QualType LHS, QualType RHS);
142843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  bool ObjCQualifiedIdTypesAreCompatible(QualType LHS, QualType RHS,
14299ee27ae43ab88e9bb6417ff9e27af64e0cf13729ager@chromium.org                                         bool ForCompare);
1430c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com
1431c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com  bool ObjCQualifiedClassTypesAreCompatible(QualType LHS, QualType RHS);
1432c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com
1433c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com  // Check the safety of assignment from LHS to RHS
1434c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com  bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT,
1435c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com                               const ObjCObjectPointerType *RHSOPT);
1436c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com  bool canAssignObjCInterfaces(const ObjCObjectType *LHS,
1437f705b5034dc5bc422ac1019b591469a7d0534772mstarzinger@chromium.org                               const ObjCObjectType *RHS);
1438f705b5034dc5bc422ac1019b591469a7d0534772mstarzinger@chromium.org  bool canAssignObjCInterfacesInBlockPointer(
1439f705b5034dc5bc422ac1019b591469a7d0534772mstarzinger@chromium.org                                          const ObjCObjectPointerType *LHSOPT,
1440f705b5034dc5bc422ac1019b591469a7d0534772mstarzinger@chromium.org                                          const ObjCObjectPointerType *RHSOPT,
14411b3afd1cab9087ca3c4e585d3da77d374d65c082mstarzinger@chromium.org                                          bool BlockReturnType);
14429ee27ae43ab88e9bb6417ff9e27af64e0cf13729ager@chromium.org  bool areComparableObjCPointerTypes(QualType LHS, QualType RHS);
14439ee27ae43ab88e9bb6417ff9e27af64e0cf13729ager@chromium.org  QualType areCommonBaseCompatible(const ObjCObjectPointerType *LHSOPT,
14449ee27ae43ab88e9bb6417ff9e27af64e0cf13729ager@chromium.org                                   const ObjCObjectPointerType *RHSOPT);
14459ee27ae43ab88e9bb6417ff9e27af64e0cf13729ager@chromium.org  bool canBindObjCObjectType(QualType To, QualType From);
14469ee27ae43ab88e9bb6417ff9e27af64e0cf13729ager@chromium.org
1447812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  // Functions for calculating composite types
14489ee27ae43ab88e9bb6417ff9e27af64e0cf13729ager@chromium.org  QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false,
144943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen                      bool Unqualified = false, bool BlockReturnType = false);
145043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer=false,
1451a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org                              bool Unqualified = false);
145243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  QualType mergeFunctionArgumentTypes(QualType, QualType,
145343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen                                      bool OfBlockPointer=false,
1454a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org                                      bool Unqualified = false);
145543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  QualType mergeTransparentUnionType(QualType, QualType,
145643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen                                     bool OfBlockPointer=false,
145743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen                                     bool Unqualified = false);
145843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
1459bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  QualType mergeObjCGCQualifiers(QualType, QualType);
1460bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
1461b645116853c677aca8a316381b87441ba6004f67danno@chromium.org  void ResetObjCLayout(const ObjCContainerDecl *CD) {
1462b645116853c677aca8a316381b87441ba6004f67danno@chromium.org    ObjCLayouts[CD] = 0;
1463b645116853c677aca8a316381b87441ba6004f67danno@chromium.org  }
1464394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com
1465394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com  //===--------------------------------------------------------------------===//
1466812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  //                    Integer Predicates
1467a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  //===--------------------------------------------------------------------===//
1468812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org
1469812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  // The width of an integer, as defined in C99 6.2.6.2. This is the number
1470812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  // of bits in an integer type excluding any padding bits.
1471812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  unsigned getIntWidth(QualType T) const;
1472bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
1473bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  // Per C99 6.2.5p6, for every signed integer type, there is a corresponding
1474812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  // unsigned integer type.  This method takes a signed type, and returns the
1475812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  // corresponding unsigned integer type.
1476812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  QualType getCorrespondingUnsignedType(QualType T);
147743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
147881cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org  //===--------------------------------------------------------------------===//
147943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  //                    Type Iterators.
148043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  //===--------------------------------------------------------------------===//
148143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
148243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  typedef std::vector<Type*>::iterator       type_iterator;
148343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  typedef std::vector<Type*>::const_iterator const_type_iterator;
14848e8294a88dc7d58f579aee0ba08c19fc8a616e2dsgjesse@chromium.org
14858e8294a88dc7d58f579aee0ba08c19fc8a616e2dsgjesse@chromium.org  type_iterator types_begin() { return Types.begin(); }
14864f693d6b99ffdbc05e5e211e08ed5039e13279d2ricow@chromium.org  type_iterator types_end() { return Types.end(); }
14871b3afd1cab9087ca3c4e585d3da77d374d65c082mstarzinger@chromium.org  const_type_iterator types_begin() const { return Types.begin(); }
1488f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  const_type_iterator types_end() const { return Types.end(); }
1489bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
1490355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  //===--------------------------------------------------------------------===//
149181cac2ba397bd57f2967c8b4b677bef08a869991danno@chromium.org  //                    Integer Values
1492355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  //===--------------------------------------------------------------------===//
1493355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org
1494355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  /// MakeIntValue - Make an APSInt of the appropriate width and
1495355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  /// signedness for the given \arg Value and integer \arg Type.
1496355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const {
1497355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org    llvm::APSInt Res(getIntWidth(Type),
149843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen                     !Type->isSignedIntegerOrEnumerationType());
149943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen    Res = Value;
1500812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org    return Res;
1501bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  }
1502355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org
1503355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  /// \brief Get the implementation of ObjCInterfaceDecl,or NULL if none exists.
1504355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  ObjCImplementationDecl *getObjCImplementation(ObjCInterfaceDecl *D);
1505355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  /// \brief Get the implementation of ObjCCategoryDecl, or NULL if none exists.
15061805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org  ObjCCategoryImplDecl   *getObjCImplementation(ObjCCategoryDecl *D);
15071805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org
1508355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  /// \brief returns true if there is at lease one @implementation in TU.
1509355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  bool AnyObjCImplementation() {
15101805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org    return !ObjCImpls.empty();
15111805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org  }
15121805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org
1513355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  /// \brief Set the implementation of ObjCInterfaceDecl.
15141805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org  void setObjCImplementation(ObjCInterfaceDecl *IFaceD,
15151805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org                             ObjCImplementationDecl *ImplD);
15161805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org  /// \brief Set the implementation of ObjCCategoryDecl.
15171805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org  void setObjCImplementation(ObjCCategoryDecl *CatD,
15181805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org                             ObjCCategoryImplDecl *ImplD);
1519355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org
1520355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  /// \brief Set the copy inialization expression of a block var decl.
1521355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  void setBlockVarCopyInits(VarDecl*VD, Expr* Init);
1522355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  /// \brief Get the copy initialization expression of VarDecl,or NULL if
1523355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  /// none exists.
1524355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  Expr *getBlockVarCopyInits(const VarDecl*VD);
1525355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org
1526355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  /// \brief Allocate an uninitialized TypeSourceInfo.
1527355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  ///
1528355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  /// The caller should initialize the memory held by TypeSourceInfo using
152943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// the TypeLoc wrappers.
1530dfe53073738bbf16023d96fce5118358a1037fd3ulan@chromium.org  ///
15318e8d8825f97138de12985f8e0d3163074dff5258ulan@chromium.org  /// \param T the type that will be the basis for type source info. This type
15328e8d8825f97138de12985f8e0d3163074dff5258ulan@chromium.org  /// should refer to how the declarator was written in source code, not to
1533355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  /// what type semantic analysis resolved the declarator to.
15344a9f6553038df6b893b3d3ccae351723f4cbbae7yangguo@chromium.org  ///
1535dfe53073738bbf16023d96fce5118358a1037fd3ulan@chromium.org  /// \param Size the size of the type info to create, or 0 if the size
1536355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  /// should be calculated based on the type.
153743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  TypeSourceInfo *CreateTypeSourceInfo(QualType T, unsigned Size = 0) const;
153843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
153943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief Allocate a TypeSourceInfo where all locations have been
154043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// initialized to a given location, which defaults to the empty
154143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// location.
154243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  TypeSourceInfo *
154343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  getTrivialTypeSourceInfo(QualType T,
154443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen                           SourceLocation Loc = SourceLocation()) const;
154543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
154643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  TypeSourceInfo *getNullTypeSourceInfo() { return &NullTypeSourceInfo; }
154743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
154843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief Add a deallocation callback that will be invoked when the
154943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// ASTContext is destroyed.
155043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  ///
155143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief Callback A callback function that will be invoked on destruction.
155243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  ///
155343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief Data Pointer data that will be provided to the callback function
155443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// when it is called.
155543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  void AddDeallocation(void (*Callback)(void*), void *Data);
1556812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org
155743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD);
1558355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org  GVALinkage GetGVALinkageForVariable(const VarDecl *VD);
155927bf28851c1fa362a3f7c709871c21dcc9c23ce7ricow@chromium.org
156043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief Determines if the decl can be CodeGen'ed or deserialized from PCH
15613e87580939cb78c5802369f723680d4a16cc2902ager@chromium.org  /// lazily, only when used; this is only relevant for function or file scoped
156210480471c0db59c51c15e57d2a3489551d61b273jkummerow@chromium.org  /// var definitions.
156310480471c0db59c51c15e57d2a3489551d61b273jkummerow@chromium.org  ///
156410480471c0db59c51c15e57d2a3489551d61b273jkummerow@chromium.org  /// \returns true if the function/var must be CodeGen'ed/deserialized even if
156527bf28851c1fa362a3f7c709871c21dcc9c23ce7ricow@chromium.org  /// it is not used.
15661b3afd1cab9087ca3c4e585d3da77d374d65c082mstarzinger@chromium.org  bool DeclMustBeEmitted(const Decl *D);
156727bf28851c1fa362a3f7c709871c21dcc9c23ce7ricow@chromium.org
156827bf28851c1fa362a3f7c709871c21dcc9c23ce7ricow@chromium.org  //===--------------------------------------------------------------------===//
156927bf28851c1fa362a3f7c709871c21dcc9c23ce7ricow@chromium.org  //                    Statistics
157027bf28851c1fa362a3f7c709871c21dcc9c23ce7ricow@chromium.org  //===--------------------------------------------------------------------===//
157110480471c0db59c51c15e57d2a3489551d61b273jkummerow@chromium.org
157210480471c0db59c51c15e57d2a3489551d61b273jkummerow@chromium.org  /// \brief The number of implicitly-declared default constructors.
157310480471c0db59c51c15e57d2a3489551d61b273jkummerow@chromium.org  static unsigned NumImplicitDefaultConstructors;
157427bf28851c1fa362a3f7c709871c21dcc9c23ce7ricow@chromium.org
157527bf28851c1fa362a3f7c709871c21dcc9c23ce7ricow@chromium.org  /// \brief The number of implicitly-declared default constructors for
157643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// which declarations were built.
157743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  static unsigned NumImplicitDefaultConstructorsDeclared;
157843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
157943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief The number of implicitly-declared copy constructors.
158043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  static unsigned NumImplicitCopyConstructors;
158143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
158243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief The number of implicitly-declared copy constructors for
158343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// which declarations were built.
158443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  static unsigned NumImplicitCopyConstructorsDeclared;
158543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
158643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief The number of implicitly-declared move constructors.
158743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  static unsigned NumImplicitMoveConstructors;
158843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
158943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief The number of implicitly-declared move constructors for
159043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// which declarations were built.
159143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  static unsigned NumImplicitMoveConstructorsDeclared;
159243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
159343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief The number of implicitly-declared copy assignment operators.
159443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  static unsigned NumImplicitCopyAssignmentOperators;
159543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
159643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief The number of implicitly-declared copy assignment operators for
159743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// which declarations were built.
159843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  static unsigned NumImplicitCopyAssignmentOperatorsDeclared;
159943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
160043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief The number of implicitly-declared move assignment operators.
160143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  static unsigned NumImplicitMoveAssignmentOperators;
1602bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
1603bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// \brief The number of implicitly-declared move assignment operators for
1604bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// which declarations were built.
1605bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  static unsigned NumImplicitMoveAssignmentOperatorsDeclared;
1606bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
1607bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// \brief The number of implicitly-declared destructors.
1608bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  static unsigned NumImplicitDestructors;
1609bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
1610bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  /// \brief The number of implicitly-declared destructors for which
16117028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org  /// declarations were built.
1612bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  static unsigned NumImplicitDestructorsDeclared;
1613bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
1614bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.comprivate:
1615bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  ASTContext(const ASTContext&); // DO NOT IMPLEMENT
1616bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  void operator=(const ASTContext&); // DO NOT IMPLEMENT
1617bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
1618bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  void InitBuiltinTypes();
1619bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  void InitBuiltinType(CanQualType &R, BuiltinType::Kind K);
1620bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com
1621bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  // Return the ObjC type encoding for a given type.
1622bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com  void getObjCEncodingForTypeImpl(QualType t, std::string &S,
1623bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com                                  bool ExpandPointedToStructures,
1624bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com                                  bool ExpandStructures,
1625bbceb57d27ec53f6d6212e690ead3174192ea3f9erik.corry@gmail.com                                  const FieldDecl *Field,
162643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen                                  bool OutermostType = false,
162743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen                                  bool EncodingProperty = false,
162843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen                                  bool StructField = false) const;
162943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
163043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  // Adds the encoding of the structure's members.
163143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  void getObjCEncodingForStructureImpl(RecordDecl *RD, std::string &S,
163243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen                                       const FieldDecl *Field,
163343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen                                       bool includeVBases = true) const;
1634a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org
163543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  const ASTRecordLayout &
163643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  getObjCLayout(const ObjCInterfaceDecl *D,
163743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen                const ObjCImplementationDecl *Impl) const;
163843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
163943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansenprivate:
164043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief A set of deallocations that should be performed when the
164143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// ASTContext is destroyed.
1642fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  SmallVector<std::pair<void (*)(void*), void *>, 16> Deallocations;
1643fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org
1644fa943b736b1d996084393011529d568165bb5d83lrn@chromium.org  // FIXME: This currently contains the set of StoredDeclMaps used
164543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  // by DeclContext objects.  This probably should not be in ASTContext,
164643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  // but we include it here so that ASTContext can quickly deallocate them.
164743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  llvm::PointerIntPair<StoredDeclsMap*,1> LastSDM;
164843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
164943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  /// \brief A counter used to uniquely identify "blocks".
165043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  mutable unsigned int UniqueBlockByRefTypeID;
165143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
165243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  friend class DeclContext;
1653812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  friend class DeclarationNameTable;
165443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen  void ReleaseDeclContextMaps();
165543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen};
165643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
1657f2038fb01417bcf7698b87a5dfaa4a861539618aerik.corry@gmail.com/// @brief Utility function for constructing a nullary selector.
165828583c92ca8f528df625800519088ac88996d504jkummerow@chromium.orgstatic inline Selector GetNullarySelector(StringRef name, ASTContext& Ctx) {
1659812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  IdentifierInfo* II = &Ctx.Idents.get(name);
1660a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  return Ctx.Selectors.getSelector(0, &II);
1661812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org}
1662a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org
1663a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org/// @brief Utility function for constructing an unary selector.
1664b1df11df5b7bdcc201852bfcdce0a8eace33b011svenpanne@chromium.orgstatic inline Selector GetUnarySelector(StringRef name, ASTContext& Ctx) {
1665b1df11df5b7bdcc201852bfcdce0a8eace33b011svenpanne@chromium.org  IdentifierInfo* II = &Ctx.Idents.get(name);
1666a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  return Ctx.Selectors.getSelector(1, &II);
1667a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org}
166843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
166943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen}  // end namespace clang
167043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
1671812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org// operator new and delete aren't allowed inside namespaces.
1672c514574143c1bf74d4fb6e7dccb175fe9ff2f5d3sgjesse@chromium.org// The throw specifications are mandated by the standard.
1673c514574143c1bf74d4fb6e7dccb175fe9ff2f5d3sgjesse@chromium.org/// @brief Placement new for using the ASTContext's allocator.
1674f705b5034dc5bc422ac1019b591469a7d0534772mstarzinger@chromium.org///
1675f705b5034dc5bc422ac1019b591469a7d0534772mstarzinger@chromium.org/// This placement form of operator new uses the ASTContext's allocator for
1676f705b5034dc5bc422ac1019b591469a7d0534772mstarzinger@chromium.org/// obtaining memory. It is a non-throwing new, which means that it returns
167743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen/// null on error. (If that is what the allocator does. The current does, so if
1678a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org/// this ever changes, this operator will have to be changed, too.)
1679e27d617298263725e8a48c2aa14029759b952623mstarzinger@chromium.org/// Usage looks like this (assuming there's an ASTContext 'Context' in scope):
168004921a8093ce8bbec34084bd742b7aa3d299be15ager@chromium.org/// @code
168104921a8093ce8bbec34084bd742b7aa3d299be15ager@chromium.org/// // Default alignment (8)
168204921a8093ce8bbec34084bd742b7aa3d299be15ager@chromium.org/// IntegerLiteral *Ex = new (Context) IntegerLiteral(arguments);
1683c514574143c1bf74d4fb6e7dccb175fe9ff2f5d3sgjesse@chromium.org/// // Specific alignment
168404921a8093ce8bbec34084bd742b7aa3d299be15ager@chromium.org/// IntegerLiteral *Ex2 = new (Context, 4) IntegerLiteral(arguments);
1685f705b5034dc5bc422ac1019b591469a7d0534772mstarzinger@chromium.org/// @endcode
1686a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org/// Please note that you cannot use delete on the pointer; it must be
16877c2628c3f0353f0558760c3ca442f934263ea766kmillikin@chromium.org/// deallocated using an explicit destructor call followed by
1688c514574143c1bf74d4fb6e7dccb175fe9ff2f5d3sgjesse@chromium.org/// @c Context.Deallocate(Ptr).
1689c514574143c1bf74d4fb6e7dccb175fe9ff2f5d3sgjesse@chromium.org///
1690355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org/// @param Bytes The number of bytes to allocate. Calculated by the compiler.
1691c514574143c1bf74d4fb6e7dccb175fe9ff2f5d3sgjesse@chromium.org/// @param C The ASTContext that provides the allocator.
1692355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org/// @param Alignment The alignment of the allocated memory (if the underlying
1693355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org///                  allocator supports it).
1694355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.org/// @return The allocated memory. Could be NULL.
1695355cfd19c23ac613f2738a40e356ea48297f7d5eyangguo@chromium.orginline void *operator new(size_t Bytes, const clang::ASTContext &C,
169628583c92ca8f528df625800519088ac88996d504jkummerow@chromium.org                          size_t Alignment) throw () {
1697812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org  return C.Allocate(Bytes, Alignment);
1698a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org}
1699812308e1488cd8261e4dbbda1d8022642d522b9bulan@chromium.org/// @brief Placement delete companion to the new above.
17007028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org///
1701a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org/// This operator is just a companion to the new above. There is no way of
170243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen/// invoking it directly; see the new operator for more details. This operator
170343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen/// is called implicitly by the compiler if a placement new expression using
170443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen/// the ASTContext throws in the object constructor.
170543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hanseninline void operator delete(void *Ptr, const clang::ASTContext &C, size_t)
17061b3afd1cab9087ca3c4e585d3da77d374d65c082mstarzinger@chromium.org              throw () {
17074acdc2c8d4caecf7606db8af710366c1d6e28fe5whesse@chromium.org  C.Deallocate(Ptr);
170843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen}
170943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen
171043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen/// This placement form of operator new[] uses the ASTContext's allocator for
171143d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen/// obtaining memory. It is a non-throwing new[], which means that it returns
171243d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen/// null on error.
171343d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen/// Usage looks like this (assuming there's an ASTContext 'Context' in scope):
171443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen/// @code
1715a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org/// // Default alignment (8)
1716a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org/// char *data = new (Context) char[10];
1717e03fb64ef23331755b7986d2560bc4c00ba3e67bfschneider@chromium.org/// // Specific alignment
171843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen/// char *data = new (Context, 4) char[10];
171943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen/// @endcode
172043d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen/// Please note that you cannot use delete on the pointer; it must be
17216db8871df97e7137d11f956af3c772f4f8370761sgjesse@chromium.org/// deallocated using an explicit destructor call followed by
1722400388edd471bd4d4a97b21c52c1024cd1cc5708rossberg@chromium.org/// @c Context.Deallocate(Ptr).
17236db8871df97e7137d11f956af3c772f4f8370761sgjesse@chromium.org///
172443d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen/// @param Bytes The number of bytes to allocate. Calculated by the compiler.
172543d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen/// @param C The ASTContext that provides the allocator.
172643d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen/// @param Alignment The alignment of the allocated memory (if the underlying
172743d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen///                  allocator supports it).
172843d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hansen/// @return The allocated memory. Could be NULL.
172943d26ecc3563a46f62a0224030667c8f8f3f6cebchristian.plesner.hanseninline void *operator new[](size_t Bytes, const clang::ASTContext& C,
17304acdc2c8d4caecf7606db8af710366c1d6e28fe5whesse@chromium.org                            size_t Alignment = 8) throw () {
1731f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org  return C.Allocate(Bytes, Alignment);
1732c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com}
1733c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com
1734f7a588466d1e61e14fec951e5f10c7cec501b3b4jkummerow@chromium.org/// @brief Placement delete[] companion to the new[] above.
1735c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com///
17364acdc2c8d4caecf7606db8af710366c1d6e28fe5whesse@chromium.org/// This operator is just a companion to the new[] above. There is no way of
1737a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org/// invoking it directly; see the new[] operator for more details. This operator
1738a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org/// is called implicitly by the compiler if a placement new[] expression using
1739394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com/// the ASTContext throws in the object constructor.
17404acdc2c8d4caecf7606db8af710366c1d6e28fe5whesse@chromium.orginline void operator delete[](void *Ptr, const clang::ASTContext &C, size_t)
17414acdc2c8d4caecf7606db8af710366c1d6e28fe5whesse@chromium.org              throw () {
17424acdc2c8d4caecf7606db8af710366c1d6e28fe5whesse@chromium.org  C.Deallocate(Ptr);
1743394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com}
1744c612e0211bdb8821cbd7886e15b0273ed82d2e9edanno@chromium.org
17457028c05c1c71b9d5c5fe1bca01f2461d17a2dda7mmassi@chromium.org#endif
1746394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com