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 "clang/Basic/LangOptions.h"
18 #include "clang/AST/Attr.h"
19 #include "clang/AST/DeclCXX.h"
20 #include "clang/AST/DeclObjC.h"
21 #include "CGBlocks.h"
22 #include "CGCall.h"
23 #include "CGCXX.h"
24 #include "CGVTables.h"
25 #include "CGCXXABI.h"
26 #include "CodeGenTypes.h"
27 #include "GlobalDecl.h"
28 #include "Mangle.h"
29 #include "llvm/Module.h"
30 #include "llvm/ADT/DenseMap.h"
31 #include "llvm/ADT/StringMap.h"
32 #include "llvm/ADT/StringSet.h"
33 #include "llvm/ADT/SmallPtrSet.h"
34 #include "llvm/Support/ValueHandle.h"
35 
36 namespace llvm {
37   class Module;
38   class Constant;
39   class Function;
40   class GlobalValue;
41   class TargetData;
42   class FunctionType;
43   class LLVMContext;
44 }
45 
46 namespace clang {
47   class TargetCodeGenInfo;
48   class ASTContext;
49   class FunctionDecl;
50   class IdentifierInfo;
51   class ObjCMethodDecl;
52   class ObjCImplementationDecl;
53   class ObjCCategoryImplDecl;
54   class ObjCProtocolDecl;
55   class ObjCEncodeExpr;
56   class BlockExpr;
57   class CharUnits;
58   class Decl;
59   class Expr;
60   class Stmt;
61   class StringLiteral;
62   class NamedDecl;
63   class ValueDecl;
64   class VarDecl;
65   class LangOptions;
66   class CodeGenOptions;
67   class Diagnostic;
68   class AnnotateAttr;
69   class CXXDestructorDecl;
70 
71 namespace CodeGen {
72 
73   class CodeGenFunction;
74   class CGDebugInfo;
75   class CGObjCRuntime;
76   class MangleBuffer;
77 
78 /// CodeGenModule - This class organizes the cross-function state that is used
79 /// while generating LLVM code.
80 class CodeGenModule : public BlockModule {
81   CodeGenModule(const CodeGenModule&);  // DO NOT IMPLEMENT
82   void operator=(const CodeGenModule&); // DO NOT IMPLEMENT
83 
84   typedef std::vector<std::pair<llvm::Constant*, int> > CtorList;
85 
86   ASTContext &Context;
87   const LangOptions &Features;
88   const CodeGenOptions &CodeGenOpts;
89   llvm::Module &TheModule;
90   const llvm::TargetData &TheTargetData;
91   mutable const TargetCodeGenInfo *TheTargetCodeGenInfo;
92   Diagnostic &Diags;
93   CodeGenTypes Types;
94 
95   /// VTables - Holds information about C++ vtables.
96   CodeGenVTables VTables;
97   friend class CodeGenVTables;
98 
99   CGObjCRuntime* Runtime;
100   CXXABI* ABI;
101   CGDebugInfo* DebugInfo;
102 
103   // WeakRefReferences - A set of references that have only been seen via
104   // a weakref so far. This is used to remove the weak of the reference if we ever
105   // see a direct reference or a definition.
106   llvm::SmallPtrSet<llvm::GlobalValue*, 10> WeakRefReferences;
107 
108   /// DeferredDecls - This contains all the decls which have definitions but
109   /// which are deferred for emission and therefore should only be output if
110   /// they are actually used.  If a decl is in this, then it is known to have
111   /// not been referenced yet.
112   llvm::StringMap<GlobalDecl> DeferredDecls;
113 
114   /// DeferredDeclsToEmit - This is a list of deferred decls which we have seen
115   /// that *are* actually referenced.  These get code generated when the module
116   /// is done.
117   std::vector<GlobalDecl> DeferredDeclsToEmit;
118 
119   /// LLVMUsed - List of global values which are required to be
120   /// present in the object file; bitcast to i8*. This is used for
121   /// forcing visibility of symbols which may otherwise be optimized
122   /// out.
123   std::vector<llvm::WeakVH> LLVMUsed;
124 
125   /// GlobalCtors - Store the list of global constructors and their respective
126   /// priorities to be emitted when the translation unit is complete.
127   CtorList GlobalCtors;
128 
129   /// GlobalDtors - Store the list of global destructors and their respective
130   /// priorities to be emitted when the translation unit is complete.
131   CtorList GlobalDtors;
132 
133   std::vector<llvm::Constant*> Annotations;
134 
135   llvm::StringMap<llvm::Constant*> CFConstantStringMap;
136   llvm::StringMap<llvm::Constant*> ConstantStringMap;
137   llvm::DenseMap<const Decl*, llvm::Value*> StaticLocalDeclMap;
138 
139   /// CXXGlobalInits - Global variables with initializers that need to run
140   /// before main.
141   std::vector<llvm::Constant*> CXXGlobalInits;
142 
143   /// CXXGlobalDtors - Global destructor functions and arguments that need to
144   /// run on termination.
145   std::vector<std::pair<llvm::Constant*,llvm::Constant*> > CXXGlobalDtors;
146 
147   /// CFConstantStringClassRef - Cached reference to the class for constant
148   /// strings. This value has type int * but is actually an Obj-C class pointer.
149   llvm::Constant *CFConstantStringClassRef;
150 
151   /// NSConstantStringClassRef - Cached reference to the class for constant
152   /// strings. This value has type int * but is actually an Obj-C class pointer.
153   llvm::Constant *NSConstantStringClassRef;
154 
155   /// Lazily create the Objective-C runtime
156   void createObjCRuntime();
157   /// Lazily create the C++ ABI
158   void createCXXABI();
159 
160   llvm::LLVMContext &VMContext;
161 public:
162   CodeGenModule(ASTContext &C, const CodeGenOptions &CodeGenOpts,
163                 llvm::Module &M, const llvm::TargetData &TD, Diagnostic &Diags);
164 
165   ~CodeGenModule();
166 
167   /// Release - Finalize LLVM code generation.
168   void Release();
169 
170   /// getObjCRuntime() - Return a reference to the configured
171   /// Objective-C runtime.
172   CGObjCRuntime &getObjCRuntime() {
173     if (!Runtime) createObjCRuntime();
174     return *Runtime;
175   }
176 
177   /// hasObjCRuntime() - Return true iff an Objective-C runtime has
178   /// been configured.
179   bool hasObjCRuntime() { return !!Runtime; }
180 
181   /// getCXXABI() - Return a reference to the configured
182   /// C++ ABI.
183   CXXABI &getCXXABI() {
184     if (!ABI) createCXXABI();
185     return *ABI;
186   }
187 
188   /// hasCXXABI() - Return true iff a C++ ABI has been configured.
189   bool hasCXXABI() { return !!ABI; }
190 
191   llvm::Value *getStaticLocalDeclAddress(const VarDecl *VD) {
192     return StaticLocalDeclMap[VD];
193   }
194   void setStaticLocalDeclAddress(const VarDecl *D,
195                              llvm::GlobalVariable *GV) {
196     StaticLocalDeclMap[D] = GV;
197   }
198 
199   CGDebugInfo *getDebugInfo() { return DebugInfo; }
200   ASTContext &getContext() const { return Context; }
201   const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; }
202   const LangOptions &getLangOptions() const { return Features; }
203   llvm::Module &getModule() const { return TheModule; }
204   CodeGenTypes &getTypes() { return Types; }
205   MangleContext &getMangleContext() {
206     if (!ABI) createCXXABI();
207     return ABI->getMangleContext();
208   }
209   CodeGenVTables &getVTables() { return VTables; }
210   Diagnostic &getDiags() const { return Diags; }
211   const llvm::TargetData &getTargetData() const { return TheTargetData; }
212   llvm::LLVMContext &getLLVMContext() { return VMContext; }
213   const TargetCodeGenInfo &getTargetCodeGenInfo() const;
214   bool isTargetDarwin() const;
215 
216   /// getDeclVisibilityMode - Compute the visibility of the decl \arg D.
217   LangOptions::VisibilityMode getDeclVisibilityMode(const Decl *D) const;
218 
219   /// setGlobalVisibility - Set the visibility for the given LLVM
220   /// GlobalValue.
221   void setGlobalVisibility(llvm::GlobalValue *GV, const Decl *D) const;
222 
223   llvm::Constant *GetAddrOfGlobal(GlobalDecl GD) {
224     if (isa<CXXConstructorDecl>(GD.getDecl()))
225       return GetAddrOfCXXConstructor(cast<CXXConstructorDecl>(GD.getDecl()),
226                                      GD.getCtorType());
227     else if (isa<CXXDestructorDecl>(GD.getDecl()))
228       return GetAddrOfCXXDestructor(cast<CXXDestructorDecl>(GD.getDecl()),
229                                      GD.getDtorType());
230     else if (isa<FunctionDecl>(GD.getDecl()))
231       return GetAddrOfFunction(GD);
232     else
233       return GetAddrOfGlobalVar(cast<VarDecl>(GD.getDecl()));
234   }
235 
236   /// GetAddrOfGlobalVar - Return the llvm::Constant for the address of the
237   /// given global variable.  If Ty is non-null and if the global doesn't exist,
238   /// then it will be greated with the specified type instead of whatever the
239   /// normal requested type would be.
240   llvm::Constant *GetAddrOfGlobalVar(const VarDecl *D,
241                                      const llvm::Type *Ty = 0);
242 
243   /// GetAddrOfFunction - Return the address of the given function.  If Ty is
244   /// non-null, then this function will use the specified type if it has to
245   /// create it.
246   llvm::Constant *GetAddrOfFunction(GlobalDecl GD,
247                                     const llvm::Type *Ty = 0);
248 
249   /// GetAddrOfRTTIDescriptor - Get the address of the RTTI descriptor
250   /// for the given type.
251   llvm::Constant *GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH = false);
252 
253   /// GetAddrOfThunk - Get the address of the thunk for the given global decl.
254   llvm::Constant *GetAddrOfThunk(GlobalDecl GD, const ThunkInfo &Thunk);
255 
256   /// GetWeakRefReference - Get a reference to the target of VD.
257   llvm::Constant *GetWeakRefReference(const ValueDecl *VD);
258 
259   /// GetNonVirtualBaseClassOffset - Returns the offset from a derived class to
260   /// a class. Returns null if the offset is 0.
261   llvm::Constant *
262   GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl,
263                                const CXXBaseSpecifierArray &BasePath);
264 
265   /// GetStringForStringLiteral - Return the appropriate bytes for a string
266   /// literal, properly padded to match the literal type. If only the address of
267   /// a constant is needed consider using GetAddrOfConstantStringLiteral.
268   std::string GetStringForStringLiteral(const StringLiteral *E);
269 
270   /// GetAddrOfConstantCFString - Return a pointer to a constant CFString object
271   /// for the given string.
272   llvm::Constant *GetAddrOfConstantCFString(const StringLiteral *Literal);
273 
274   /// GetAddrOfConstantNSString - Return a pointer to a constant NSString object
275   /// for the given string.
276   llvm::Constant *GetAddrOfConstantNSString(const StringLiteral *Literal);
277 
278   /// GetAddrOfConstantStringFromLiteral - Return a pointer to a constant array
279   /// for the given string literal.
280   llvm::Constant *GetAddrOfConstantStringFromLiteral(const StringLiteral *S);
281 
282   /// GetAddrOfConstantStringFromObjCEncode - Return a pointer to a constant
283   /// array for the given ObjCEncodeExpr node.
284   llvm::Constant *GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *);
285 
286   /// GetAddrOfConstantString - Returns a pointer to a character array
287   /// containing the literal. This contents are exactly that of the given
288   /// string, i.e. it will not be null terminated automatically; see
289   /// GetAddrOfConstantCString. Note that whether the result is actually a
290   /// pointer to an LLVM constant depends on Feature.WriteableStrings.
291   ///
292   /// The result has pointer to array type.
293   ///
294   /// \param GlobalName If provided, the name to use for the global
295   /// (if one is created).
296   llvm::Constant *GetAddrOfConstantString(const std::string& str,
297                                           const char *GlobalName=0);
298 
299   /// GetAddrOfConstantCString - Returns a pointer to a character array
300   /// containing the literal and a terminating '\0' character. The result has
301   /// pointer to array type.
302   ///
303   /// \param GlobalName If provided, the name to use for the global (if one is
304   /// created).
305   llvm::Constant *GetAddrOfConstantCString(const std::string &str,
306                                            const char *GlobalName=0);
307 
308   /// GetAddrOfCXXConstructor - Return the address of the constructor of the
309   /// given type.
310   llvm::GlobalValue *GetAddrOfCXXConstructor(const CXXConstructorDecl *D,
311                                              CXXCtorType Type);
312 
313   /// GetAddrOfCXXDestructor - Return the address of the constructor of the
314   /// given type.
315   llvm::GlobalValue *GetAddrOfCXXDestructor(const CXXDestructorDecl *D,
316                                             CXXDtorType Type);
317 
318   // GetCXXMemberFunctionPointerValue - Given a method declaration, return the
319   // integer used in a member function pointer to refer to that value.
320   llvm::Constant *GetCXXMemberFunctionPointerValue(const CXXMethodDecl *MD);
321 
322   /// getBuiltinLibFunction - Given a builtin id for a function like
323   /// "__builtin_fabsf", return a Function* for "fabsf".
324   llvm::Value *getBuiltinLibFunction(const FunctionDecl *FD,
325                                      unsigned BuiltinID);
326 
327   llvm::Function *getMemCpyFn(const llvm::Type *DestType,
328                               const llvm::Type *SrcType,
329                               const llvm::Type *SizeType);
330 
331   llvm::Function *getMemMoveFn(const llvm::Type *DestType,
332                                const llvm::Type *SrcType,
333                                const llvm::Type *SizeType);
334 
335   llvm::Function *getMemSetFn(const llvm::Type *DestType,
336                               const llvm::Type *SizeType);
337 
338   llvm::Function *getIntrinsic(unsigned IID, const llvm::Type **Tys = 0,
339                                unsigned NumTys = 0);
340 
341   /// EmitTopLevelDecl - Emit code for a single top level declaration.
342   void EmitTopLevelDecl(Decl *D);
343 
344   /// AddUsedGlobal - Add a global which should be forced to be
345   /// present in the object file; these are emitted to the llvm.used
346   /// metadata global.
347   void AddUsedGlobal(llvm::GlobalValue *GV);
348 
349   void AddAnnotation(llvm::Constant *C) { Annotations.push_back(C); }
350 
351   /// AddCXXDtorEntry - Add a destructor and object to add to the C++ global
352   /// destructor function.
353   void AddCXXDtorEntry(llvm::Constant *DtorFn, llvm::Constant *Object);
354 
355   /// CreateRuntimeFunction - Create a new runtime function with the specified
356   /// type and name.
357   llvm::Constant *CreateRuntimeFunction(const llvm::FunctionType *Ty,
358                                         llvm::StringRef Name);
359   /// CreateRuntimeVariable - Create a new runtime global variable with the
360   /// specified type and name.
361   llvm::Constant *CreateRuntimeVariable(const llvm::Type *Ty,
362                                         llvm::StringRef Name);
363 
364   void UpdateCompletedType(const TagDecl *TD) {
365     // Make sure that this type is translated.
366     Types.UpdateCompletedType(TD);
367   }
368 
369   /// EmitConstantExpr - Try to emit the given expression as a
370   /// constant; returns 0 if the expression cannot be emitted as a
371   /// constant.
372   llvm::Constant *EmitConstantExpr(const Expr *E, QualType DestType,
373                                    CodeGenFunction *CGF = 0);
374 
375   /// EmitNullConstant - Return the result of value-initializing the given
376   /// type, i.e. a null expression of the given type.  This is usually,
377   /// but not always, an LLVM null constant.
378   llvm::Constant *EmitNullConstant(QualType T);
379 
380   llvm::Constant *EmitAnnotateAttr(llvm::GlobalValue *GV,
381                                    const AnnotateAttr *AA, unsigned LineNo);
382 
383   llvm::Constant *EmitPointerToDataMember(const FieldDecl *FD);
384 
385   /// ErrorUnsupported - Print out an error that codegen doesn't support the
386   /// specified stmt yet.
387   /// \param OmitOnError - If true, then this error should only be emitted if no
388   /// other errors have been reported.
389   void ErrorUnsupported(const Stmt *S, const char *Type,
390                         bool OmitOnError=false);
391 
392   /// ErrorUnsupported - Print out an error that codegen doesn't support the
393   /// specified decl yet.
394   /// \param OmitOnError - If true, then this error should only be emitted if no
395   /// other errors have been reported.
396   void ErrorUnsupported(const Decl *D, const char *Type,
397                         bool OmitOnError=false);
398 
399   /// SetInternalFunctionAttributes - Set the attributes on the LLVM
400   /// function for the given decl and function info. This applies
401   /// attributes necessary for handling the ABI as well as user
402   /// specified attributes like section.
403   void SetInternalFunctionAttributes(const Decl *D, llvm::Function *F,
404                                      const CGFunctionInfo &FI);
405 
406   /// SetLLVMFunctionAttributes - Set the LLVM function attributes
407   /// (sext, zext, etc).
408   void SetLLVMFunctionAttributes(const Decl *D,
409                                  const CGFunctionInfo &Info,
410                                  llvm::Function *F);
411 
412   /// SetLLVMFunctionAttributesForDefinition - Set the LLVM function attributes
413   /// which only apply to a function definintion.
414   void SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F);
415 
416   /// ReturnTypeUsesSret - Return true iff the given type uses 'sret' when used
417   /// as a return type.
418   bool ReturnTypeUsesSret(const CGFunctionInfo &FI);
419 
420   /// ConstructAttributeList - Get the LLVM attributes and calling convention to
421   /// use for a particular function type.
422   ///
423   /// \param Info - The function type information.
424   /// \param TargetDecl - The decl these attributes are being constructed
425   /// for. If supplied the attributes applied to this decl may contribute to the
426   /// function attributes and calling convention.
427   /// \param PAL [out] - On return, the attribute list to use.
428   /// \param CallingConv [out] - On return, the LLVM calling convention to use.
429   void ConstructAttributeList(const CGFunctionInfo &Info,
430                               const Decl *TargetDecl,
431                               AttributeListType &PAL,
432                               unsigned &CallingConv);
433 
434   void getMangledName(MangleBuffer &Buffer, GlobalDecl D);
435   void getMangledName(MangleBuffer &Buffer, const NamedDecl *ND);
436   void getMangledName(MangleBuffer &Buffer, const BlockDecl *BD);
437   void getMangledCXXCtorName(MangleBuffer &Buffer,
438                              const CXXConstructorDecl *D,
439                              CXXCtorType Type);
440   void getMangledCXXDtorName(MangleBuffer &Buffer,
441                              const CXXDestructorDecl *D,
442                              CXXDtorType Type);
443 
444   void EmitTentativeDefinition(const VarDecl *D);
445 
446   void EmitVTable(CXXRecordDecl *Class, bool DefinitionRequired);
447 
448   enum GVALinkage {
449     GVA_Internal,
450     GVA_C99Inline,
451     GVA_CXXInline,
452     GVA_StrongExternal,
453     GVA_TemplateInstantiation,
454     GVA_ExplicitTemplateInstantiation
455   };
456 
457   llvm::GlobalVariable::LinkageTypes
458   getFunctionLinkage(const FunctionDecl *FD);
459 
460   void setFunctionLinkage(const FunctionDecl *FD, llvm::GlobalValue *V) {
461     V->setLinkage(getFunctionLinkage(FD));
462   }
463 
464   /// getVTableLinkage - Return the appropriate linkage for the vtable, VTT,
465   /// and type information of the given class.
466   static llvm::GlobalVariable::LinkageTypes
467   getVTableLinkage(const CXXRecordDecl *RD);
468 
469   /// GetTargetTypeStoreSize - Return the store size, in character units, of
470   /// the given LLVM type.
471   CharUnits GetTargetTypeStoreSize(const llvm::Type *Ty) const;
472 
473   std::vector<const CXXRecordDecl*> DeferredVTables;
474 
475 private:
476   llvm::GlobalValue *GetGlobalValue(llvm::StringRef Ref);
477 
478   llvm::Constant *GetOrCreateLLVMFunction(llvm::StringRef MangledName,
479                                           const llvm::Type *Ty,
480                                           GlobalDecl D);
481   llvm::Constant *GetOrCreateLLVMGlobal(llvm::StringRef MangledName,
482                                         const llvm::PointerType *PTy,
483                                         const VarDecl *D);
484 
485   /// SetCommonAttributes - Set attributes which are common to any
486   /// form of a global definition (alias, Objective-C method,
487   /// function, global variable).
488   ///
489   /// NOTE: This should only be called for definitions.
490   void SetCommonAttributes(const Decl *D, llvm::GlobalValue *GV);
491 
492   /// SetFunctionDefinitionAttributes - Set attributes for a global definition.
493   void SetFunctionDefinitionAttributes(const FunctionDecl *D,
494                                        llvm::GlobalValue *GV);
495 
496   /// SetFunctionAttributes - Set function attributes for a function
497   /// declaration.
498   void SetFunctionAttributes(GlobalDecl GD,
499                              llvm::Function *F,
500                              bool IsIncompleteFunction);
501 
502   /// EmitGlobal - Emit code for a singal global function or var decl. Forward
503   /// declarations are emitted lazily.
504   void EmitGlobal(GlobalDecl D);
505 
506   void EmitGlobalDefinition(GlobalDecl D);
507 
508   void EmitGlobalFunctionDefinition(GlobalDecl GD);
509   void EmitGlobalVarDefinition(const VarDecl *D);
510   void EmitAliasDefinition(GlobalDecl GD);
511   void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D);
512   void EmitObjCIvarInitializations(ObjCImplementationDecl *D);
513 
514   // C++ related functions.
515 
516   bool TryEmitDefinitionAsAlias(GlobalDecl Alias, GlobalDecl Target);
517   bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D);
518 
519   void EmitNamespace(const NamespaceDecl *D);
520   void EmitLinkageSpec(const LinkageSpecDecl *D);
521 
522   /// EmitCXXConstructors - Emit constructors (base, complete) from a
523   /// C++ constructor Decl.
524   void EmitCXXConstructors(const CXXConstructorDecl *D);
525 
526   /// EmitCXXConstructor - Emit a single constructor with the given type from
527   /// a C++ constructor Decl.
528   void EmitCXXConstructor(const CXXConstructorDecl *D, CXXCtorType Type);
529 
530   /// EmitCXXDestructors - Emit destructors (base, complete) from a
531   /// C++ destructor Decl.
532   void EmitCXXDestructors(const CXXDestructorDecl *D);
533 
534   /// EmitCXXDestructor - Emit a single destructor with the given type from
535   /// a C++ destructor Decl.
536   void EmitCXXDestructor(const CXXDestructorDecl *D, CXXDtorType Type);
537 
538   /// EmitCXXGlobalInitFunc - Emit the function that initializes C++ globals.
539   void EmitCXXGlobalInitFunc();
540 
541   /// EmitCXXGlobalDtorFunc - Emit the function that destroys C++ globals.
542   void EmitCXXGlobalDtorFunc();
543 
544   void EmitCXXGlobalVarDeclInitFunc(const VarDecl *D);
545 
546   // FIXME: Hardcoding priority here is gross.
547   void AddGlobalCtor(llvm::Function *Ctor, int Priority=65535);
548   void AddGlobalDtor(llvm::Function *Dtor, int Priority=65535);
549 
550   /// EmitCtorList - Generates a global array of functions and priorities using
551   /// the given list and name. This array will have appending linkage and is
552   /// suitable for use as a LLVM constructor or destructor array.
553   void EmitCtorList(const CtorList &Fns, const char *GlobalName);
554 
555   void EmitAnnotations(void);
556 
557   /// EmitFundamentalRTTIDescriptor - Emit the RTTI descriptors for the
558   /// given type.
559   void EmitFundamentalRTTIDescriptor(QualType Type);
560 
561   /// EmitFundamentalRTTIDescriptors - Emit the RTTI descriptors for the
562   /// builtin types.
563   void EmitFundamentalRTTIDescriptors();
564 
565   /// EmitDeferred - Emit any needed decls for which code generation
566   /// was deferred.
567   void EmitDeferred(void);
568 
569   /// EmitLLVMUsed - Emit the llvm.used metadata used to force
570   /// references to global which may otherwise be optimized out.
571   void EmitLLVMUsed(void);
572 
573   /// MayDeferGeneration - Determine if the given decl can be emitted
574   /// lazily; this is only relevant for definitions. The given decl
575   /// must be either a function or var decl.
576   bool MayDeferGeneration(const ValueDecl *D);
577 };
578 }  // end namespace CodeGen
579 }  // end namespace clang
580 
581 #endif
582