ASTContext.h revision 4fb86f8c4585e53c21c847ad3de9e3b2de123cd9
1//===--- ASTContext.h - Context to hold long-lived AST nodes ----*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file defines the ASTContext interface. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_CLANG_AST_ASTCONTEXT_H 15#define LLVM_CLANG_AST_ASTCONTEXT_H 16 17#include "clang/Basic/AddressSpaces.h" 18#include "clang/Basic/IdentifierTable.h" 19#include "clang/Basic/LangOptions.h" 20#include "clang/Basic/OperatorKinds.h" 21#include "clang/Basic/PartialDiagnostic.h" 22#include "clang/Basic/VersionTuple.h" 23#include "clang/AST/Decl.h" 24#include "clang/AST/NestedNameSpecifier.h" 25#include "clang/AST/PrettyPrinter.h" 26#include "clang/AST/TemplateName.h" 27#include "clang/AST/Type.h" 28#include "clang/AST/CanonicalType.h" 29#include "clang/AST/UsuallyTinyPtrVector.h" 30#include "llvm/ADT/DenseMap.h" 31#include "llvm/ADT/FoldingSet.h" 32#include "llvm/ADT/IntrusiveRefCntPtr.h" 33#include "llvm/ADT/OwningPtr.h" 34#include "llvm/ADT/SmallPtrSet.h" 35#include "llvm/Support/Allocator.h" 36#include <vector> 37 38namespace llvm { 39 struct fltSemantics; 40 class raw_ostream; 41} 42 43namespace clang { 44 class FileManager; 45 class ASTRecordLayout; 46 class BlockExpr; 47 class CharUnits; 48 class Diagnostic; 49 class Expr; 50 class ExternalASTSource; 51 class ASTMutationListener; 52 class IdentifierTable; 53 class SelectorTable; 54 class SourceManager; 55 class TargetInfo; 56 class CXXABI; 57 // Decls 58 class DeclContext; 59 class CXXMethodDecl; 60 class CXXRecordDecl; 61 class Decl; 62 class FieldDecl; 63 class MangleContext; 64 class ObjCIvarDecl; 65 class ObjCIvarRefExpr; 66 class ObjCPropertyDecl; 67 class RecordDecl; 68 class StoredDeclsMap; 69 class TagDecl; 70 class TemplateTemplateParmDecl; 71 class TemplateTypeParmDecl; 72 class TranslationUnitDecl; 73 class TypeDecl; 74 class TypedefNameDecl; 75 class UsingDecl; 76 class UsingShadowDecl; 77 class UnresolvedSetIterator; 78 79 namespace Builtin { class Context; } 80 81/// ASTContext - This class holds long-lived AST nodes (such as types and 82/// decls) that can be referred to throughout the semantic analysis of a file. 83class ASTContext : public llvm::RefCountedBase<ASTContext> { 84 ASTContext &this_() { return *this; } 85 86 mutable std::vector<Type*> Types; 87 mutable llvm::FoldingSet<ExtQuals> ExtQualNodes; 88 mutable llvm::FoldingSet<ComplexType> ComplexTypes; 89 mutable llvm::FoldingSet<PointerType> PointerTypes; 90 mutable llvm::FoldingSet<BlockPointerType> BlockPointerTypes; 91 mutable llvm::FoldingSet<LValueReferenceType> LValueReferenceTypes; 92 mutable llvm::FoldingSet<RValueReferenceType> RValueReferenceTypes; 93 mutable llvm::FoldingSet<MemberPointerType> MemberPointerTypes; 94 mutable llvm::FoldingSet<ConstantArrayType> ConstantArrayTypes; 95 mutable llvm::FoldingSet<IncompleteArrayType> IncompleteArrayTypes; 96 mutable std::vector<VariableArrayType*> VariableArrayTypes; 97 mutable llvm::FoldingSet<DependentSizedArrayType> DependentSizedArrayTypes; 98 mutable llvm::FoldingSet<DependentSizedExtVectorType> 99 DependentSizedExtVectorTypes; 100 mutable llvm::FoldingSet<VectorType> VectorTypes; 101 mutable llvm::FoldingSet<FunctionNoProtoType> FunctionNoProtoTypes; 102 mutable llvm::ContextualFoldingSet<FunctionProtoType, ASTContext&> 103 FunctionProtoTypes; 104 mutable llvm::FoldingSet<DependentTypeOfExprType> DependentTypeOfExprTypes; 105 mutable llvm::FoldingSet<DependentDecltypeType> DependentDecltypeTypes; 106 mutable llvm::FoldingSet<TemplateTypeParmType> TemplateTypeParmTypes; 107 mutable llvm::FoldingSet<SubstTemplateTypeParmType> 108 SubstTemplateTypeParmTypes; 109 mutable llvm::FoldingSet<SubstTemplateTypeParmPackType> 110 SubstTemplateTypeParmPackTypes; 111 mutable llvm::ContextualFoldingSet<TemplateSpecializationType, ASTContext&> 112 TemplateSpecializationTypes; 113 mutable llvm::FoldingSet<ParenType> ParenTypes; 114 mutable llvm::FoldingSet<ElaboratedType> ElaboratedTypes; 115 mutable llvm::FoldingSet<DependentNameType> DependentNameTypes; 116 mutable llvm::ContextualFoldingSet<DependentTemplateSpecializationType, 117 ASTContext&> 118 DependentTemplateSpecializationTypes; 119 llvm::FoldingSet<PackExpansionType> PackExpansionTypes; 120 mutable llvm::FoldingSet<ObjCObjectTypeImpl> ObjCObjectTypes; 121 mutable llvm::FoldingSet<ObjCObjectPointerType> ObjCObjectPointerTypes; 122 mutable llvm::FoldingSet<AutoType> AutoTypes; 123 llvm::FoldingSet<AttributedType> AttributedTypes; 124 125 mutable llvm::FoldingSet<QualifiedTemplateName> QualifiedTemplateNames; 126 mutable llvm::FoldingSet<DependentTemplateName> DependentTemplateNames; 127 mutable llvm::FoldingSet<SubstTemplateTemplateParmPackStorage> 128 SubstTemplateTemplateParmPacks; 129 130 /// \brief The set of nested name specifiers. 131 /// 132 /// This set is managed by the NestedNameSpecifier class. 133 mutable llvm::FoldingSet<NestedNameSpecifier> NestedNameSpecifiers; 134 mutable NestedNameSpecifier *GlobalNestedNameSpecifier; 135 friend class NestedNameSpecifier; 136 137 /// ASTRecordLayouts - A cache mapping from RecordDecls to ASTRecordLayouts. 138 /// This is lazily created. This is intentionally not serialized. 139 mutable llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*> 140 ASTRecordLayouts; 141 mutable llvm::DenseMap<const ObjCContainerDecl*, const ASTRecordLayout*> 142 ObjCLayouts; 143 144 /// KeyFunctions - A cache mapping from CXXRecordDecls to key functions. 145 llvm::DenseMap<const CXXRecordDecl*, const CXXMethodDecl*> KeyFunctions; 146 147 /// \brief Mapping from ObjCContainers to their ObjCImplementations. 148 llvm::DenseMap<ObjCContainerDecl*, ObjCImplDecl*> ObjCImpls; 149 150 /// \brief Mapping from __block VarDecls to their copy initialization expr. 151 llvm::DenseMap<const VarDecl*, Expr*> BlockVarCopyInits; 152 153 /// \brief Representation of a "canonical" template template parameter that 154 /// is used in canonical template names. 155 class CanonicalTemplateTemplateParm : public llvm::FoldingSetNode { 156 TemplateTemplateParmDecl *Parm; 157 158 public: 159 CanonicalTemplateTemplateParm(TemplateTemplateParmDecl *Parm) 160 : Parm(Parm) { } 161 162 TemplateTemplateParmDecl *getParam() const { return Parm; } 163 164 void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, Parm); } 165 166 static void Profile(llvm::FoldingSetNodeID &ID, 167 TemplateTemplateParmDecl *Parm); 168 }; 169 mutable llvm::FoldingSet<CanonicalTemplateTemplateParm> 170 CanonTemplateTemplateParms; 171 172 TemplateTemplateParmDecl * 173 getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const; 174 175 /// \brief Whether __[u]int128_t identifier is installed. 176 bool IsInt128Installed; 177 178 /// BuiltinVaListType - built-in va list type. 179 /// This is initially null and set by Sema::LazilyCreateBuiltin when 180 /// a builtin that takes a valist is encountered. 181 QualType BuiltinVaListType; 182 183 /// ObjCIdType - a pseudo built-in typedef type (set by Sema). 184 QualType ObjCIdTypedefType; 185 186 /// ObjCSelType - another pseudo built-in typedef type (set by Sema). 187 QualType ObjCSelTypedefType; 188 189 /// ObjCProtoType - another pseudo built-in typedef type (set by Sema). 190 QualType ObjCProtoType; 191 const RecordType *ProtoStructType; 192 193 /// ObjCClassType - another pseudo built-in typedef type (set by Sema). 194 QualType ObjCClassTypedefType; 195 196 QualType ObjCConstantStringType; 197 mutable RecordDecl *CFConstantStringTypeDecl; 198 199 mutable RecordDecl *NSConstantStringTypeDecl; 200 201 mutable RecordDecl *ObjCFastEnumerationStateTypeDecl; 202 203 /// \brief The type for the C FILE type. 204 TypeDecl *FILEDecl; 205 206 /// \brief The type for the C jmp_buf type. 207 TypeDecl *jmp_bufDecl; 208 209 /// \brief The type for the C sigjmp_buf type. 210 TypeDecl *sigjmp_bufDecl; 211 212 /// \brief Type for the Block descriptor for Blocks CodeGen. 213 mutable RecordDecl *BlockDescriptorType; 214 215 /// \brief Type for the Block descriptor for Blocks CodeGen. 216 mutable RecordDecl *BlockDescriptorExtendedType; 217 218 /// \brief Declaration for the CUDA cudaConfigureCall function. 219 FunctionDecl *cudaConfigureCallDecl; 220 221 TypeSourceInfo NullTypeSourceInfo; 222 223 /// \brief Keeps track of all declaration attributes. 224 /// 225 /// Since so few decls have attrs, we keep them in a hash map instead of 226 /// wasting space in the Decl class. 227 llvm::DenseMap<const Decl*, AttrVec*> DeclAttrs; 228 229 /// \brief Keeps track of the static data member templates from which 230 /// static data members of class template specializations were instantiated. 231 /// 232 /// This data structure stores the mapping from instantiations of static 233 /// data members to the static data member representations within the 234 /// class template from which they were instantiated along with the kind 235 /// of instantiation or specialization (a TemplateSpecializationKind - 1). 236 /// 237 /// Given the following example: 238 /// 239 /// \code 240 /// template<typename T> 241 /// struct X { 242 /// static T value; 243 /// }; 244 /// 245 /// template<typename T> 246 /// T X<T>::value = T(17); 247 /// 248 /// int *x = &X<int>::value; 249 /// \endcode 250 /// 251 /// This mapping will contain an entry that maps from the VarDecl for 252 /// X<int>::value to the corresponding VarDecl for X<T>::value (within the 253 /// class template X) and will be marked TSK_ImplicitInstantiation. 254 llvm::DenseMap<const VarDecl *, MemberSpecializationInfo *> 255 InstantiatedFromStaticDataMember; 256 257 /// \brief Keeps track of the declaration from which a UsingDecl was 258 /// created during instantiation. The source declaration is always 259 /// a UsingDecl, an UnresolvedUsingValueDecl, or an 260 /// UnresolvedUsingTypenameDecl. 261 /// 262 /// For example: 263 /// \code 264 /// template<typename T> 265 /// struct A { 266 /// void f(); 267 /// }; 268 /// 269 /// template<typename T> 270 /// struct B : A<T> { 271 /// using A<T>::f; 272 /// }; 273 /// 274 /// template struct B<int>; 275 /// \endcode 276 /// 277 /// This mapping will contain an entry that maps from the UsingDecl in 278 /// B<int> to the UnresolvedUsingDecl in B<T>. 279 llvm::DenseMap<UsingDecl *, NamedDecl *> InstantiatedFromUsingDecl; 280 281 llvm::DenseMap<UsingShadowDecl*, UsingShadowDecl*> 282 InstantiatedFromUsingShadowDecl; 283 284 llvm::DenseMap<FieldDecl *, FieldDecl *> InstantiatedFromUnnamedFieldDecl; 285 286 /// \brief Mapping that stores the methods overridden by a given C++ 287 /// member function. 288 /// 289 /// Since most C++ member functions aren't virtual and therefore 290 /// don't override anything, we store the overridden functions in 291 /// this map on the side rather than within the CXXMethodDecl structure. 292 typedef UsuallyTinyPtrVector<const CXXMethodDecl> CXXMethodVector; 293 llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector> OverriddenMethods; 294 295 TranslationUnitDecl *TUDecl; 296 297 /// SourceMgr - The associated SourceManager object. 298 SourceManager &SourceMgr; 299 300 /// LangOpts - The language options used to create the AST associated with 301 /// this ASTContext object. 302 LangOptions LangOpts; 303 304 /// \brief The allocator used to create AST objects. 305 /// 306 /// AST objects are never destructed; rather, all memory associated with the 307 /// AST objects will be released when the ASTContext itself is destroyed. 308 mutable llvm::BumpPtrAllocator BumpAlloc; 309 310 /// \brief Allocator for partial diagnostics. 311 PartialDiagnostic::StorageAllocator DiagAllocator; 312 313 /// \brief The current C++ ABI. 314 llvm::OwningPtr<CXXABI> ABI; 315 CXXABI *createCXXABI(const TargetInfo &T); 316 317 /// \brief The logical -> physical address space map. 318 const LangAS::Map &AddrSpaceMap; 319 320 friend class ASTDeclReader; 321 322public: 323 const TargetInfo &Target; 324 IdentifierTable &Idents; 325 SelectorTable &Selectors; 326 Builtin::Context &BuiltinInfo; 327 mutable DeclarationNameTable DeclarationNames; 328 llvm::OwningPtr<ExternalASTSource> ExternalSource; 329 ASTMutationListener *Listener; 330 clang::PrintingPolicy PrintingPolicy; 331 332 // Typedefs which may be provided defining the structure of Objective-C 333 // pseudo-builtins 334 QualType ObjCIdRedefinitionType; 335 QualType ObjCClassRedefinitionType; 336 QualType ObjCSelRedefinitionType; 337 338 SourceManager& getSourceManager() { return SourceMgr; } 339 const SourceManager& getSourceManager() const { return SourceMgr; } 340 void *Allocate(unsigned Size, unsigned Align = 8) const { 341 return BumpAlloc.Allocate(Size, Align); 342 } 343 void Deallocate(void *Ptr) const { } 344 345 /// Return the total amount of physical memory allocated for representing 346 /// AST nodes and type information. 347 size_t getASTAllocatedMemory() const { 348 return BumpAlloc.getTotalMemory(); 349 } 350 /// Return the total memory used for various side tables. 351 size_t getSideTableAllocatedMemory() const; 352 353 PartialDiagnostic::StorageAllocator &getDiagAllocator() { 354 return DiagAllocator; 355 } 356 357 const LangOptions& getLangOptions() const { return LangOpts; } 358 359 Diagnostic &getDiagnostics() const; 360 361 FullSourceLoc getFullLoc(SourceLocation Loc) const { 362 return FullSourceLoc(Loc,SourceMgr); 363 } 364 365 /// \brief Retrieve the attributes for the given declaration. 366 AttrVec& getDeclAttrs(const Decl *D); 367 368 /// \brief Erase the attributes corresponding to the given declaration. 369 void eraseDeclAttrs(const Decl *D); 370 371 /// \brief If this variable is an instantiated static data member of a 372 /// class template specialization, returns the templated static data member 373 /// from which it was instantiated. 374 MemberSpecializationInfo *getInstantiatedFromStaticDataMember( 375 const VarDecl *Var); 376 377 /// \brief Note that the static data member \p Inst is an instantiation of 378 /// the static data member template \p Tmpl of a class template. 379 void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl, 380 TemplateSpecializationKind TSK, 381 SourceLocation PointOfInstantiation = SourceLocation()); 382 383 /// \brief If the given using decl is an instantiation of a 384 /// (possibly unresolved) using decl from a template instantiation, 385 /// return it. 386 NamedDecl *getInstantiatedFromUsingDecl(UsingDecl *Inst); 387 388 /// \brief Remember that the using decl \p Inst is an instantiation 389 /// of the using decl \p Pattern of a class template. 390 void setInstantiatedFromUsingDecl(UsingDecl *Inst, NamedDecl *Pattern); 391 392 void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, 393 UsingShadowDecl *Pattern); 394 UsingShadowDecl *getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst); 395 396 FieldDecl *getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field); 397 398 void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl); 399 400 /// ZeroBitfieldFollowsNonBitfield - return 'true" if 'FD' is a zero-length 401 /// bitfield which follows the non-bitfield 'LastFD'. 402 bool ZeroBitfieldFollowsNonBitfield(const FieldDecl *FD, 403 const FieldDecl *LastFD) const; 404 405 // Access to the set of methods overridden by the given C++ method. 406 typedef CXXMethodVector::iterator overridden_cxx_method_iterator; 407 overridden_cxx_method_iterator 408 overridden_methods_begin(const CXXMethodDecl *Method) const; 409 410 overridden_cxx_method_iterator 411 overridden_methods_end(const CXXMethodDecl *Method) const; 412 413 unsigned overridden_methods_size(const CXXMethodDecl *Method) const; 414 415 /// \brief Note that the given C++ \p Method overrides the given \p 416 /// Overridden method. 417 void addOverriddenMethod(const CXXMethodDecl *Method, 418 const CXXMethodDecl *Overridden); 419 420 TranslationUnitDecl *getTranslationUnitDecl() const { return TUDecl; } 421 422 423 // Builtin Types. 424 CanQualType VoidTy; 425 CanQualType BoolTy; 426 CanQualType CharTy; 427 CanQualType WCharTy; // [C++ 3.9.1p5], integer type in C99. 428 CanQualType Char16Ty; // [C++0x 3.9.1p5], integer type in C99. 429 CanQualType Char32Ty; // [C++0x 3.9.1p5], integer type in C99. 430 CanQualType SignedCharTy, ShortTy, IntTy, LongTy, LongLongTy, Int128Ty; 431 CanQualType UnsignedCharTy, UnsignedShortTy, UnsignedIntTy, UnsignedLongTy; 432 CanQualType UnsignedLongLongTy, UnsignedInt128Ty; 433 CanQualType FloatTy, DoubleTy, LongDoubleTy; 434 CanQualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy; 435 CanQualType VoidPtrTy, NullPtrTy; 436 CanQualType DependentTy, OverloadTy, BoundMemberTy, UnknownAnyTy; 437 CanQualType ObjCBuiltinIdTy, ObjCBuiltinClassTy, ObjCBuiltinSelTy; 438 439 // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. 440 mutable QualType AutoDeductTy; // Deduction against 'auto'. 441 mutable QualType AutoRRefDeductTy; // Deduction against 'auto &&'. 442 443 ASTContext(const LangOptions& LOpts, SourceManager &SM, const TargetInfo &t, 444 IdentifierTable &idents, SelectorTable &sels, 445 Builtin::Context &builtins, 446 unsigned size_reserve); 447 448 ~ASTContext(); 449 450 /// \brief Attach an external AST source to the AST context. 451 /// 452 /// The external AST source provides the ability to load parts of 453 /// the abstract syntax tree as needed from some external storage, 454 /// e.g., a precompiled header. 455 void setExternalSource(llvm::OwningPtr<ExternalASTSource> &Source); 456 457 /// \brief Retrieve a pointer to the external AST source associated 458 /// with this AST context, if any. 459 ExternalASTSource *getExternalSource() const { return ExternalSource.get(); } 460 461 /// \brief Attach an AST mutation listener to the AST context. 462 /// 463 /// The AST mutation listener provides the ability to track modifications to 464 /// the abstract syntax tree entities committed after they were initially 465 /// created. 466 void setASTMutationListener(ASTMutationListener *Listener) { 467 this->Listener = Listener; 468 } 469 470 /// \brief Retrieve a pointer to the AST mutation listener associated 471 /// with this AST context, if any. 472 ASTMutationListener *getASTMutationListener() const { return Listener; } 473 474 void PrintStats() const; 475 const std::vector<Type*>& getTypes() const { return Types; } 476 477 //===--------------------------------------------------------------------===// 478 // Type Constructors 479 //===--------------------------------------------------------------------===// 480 481private: 482 /// getExtQualType - Return a type with extended qualifiers. 483 QualType getExtQualType(const Type *Base, Qualifiers Quals) const; 484 485 QualType getTypeDeclTypeSlow(const TypeDecl *Decl) const; 486 487public: 488 /// getAddSpaceQualType - Return the uniqued reference to the type for an 489 /// address space qualified type with the specified type and address space. 490 /// The resulting type has a union of the qualifiers from T and the address 491 /// space. If T already has an address space specifier, it is silently 492 /// replaced. 493 QualType getAddrSpaceQualType(QualType T, unsigned AddressSpace) const; 494 495 /// getObjCGCQualType - Returns the uniqued reference to the type for an 496 /// objc gc qualified type. The retulting type has a union of the qualifiers 497 /// from T and the gc attribute. 498 QualType getObjCGCQualType(QualType T, Qualifiers::GC gcAttr) const; 499 500 /// getRestrictType - Returns the uniqued reference to the type for a 501 /// 'restrict' qualified type. The resulting type has a union of the 502 /// qualifiers from T and 'restrict'. 503 QualType getRestrictType(QualType T) const { 504 return T.withFastQualifiers(Qualifiers::Restrict); 505 } 506 507 /// getVolatileType - Returns the uniqued reference to the type for a 508 /// 'volatile' qualified type. The resulting type has a union of the 509 /// qualifiers from T and 'volatile'. 510 QualType getVolatileType(QualType T) const { 511 return T.withFastQualifiers(Qualifiers::Volatile); 512 } 513 514 /// getConstType - Returns the uniqued reference to the type for a 515 /// 'const' qualified type. The resulting type has a union of the 516 /// qualifiers from T and 'const'. 517 /// 518 /// It can be reasonably expected that this will always be 519 /// equivalent to calling T.withConst(). 520 QualType getConstType(QualType T) const { return T.withConst(); } 521 522 /// adjustFunctionType - Change the ExtInfo on a function type. 523 const FunctionType *adjustFunctionType(const FunctionType *Fn, 524 FunctionType::ExtInfo EInfo); 525 526 /// getComplexType - Return the uniqued reference to the type for a complex 527 /// number with the specified element type. 528 QualType getComplexType(QualType T) const; 529 CanQualType getComplexType(CanQualType T) const { 530 return CanQualType::CreateUnsafe(getComplexType((QualType) T)); 531 } 532 533 /// getPointerType - Return the uniqued reference to the type for a pointer to 534 /// the specified type. 535 QualType getPointerType(QualType T) const; 536 CanQualType getPointerType(CanQualType T) const { 537 return CanQualType::CreateUnsafe(getPointerType((QualType) T)); 538 } 539 540 /// getBlockPointerType - Return the uniqued reference to the type for a block 541 /// of the specified type. 542 QualType getBlockPointerType(QualType T) const; 543 544 /// This gets the struct used to keep track of the descriptor for pointer to 545 /// blocks. 546 QualType getBlockDescriptorType() const; 547 548 // Set the type for a Block descriptor type. 549 void setBlockDescriptorType(QualType T); 550 /// Get the BlockDescriptorType type, or NULL if it hasn't yet been built. 551 QualType getRawBlockdescriptorType() { 552 if (BlockDescriptorType) 553 return getTagDeclType(BlockDescriptorType); 554 return QualType(); 555 } 556 557 /// This gets the struct used to keep track of the extended descriptor for 558 /// pointer to blocks. 559 QualType getBlockDescriptorExtendedType() const; 560 561 // Set the type for a Block descriptor extended type. 562 void setBlockDescriptorExtendedType(QualType T); 563 /// Get the BlockDescriptorExtendedType type, or NULL if it hasn't yet been 564 /// built. 565 QualType getRawBlockdescriptorExtendedType() const { 566 if (BlockDescriptorExtendedType) 567 return getTagDeclType(BlockDescriptorExtendedType); 568 return QualType(); 569 } 570 571 void setcudaConfigureCallDecl(FunctionDecl *FD) { 572 cudaConfigureCallDecl = FD; 573 } 574 FunctionDecl *getcudaConfigureCallDecl() { 575 return cudaConfigureCallDecl; 576 } 577 578 /// This builds the struct used for __block variables. 579 QualType BuildByRefType(llvm::StringRef DeclName, QualType Ty) const; 580 581 /// Returns true iff we need copy/dispose helpers for the given type. 582 bool BlockRequiresCopying(QualType Ty) const; 583 584 /// getLValueReferenceType - Return the uniqued reference to the type for an 585 /// lvalue reference to the specified type. 586 QualType getLValueReferenceType(QualType T, bool SpelledAsLValue = true) 587 const; 588 589 /// getRValueReferenceType - Return the uniqued reference to the type for an 590 /// rvalue reference to the specified type. 591 QualType getRValueReferenceType(QualType T) const; 592 593 /// getMemberPointerType - Return the uniqued reference to the type for a 594 /// member pointer to the specified type in the specified class. The class 595 /// is a Type because it could be a dependent name. 596 QualType getMemberPointerType(QualType T, const Type *Cls) const; 597 598 /// getVariableArrayType - Returns a non-unique reference to the type for a 599 /// variable array of the specified element type. 600 QualType getVariableArrayType(QualType EltTy, Expr *NumElts, 601 ArrayType::ArraySizeModifier ASM, 602 unsigned IndexTypeQuals, 603 SourceRange Brackets) const; 604 605 /// getDependentSizedArrayType - Returns a non-unique reference to 606 /// the type for a dependently-sized array of the specified element 607 /// type. FIXME: We will need these to be uniqued, or at least 608 /// comparable, at some point. 609 QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, 610 ArrayType::ArraySizeModifier ASM, 611 unsigned IndexTypeQuals, 612 SourceRange Brackets) const; 613 614 /// getIncompleteArrayType - Returns a unique reference to the type for a 615 /// incomplete array of the specified element type. 616 QualType getIncompleteArrayType(QualType EltTy, 617 ArrayType::ArraySizeModifier ASM, 618 unsigned IndexTypeQuals) const; 619 620 /// getConstantArrayType - Return the unique reference to the type for a 621 /// constant array of the specified element type. 622 QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, 623 ArrayType::ArraySizeModifier ASM, 624 unsigned IndexTypeQuals) const; 625 626 /// getVariableArrayDecayedType - Returns a vla type where known sizes 627 /// are replaced with [*]. 628 QualType getVariableArrayDecayedType(QualType Ty) const; 629 630 /// getVectorType - Return the unique reference to a vector type of 631 /// the specified element type and size. VectorType must be a built-in type. 632 QualType getVectorType(QualType VectorType, unsigned NumElts, 633 VectorType::VectorKind VecKind) const; 634 635 /// getExtVectorType - Return the unique reference to an extended vector type 636 /// of the specified element type and size. VectorType must be a built-in 637 /// type. 638 QualType getExtVectorType(QualType VectorType, unsigned NumElts) const; 639 640 /// getDependentSizedExtVectorType - Returns a non-unique reference to 641 /// the type for a dependently-sized vector of the specified element 642 /// type. FIXME: We will need these to be uniqued, or at least 643 /// comparable, at some point. 644 QualType getDependentSizedExtVectorType(QualType VectorType, 645 Expr *SizeExpr, 646 SourceLocation AttrLoc) const; 647 648 /// getFunctionNoProtoType - Return a K&R style C function type like 'int()'. 649 /// 650 QualType getFunctionNoProtoType(QualType ResultTy, 651 const FunctionType::ExtInfo &Info) const; 652 653 QualType getFunctionNoProtoType(QualType ResultTy) const { 654 return getFunctionNoProtoType(ResultTy, FunctionType::ExtInfo()); 655 } 656 657 /// getFunctionType - Return a normal function type with a typed 658 /// argument list. 659 QualType getFunctionType(QualType ResultTy, 660 const QualType *Args, unsigned NumArgs, 661 const FunctionProtoType::ExtProtoInfo &EPI) const; 662 663 /// getTypeDeclType - Return the unique reference to the type for 664 /// the specified type declaration. 665 QualType getTypeDeclType(const TypeDecl *Decl, 666 const TypeDecl *PrevDecl = 0) const { 667 assert(Decl && "Passed null for Decl param"); 668 if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0); 669 670 if (PrevDecl) { 671 assert(PrevDecl->TypeForDecl && "previous decl has no TypeForDecl"); 672 Decl->TypeForDecl = PrevDecl->TypeForDecl; 673 return QualType(PrevDecl->TypeForDecl, 0); 674 } 675 676 return getTypeDeclTypeSlow(Decl); 677 } 678 679 /// getTypedefType - Return the unique reference to the type for the 680 /// specified typedef-name decl. 681 QualType getTypedefType(const TypedefNameDecl *Decl, 682 QualType Canon = QualType()) const; 683 684 QualType getRecordType(const RecordDecl *Decl) const; 685 686 QualType getEnumType(const EnumDecl *Decl) const; 687 688 QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const; 689 690 QualType getAttributedType(AttributedType::Kind attrKind, 691 QualType modifiedType, 692 QualType equivalentType); 693 694 QualType getSubstTemplateTypeParmType(const TemplateTypeParmType *Replaced, 695 QualType Replacement) const; 696 QualType getSubstTemplateTypeParmPackType( 697 const TemplateTypeParmType *Replaced, 698 const TemplateArgument &ArgPack); 699 700 QualType getTemplateTypeParmType(unsigned Depth, unsigned Index, 701 bool ParameterPack, 702 TemplateTypeParmDecl *ParmDecl = 0) const; 703 704 QualType getTemplateSpecializationType(TemplateName T, 705 const TemplateArgument *Args, 706 unsigned NumArgs, 707 QualType Canon = QualType()) const; 708 709 QualType getCanonicalTemplateSpecializationType(TemplateName T, 710 const TemplateArgument *Args, 711 unsigned NumArgs) const; 712 713 QualType getTemplateSpecializationType(TemplateName T, 714 const TemplateArgumentListInfo &Args, 715 QualType Canon = QualType()) const; 716 717 TypeSourceInfo * 718 getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc, 719 const TemplateArgumentListInfo &Args, 720 QualType Canon = QualType()) const; 721 722 QualType getParenType(QualType NamedType) const; 723 724 QualType getElaboratedType(ElaboratedTypeKeyword Keyword, 725 NestedNameSpecifier *NNS, 726 QualType NamedType) const; 727 QualType getDependentNameType(ElaboratedTypeKeyword Keyword, 728 NestedNameSpecifier *NNS, 729 const IdentifierInfo *Name, 730 QualType Canon = QualType()) const; 731 732 QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, 733 NestedNameSpecifier *NNS, 734 const IdentifierInfo *Name, 735 const TemplateArgumentListInfo &Args) const; 736 QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, 737 NestedNameSpecifier *NNS, 738 const IdentifierInfo *Name, 739 unsigned NumArgs, 740 const TemplateArgument *Args) const; 741 742 QualType getPackExpansionType(QualType Pattern, 743 llvm::Optional<unsigned> NumExpansions); 744 745 QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl) const; 746 747 QualType getObjCObjectType(QualType Base, 748 ObjCProtocolDecl * const *Protocols, 749 unsigned NumProtocols) const; 750 751 /// getObjCObjectPointerType - Return a ObjCObjectPointerType type 752 /// for the given ObjCObjectType. 753 QualType getObjCObjectPointerType(QualType OIT) const; 754 755 /// getTypeOfType - GCC extension. 756 QualType getTypeOfExprType(Expr *e) const; 757 QualType getTypeOfType(QualType t) const; 758 759 /// getDecltypeType - C++0x decltype. 760 QualType getDecltypeType(Expr *e) const; 761 762 /// getAutoType - C++0x deduced auto type. 763 QualType getAutoType(QualType DeducedType) const; 764 765 /// getAutoDeductType - C++0x deduction pattern for 'auto' type. 766 QualType getAutoDeductType() const; 767 768 /// getAutoRRefDeductType - C++0x deduction pattern for 'auto &&' type. 769 QualType getAutoRRefDeductType() const; 770 771 /// getTagDeclType - Return the unique reference to the type for the 772 /// specified TagDecl (struct/union/class/enum) decl. 773 QualType getTagDeclType(const TagDecl *Decl) const; 774 775 /// getSizeType - Return the unique type for "size_t" (C99 7.17), defined 776 /// in <stddef.h>. The sizeof operator requires this (C99 6.5.3.4p4). 777 CanQualType getSizeType() const; 778 779 /// getWCharType - In C++, this returns the unique wchar_t type. In C99, this 780 /// returns a type compatible with the type defined in <stddef.h> as defined 781 /// by the target. 782 QualType getWCharType() const { return WCharTy; } 783 784 /// getSignedWCharType - Return the type of "signed wchar_t". 785 /// Used when in C++, as a GCC extension. 786 QualType getSignedWCharType() const; 787 788 /// getUnsignedWCharType - Return the type of "unsigned wchar_t". 789 /// Used when in C++, as a GCC extension. 790 QualType getUnsignedWCharType() const; 791 792 /// getPointerDiffType - Return the unique type for "ptrdiff_t" (ref?) 793 /// defined in <stddef.h>. Pointer - pointer requires this (C99 6.5.6p9). 794 QualType getPointerDiffType() const; 795 796 // getCFConstantStringType - Return the C structure type used to represent 797 // constant CFStrings. 798 QualType getCFConstantStringType() const; 799 800 // getNSConstantStringType - Return the C structure type used to represent 801 // constant NSStrings. 802 QualType getNSConstantStringType() const; 803 /// Get the structure type used to representation NSStrings, or NULL 804 /// if it hasn't yet been built. 805 QualType getRawNSConstantStringType() const { 806 if (NSConstantStringTypeDecl) 807 return getTagDeclType(NSConstantStringTypeDecl); 808 return QualType(); 809 } 810 void setNSConstantStringType(QualType T); 811 812 813 /// Get the structure type used to representation CFStrings, or NULL 814 /// if it hasn't yet been built. 815 QualType getRawCFConstantStringType() const { 816 if (CFConstantStringTypeDecl) 817 return getTagDeclType(CFConstantStringTypeDecl); 818 return QualType(); 819 } 820 void setCFConstantStringType(QualType T); 821 822 // This setter/getter represents the ObjC type for an NSConstantString. 823 void setObjCConstantStringInterface(ObjCInterfaceDecl *Decl); 824 QualType getObjCConstantStringInterface() const { 825 return ObjCConstantStringType; 826 } 827 828 //// This gets the struct used to keep track of fast enumerations. 829 QualType getObjCFastEnumerationStateType() const; 830 831 /// Get the ObjCFastEnumerationState type, or NULL if it hasn't yet 832 /// been built. 833 QualType getRawObjCFastEnumerationStateType() const { 834 if (ObjCFastEnumerationStateTypeDecl) 835 return getTagDeclType(ObjCFastEnumerationStateTypeDecl); 836 return QualType(); 837 } 838 839 void setObjCFastEnumerationStateType(QualType T); 840 841 /// \brief Set the type for the C FILE type. 842 void setFILEDecl(TypeDecl *FILEDecl) { this->FILEDecl = FILEDecl; } 843 844 /// \brief Retrieve the C FILE type. 845 QualType getFILEType() const { 846 if (FILEDecl) 847 return getTypeDeclType(FILEDecl); 848 return QualType(); 849 } 850 851 /// \brief Set the type for the C jmp_buf type. 852 void setjmp_bufDecl(TypeDecl *jmp_bufDecl) { 853 this->jmp_bufDecl = jmp_bufDecl; 854 } 855 856 /// \brief Retrieve the C jmp_buf type. 857 QualType getjmp_bufType() const { 858 if (jmp_bufDecl) 859 return getTypeDeclType(jmp_bufDecl); 860 return QualType(); 861 } 862 863 /// \brief Set the type for the C sigjmp_buf type. 864 void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl) { 865 this->sigjmp_bufDecl = sigjmp_bufDecl; 866 } 867 868 /// \brief Retrieve the C sigjmp_buf type. 869 QualType getsigjmp_bufType() const { 870 if (sigjmp_bufDecl) 871 return getTypeDeclType(sigjmp_bufDecl); 872 return QualType(); 873 } 874 875 /// \brief The result type of logical operations, '<', '>', '!=', etc. 876 QualType getLogicalOperationType() const { 877 return getLangOptions().CPlusPlus ? BoolTy : IntTy; 878 } 879 880 /// getObjCEncodingForType - Emit the ObjC type encoding for the 881 /// given type into \arg S. If \arg NameFields is specified then 882 /// record field names are also encoded. 883 void getObjCEncodingForType(QualType t, std::string &S, 884 const FieldDecl *Field=0) const; 885 886 void getLegacyIntegralTypeEncoding(QualType &t) const; 887 888 // Put the string version of type qualifiers into S. 889 void getObjCEncodingForTypeQualifier(Decl::ObjCDeclQualifier QT, 890 std::string &S) const; 891 892 /// getObjCEncodingForFunctionDecl - Returns the encoded type for this 893 //function. This is in the same format as Objective-C method encodings. 894 void getObjCEncodingForFunctionDecl(const FunctionDecl *Decl, std::string& S); 895 896 /// getObjCEncodingForMethodDecl - Return the encoded type for this method 897 /// declaration. 898 void getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl, std::string &S) 899 const; 900 901 /// getObjCEncodingForBlock - Return the encoded type for this block 902 /// declaration. 903 std::string getObjCEncodingForBlock(const BlockExpr *blockExpr) const; 904 905 /// getObjCEncodingForPropertyDecl - Return the encoded type for 906 /// this method declaration. If non-NULL, Container must be either 907 /// an ObjCCategoryImplDecl or ObjCImplementationDecl; it should 908 /// only be NULL when getting encodings for protocol properties. 909 void getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD, 910 const Decl *Container, 911 std::string &S) const; 912 913 bool ProtocolCompatibleWithProtocol(ObjCProtocolDecl *lProto, 914 ObjCProtocolDecl *rProto) const; 915 916 /// getObjCEncodingTypeSize returns size of type for objective-c encoding 917 /// purpose in characters. 918 CharUnits getObjCEncodingTypeSize(QualType t) const; 919 920 /// \brief Whether __[u]int128_t identifier is installed. 921 bool isInt128Installed() const { return IsInt128Installed; } 922 void setInt128Installed() { IsInt128Installed = true; } 923 924 /// This setter/getter represents the ObjC 'id' type. It is setup lazily, by 925 /// Sema. id is always a (typedef for a) pointer type, a pointer to a struct. 926 QualType getObjCIdType() const { return ObjCIdTypedefType; } 927 void setObjCIdType(QualType T); 928 929 void setObjCSelType(QualType T); 930 QualType getObjCSelType() const { return ObjCSelTypedefType; } 931 932 void setObjCProtoType(QualType QT); 933 QualType getObjCProtoType() const { return ObjCProtoType; } 934 935 /// This setter/getter repreents the ObjC 'Class' type. It is setup lazily, by 936 /// Sema. 'Class' is always a (typedef for a) pointer type, a pointer to a 937 /// struct. 938 QualType getObjCClassType() const { return ObjCClassTypedefType; } 939 void setObjCClassType(QualType T); 940 941 void setBuiltinVaListType(QualType T); 942 QualType getBuiltinVaListType() const { return BuiltinVaListType; } 943 944 /// getCVRQualifiedType - Returns a type with additional const, 945 /// volatile, or restrict qualifiers. 946 QualType getCVRQualifiedType(QualType T, unsigned CVR) const { 947 return getQualifiedType(T, Qualifiers::fromCVRMask(CVR)); 948 } 949 950 /// getQualifiedType - Returns a type with additional qualifiers. 951 QualType getQualifiedType(QualType T, Qualifiers Qs) const { 952 if (!Qs.hasNonFastQualifiers()) 953 return T.withFastQualifiers(Qs.getFastQualifiers()); 954 QualifierCollector Qc(Qs); 955 const Type *Ptr = Qc.strip(T); 956 return getExtQualType(Ptr, Qc); 957 } 958 959 /// getQualifiedType - Returns a type with additional qualifiers. 960 QualType getQualifiedType(const Type *T, Qualifiers Qs) const { 961 if (!Qs.hasNonFastQualifiers()) 962 return QualType(T, Qs.getFastQualifiers()); 963 return getExtQualType(T, Qs); 964 } 965 966 DeclarationNameInfo getNameForTemplate(TemplateName Name, 967 SourceLocation NameLoc) const; 968 969 TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, 970 UnresolvedSetIterator End) const; 971 972 TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, 973 bool TemplateKeyword, 974 TemplateDecl *Template) const; 975 976 TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, 977 const IdentifierInfo *Name) const; 978 TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, 979 OverloadedOperatorKind Operator) const; 980 TemplateName getSubstTemplateTemplateParmPack(TemplateTemplateParmDecl *Param, 981 const TemplateArgument &ArgPack) const; 982 983 enum GetBuiltinTypeError { 984 GE_None, //< No error 985 GE_Missing_stdio, //< Missing a type from <stdio.h> 986 GE_Missing_setjmp //< Missing a type from <setjmp.h> 987 }; 988 989 /// GetBuiltinType - Return the type for the specified builtin. If 990 /// IntegerConstantArgs is non-null, it is filled in with a bitmask of 991 /// arguments to the builtin that are required to be integer constant 992 /// expressions. 993 QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, 994 unsigned *IntegerConstantArgs = 0) const; 995 996private: 997 CanQualType getFromTargetType(unsigned Type) const; 998 999 //===--------------------------------------------------------------------===// 1000 // Type Predicates. 1001 //===--------------------------------------------------------------------===// 1002 1003public: 1004 /// getObjCGCAttr - Returns one of GCNone, Weak or Strong objc's 1005 /// garbage collection attribute. 1006 /// 1007 Qualifiers::GC getObjCGCAttrKind(QualType Ty) const; 1008 1009 /// areCompatibleVectorTypes - Return true if the given vector types 1010 /// are of the same unqualified type or if they are equivalent to the same 1011 /// GCC vector type, ignoring whether they are target-specific (AltiVec or 1012 /// Neon) types. 1013 bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec); 1014 1015 /// isObjCNSObjectType - Return true if this is an NSObject object with 1016 /// its NSObject attribute set. 1017 bool isObjCNSObjectType(QualType Ty) const; 1018 1019 //===--------------------------------------------------------------------===// 1020 // Type Sizing and Analysis 1021 //===--------------------------------------------------------------------===// 1022 1023 /// getFloatTypeSemantics - Return the APFloat 'semantics' for the specified 1024 /// scalar floating point type. 1025 const llvm::fltSemantics &getFloatTypeSemantics(QualType T) const; 1026 1027 /// getTypeInfo - Get the size and alignment of the specified complete type in 1028 /// bits. 1029 std::pair<uint64_t, unsigned> getTypeInfo(const Type *T) const; 1030 std::pair<uint64_t, unsigned> getTypeInfo(QualType T) const { 1031 return getTypeInfo(T.getTypePtr()); 1032 } 1033 1034 /// getTypeSize - Return the size of the specified type, in bits. This method 1035 /// does not work on incomplete types. 1036 uint64_t getTypeSize(QualType T) const { 1037 return getTypeInfo(T).first; 1038 } 1039 uint64_t getTypeSize(const Type *T) const { 1040 return getTypeInfo(T).first; 1041 } 1042 1043 /// getCharWidth - Return the size of the character type, in bits 1044 uint64_t getCharWidth() const { 1045 return getTypeSize(CharTy); 1046 } 1047 1048 /// toCharUnitsFromBits - Convert a size in bits to a size in characters. 1049 CharUnits toCharUnitsFromBits(int64_t BitSize) const; 1050 1051 /// toBits - Convert a size in characters to a size in bits. 1052 int64_t toBits(CharUnits CharSize) const; 1053 1054 /// getTypeSizeInChars - Return the size of the specified type, in characters. 1055 /// This method does not work on incomplete types. 1056 CharUnits getTypeSizeInChars(QualType T) const; 1057 CharUnits getTypeSizeInChars(const Type *T) const; 1058 1059 /// getTypeAlign - Return the ABI-specified alignment of a type, in bits. 1060 /// This method does not work on incomplete types. 1061 unsigned getTypeAlign(QualType T) const { 1062 return getTypeInfo(T).second; 1063 } 1064 unsigned getTypeAlign(const Type *T) const { 1065 return getTypeInfo(T).second; 1066 } 1067 1068 /// getTypeAlignInChars - Return the ABI-specified alignment of a type, in 1069 /// characters. This method does not work on incomplete types. 1070 CharUnits getTypeAlignInChars(QualType T) const; 1071 CharUnits getTypeAlignInChars(const Type *T) const; 1072 1073 std::pair<CharUnits, CharUnits> getTypeInfoInChars(const Type *T) const; 1074 std::pair<CharUnits, CharUnits> getTypeInfoInChars(QualType T) const; 1075 1076 /// getPreferredTypeAlign - Return the "preferred" alignment of the specified 1077 /// type for the current target in bits. This can be different than the ABI 1078 /// alignment in cases where it is beneficial for performance to overalign 1079 /// a data type. 1080 unsigned getPreferredTypeAlign(const Type *T) const; 1081 1082 /// getDeclAlign - Return a conservative estimate of the alignment of 1083 /// the specified decl. Note that bitfields do not have a valid alignment, so 1084 /// this method will assert on them. 1085 /// If @p RefAsPointee, references are treated like their underlying type 1086 /// (for alignof), else they're treated like pointers (for CodeGen). 1087 CharUnits getDeclAlign(const Decl *D, bool RefAsPointee = false) const; 1088 1089 /// getASTRecordLayout - Get or compute information about the layout of the 1090 /// specified record (struct/union/class), which indicates its size and field 1091 /// position information. 1092 const ASTRecordLayout &getASTRecordLayout(const RecordDecl *D) const; 1093 1094 /// getASTObjCInterfaceLayout - Get or compute information about the 1095 /// layout of the specified Objective-C interface. 1096 const ASTRecordLayout &getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) 1097 const; 1098 1099 void DumpRecordLayout(const RecordDecl *RD, llvm::raw_ostream &OS) const; 1100 1101 /// getASTObjCImplementationLayout - Get or compute information about 1102 /// the layout of the specified Objective-C implementation. This may 1103 /// differ from the interface if synthesized ivars are present. 1104 const ASTRecordLayout & 1105 getASTObjCImplementationLayout(const ObjCImplementationDecl *D) const; 1106 1107 /// getKeyFunction - Get the key function for the given record decl, or NULL 1108 /// if there isn't one. The key function is, according to the Itanium C++ ABI 1109 /// section 5.2.3: 1110 /// 1111 /// ...the first non-pure virtual function that is not inline at the point 1112 /// of class definition. 1113 const CXXMethodDecl *getKeyFunction(const CXXRecordDecl *RD); 1114 1115 bool isNearlyEmpty(const CXXRecordDecl *RD) const; 1116 1117 MangleContext *createMangleContext(); 1118 1119 void ShallowCollectObjCIvars(const ObjCInterfaceDecl *OI, 1120 llvm::SmallVectorImpl<ObjCIvarDecl*> &Ivars) 1121 const; 1122 1123 void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass, 1124 llvm::SmallVectorImpl<ObjCIvarDecl*> &Ivars) const; 1125 1126 unsigned CountNonClassIvars(const ObjCInterfaceDecl *OI) const; 1127 void CollectInheritedProtocols(const Decl *CDecl, 1128 llvm::SmallPtrSet<ObjCProtocolDecl*, 8> &Protocols); 1129 1130 //===--------------------------------------------------------------------===// 1131 // Type Operators 1132 //===--------------------------------------------------------------------===// 1133 1134 /// getCanonicalType - Return the canonical (structural) type corresponding to 1135 /// the specified potentially non-canonical type. The non-canonical version 1136 /// of a type may have many "decorated" versions of types. Decorators can 1137 /// include typedefs, 'typeof' operators, etc. The returned type is guaranteed 1138 /// to be free of any of these, allowing two canonical types to be compared 1139 /// for exact equality with a simple pointer comparison. 1140 CanQualType getCanonicalType(QualType T) const { 1141 return CanQualType::CreateUnsafe(T.getCanonicalType()); 1142 } 1143 1144 const Type *getCanonicalType(const Type *T) const { 1145 return T->getCanonicalTypeInternal().getTypePtr(); 1146 } 1147 1148 /// getCanonicalParamType - Return the canonical parameter type 1149 /// corresponding to the specific potentially non-canonical one. 1150 /// Qualifiers are stripped off, functions are turned into function 1151 /// pointers, and arrays decay one level into pointers. 1152 CanQualType getCanonicalParamType(QualType T) const; 1153 1154 /// \brief Determine whether the given types are equivalent. 1155 bool hasSameType(QualType T1, QualType T2) { 1156 return getCanonicalType(T1) == getCanonicalType(T2); 1157 } 1158 1159 /// \brief Returns this type as a completely-unqualified array type, 1160 /// capturing the qualifiers in Quals. This will remove the minimal amount of 1161 /// sugaring from the types, similar to the behavior of 1162 /// QualType::getUnqualifiedType(). 1163 /// 1164 /// \param T is the qualified type, which may be an ArrayType 1165 /// 1166 /// \param Quals will receive the full set of qualifiers that were 1167 /// applied to the array. 1168 /// 1169 /// \returns if this is an array type, the completely unqualified array type 1170 /// that corresponds to it. Otherwise, returns T.getUnqualifiedType(). 1171 QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals); 1172 1173 /// \brief Determine whether the given types are equivalent after 1174 /// cvr-qualifiers have been removed. 1175 bool hasSameUnqualifiedType(QualType T1, QualType T2) { 1176 return getCanonicalType(T1).getTypePtr() == 1177 getCanonicalType(T2).getTypePtr(); 1178 } 1179 1180 bool UnwrapSimilarPointerTypes(QualType &T1, QualType &T2); 1181 1182 /// \brief Retrieves the "canonical" nested name specifier for a 1183 /// given nested name specifier. 1184 /// 1185 /// The canonical nested name specifier is a nested name specifier 1186 /// that uniquely identifies a type or namespace within the type 1187 /// system. For example, given: 1188 /// 1189 /// \code 1190 /// namespace N { 1191 /// struct S { 1192 /// template<typename T> struct X { typename T* type; }; 1193 /// }; 1194 /// } 1195 /// 1196 /// template<typename T> struct Y { 1197 /// typename N::S::X<T>::type member; 1198 /// }; 1199 /// \endcode 1200 /// 1201 /// Here, the nested-name-specifier for N::S::X<T>:: will be 1202 /// S::X<template-param-0-0>, since 'S' and 'X' are uniquely defined 1203 /// by declarations in the type system and the canonical type for 1204 /// the template type parameter 'T' is template-param-0-0. 1205 NestedNameSpecifier * 1206 getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const; 1207 1208 /// \brief Retrieves the default calling convention to use for 1209 /// C++ instance methods. 1210 CallingConv getDefaultMethodCallConv(); 1211 1212 /// \brief Retrieves the canonical representation of the given 1213 /// calling convention. 1214 CallingConv getCanonicalCallConv(CallingConv CC) const { 1215 if (CC == CC_C) 1216 return CC_Default; 1217 return CC; 1218 } 1219 1220 /// \brief Determines whether two calling conventions name the same 1221 /// calling convention. 1222 bool isSameCallConv(CallingConv lcc, CallingConv rcc) { 1223 return (getCanonicalCallConv(lcc) == getCanonicalCallConv(rcc)); 1224 } 1225 1226 /// \brief Retrieves the "canonical" template name that refers to a 1227 /// given template. 1228 /// 1229 /// The canonical template name is the simplest expression that can 1230 /// be used to refer to a given template. For most templates, this 1231 /// expression is just the template declaration itself. For example, 1232 /// the template std::vector can be referred to via a variety of 1233 /// names---std::vector, ::std::vector, vector (if vector is in 1234 /// scope), etc.---but all of these names map down to the same 1235 /// TemplateDecl, which is used to form the canonical template name. 1236 /// 1237 /// Dependent template names are more interesting. Here, the 1238 /// template name could be something like T::template apply or 1239 /// std::allocator<T>::template rebind, where the nested name 1240 /// specifier itself is dependent. In this case, the canonical 1241 /// template name uses the shortest form of the dependent 1242 /// nested-name-specifier, which itself contains all canonical 1243 /// types, values, and templates. 1244 TemplateName getCanonicalTemplateName(TemplateName Name) const; 1245 1246 /// \brief Determine whether the given template names refer to the same 1247 /// template. 1248 bool hasSameTemplateName(TemplateName X, TemplateName Y); 1249 1250 /// \brief Retrieve the "canonical" template argument. 1251 /// 1252 /// The canonical template argument is the simplest template argument 1253 /// (which may be a type, value, expression, or declaration) that 1254 /// expresses the value of the argument. 1255 TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) 1256 const; 1257 1258 /// Type Query functions. If the type is an instance of the specified class, 1259 /// return the Type pointer for the underlying maximally pretty type. This 1260 /// is a member of ASTContext because this may need to do some amount of 1261 /// canonicalization, e.g. to move type qualifiers into the element type. 1262 const ArrayType *getAsArrayType(QualType T) const; 1263 const ConstantArrayType *getAsConstantArrayType(QualType T) const { 1264 return dyn_cast_or_null<ConstantArrayType>(getAsArrayType(T)); 1265 } 1266 const VariableArrayType *getAsVariableArrayType(QualType T) const { 1267 return dyn_cast_or_null<VariableArrayType>(getAsArrayType(T)); 1268 } 1269 const IncompleteArrayType *getAsIncompleteArrayType(QualType T) const { 1270 return dyn_cast_or_null<IncompleteArrayType>(getAsArrayType(T)); 1271 } 1272 const DependentSizedArrayType *getAsDependentSizedArrayType(QualType T) 1273 const { 1274 return dyn_cast_or_null<DependentSizedArrayType>(getAsArrayType(T)); 1275 } 1276 1277 /// getBaseElementType - Returns the innermost element type of an array type. 1278 /// For example, will return "int" for int[m][n] 1279 QualType getBaseElementType(const ArrayType *VAT) const; 1280 1281 /// getBaseElementType - Returns the innermost element type of a type 1282 /// (which needn't actually be an array type). 1283 QualType getBaseElementType(QualType QT) const; 1284 1285 /// getConstantArrayElementCount - Returns number of constant array elements. 1286 uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const; 1287 1288 /// getArrayDecayedType - Return the properly qualified result of decaying the 1289 /// specified array type to a pointer. This operation is non-trivial when 1290 /// handling typedefs etc. The canonical type of "T" must be an array type, 1291 /// this returns a pointer to a properly qualified element of the array. 1292 /// 1293 /// See C99 6.7.5.3p7 and C99 6.3.2.1p3. 1294 QualType getArrayDecayedType(QualType T) const; 1295 1296 /// getPromotedIntegerType - Returns the type that Promotable will 1297 /// promote to: C99 6.3.1.1p2, assuming that Promotable is a promotable 1298 /// integer type. 1299 QualType getPromotedIntegerType(QualType PromotableType) const; 1300 1301 /// \brief Whether this is a promotable bitfield reference according 1302 /// to C99 6.3.1.1p2, bullet 2 (and GCC extensions). 1303 /// 1304 /// \returns the type this bit-field will promote to, or NULL if no 1305 /// promotion occurs. 1306 QualType isPromotableBitField(Expr *E) const; 1307 1308 /// getIntegerTypeOrder - Returns the highest ranked integer type: 1309 /// C99 6.3.1.8p1. If LHS > RHS, return 1. If LHS == RHS, return 0. If 1310 /// LHS < RHS, return -1. 1311 int getIntegerTypeOrder(QualType LHS, QualType RHS) const; 1312 1313 /// getFloatingTypeOrder - Compare the rank of the two specified floating 1314 /// point types, ignoring the domain of the type (i.e. 'double' == 1315 /// '_Complex double'). If LHS > RHS, return 1. If LHS == RHS, return 0. If 1316 /// LHS < RHS, return -1. 1317 int getFloatingTypeOrder(QualType LHS, QualType RHS) const; 1318 1319 /// getFloatingTypeOfSizeWithinDomain - Returns a real floating 1320 /// point or a complex type (based on typeDomain/typeSize). 1321 /// 'typeDomain' is a real floating point or complex type. 1322 /// 'typeSize' is a real floating point or complex type. 1323 QualType getFloatingTypeOfSizeWithinDomain(QualType typeSize, 1324 QualType typeDomain) const; 1325 1326 unsigned getTargetAddressSpace(QualType T) const { 1327 return getTargetAddressSpace(T.getQualifiers()); 1328 } 1329 1330 unsigned getTargetAddressSpace(Qualifiers Q) const { 1331 return getTargetAddressSpace(Q.getAddressSpace()); 1332 } 1333 1334 unsigned getTargetAddressSpace(unsigned AS) const { 1335 if (AS < LangAS::Offset || AS >= LangAS::Offset + LangAS::Count) 1336 return AS; 1337 else 1338 return AddrSpaceMap[AS - LangAS::Offset]; 1339 } 1340 1341private: 1342 // Helper for integer ordering 1343 unsigned getIntegerRank(const Type *T) const; 1344 1345public: 1346 1347 //===--------------------------------------------------------------------===// 1348 // Type Compatibility Predicates 1349 //===--------------------------------------------------------------------===// 1350 1351 /// Compatibility predicates used to check assignment expressions. 1352 bool typesAreCompatible(QualType T1, QualType T2, 1353 bool CompareUnqualified = false); // C99 6.2.7p1 1354 1355 bool typesAreBlockPointerCompatible(QualType, QualType); 1356 1357 bool isObjCIdType(QualType T) const { 1358 return T == ObjCIdTypedefType; 1359 } 1360 bool isObjCClassType(QualType T) const { 1361 return T == ObjCClassTypedefType; 1362 } 1363 bool isObjCSelType(QualType T) const { 1364 return T == ObjCSelTypedefType; 1365 } 1366 bool QualifiedIdConformsQualifiedId(QualType LHS, QualType RHS); 1367 bool ObjCQualifiedIdTypesAreCompatible(QualType LHS, QualType RHS, 1368 bool ForCompare); 1369 1370 bool ObjCQualifiedClassTypesAreCompatible(QualType LHS, QualType RHS); 1371 1372 // Check the safety of assignment from LHS to RHS 1373 bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, 1374 const ObjCObjectPointerType *RHSOPT); 1375 bool canAssignObjCInterfaces(const ObjCObjectType *LHS, 1376 const ObjCObjectType *RHS); 1377 bool canAssignObjCInterfacesInBlockPointer( 1378 const ObjCObjectPointerType *LHSOPT, 1379 const ObjCObjectPointerType *RHSOPT, 1380 bool BlockReturnType); 1381 bool areComparableObjCPointerTypes(QualType LHS, QualType RHS); 1382 QualType areCommonBaseCompatible(const ObjCObjectPointerType *LHSOPT, 1383 const ObjCObjectPointerType *RHSOPT); 1384 bool canBindObjCObjectType(QualType To, QualType From); 1385 1386 // Functions for calculating composite types 1387 QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, 1388 bool Unqualified = false, bool BlockReturnType = false); 1389 QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer=false, 1390 bool Unqualified = false); 1391 QualType mergeFunctionArgumentTypes(QualType, QualType, 1392 bool OfBlockPointer=false, 1393 bool Unqualified = false); 1394 QualType mergeTransparentUnionType(QualType, QualType, 1395 bool OfBlockPointer=false, 1396 bool Unqualified = false); 1397 1398 QualType mergeObjCGCQualifiers(QualType, QualType); 1399 1400 void ResetObjCLayout(const ObjCContainerDecl *CD) { 1401 ObjCLayouts[CD] = 0; 1402 } 1403 1404 //===--------------------------------------------------------------------===// 1405 // Integer Predicates 1406 //===--------------------------------------------------------------------===// 1407 1408 // The width of an integer, as defined in C99 6.2.6.2. This is the number 1409 // of bits in an integer type excluding any padding bits. 1410 unsigned getIntWidth(QualType T) const; 1411 1412 // Per C99 6.2.5p6, for every signed integer type, there is a corresponding 1413 // unsigned integer type. This method takes a signed type, and returns the 1414 // corresponding unsigned integer type. 1415 QualType getCorrespondingUnsignedType(QualType T); 1416 1417 //===--------------------------------------------------------------------===// 1418 // Type Iterators. 1419 //===--------------------------------------------------------------------===// 1420 1421 typedef std::vector<Type*>::iterator type_iterator; 1422 typedef std::vector<Type*>::const_iterator const_type_iterator; 1423 1424 type_iterator types_begin() { return Types.begin(); } 1425 type_iterator types_end() { return Types.end(); } 1426 const_type_iterator types_begin() const { return Types.begin(); } 1427 const_type_iterator types_end() const { return Types.end(); } 1428 1429 //===--------------------------------------------------------------------===// 1430 // Integer Values 1431 //===--------------------------------------------------------------------===// 1432 1433 /// MakeIntValue - Make an APSInt of the appropriate width and 1434 /// signedness for the given \arg Value and integer \arg Type. 1435 llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const { 1436 llvm::APSInt Res(getIntWidth(Type), !Type->isSignedIntegerType()); 1437 Res = Value; 1438 return Res; 1439 } 1440 1441 /// \brief Get the implementation of ObjCInterfaceDecl,or NULL if none exists. 1442 ObjCImplementationDecl *getObjCImplementation(ObjCInterfaceDecl *D); 1443 /// \brief Get the implementation of ObjCCategoryDecl, or NULL if none exists. 1444 ObjCCategoryImplDecl *getObjCImplementation(ObjCCategoryDecl *D); 1445 1446 /// \brief returns true if there is at lease one @implementation in TU. 1447 bool AnyObjCImplementation() { 1448 return !ObjCImpls.empty(); 1449 } 1450 1451 /// \brief Set the implementation of ObjCInterfaceDecl. 1452 void setObjCImplementation(ObjCInterfaceDecl *IFaceD, 1453 ObjCImplementationDecl *ImplD); 1454 /// \brief Set the implementation of ObjCCategoryDecl. 1455 void setObjCImplementation(ObjCCategoryDecl *CatD, 1456 ObjCCategoryImplDecl *ImplD); 1457 1458 /// \brief Set the copy inialization expression of a block var decl. 1459 void setBlockVarCopyInits(VarDecl*VD, Expr* Init); 1460 /// \brief Get the copy initialization expression of VarDecl,or NULL if 1461 /// none exists. 1462 Expr *getBlockVarCopyInits(const VarDecl*VD); 1463 1464 /// \brief Allocate an uninitialized TypeSourceInfo. 1465 /// 1466 /// The caller should initialize the memory held by TypeSourceInfo using 1467 /// the TypeLoc wrappers. 1468 /// 1469 /// \param T the type that will be the basis for type source info. This type 1470 /// should refer to how the declarator was written in source code, not to 1471 /// what type semantic analysis resolved the declarator to. 1472 /// 1473 /// \param Size the size of the type info to create, or 0 if the size 1474 /// should be calculated based on the type. 1475 TypeSourceInfo *CreateTypeSourceInfo(QualType T, unsigned Size = 0) const; 1476 1477 /// \brief Allocate a TypeSourceInfo where all locations have been 1478 /// initialized to a given location, which defaults to the empty 1479 /// location. 1480 TypeSourceInfo * 1481 getTrivialTypeSourceInfo(QualType T, 1482 SourceLocation Loc = SourceLocation()) const; 1483 1484 TypeSourceInfo *getNullTypeSourceInfo() { return &NullTypeSourceInfo; } 1485 1486 /// \brief Add a deallocation callback that will be invoked when the 1487 /// ASTContext is destroyed. 1488 /// 1489 /// \brief Callback A callback function that will be invoked on destruction. 1490 /// 1491 /// \brief Data Pointer data that will be provided to the callback function 1492 /// when it is called. 1493 void AddDeallocation(void (*Callback)(void*), void *Data); 1494 1495 GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD); 1496 GVALinkage GetGVALinkageForVariable(const VarDecl *VD); 1497 1498 /// \brief Determines if the decl can be CodeGen'ed or deserialized from PCH 1499 /// lazily, only when used; this is only relevant for function or file scoped 1500 /// var definitions. 1501 /// 1502 /// \returns true if the function/var must be CodeGen'ed/deserialized even if 1503 /// it is not used. 1504 bool DeclMustBeEmitted(const Decl *D); 1505 1506 //===--------------------------------------------------------------------===// 1507 // Statistics 1508 //===--------------------------------------------------------------------===// 1509 1510 /// \brief The number of implicitly-declared default constructors. 1511 static unsigned NumImplicitDefaultConstructors; 1512 1513 /// \brief The number of implicitly-declared default constructors for 1514 /// which declarations were built. 1515 static unsigned NumImplicitDefaultConstructorsDeclared; 1516 1517 /// \brief The number of implicitly-declared copy constructors. 1518 static unsigned NumImplicitCopyConstructors; 1519 1520 /// \brief The number of implicitly-declared copy constructors for 1521 /// which declarations were built. 1522 static unsigned NumImplicitCopyConstructorsDeclared; 1523 1524 /// \brief The number of implicitly-declared copy assignment operators. 1525 static unsigned NumImplicitCopyAssignmentOperators; 1526 1527 /// \brief The number of implicitly-declared copy assignment operators for 1528 /// which declarations were built. 1529 static unsigned NumImplicitCopyAssignmentOperatorsDeclared; 1530 1531 /// \brief The number of implicitly-declared destructors. 1532 static unsigned NumImplicitDestructors; 1533 1534 /// \brief The number of implicitly-declared destructors for which 1535 /// declarations were built. 1536 static unsigned NumImplicitDestructorsDeclared; 1537 1538private: 1539 ASTContext(const ASTContext&); // DO NOT IMPLEMENT 1540 void operator=(const ASTContext&); // DO NOT IMPLEMENT 1541 1542 void InitBuiltinTypes(); 1543 void InitBuiltinType(CanQualType &R, BuiltinType::Kind K); 1544 1545 // Return the ObjC type encoding for a given type. 1546 void getObjCEncodingForTypeImpl(QualType t, std::string &S, 1547 bool ExpandPointedToStructures, 1548 bool ExpandStructures, 1549 const FieldDecl *Field, 1550 bool OutermostType = false, 1551 bool EncodingProperty = false) const; 1552 1553 const ASTRecordLayout & 1554 getObjCLayout(const ObjCInterfaceDecl *D, 1555 const ObjCImplementationDecl *Impl) const; 1556 1557private: 1558 /// \brief A set of deallocations that should be performed when the 1559 /// ASTContext is destroyed. 1560 llvm::SmallVector<std::pair<void (*)(void*), void *>, 16> Deallocations; 1561 1562 // FIXME: This currently contains the set of StoredDeclMaps used 1563 // by DeclContext objects. This probably should not be in ASTContext, 1564 // but we include it here so that ASTContext can quickly deallocate them. 1565 llvm::PointerIntPair<StoredDeclsMap*,1> LastSDM; 1566 1567 /// \brief A counter used to uniquely identify "blocks". 1568 mutable unsigned int UniqueBlockByRefTypeID; 1569 1570 friend class DeclContext; 1571 friend class DeclarationNameTable; 1572 void ReleaseDeclContextMaps(); 1573}; 1574 1575/// @brief Utility function for constructing a nullary selector. 1576static inline Selector GetNullarySelector(llvm::StringRef name, ASTContext& Ctx) { 1577 IdentifierInfo* II = &Ctx.Idents.get(name); 1578 return Ctx.Selectors.getSelector(0, &II); 1579} 1580 1581/// @brief Utility function for constructing an unary selector. 1582static inline Selector GetUnarySelector(llvm::StringRef name, ASTContext& Ctx) { 1583 IdentifierInfo* II = &Ctx.Idents.get(name); 1584 return Ctx.Selectors.getSelector(1, &II); 1585} 1586 1587} // end namespace clang 1588 1589// operator new and delete aren't allowed inside namespaces. 1590// The throw specifications are mandated by the standard. 1591/// @brief Placement new for using the ASTContext's allocator. 1592/// 1593/// This placement form of operator new uses the ASTContext's allocator for 1594/// obtaining memory. It is a non-throwing new, which means that it returns 1595/// null on error. (If that is what the allocator does. The current does, so if 1596/// this ever changes, this operator will have to be changed, too.) 1597/// Usage looks like this (assuming there's an ASTContext 'Context' in scope): 1598/// @code 1599/// // Default alignment (8) 1600/// IntegerLiteral *Ex = new (Context) IntegerLiteral(arguments); 1601/// // Specific alignment 1602/// IntegerLiteral *Ex2 = new (Context, 4) IntegerLiteral(arguments); 1603/// @endcode 1604/// Please note that you cannot use delete on the pointer; it must be 1605/// deallocated using an explicit destructor call followed by 1606/// @c Context.Deallocate(Ptr). 1607/// 1608/// @param Bytes The number of bytes to allocate. Calculated by the compiler. 1609/// @param C The ASTContext that provides the allocator. 1610/// @param Alignment The alignment of the allocated memory (if the underlying 1611/// allocator supports it). 1612/// @return The allocated memory. Could be NULL. 1613inline void *operator new(size_t Bytes, const clang::ASTContext &C, 1614 size_t Alignment) throw () { 1615 return C.Allocate(Bytes, Alignment); 1616} 1617/// @brief Placement delete companion to the new above. 1618/// 1619/// This operator is just a companion to the new above. There is no way of 1620/// invoking it directly; see the new operator for more details. This operator 1621/// is called implicitly by the compiler if a placement new expression using 1622/// the ASTContext throws in the object constructor. 1623inline void operator delete(void *Ptr, const clang::ASTContext &C, size_t) 1624 throw () { 1625 C.Deallocate(Ptr); 1626} 1627 1628/// This placement form of operator new[] uses the ASTContext's allocator for 1629/// obtaining memory. It is a non-throwing new[], which means that it returns 1630/// null on error. 1631/// Usage looks like this (assuming there's an ASTContext 'Context' in scope): 1632/// @code 1633/// // Default alignment (8) 1634/// char *data = new (Context) char[10]; 1635/// // Specific alignment 1636/// char *data = new (Context, 4) char[10]; 1637/// @endcode 1638/// Please note that you cannot use delete on the pointer; it must be 1639/// deallocated using an explicit destructor call followed by 1640/// @c Context.Deallocate(Ptr). 1641/// 1642/// @param Bytes The number of bytes to allocate. Calculated by the compiler. 1643/// @param C The ASTContext that provides the allocator. 1644/// @param Alignment The alignment of the allocated memory (if the underlying 1645/// allocator supports it). 1646/// @return The allocated memory. Could be NULL. 1647inline void *operator new[](size_t Bytes, const clang::ASTContext& C, 1648 size_t Alignment = 8) throw () { 1649 return C.Allocate(Bytes, Alignment); 1650} 1651 1652/// @brief Placement delete[] companion to the new[] above. 1653/// 1654/// This operator is just a companion to the new[] above. There is no way of 1655/// invoking it directly; see the new[] operator for more details. This operator 1656/// is called implicitly by the compiler if a placement new[] expression using 1657/// the ASTContext throws in the object constructor. 1658inline void operator delete[](void *Ptr, const clang::ASTContext &C, size_t) 1659 throw () { 1660 C.Deallocate(Ptr); 1661} 1662 1663#endif 1664