1 //===--- CodeGenModule.h - Per-Module state for LLVM CodeGen ----*- 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 is the internal per-translation-unit state used for llvm translation. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef CLANG_CODEGEN_CODEGENMODULE_H 15 #define CLANG_CODEGEN_CODEGENMODULE_H 16 17 #include "CGVTables.h" 18 #include "CodeGenTypes.h" 19 #include "clang/AST/Attr.h" 20 #include "clang/AST/DeclCXX.h" 21 #include "clang/AST/DeclObjC.h" 22 #include "clang/AST/GlobalDecl.h" 23 #include "clang/AST/Mangle.h" 24 #include "clang/Basic/ABI.h" 25 #include "clang/Basic/LangOptions.h" 26 #include "clang/Basic/Module.h" 27 #include "llvm/ADT/DenseMap.h" 28 #include "llvm/ADT/SetVector.h" 29 #include "llvm/ADT/SmallPtrSet.h" 30 #include "llvm/ADT/StringMap.h" 31 #include "llvm/IR/CallingConv.h" 32 #include "llvm/IR/Module.h" 33 #include "llvm/IR/ValueHandle.h" 34 #include "llvm/Transforms/Utils/SpecialCaseList.h" 35 36 namespace llvm { 37 class Module; 38 class Constant; 39 class ConstantInt; 40 class Function; 41 class GlobalValue; 42 class DataLayout; 43 class FunctionType; 44 class LLVMContext; 45 } 46 47 namespace clang { 48 class TargetCodeGenInfo; 49 class ASTContext; 50 class AtomicType; 51 class FunctionDecl; 52 class IdentifierInfo; 53 class ObjCMethodDecl; 54 class ObjCImplementationDecl; 55 class ObjCCategoryImplDecl; 56 class ObjCProtocolDecl; 57 class ObjCEncodeExpr; 58 class BlockExpr; 59 class CharUnits; 60 class Decl; 61 class Expr; 62 class Stmt; 63 class InitListExpr; 64 class StringLiteral; 65 class NamedDecl; 66 class ValueDecl; 67 class VarDecl; 68 class LangOptions; 69 class CodeGenOptions; 70 class DiagnosticsEngine; 71 class AnnotateAttr; 72 class CXXDestructorDecl; 73 class MangleBuffer; 74 class Module; 75 76 namespace CodeGen { 77 78 class CallArgList; 79 class CodeGenFunction; 80 class CodeGenTBAA; 81 class CGCXXABI; 82 class CGDebugInfo; 83 class CGObjCRuntime; 84 class CGOpenCLRuntime; 85 class CGCUDARuntime; 86 class BlockFieldFlags; 87 class FunctionArgList; 88 class PGOProfileData; 89 90 struct OrderGlobalInits { 91 unsigned int priority; 92 unsigned int lex_order; 93 OrderGlobalInits(unsigned int p, unsigned int l) 94 : priority(p), lex_order(l) {} 95 96 bool operator==(const OrderGlobalInits &RHS) const { 97 return priority == RHS.priority && 98 lex_order == RHS.lex_order; 99 } 100 101 bool operator<(const OrderGlobalInits &RHS) const { 102 return std::tie(priority, lex_order) < 103 std::tie(RHS.priority, RHS.lex_order); 104 } 105 }; 106 107 struct CodeGenTypeCache { 108 /// void 109 llvm::Type *VoidTy; 110 111 /// i8, i16, i32, and i64 112 llvm::IntegerType *Int8Ty, *Int16Ty, *Int32Ty, *Int64Ty; 113 /// float, double 114 llvm::Type *FloatTy, *DoubleTy; 115 116 /// int 117 llvm::IntegerType *IntTy; 118 119 /// intptr_t, size_t, and ptrdiff_t, which we assume are the same size. 120 union { 121 llvm::IntegerType *IntPtrTy; 122 llvm::IntegerType *SizeTy; 123 llvm::IntegerType *PtrDiffTy; 124 }; 125 126 /// void* in address space 0 127 union { 128 llvm::PointerType *VoidPtrTy; 129 llvm::PointerType *Int8PtrTy; 130 }; 131 132 /// void** in address space 0 133 union { 134 llvm::PointerType *VoidPtrPtrTy; 135 llvm::PointerType *Int8PtrPtrTy; 136 }; 137 138 /// The width of a pointer into the generic address space. 139 unsigned char PointerWidthInBits; 140 141 /// The size and alignment of a pointer into the generic address 142 /// space. 143 union { 144 unsigned char PointerAlignInBytes; 145 unsigned char PointerSizeInBytes; 146 unsigned char SizeSizeInBytes; // sizeof(size_t) 147 }; 148 149 llvm::CallingConv::ID RuntimeCC; 150 llvm::CallingConv::ID getRuntimeCC() const { 151 return RuntimeCC; 152 } 153 }; 154 155 struct RREntrypoints { 156 RREntrypoints() { memset(this, 0, sizeof(*this)); } 157 /// void objc_autoreleasePoolPop(void*); 158 llvm::Constant *objc_autoreleasePoolPop; 159 160 /// void *objc_autoreleasePoolPush(void); 161 llvm::Constant *objc_autoreleasePoolPush; 162 }; 163 164 struct ARCEntrypoints { 165 ARCEntrypoints() { memset(this, 0, sizeof(*this)); } 166 167 /// id objc_autorelease(id); 168 llvm::Constant *objc_autorelease; 169 170 /// id objc_autoreleaseReturnValue(id); 171 llvm::Constant *objc_autoreleaseReturnValue; 172 173 /// void objc_copyWeak(id *dest, id *src); 174 llvm::Constant *objc_copyWeak; 175 176 /// void objc_destroyWeak(id*); 177 llvm::Constant *objc_destroyWeak; 178 179 /// id objc_initWeak(id*, id); 180 llvm::Constant *objc_initWeak; 181 182 /// id objc_loadWeak(id*); 183 llvm::Constant *objc_loadWeak; 184 185 /// id objc_loadWeakRetained(id*); 186 llvm::Constant *objc_loadWeakRetained; 187 188 /// void objc_moveWeak(id *dest, id *src); 189 llvm::Constant *objc_moveWeak; 190 191 /// id objc_retain(id); 192 llvm::Constant *objc_retain; 193 194 /// id objc_retainAutorelease(id); 195 llvm::Constant *objc_retainAutorelease; 196 197 /// id objc_retainAutoreleaseReturnValue(id); 198 llvm::Constant *objc_retainAutoreleaseReturnValue; 199 200 /// id objc_retainAutoreleasedReturnValue(id); 201 llvm::Constant *objc_retainAutoreleasedReturnValue; 202 203 /// id objc_retainBlock(id); 204 llvm::Constant *objc_retainBlock; 205 206 /// void objc_release(id); 207 llvm::Constant *objc_release; 208 209 /// id objc_storeStrong(id*, id); 210 llvm::Constant *objc_storeStrong; 211 212 /// id objc_storeWeak(id*, id); 213 llvm::Constant *objc_storeWeak; 214 215 /// A void(void) inline asm to use to mark that the return value of 216 /// a call will be immediately retain. 217 llvm::InlineAsm *retainAutoreleasedReturnValueMarker; 218 219 /// void clang.arc.use(...); 220 llvm::Constant *clang_arc_use; 221 }; 222 223 /// This class records statistics on instrumentation based profiling. 224 struct InstrProfStats { 225 InstrProfStats() : Visited(0), Missing(0), Mismatched(0) {} 226 bool isOutOfDate() { return Missing || Mismatched; } 227 uint32_t Visited; 228 uint32_t Missing; 229 uint32_t Mismatched; 230 }; 231 232 /// CodeGenModule - This class organizes the cross-function state that is used 233 /// while generating LLVM code. 234 class CodeGenModule : public CodeGenTypeCache { 235 CodeGenModule(const CodeGenModule &) LLVM_DELETED_FUNCTION; 236 void operator=(const CodeGenModule &) LLVM_DELETED_FUNCTION; 237 238 typedef std::vector<std::pair<llvm::Constant*, int> > CtorList; 239 240 ASTContext &Context; 241 const LangOptions &LangOpts; 242 const CodeGenOptions &CodeGenOpts; 243 llvm::Module &TheModule; 244 DiagnosticsEngine &Diags; 245 const llvm::DataLayout &TheDataLayout; 246 const TargetInfo &Target; 247 std::unique_ptr<CGCXXABI> ABI; 248 llvm::LLVMContext &VMContext; 249 250 CodeGenTBAA *TBAA; 251 252 mutable const TargetCodeGenInfo *TheTargetCodeGenInfo; 253 254 // This should not be moved earlier, since its initialization depends on some 255 // of the previous reference members being already initialized and also checks 256 // if TheTargetCodeGenInfo is NULL 257 CodeGenTypes Types; 258 259 /// VTables - Holds information about C++ vtables. 260 CodeGenVTables VTables; 261 262 CGObjCRuntime* ObjCRuntime; 263 CGOpenCLRuntime* OpenCLRuntime; 264 CGCUDARuntime* CUDARuntime; 265 CGDebugInfo* DebugInfo; 266 ARCEntrypoints *ARCData; 267 llvm::MDNode *NoObjCARCExceptionsMetadata; 268 RREntrypoints *RRData; 269 PGOProfileData *PGOData; 270 InstrProfStats PGOStats; 271 272 // WeakRefReferences - A set of references that have only been seen via 273 // a weakref so far. This is used to remove the weak of the reference if we 274 // ever see a direct reference or a definition. 275 llvm::SmallPtrSet<llvm::GlobalValue*, 10> WeakRefReferences; 276 277 /// DeferredDecls - This contains all the decls which have definitions but 278 /// which are deferred for emission and therefore should only be output if 279 /// they are actually used. If a decl is in this, then it is known to have 280 /// not been referenced yet. 281 llvm::StringMap<GlobalDecl> DeferredDecls; 282 283 /// DeferredDeclsToEmit - This is a list of deferred decls which we have seen 284 /// that *are* actually referenced. These get code generated when the module 285 /// is done. 286 struct DeferredGlobal { 287 DeferredGlobal(llvm::GlobalValue *GV, GlobalDecl GD) : GV(GV), GD(GD) {} 288 llvm::AssertingVH<llvm::GlobalValue> GV; 289 GlobalDecl GD; 290 }; 291 std::vector<DeferredGlobal> DeferredDeclsToEmit; 292 void addDeferredDeclToEmit(llvm::GlobalValue *GV, GlobalDecl GD) { 293 DeferredDeclsToEmit.push_back(DeferredGlobal(GV, GD)); 294 } 295 296 /// List of alias we have emitted. Used to make sure that what they point to 297 /// is defined once we get to the end of the of the translation unit. 298 std::vector<GlobalDecl> Aliases; 299 300 typedef llvm::StringMap<llvm::TrackingVH<llvm::Constant> > ReplacementsTy; 301 ReplacementsTy Replacements; 302 303 /// DeferredVTables - A queue of (optional) vtables to consider emitting. 304 std::vector<const CXXRecordDecl*> DeferredVTables; 305 306 /// LLVMUsed - List of global values which are required to be 307 /// present in the object file; bitcast to i8*. This is used for 308 /// forcing visibility of symbols which may otherwise be optimized 309 /// out. 310 std::vector<llvm::WeakVH> LLVMUsed; 311 std::vector<llvm::WeakVH> LLVMCompilerUsed; 312 313 /// GlobalCtors - Store the list of global constructors and their respective 314 /// priorities to be emitted when the translation unit is complete. 315 CtorList GlobalCtors; 316 317 /// GlobalDtors - Store the list of global destructors and their respective 318 /// priorities to be emitted when the translation unit is complete. 319 CtorList GlobalDtors; 320 321 /// MangledDeclNames - A map of canonical GlobalDecls to their mangled names. 322 llvm::DenseMap<GlobalDecl, StringRef> MangledDeclNames; 323 llvm::BumpPtrAllocator MangledNamesAllocator; 324 325 /// Global annotations. 326 std::vector<llvm::Constant*> Annotations; 327 328 /// Map used to get unique annotation strings. 329 llvm::StringMap<llvm::Constant*> AnnotationStrings; 330 331 llvm::StringMap<llvm::Constant*> CFConstantStringMap; 332 333 llvm::StringMap<llvm::GlobalVariable *> Constant1ByteStringMap; 334 llvm::StringMap<llvm::GlobalVariable *> Constant2ByteStringMap; 335 llvm::StringMap<llvm::GlobalVariable *> Constant4ByteStringMap; 336 llvm::DenseMap<const Decl*, llvm::Constant *> StaticLocalDeclMap; 337 llvm::DenseMap<const Decl*, llvm::GlobalVariable*> StaticLocalDeclGuardMap; 338 llvm::DenseMap<const Expr*, llvm::Constant *> MaterializedGlobalTemporaryMap; 339 340 llvm::DenseMap<QualType, llvm::Constant *> AtomicSetterHelperFnMap; 341 llvm::DenseMap<QualType, llvm::Constant *> AtomicGetterHelperFnMap; 342 343 /// Map used to get unique type descriptor constants for sanitizers. 344 llvm::DenseMap<QualType, llvm::Constant *> TypeDescriptorMap; 345 346 /// Map used to track internal linkage functions declared within 347 /// extern "C" regions. 348 typedef llvm::MapVector<IdentifierInfo *, 349 llvm::GlobalValue *> StaticExternCMap; 350 StaticExternCMap StaticExternCValues; 351 352 /// \brief thread_local variables defined or used in this TU. 353 std::vector<std::pair<const VarDecl *, llvm::GlobalVariable *> > 354 CXXThreadLocals; 355 356 /// \brief thread_local variables with initializers that need to run 357 /// before any thread_local variable in this TU is odr-used. 358 std::vector<llvm::Constant*> CXXThreadLocalInits; 359 360 /// CXXGlobalInits - Global variables with initializers that need to run 361 /// before main. 362 std::vector<llvm::Constant*> CXXGlobalInits; 363 364 /// When a C++ decl with an initializer is deferred, null is 365 /// appended to CXXGlobalInits, and the index of that null is placed 366 /// here so that the initializer will be performed in the correct 367 /// order. 368 llvm::DenseMap<const Decl*, unsigned> DelayedCXXInitPosition; 369 370 typedef std::pair<OrderGlobalInits, llvm::Function*> GlobalInitData; 371 372 struct GlobalInitPriorityCmp { 373 bool operator()(const GlobalInitData &LHS, 374 const GlobalInitData &RHS) const { 375 return LHS.first.priority < RHS.first.priority; 376 } 377 }; 378 379 /// - Global variables with initializers whose order of initialization 380 /// is set by init_priority attribute. 381 SmallVector<GlobalInitData, 8> PrioritizedCXXGlobalInits; 382 383 /// CXXGlobalDtors - Global destructor functions and arguments that need to 384 /// run on termination. 385 std::vector<std::pair<llvm::WeakVH,llvm::Constant*> > CXXGlobalDtors; 386 387 /// \brief The complete set of modules that has been imported. 388 llvm::SetVector<clang::Module *> ImportedModules; 389 390 /// \brief A vector of metadata strings. 391 SmallVector<llvm::Value *, 16> LinkerOptionsMetadata; 392 393 /// @name Cache for Objective-C runtime types 394 /// @{ 395 396 /// CFConstantStringClassRef - Cached reference to the class for constant 397 /// strings. This value has type int * but is actually an Obj-C class pointer. 398 llvm::WeakVH CFConstantStringClassRef; 399 400 /// ConstantStringClassRef - Cached reference to the class for constant 401 /// strings. This value has type int * but is actually an Obj-C class pointer. 402 llvm::WeakVH ConstantStringClassRef; 403 404 /// \brief The LLVM type corresponding to NSConstantString. 405 llvm::StructType *NSConstantStringType; 406 407 /// \brief The type used to describe the state of a fast enumeration in 408 /// Objective-C's for..in loop. 409 QualType ObjCFastEnumerationStateType; 410 411 /// @} 412 413 /// Lazily create the Objective-C runtime 414 void createObjCRuntime(); 415 416 void createOpenCLRuntime(); 417 void createCUDARuntime(); 418 419 bool isTriviallyRecursive(const FunctionDecl *F); 420 bool shouldEmitFunction(GlobalDecl GD); 421 422 /// @name Cache for Blocks Runtime Globals 423 /// @{ 424 425 llvm::Constant *NSConcreteGlobalBlock; 426 llvm::Constant *NSConcreteStackBlock; 427 428 llvm::Constant *BlockObjectAssign; 429 llvm::Constant *BlockObjectDispose; 430 431 llvm::Type *BlockDescriptorType; 432 llvm::Type *GenericBlockLiteralType; 433 434 struct { 435 int GlobalUniqueCount; 436 } Block; 437 438 /// void @llvm.lifetime.start(i64 %size, i8* nocapture <ptr>) 439 llvm::Constant *LifetimeStartFn; 440 441 /// void @llvm.lifetime.end(i64 %size, i8* nocapture <ptr>) 442 llvm::Constant *LifetimeEndFn; 443 444 GlobalDecl initializedGlobalDecl; 445 446 std::unique_ptr<llvm::SpecialCaseList> SanitizerBlacklist; 447 448 const SanitizerOptions &SanOpts; 449 450 /// @} 451 public: 452 CodeGenModule(ASTContext &C, const CodeGenOptions &CodeGenOpts, 453 llvm::Module &M, const llvm::DataLayout &TD, 454 DiagnosticsEngine &Diags); 455 456 ~CodeGenModule(); 457 458 void clear(); 459 460 /// Release - Finalize LLVM code generation. 461 void Release(); 462 463 /// getObjCRuntime() - Return a reference to the configured 464 /// Objective-C runtime. 465 CGObjCRuntime &getObjCRuntime() { 466 if (!ObjCRuntime) createObjCRuntime(); 467 return *ObjCRuntime; 468 } 469 470 /// hasObjCRuntime() - Return true iff an Objective-C runtime has 471 /// been configured. 472 bool hasObjCRuntime() { return !!ObjCRuntime; } 473 474 /// getOpenCLRuntime() - Return a reference to the configured OpenCL runtime. 475 CGOpenCLRuntime &getOpenCLRuntime() { 476 assert(OpenCLRuntime != 0); 477 return *OpenCLRuntime; 478 } 479 480 /// getCUDARuntime() - Return a reference to the configured CUDA runtime. 481 CGCUDARuntime &getCUDARuntime() { 482 assert(CUDARuntime != 0); 483 return *CUDARuntime; 484 } 485 486 ARCEntrypoints &getARCEntrypoints() const { 487 assert(getLangOpts().ObjCAutoRefCount && ARCData != 0); 488 return *ARCData; 489 } 490 491 RREntrypoints &getRREntrypoints() const { 492 assert(RRData != 0); 493 return *RRData; 494 } 495 496 InstrProfStats &getPGOStats() { 497 return PGOStats; 498 } 499 500 PGOProfileData *getPGOData() const { 501 return PGOData; 502 } 503 504 llvm::Constant *getStaticLocalDeclAddress(const VarDecl *D) { 505 return StaticLocalDeclMap[D]; 506 } 507 void setStaticLocalDeclAddress(const VarDecl *D, 508 llvm::Constant *C) { 509 StaticLocalDeclMap[D] = C; 510 } 511 512 llvm::GlobalVariable *getStaticLocalDeclGuardAddress(const VarDecl *D) { 513 return StaticLocalDeclGuardMap[D]; 514 } 515 void setStaticLocalDeclGuardAddress(const VarDecl *D, 516 llvm::GlobalVariable *C) { 517 StaticLocalDeclGuardMap[D] = C; 518 } 519 520 llvm::Constant *getAtomicSetterHelperFnMap(QualType Ty) { 521 return AtomicSetterHelperFnMap[Ty]; 522 } 523 void setAtomicSetterHelperFnMap(QualType Ty, 524 llvm::Constant *Fn) { 525 AtomicSetterHelperFnMap[Ty] = Fn; 526 } 527 528 llvm::Constant *getAtomicGetterHelperFnMap(QualType Ty) { 529 return AtomicGetterHelperFnMap[Ty]; 530 } 531 void setAtomicGetterHelperFnMap(QualType Ty, 532 llvm::Constant *Fn) { 533 AtomicGetterHelperFnMap[Ty] = Fn; 534 } 535 536 llvm::Constant *getTypeDescriptor(QualType Ty) { 537 return TypeDescriptorMap[Ty]; 538 } 539 void setTypeDescriptor(QualType Ty, llvm::Constant *C) { 540 TypeDescriptorMap[Ty] = C; 541 } 542 543 CGDebugInfo *getModuleDebugInfo() { return DebugInfo; } 544 545 llvm::MDNode *getNoObjCARCExceptionsMetadata() { 546 if (!NoObjCARCExceptionsMetadata) 547 NoObjCARCExceptionsMetadata = 548 llvm::MDNode::get(getLLVMContext(), 549 SmallVector<llvm::Value*,1>()); 550 return NoObjCARCExceptionsMetadata; 551 } 552 553 ASTContext &getContext() const { return Context; } 554 const LangOptions &getLangOpts() const { return LangOpts; } 555 const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; } 556 llvm::Module &getModule() const { return TheModule; } 557 DiagnosticsEngine &getDiags() const { return Diags; } 558 const llvm::DataLayout &getDataLayout() const { return TheDataLayout; } 559 const TargetInfo &getTarget() const { return Target; } 560 CGCXXABI &getCXXABI() const { return *ABI; } 561 llvm::LLVMContext &getLLVMContext() { return VMContext; } 562 563 bool shouldUseTBAA() const { return TBAA != 0; } 564 565 const TargetCodeGenInfo &getTargetCodeGenInfo(); 566 567 CodeGenTypes &getTypes() { return Types; } 568 569 CodeGenVTables &getVTables() { return VTables; } 570 571 ItaniumVTableContext &getItaniumVTableContext() { 572 return VTables.getItaniumVTableContext(); 573 } 574 575 MicrosoftVTableContext &getMicrosoftVTableContext() { 576 return VTables.getMicrosoftVTableContext(); 577 } 578 579 llvm::MDNode *getTBAAInfo(QualType QTy); 580 llvm::MDNode *getTBAAInfoForVTablePtr(); 581 llvm::MDNode *getTBAAStructInfo(QualType QTy); 582 /// Return the MDNode in the type DAG for the given struct type. 583 llvm::MDNode *getTBAAStructTypeInfo(QualType QTy); 584 /// Return the path-aware tag for given base type, access node and offset. 585 llvm::MDNode *getTBAAStructTagInfo(QualType BaseTy, llvm::MDNode *AccessN, 586 uint64_t O); 587 588 bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor); 589 590 bool isPaddedAtomicType(QualType type); 591 bool isPaddedAtomicType(const AtomicType *type); 592 593 /// Decorate the instruction with a TBAA tag. For scalar TBAA, the tag 594 /// is the same as the type. For struct-path aware TBAA, the tag 595 /// is different from the type: base type, access type and offset. 596 /// When ConvertTypeToTag is true, we create a tag based on the scalar type. 597 void DecorateInstruction(llvm::Instruction *Inst, 598 llvm::MDNode *TBAAInfo, 599 bool ConvertTypeToTag = true); 600 601 /// getSize - Emit the given number of characters as a value of type size_t. 602 llvm::ConstantInt *getSize(CharUnits numChars); 603 604 /// setGlobalVisibility - Set the visibility for the given LLVM 605 /// GlobalValue. 606 void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const; 607 608 /// setTLSMode - Set the TLS mode for the given LLVM GlobalVariable 609 /// for the thread-local variable declaration D. 610 void setTLSMode(llvm::GlobalVariable *GV, const VarDecl &D) const; 611 612 static llvm::GlobalValue::VisibilityTypes GetLLVMVisibility(Visibility V) { 613 switch (V) { 614 case DefaultVisibility: return llvm::GlobalValue::DefaultVisibility; 615 case HiddenVisibility: return llvm::GlobalValue::HiddenVisibility; 616 case ProtectedVisibility: return llvm::GlobalValue::ProtectedVisibility; 617 } 618 llvm_unreachable("unknown visibility!"); 619 } 620 621 llvm::Constant *GetAddrOfGlobal(GlobalDecl GD) { 622 if (isa<CXXConstructorDecl>(GD.getDecl())) 623 return GetAddrOfCXXConstructor(cast<CXXConstructorDecl>(GD.getDecl()), 624 GD.getCtorType()); 625 else if (isa<CXXDestructorDecl>(GD.getDecl())) 626 return GetAddrOfCXXDestructor(cast<CXXDestructorDecl>(GD.getDecl()), 627 GD.getDtorType()); 628 else if (isa<FunctionDecl>(GD.getDecl())) 629 return GetAddrOfFunction(GD); 630 else 631 return GetAddrOfGlobalVar(cast<VarDecl>(GD.getDecl())); 632 } 633 634 /// CreateOrReplaceCXXRuntimeVariable - Will return a global variable of the 635 /// given type. If a variable with a different type already exists then a new 636 /// variable with the right type will be created and all uses of the old 637 /// variable will be replaced with a bitcast to the new variable. 638 llvm::GlobalVariable * 639 CreateOrReplaceCXXRuntimeVariable(StringRef Name, llvm::Type *Ty, 640 llvm::GlobalValue::LinkageTypes Linkage); 641 642 /// GetGlobalVarAddressSpace - Return the address space of the underlying 643 /// global variable for D, as determined by its declaration. Normally this 644 /// is the same as the address space of D's type, but in CUDA, address spaces 645 /// are associated with declarations, not types. 646 unsigned GetGlobalVarAddressSpace(const VarDecl *D, unsigned AddrSpace); 647 648 /// GetAddrOfGlobalVar - Return the llvm::Constant for the address of the 649 /// given global variable. If Ty is non-null and if the global doesn't exist, 650 /// then it will be greated with the specified type instead of whatever the 651 /// normal requested type would be. 652 llvm::Constant *GetAddrOfGlobalVar(const VarDecl *D, 653 llvm::Type *Ty = 0); 654 655 656 /// GetAddrOfFunction - Return the address of the given function. If Ty is 657 /// non-null, then this function will use the specified type if it has to 658 /// create it. 659 llvm::Constant *GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty = 0, 660 bool ForVTable = false, 661 bool DontDefer = false); 662 663 /// GetAddrOfRTTIDescriptor - Get the address of the RTTI descriptor 664 /// for the given type. 665 llvm::Constant *GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH = false); 666 667 /// GetAddrOfUuidDescriptor - Get the address of a uuid descriptor . 668 llvm::Constant *GetAddrOfUuidDescriptor(const CXXUuidofExpr* E); 669 670 /// GetAddrOfThunk - Get the address of the thunk for the given global decl. 671 llvm::Constant *GetAddrOfThunk(GlobalDecl GD, const ThunkInfo &Thunk); 672 673 /// GetWeakRefReference - Get a reference to the target of VD. 674 llvm::Constant *GetWeakRefReference(const ValueDecl *VD); 675 676 /// GetNonVirtualBaseClassOffset - Returns the offset from a derived class to 677 /// a class. Returns null if the offset is 0. 678 llvm::Constant * 679 GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl, 680 CastExpr::path_const_iterator PathBegin, 681 CastExpr::path_const_iterator PathEnd); 682 683 /// A pair of helper functions for a __block variable. 684 class ByrefHelpers : public llvm::FoldingSetNode { 685 public: 686 llvm::Constant *CopyHelper; 687 llvm::Constant *DisposeHelper; 688 689 /// The alignment of the field. This is important because 690 /// different offsets to the field within the byref struct need to 691 /// have different helper functions. 692 CharUnits Alignment; 693 694 ByrefHelpers(CharUnits alignment) : Alignment(alignment) {} 695 virtual ~ByrefHelpers(); 696 697 void Profile(llvm::FoldingSetNodeID &id) const { 698 id.AddInteger(Alignment.getQuantity()); 699 profileImpl(id); 700 } 701 virtual void profileImpl(llvm::FoldingSetNodeID &id) const = 0; 702 703 virtual bool needsCopy() const { return true; } 704 virtual void emitCopy(CodeGenFunction &CGF, 705 llvm::Value *dest, llvm::Value *src) = 0; 706 707 virtual bool needsDispose() const { return true; } 708 virtual void emitDispose(CodeGenFunction &CGF, llvm::Value *field) = 0; 709 }; 710 711 llvm::FoldingSet<ByrefHelpers> ByrefHelpersCache; 712 713 /// getUniqueBlockCount - Fetches the global unique block count. 714 int getUniqueBlockCount() { return ++Block.GlobalUniqueCount; } 715 716 /// getBlockDescriptorType - Fetches the type of a generic block 717 /// descriptor. 718 llvm::Type *getBlockDescriptorType(); 719 720 /// getGenericBlockLiteralType - The type of a generic block literal. 721 llvm::Type *getGenericBlockLiteralType(); 722 723 /// GetAddrOfGlobalBlock - Gets the address of a block which 724 /// requires no captures. 725 llvm::Constant *GetAddrOfGlobalBlock(const BlockExpr *BE, const char *); 726 727 /// GetAddrOfConstantCFString - Return a pointer to a constant CFString object 728 /// for the given string. 729 llvm::Constant *GetAddrOfConstantCFString(const StringLiteral *Literal); 730 731 /// GetAddrOfConstantString - Return a pointer to a constant NSString object 732 /// for the given string. Or a user defined String object as defined via 733 /// -fconstant-string-class=class_name option. 734 llvm::Constant *GetAddrOfConstantString(const StringLiteral *Literal); 735 736 /// GetConstantArrayFromStringLiteral - Return a constant array for the given 737 /// string. 738 llvm::Constant *GetConstantArrayFromStringLiteral(const StringLiteral *E); 739 740 /// GetAddrOfConstantStringFromLiteral - Return a pointer to a constant array 741 /// for the given string literal. 742 llvm::Constant *GetAddrOfConstantStringFromLiteral(const StringLiteral *S); 743 744 /// GetAddrOfConstantStringFromObjCEncode - Return a pointer to a constant 745 /// array for the given ObjCEncodeExpr node. 746 llvm::Constant *GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *); 747 748 /// GetAddrOfConstantString - Returns a pointer to a character array 749 /// containing the literal. This contents are exactly that of the given 750 /// string, i.e. it will not be null terminated automatically; see 751 /// GetAddrOfConstantCString. Note that whether the result is actually a 752 /// pointer to an LLVM constant depends on Feature.WriteableStrings. 753 /// 754 /// The result has pointer to array type. 755 /// 756 /// \param GlobalName If provided, the name to use for the global 757 /// (if one is created). 758 llvm::Constant *GetAddrOfConstantString(StringRef Str, 759 const char *GlobalName=0, 760 unsigned Alignment=0); 761 762 /// GetAddrOfConstantCString - Returns a pointer to a character array 763 /// containing the literal and a terminating '\0' character. The result has 764 /// pointer to array type. 765 /// 766 /// \param GlobalName If provided, the name to use for the global (if one is 767 /// created). 768 llvm::Constant *GetAddrOfConstantCString(const std::string &str, 769 const char *GlobalName=0, 770 unsigned Alignment=0); 771 772 /// GetAddrOfConstantCompoundLiteral - Returns a pointer to a constant global 773 /// variable for the given file-scope compound literal expression. 774 llvm::Constant *GetAddrOfConstantCompoundLiteral(const CompoundLiteralExpr*E); 775 776 /// \brief Returns a pointer to a global variable representing a temporary 777 /// with static or thread storage duration. 778 llvm::Constant *GetAddrOfGlobalTemporary(const MaterializeTemporaryExpr *E, 779 const Expr *Inner); 780 781 /// \brief Retrieve the record type that describes the state of an 782 /// Objective-C fast enumeration loop (for..in). 783 QualType getObjCFastEnumerationStateType(); 784 785 /// GetAddrOfCXXConstructor - Return the address of the constructor of the 786 /// given type. 787 llvm::GlobalValue *GetAddrOfCXXConstructor(const CXXConstructorDecl *ctor, 788 CXXCtorType ctorType, 789 const CGFunctionInfo *fnInfo = 0, 790 bool DontDefer = false); 791 792 /// GetAddrOfCXXDestructor - Return the address of the constructor of the 793 /// given type. 794 llvm::GlobalValue *GetAddrOfCXXDestructor(const CXXDestructorDecl *dtor, 795 CXXDtorType dtorType, 796 const CGFunctionInfo *fnInfo = 0, 797 llvm::FunctionType *fnType = 0, 798 bool DontDefer = false); 799 800 /// getBuiltinLibFunction - Given a builtin id for a function like 801 /// "__builtin_fabsf", return a Function* for "fabsf". 802 llvm::Value *getBuiltinLibFunction(const FunctionDecl *FD, 803 unsigned BuiltinID); 804 805 llvm::Function *getIntrinsic(unsigned IID, ArrayRef<llvm::Type*> Tys = None); 806 807 /// EmitTopLevelDecl - Emit code for a single top level declaration. 808 void EmitTopLevelDecl(Decl *D); 809 810 /// HandleCXXStaticMemberVarInstantiation - Tell the consumer that this 811 // variable has been instantiated. 812 void HandleCXXStaticMemberVarInstantiation(VarDecl *VD); 813 814 /// \brief If the declaration has internal linkage but is inside an 815 /// extern "C" linkage specification, prepare to emit an alias for it 816 /// to the expected name. 817 template<typename SomeDecl> 818 void MaybeHandleStaticInExternC(const SomeDecl *D, llvm::GlobalValue *GV); 819 820 /// Add a global to a list to be added to the llvm.used metadata. 821 void addUsedGlobal(llvm::GlobalValue *GV); 822 823 /// Add a global to a list to be added to the llvm.compiler.used metadata. 824 void addCompilerUsedGlobal(llvm::GlobalValue *GV); 825 826 /// AddCXXDtorEntry - Add a destructor and object to add to the C++ global 827 /// destructor function. 828 void AddCXXDtorEntry(llvm::Constant *DtorFn, llvm::Constant *Object) { 829 CXXGlobalDtors.push_back(std::make_pair(DtorFn, Object)); 830 } 831 832 /// CreateRuntimeFunction - Create a new runtime function with the specified 833 /// type and name. 834 llvm::Constant *CreateRuntimeFunction(llvm::FunctionType *Ty, 835 StringRef Name, 836 llvm::AttributeSet ExtraAttrs = 837 llvm::AttributeSet()); 838 /// CreateRuntimeVariable - Create a new runtime global variable with the 839 /// specified type and name. 840 llvm::Constant *CreateRuntimeVariable(llvm::Type *Ty, 841 StringRef Name); 842 843 ///@name Custom Blocks Runtime Interfaces 844 ///@{ 845 846 llvm::Constant *getNSConcreteGlobalBlock(); 847 llvm::Constant *getNSConcreteStackBlock(); 848 llvm::Constant *getBlockObjectAssign(); 849 llvm::Constant *getBlockObjectDispose(); 850 851 ///@} 852 853 llvm::Constant *getLLVMLifetimeStartFn(); 854 llvm::Constant *getLLVMLifetimeEndFn(); 855 856 // UpdateCompleteType - Make sure that this type is translated. 857 void UpdateCompletedType(const TagDecl *TD); 858 859 llvm::Constant *getMemberPointerConstant(const UnaryOperator *e); 860 861 /// EmitConstantInit - Try to emit the initializer for the given declaration 862 /// as a constant; returns 0 if the expression cannot be emitted as a 863 /// constant. 864 llvm::Constant *EmitConstantInit(const VarDecl &D, CodeGenFunction *CGF = 0); 865 866 /// EmitConstantExpr - Try to emit the given expression as a 867 /// constant; returns 0 if the expression cannot be emitted as a 868 /// constant. 869 llvm::Constant *EmitConstantExpr(const Expr *E, QualType DestType, 870 CodeGenFunction *CGF = 0); 871 872 /// EmitConstantValue - Emit the given constant value as a constant, in the 873 /// type's scalar representation. 874 llvm::Constant *EmitConstantValue(const APValue &Value, QualType DestType, 875 CodeGenFunction *CGF = 0); 876 877 /// EmitConstantValueForMemory - Emit the given constant value as a constant, 878 /// in the type's memory representation. 879 llvm::Constant *EmitConstantValueForMemory(const APValue &Value, 880 QualType DestType, 881 CodeGenFunction *CGF = 0); 882 883 /// EmitNullConstant - Return the result of value-initializing the given 884 /// type, i.e. a null expression of the given type. This is usually, 885 /// but not always, an LLVM null constant. 886 llvm::Constant *EmitNullConstant(QualType T); 887 888 /// EmitNullConstantForBase - Return a null constant appropriate for 889 /// zero-initializing a base class with the given type. This is usually, 890 /// but not always, an LLVM null constant. 891 llvm::Constant *EmitNullConstantForBase(const CXXRecordDecl *Record); 892 893 /// Error - Emit a general error that something can't be done. 894 void Error(SourceLocation loc, StringRef error); 895 896 /// ErrorUnsupported - Print out an error that codegen doesn't support the 897 /// specified stmt yet. 898 void ErrorUnsupported(const Stmt *S, const char *Type); 899 900 /// ErrorUnsupported - Print out an error that codegen doesn't support the 901 /// specified decl yet. 902 void ErrorUnsupported(const Decl *D, const char *Type); 903 904 /// SetInternalFunctionAttributes - Set the attributes on the LLVM 905 /// function for the given decl and function info. This applies 906 /// attributes necessary for handling the ABI as well as user 907 /// specified attributes like section. 908 void SetInternalFunctionAttributes(const Decl *D, llvm::Function *F, 909 const CGFunctionInfo &FI); 910 911 /// SetLLVMFunctionAttributes - Set the LLVM function attributes 912 /// (sext, zext, etc). 913 void SetLLVMFunctionAttributes(const Decl *D, 914 const CGFunctionInfo &Info, 915 llvm::Function *F); 916 917 /// SetLLVMFunctionAttributesForDefinition - Set the LLVM function attributes 918 /// which only apply to a function definintion. 919 void SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F); 920 921 /// ReturnTypeUsesSRet - Return true iff the given type uses 'sret' when used 922 /// as a return type. 923 bool ReturnTypeUsesSRet(const CGFunctionInfo &FI); 924 925 /// ReturnSlotInterferesWithArgs - Return true iff the given type uses an 926 /// argument slot when 'sret' is used as a return type. 927 bool ReturnSlotInterferesWithArgs(const CGFunctionInfo &FI); 928 929 /// ReturnTypeUsesFPRet - Return true iff the given type uses 'fpret' when 930 /// used as a return type. 931 bool ReturnTypeUsesFPRet(QualType ResultType); 932 933 /// ReturnTypeUsesFP2Ret - Return true iff the given type uses 'fp2ret' when 934 /// used as a return type. 935 bool ReturnTypeUsesFP2Ret(QualType ResultType); 936 937 /// ConstructAttributeList - Get the LLVM attributes and calling convention to 938 /// use for a particular function type. 939 /// 940 /// \param Info - The function type information. 941 /// \param TargetDecl - The decl these attributes are being constructed 942 /// for. If supplied the attributes applied to this decl may contribute to the 943 /// function attributes and calling convention. 944 /// \param PAL [out] - On return, the attribute list to use. 945 /// \param CallingConv [out] - On return, the LLVM calling convention to use. 946 void ConstructAttributeList(const CGFunctionInfo &Info, 947 const Decl *TargetDecl, 948 AttributeListType &PAL, 949 unsigned &CallingConv, 950 bool AttrOnCallSite); 951 952 StringRef getMangledName(GlobalDecl GD); 953 void getBlockMangledName(GlobalDecl GD, MangleBuffer &Buffer, 954 const BlockDecl *BD); 955 956 void EmitTentativeDefinition(const VarDecl *D); 957 958 void EmitVTable(CXXRecordDecl *Class, bool DefinitionRequired); 959 960 /// EmitFundamentalRTTIDescriptors - Emit the RTTI descriptors for the 961 /// builtin types. 962 void EmitFundamentalRTTIDescriptors(); 963 964 /// \brief Appends Opts to the "Linker Options" metadata value. 965 void AppendLinkerOptions(StringRef Opts); 966 967 /// \brief Appends a detect mismatch command to the linker options. 968 void AddDetectMismatch(StringRef Name, StringRef Value); 969 970 /// \brief Appends a dependent lib to the "Linker Options" metadata value. 971 void AddDependentLib(StringRef Lib); 972 973 llvm::GlobalVariable::LinkageTypes getFunctionLinkage(GlobalDecl GD); 974 975 void setFunctionLinkage(GlobalDecl GD, llvm::GlobalValue *V) { 976 V->setLinkage(getFunctionLinkage(GD)); 977 } 978 979 /// getVTableLinkage - Return the appropriate linkage for the vtable, VTT, 980 /// and type information of the given class. 981 llvm::GlobalVariable::LinkageTypes getVTableLinkage(const CXXRecordDecl *RD); 982 983 /// GetTargetTypeStoreSize - Return the store size, in character units, of 984 /// the given LLVM type. 985 CharUnits GetTargetTypeStoreSize(llvm::Type *Ty) const; 986 987 /// GetLLVMLinkageVarDefinition - Returns LLVM linkage for a global 988 /// variable. 989 llvm::GlobalValue::LinkageTypes 990 GetLLVMLinkageVarDefinition(const VarDecl *D, bool isConstant); 991 992 /// Emit all the global annotations. 993 void EmitGlobalAnnotations(); 994 995 /// Emit an annotation string. 996 llvm::Constant *EmitAnnotationString(StringRef Str); 997 998 /// Emit the annotation's translation unit. 999 llvm::Constant *EmitAnnotationUnit(SourceLocation Loc); 1000 1001 /// Emit the annotation line number. 1002 llvm::Constant *EmitAnnotationLineNo(SourceLocation L); 1003 1004 /// EmitAnnotateAttr - Generate the llvm::ConstantStruct which contains the 1005 /// annotation information for a given GlobalValue. The annotation struct is 1006 /// {i8 *, i8 *, i8 *, i32}. The first field is a constant expression, the 1007 /// GlobalValue being annotated. The second field is the constant string 1008 /// created from the AnnotateAttr's annotation. The third field is a constant 1009 /// string containing the name of the translation unit. The fourth field is 1010 /// the line number in the file of the annotated value declaration. 1011 llvm::Constant *EmitAnnotateAttr(llvm::GlobalValue *GV, 1012 const AnnotateAttr *AA, 1013 SourceLocation L); 1014 1015 /// Add global annotations that are set on D, for the global GV. Those 1016 /// annotations are emitted during finalization of the LLVM code. 1017 void AddGlobalAnnotations(const ValueDecl *D, llvm::GlobalValue *GV); 1018 1019 const llvm::SpecialCaseList &getSanitizerBlacklist() const { 1020 return *SanitizerBlacklist; 1021 } 1022 1023 const SanitizerOptions &getSanOpts() const { return SanOpts; } 1024 1025 void addDeferredVTable(const CXXRecordDecl *RD) { 1026 DeferredVTables.push_back(RD); 1027 } 1028 1029 /// EmitGlobal - Emit code for a singal global function or var decl. Forward 1030 /// declarations are emitted lazily. 1031 void EmitGlobal(GlobalDecl D); 1032 1033 private: 1034 llvm::GlobalValue *GetGlobalValue(StringRef Ref); 1035 1036 llvm::Constant * 1037 GetOrCreateLLVMFunction(StringRef MangledName, llvm::Type *Ty, GlobalDecl D, 1038 bool ForVTable, bool DontDefer = false, 1039 llvm::AttributeSet ExtraAttrs = llvm::AttributeSet()); 1040 1041 llvm::Constant *GetOrCreateLLVMGlobal(StringRef MangledName, 1042 llvm::PointerType *PTy, 1043 const VarDecl *D, 1044 bool UnnamedAddr = false); 1045 1046 /// SetCommonAttributes - Set attributes which are common to any 1047 /// form of a global definition (alias, Objective-C method, 1048 /// function, global variable). 1049 /// 1050 /// NOTE: This should only be called for definitions. 1051 void SetCommonAttributes(const Decl *D, llvm::GlobalValue *GV); 1052 1053 /// SetFunctionDefinitionAttributes - Set attributes for a global definition. 1054 void SetFunctionDefinitionAttributes(const FunctionDecl *D, 1055 llvm::GlobalValue *GV); 1056 1057 /// SetFunctionAttributes - Set function attributes for a function 1058 /// declaration. 1059 void SetFunctionAttributes(GlobalDecl GD, 1060 llvm::Function *F, 1061 bool IsIncompleteFunction); 1062 1063 void EmitGlobalDefinition(GlobalDecl D, llvm::GlobalValue *GV = 0); 1064 1065 void EmitGlobalFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV); 1066 void EmitGlobalVarDefinition(const VarDecl *D); 1067 void EmitAliasDefinition(GlobalDecl GD); 1068 void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D); 1069 void EmitObjCIvarInitializations(ObjCImplementationDecl *D); 1070 1071 // C++ related functions. 1072 1073 bool TryEmitDefinitionAsAlias(GlobalDecl Alias, GlobalDecl Target, 1074 bool InEveryTU); 1075 bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D); 1076 1077 void EmitNamespace(const NamespaceDecl *D); 1078 void EmitLinkageSpec(const LinkageSpecDecl *D); 1079 void CompleteDIClassType(const CXXMethodDecl* D); 1080 1081 /// EmitCXXConstructor - Emit a single constructor with the given type from 1082 /// a C++ constructor Decl. 1083 void EmitCXXConstructor(const CXXConstructorDecl *D, CXXCtorType Type); 1084 1085 /// EmitCXXDestructor - Emit a single destructor with the given type from 1086 /// a C++ destructor Decl. 1087 void EmitCXXDestructor(const CXXDestructorDecl *D, CXXDtorType Type); 1088 1089 /// \brief Emit the function that initializes C++ thread_local variables. 1090 void EmitCXXThreadLocalInitFunc(); 1091 1092 /// EmitCXXGlobalInitFunc - Emit the function that initializes C++ globals. 1093 void EmitCXXGlobalInitFunc(); 1094 1095 /// EmitCXXGlobalDtorFunc - Emit the function that destroys C++ globals. 1096 void EmitCXXGlobalDtorFunc(); 1097 1098 /// EmitCXXGlobalVarDeclInitFunc - Emit the function that initializes the 1099 /// specified global (if PerformInit is true) and registers its destructor. 1100 void EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, 1101 llvm::GlobalVariable *Addr, 1102 bool PerformInit); 1103 1104 // FIXME: Hardcoding priority here is gross. 1105 void AddGlobalCtor(llvm::Function *Ctor, int Priority=65535); 1106 void AddGlobalDtor(llvm::Function *Dtor, int Priority=65535); 1107 1108 /// EmitCtorList - Generates a global array of functions and priorities using 1109 /// the given list and name. This array will have appending linkage and is 1110 /// suitable for use as a LLVM constructor or destructor array. 1111 void EmitCtorList(const CtorList &Fns, const char *GlobalName); 1112 1113 /// EmitFundamentalRTTIDescriptor - Emit the RTTI descriptors for the 1114 /// given type. 1115 void EmitFundamentalRTTIDescriptor(QualType Type); 1116 1117 /// EmitDeferred - Emit any needed decls for which code generation 1118 /// was deferred. 1119 void EmitDeferred(); 1120 1121 /// Call replaceAllUsesWith on all pairs in Replacements. 1122 void applyReplacements(); 1123 1124 void checkAliases(); 1125 1126 /// EmitDeferredVTables - Emit any vtables which we deferred and 1127 /// still have a use for. 1128 void EmitDeferredVTables(); 1129 1130 /// Emit the llvm.used and llvm.compiler.used metadata. 1131 void emitLLVMUsed(); 1132 1133 /// \brief Emit the link options introduced by imported modules. 1134 void EmitModuleLinkOptions(); 1135 1136 /// \brief Emit aliases for internal-linkage declarations inside "C" language 1137 /// linkage specifications, giving them the "expected" name where possible. 1138 void EmitStaticExternCAliases(); 1139 1140 void EmitDeclMetadata(); 1141 1142 /// \brief Emit the Clang version as llvm.ident metadata. 1143 void EmitVersionIdentMetadata(); 1144 1145 /// EmitCoverageFile - Emit the llvm.gcov metadata used to tell LLVM where 1146 /// to emit the .gcno and .gcda files in a way that persists in .bc files. 1147 void EmitCoverageFile(); 1148 1149 /// Emits the initializer for a uuidof string. 1150 llvm::Constant *EmitUuidofInitializer(StringRef uuidstr, QualType IIDType); 1151 1152 /// MayDeferGeneration - Determine if the given decl can be emitted 1153 /// lazily; this is only relevant for definitions. The given decl 1154 /// must be either a function or var decl. 1155 bool MayDeferGeneration(const ValueDecl *D); 1156 1157 /// SimplifyPersonality - Check whether we can use a "simpler", more 1158 /// core exceptions personality function. 1159 void SimplifyPersonality(); 1160 }; 1161 } // end namespace CodeGen 1162 } // end namespace clang 1163 1164 #endif 1165