clang  3.9.0
CodeGenModule.h
Go to the documentation of this file.
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 LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
15 #define LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
16 
17 #include "CGVTables.h"
18 #include "CodeGenTypeCache.h"
19 #include "CodeGenTypes.h"
20 #include "SanitizerMetadata.h"
21 #include "clang/AST/Attr.h"
22 #include "clang/AST/DeclCXX.h"
23 #include "clang/AST/DeclObjC.h"
24 #include "clang/AST/DeclOpenMP.h"
25 #include "clang/AST/GlobalDecl.h"
26 #include "clang/AST/Mangle.h"
27 #include "clang/Basic/ABI.h"
29 #include "clang/Basic/Module.h"
31 #include "llvm/ADT/DenseMap.h"
32 #include "llvm/ADT/SetVector.h"
33 #include "llvm/ADT/SmallPtrSet.h"
34 #include "llvm/ADT/StringMap.h"
35 #include "llvm/IR/Module.h"
36 #include "llvm/IR/ValueHandle.h"
37 #include "llvm/Transforms/Utils/SanitizerStats.h"
38 
39 namespace llvm {
40 class Module;
41 class Constant;
42 class ConstantInt;
43 class Function;
44 class GlobalValue;
45 class DataLayout;
46 class FunctionType;
47 class LLVMContext;
48 class IndexedInstrProfReader;
49 }
50 
51 namespace clang {
52 class ASTContext;
53 class AtomicType;
54 class FunctionDecl;
55 class IdentifierInfo;
56 class ObjCMethodDecl;
57 class ObjCImplementationDecl;
58 class ObjCCategoryImplDecl;
59 class ObjCProtocolDecl;
60 class ObjCEncodeExpr;
61 class BlockExpr;
62 class CharUnits;
63 class Decl;
64 class Expr;
65 class Stmt;
66 class InitListExpr;
67 class StringLiteral;
68 class NamedDecl;
69 class ValueDecl;
70 class VarDecl;
71 class LangOptions;
72 class CodeGenOptions;
73 class HeaderSearchOptions;
74 class PreprocessorOptions;
75 class DiagnosticsEngine;
76 class AnnotateAttr;
77 class CXXDestructorDecl;
78 class Module;
79 class CoverageSourceInfo;
80 
81 namespace CodeGen {
82 
83 class CallArgList;
84 class CodeGenFunction;
85 class CodeGenTBAA;
86 class CGCXXABI;
87 class CGDebugInfo;
88 class CGObjCRuntime;
89 class CGOpenCLRuntime;
90 class CGOpenMPRuntime;
91 class CGCUDARuntime;
92 class BlockFieldFlags;
93 class FunctionArgList;
94 class CoverageMappingModuleGen;
95 class TargetCodeGenInfo;
96 
98  unsigned int priority;
99  unsigned int lex_order;
100  OrderGlobalInits(unsigned int p, unsigned int l)
101  : priority(p), lex_order(l) {}
102 
103  bool operator==(const OrderGlobalInits &RHS) const {
104  return priority == RHS.priority && lex_order == RHS.lex_order;
105  }
106 
107  bool operator<(const OrderGlobalInits &RHS) const {
108  return std::tie(priority, lex_order) <
109  std::tie(RHS.priority, RHS.lex_order);
110  }
111 };
112 
114  ObjCEntrypoints() { memset(this, 0, sizeof(*this)); }
115 
116  /// void objc_autoreleasePoolPop(void*);
117  llvm::Constant *objc_autoreleasePoolPop;
118 
119  /// void *objc_autoreleasePoolPush(void);
120  llvm::Constant *objc_autoreleasePoolPush;
121 
122  /// id objc_autorelease(id);
123  llvm::Constant *objc_autorelease;
124 
125  /// id objc_autoreleaseReturnValue(id);
127 
128  /// void objc_copyWeak(id *dest, id *src);
129  llvm::Constant *objc_copyWeak;
130 
131  /// void objc_destroyWeak(id*);
132  llvm::Constant *objc_destroyWeak;
133 
134  /// id objc_initWeak(id*, id);
135  llvm::Constant *objc_initWeak;
136 
137  /// id objc_loadWeak(id*);
138  llvm::Constant *objc_loadWeak;
139 
140  /// id objc_loadWeakRetained(id*);
141  llvm::Constant *objc_loadWeakRetained;
142 
143  /// void objc_moveWeak(id *dest, id *src);
144  llvm::Constant *objc_moveWeak;
145 
146  /// id objc_retain(id);
147  llvm::Constant *objc_retain;
148 
149  /// id objc_retainAutorelease(id);
150  llvm::Constant *objc_retainAutorelease;
151 
152  /// id objc_retainAutoreleaseReturnValue(id);
154 
155  /// id objc_retainAutoreleasedReturnValue(id);
157 
158  /// id objc_retainBlock(id);
159  llvm::Constant *objc_retainBlock;
160 
161  /// void objc_release(id);
162  llvm::Constant *objc_release;
163 
164  /// id objc_storeStrong(id*, id);
165  llvm::Constant *objc_storeStrong;
166 
167  /// id objc_storeWeak(id*, id);
168  llvm::Constant *objc_storeWeak;
169 
170  /// id objc_unsafeClaimAutoreleasedReturnValue(id);
172 
173  /// A void(void) inline asm to use to mark that the return value of
174  /// a call will be immediately retain.
176 
177  /// void clang.arc.use(...);
178  llvm::Constant *clang_arc_use;
179 };
180 
181 /// This class records statistics on instrumentation based profiling.
183  uint32_t VisitedInMainFile;
184  uint32_t MissingInMainFile;
185  uint32_t Visited;
186  uint32_t Missing;
187  uint32_t Mismatched;
188 
189 public:
191  : VisitedInMainFile(0), MissingInMainFile(0), Visited(0), Missing(0),
192  Mismatched(0) {}
193  /// Record that we've visited a function and whether or not that function was
194  /// in the main source file.
195  void addVisited(bool MainFile) {
196  if (MainFile)
197  ++VisitedInMainFile;
198  ++Visited;
199  }
200  /// Record that a function we've visited has no profile data.
201  void addMissing(bool MainFile) {
202  if (MainFile)
203  ++MissingInMainFile;
204  ++Missing;
205  }
206  /// Record that a function we've visited has mismatched profile data.
207  void addMismatched(bool MainFile) { ++Mismatched; }
208  /// Whether or not the stats we've gathered indicate any potential problems.
209  bool hasDiagnostics() { return Missing || Mismatched; }
210  /// Report potential problems we've found to \c Diags.
211  void reportDiagnostics(DiagnosticsEngine &Diags, StringRef MainFile);
212 };
213 
214 /// A pair of helper functions for a __block variable.
215 class BlockByrefHelpers : public llvm::FoldingSetNode {
216  // MSVC requires this type to be complete in order to process this
217  // header.
218 public:
219  llvm::Constant *CopyHelper;
220  llvm::Constant *DisposeHelper;
221 
222  /// The alignment of the field. This is important because
223  /// different offsets to the field within the byref struct need to
224  /// have different helper functions.
226 
227  BlockByrefHelpers(CharUnits alignment) : Alignment(alignment) {}
228  BlockByrefHelpers(const BlockByrefHelpers &) = default;
229  virtual ~BlockByrefHelpers();
230 
231  void Profile(llvm::FoldingSetNodeID &id) const {
232  id.AddInteger(Alignment.getQuantity());
233  profileImpl(id);
234  }
235  virtual void profileImpl(llvm::FoldingSetNodeID &id) const = 0;
236 
237  virtual bool needsCopy() const { return true; }
238  virtual void emitCopy(CodeGenFunction &CGF, Address dest, Address src) = 0;
239 
240  virtual bool needsDispose() const { return true; }
241  virtual void emitDispose(CodeGenFunction &CGF, Address field) = 0;
242 };
243 
244 /// This class organizes the cross-function state that is used while generating
245 /// LLVM code.
247  CodeGenModule(const CodeGenModule &) = delete;
248  void operator=(const CodeGenModule &) = delete;
249 
250 public:
251  struct Structor {
252  Structor() : Priority(0), Initializer(nullptr), AssociatedData(nullptr) {}
253  Structor(int Priority, llvm::Constant *Initializer,
254  llvm::Constant *AssociatedData)
255  : Priority(Priority), Initializer(Initializer),
256  AssociatedData(AssociatedData) {}
257  int Priority;
258  llvm::Constant *Initializer;
259  llvm::Constant *AssociatedData;
260  };
261 
262  typedef std::vector<Structor> CtorList;
263 
264 private:
265  ASTContext &Context;
266  const LangOptions &LangOpts;
267  const HeaderSearchOptions &HeaderSearchOpts; // Only used for debug info.
268  const PreprocessorOptions &PreprocessorOpts; // Only used for debug info.
269  const CodeGenOptions &CodeGenOpts;
270  llvm::Module &TheModule;
271  DiagnosticsEngine &Diags;
272  const TargetInfo &Target;
273  std::unique_ptr<CGCXXABI> ABI;
274  llvm::LLVMContext &VMContext;
275 
276  std::unique_ptr<CodeGenTBAA> TBAA;
277 
278  mutable std::unique_ptr<TargetCodeGenInfo> TheTargetCodeGenInfo;
279 
280  // This should not be moved earlier, since its initialization depends on some
281  // of the previous reference members being already initialized and also checks
282  // if TheTargetCodeGenInfo is NULL
283  CodeGenTypes Types;
284 
285  /// Holds information about C++ vtables.
286  CodeGenVTables VTables;
287 
288  std::unique_ptr<CGObjCRuntime> ObjCRuntime;
289  std::unique_ptr<CGOpenCLRuntime> OpenCLRuntime;
290  std::unique_ptr<CGOpenMPRuntime> OpenMPRuntime;
291  std::unique_ptr<CGCUDARuntime> CUDARuntime;
292  std::unique_ptr<CGDebugInfo> DebugInfo;
293  std::unique_ptr<ObjCEntrypoints> ObjCData;
294  llvm::MDNode *NoObjCARCExceptionsMetadata = nullptr;
295  std::unique_ptr<llvm::IndexedInstrProfReader> PGOReader;
296  InstrProfStats PGOStats;
297  std::unique_ptr<llvm::SanitizerStatReport> SanStats;
298 
299  // A set of references that have only been seen via a weakref so far. This is
300  // used to remove the weak of the reference if we ever see a direct reference
301  // or a definition.
302  llvm::SmallPtrSet<llvm::GlobalValue*, 10> WeakRefReferences;
303 
304  /// This contains all the decls which have definitions but/ which are deferred
305  /// for emission and therefore should only be output if they are actually
306  /// used. If a decl is in this, then it is known to have not been referenced
307  /// yet.
308  std::map<StringRef, GlobalDecl> DeferredDecls;
309 
310  /// This is a list of deferred decls which we have seen that *are* actually
311  /// referenced. These get code generated when the module is done.
312  struct DeferredGlobal {
313  DeferredGlobal(llvm::GlobalValue *GV, GlobalDecl GD) : GV(GV), GD(GD) {}
314  llvm::TrackingVH<llvm::GlobalValue> GV;
315  GlobalDecl GD;
316  };
317  std::vector<DeferredGlobal> DeferredDeclsToEmit;
318  void addDeferredDeclToEmit(llvm::GlobalValue *GV, GlobalDecl GD) {
319  DeferredDeclsToEmit.emplace_back(GV, GD);
320  }
321 
322  /// List of alias we have emitted. Used to make sure that what they point to
323  /// is defined once we get to the end of the of the translation unit.
324  std::vector<GlobalDecl> Aliases;
325 
326  typedef llvm::StringMap<llvm::TrackingVH<llvm::Constant> > ReplacementsTy;
327  ReplacementsTy Replacements;
328 
329  /// List of global values to be replaced with something else. Used when we
330  /// want to replace a GlobalValue but can't identify it by its mangled name
331  /// anymore (because the name is already taken).
333  GlobalValReplacements;
334 
335  /// Set of global decls for which we already diagnosed mangled name conflict.
336  /// Required to not issue a warning (on a mangling conflict) multiple times
337  /// for the same decl.
338  llvm::DenseSet<GlobalDecl> DiagnosedConflictingDefinitions;
339 
340  /// A queue of (optional) vtables to consider emitting.
341  std::vector<const CXXRecordDecl*> DeferredVTables;
342 
343  /// List of global values which are required to be present in the object file;
344  /// bitcast to i8*. This is used for forcing visibility of symbols which may
345  /// otherwise be optimized out.
346  std::vector<llvm::WeakVH> LLVMUsed;
347  std::vector<llvm::WeakVH> LLVMCompilerUsed;
348 
349  /// Store the list of global constructors and their respective priorities to
350  /// be emitted when the translation unit is complete.
351  CtorList GlobalCtors;
352 
353  /// Store the list of global destructors and their respective priorities to be
354  /// emitted when the translation unit is complete.
355  CtorList GlobalDtors;
356 
357  /// An ordered map of canonical GlobalDecls to their mangled names.
358  llvm::MapVector<GlobalDecl, StringRef> MangledDeclNames;
359  llvm::StringMap<GlobalDecl, llvm::BumpPtrAllocator> Manglings;
360 
361  /// Global annotations.
362  std::vector<llvm::Constant*> Annotations;
363 
364  /// Map used to get unique annotation strings.
365  llvm::StringMap<llvm::Constant*> AnnotationStrings;
366 
367  llvm::StringMap<llvm::GlobalVariable *> CFConstantStringMap;
368 
369  llvm::DenseMap<llvm::Constant *, llvm::GlobalVariable *> ConstantStringMap;
370  llvm::DenseMap<const Decl*, llvm::Constant *> StaticLocalDeclMap;
371  llvm::DenseMap<const Decl*, llvm::GlobalVariable*> StaticLocalDeclGuardMap;
372  llvm::DenseMap<const Expr*, llvm::Constant *> MaterializedGlobalTemporaryMap;
373 
374  llvm::DenseMap<QualType, llvm::Constant *> AtomicSetterHelperFnMap;
375  llvm::DenseMap<QualType, llvm::Constant *> AtomicGetterHelperFnMap;
376 
377  /// Map used to get unique type descriptor constants for sanitizers.
378  llvm::DenseMap<QualType, llvm::Constant *> TypeDescriptorMap;
379 
380  /// Map used to track internal linkage functions declared within
381  /// extern "C" regions.
382  typedef llvm::MapVector<IdentifierInfo *,
383  llvm::GlobalValue *> StaticExternCMap;
384  StaticExternCMap StaticExternCValues;
385 
386  /// \brief thread_local variables defined or used in this TU.
387  std::vector<const VarDecl *> CXXThreadLocals;
388 
389  /// \brief thread_local variables with initializers that need to run
390  /// before any thread_local variable in this TU is odr-used.
391  std::vector<llvm::Function *> CXXThreadLocalInits;
392  std::vector<const VarDecl *> CXXThreadLocalInitVars;
393 
394  /// Global variables with initializers that need to run before main.
395  std::vector<llvm::Function *> CXXGlobalInits;
396 
397  /// When a C++ decl with an initializer is deferred, null is
398  /// appended to CXXGlobalInits, and the index of that null is placed
399  /// here so that the initializer will be performed in the correct
400  /// order. Once the decl is emitted, the index is replaced with ~0U to ensure
401  /// that we don't re-emit the initializer.
402  llvm::DenseMap<const Decl*, unsigned> DelayedCXXInitPosition;
403 
404  typedef std::pair<OrderGlobalInits, llvm::Function*> GlobalInitData;
405 
406  struct GlobalInitPriorityCmp {
407  bool operator()(const GlobalInitData &LHS,
408  const GlobalInitData &RHS) const {
409  return LHS.first.priority < RHS.first.priority;
410  }
411  };
412 
413  /// Global variables with initializers whose order of initialization is set by
414  /// init_priority attribute.
415  SmallVector<GlobalInitData, 8> PrioritizedCXXGlobalInits;
416 
417  /// Global destructor functions and arguments that need to run on termination.
418  std::vector<std::pair<llvm::WeakVH,llvm::Constant*> > CXXGlobalDtors;
419 
420  /// \brief The complete set of modules that has been imported.
421  llvm::SetVector<clang::Module *> ImportedModules;
422 
423  /// \brief A vector of metadata strings.
424  SmallVector<llvm::Metadata *, 16> LinkerOptionsMetadata;
425 
426  /// @name Cache for Objective-C runtime types
427  /// @{
428 
429  /// Cached reference to the class for constant strings. This value has type
430  /// int * but is actually an Obj-C class pointer.
431  llvm::WeakVH CFConstantStringClassRef;
432 
433  /// Cached reference to the class for constant strings. This value has type
434  /// int * but is actually an Obj-C class pointer.
435  llvm::WeakVH ConstantStringClassRef;
436 
437  /// \brief The LLVM type corresponding to NSConstantString.
438  llvm::StructType *NSConstantStringType = nullptr;
439 
440  /// \brief The type used to describe the state of a fast enumeration in
441  /// Objective-C's for..in loop.
442  QualType ObjCFastEnumerationStateType;
443 
444  /// @}
445 
446  /// Lazily create the Objective-C runtime
447  void createObjCRuntime();
448 
449  void createOpenCLRuntime();
450  void createOpenMPRuntime();
451  void createCUDARuntime();
452 
453  bool isTriviallyRecursive(const FunctionDecl *F);
454  bool shouldEmitFunction(GlobalDecl GD);
455 
456  /// @name Cache for Blocks Runtime Globals
457  /// @{
458 
459  llvm::Constant *NSConcreteGlobalBlock = nullptr;
460  llvm::Constant *NSConcreteStackBlock = nullptr;
461 
462  llvm::Constant *BlockObjectAssign = nullptr;
463  llvm::Constant *BlockObjectDispose = nullptr;
464 
465  llvm::Type *BlockDescriptorType = nullptr;
466  llvm::Type *GenericBlockLiteralType = nullptr;
467 
468  struct {
470  } Block;
471 
472  /// void @llvm.lifetime.start(i64 %size, i8* nocapture <ptr>)
473  llvm::Constant *LifetimeStartFn = nullptr;
474 
475  /// void @llvm.lifetime.end(i64 %size, i8* nocapture <ptr>)
476  llvm::Constant *LifetimeEndFn = nullptr;
477 
478  GlobalDecl initializedGlobalDecl;
479 
480  std::unique_ptr<SanitizerMetadata> SanitizerMD;
481 
482  /// @}
483 
484  llvm::DenseMap<const Decl *, bool> DeferredEmptyCoverageMappingDecls;
485 
486  std::unique_ptr<CoverageMappingModuleGen> CoverageMapping;
487 
488  /// Mapping from canonical types to their metadata identifiers. We need to
489  /// maintain this mapping because identifiers may be formed from distinct
490  /// MDNodes.
491  llvm::DenseMap<QualType, llvm::Metadata *> MetadataIdMap;
492 
493 public:
494  CodeGenModule(ASTContext &C, const HeaderSearchOptions &headersearchopts,
495  const PreprocessorOptions &ppopts,
496  const CodeGenOptions &CodeGenOpts, llvm::Module &M,
497  DiagnosticsEngine &Diags,
498  CoverageSourceInfo *CoverageInfo = nullptr);
499 
500  ~CodeGenModule();
501 
502  void clear();
503 
504  /// Finalize LLVM code generation.
505  void Release();
506 
507  /// Return a reference to the configured Objective-C runtime.
509  if (!ObjCRuntime) createObjCRuntime();
510  return *ObjCRuntime;
511  }
512 
513  /// Return true iff an Objective-C runtime has been configured.
514  bool hasObjCRuntime() { return !!ObjCRuntime; }
515 
516  /// Return a reference to the configured OpenCL runtime.
518  assert(OpenCLRuntime != nullptr);
519  return *OpenCLRuntime;
520  }
521 
522  /// Return a reference to the configured OpenMP runtime.
524  assert(OpenMPRuntime != nullptr);
525  return *OpenMPRuntime;
526  }
527 
528  /// Return a reference to the configured CUDA runtime.
530  assert(CUDARuntime != nullptr);
531  return *CUDARuntime;
532  }
533 
535  assert(ObjCData != nullptr);
536  return *ObjCData;
537  }
538 
539  InstrProfStats &getPGOStats() { return PGOStats; }
540  llvm::IndexedInstrProfReader *getPGOReader() const { return PGOReader.get(); }
541 
543  return CoverageMapping.get();
544  }
545 
546  llvm::Constant *getStaticLocalDeclAddress(const VarDecl *D) {
547  return StaticLocalDeclMap[D];
548  }
550  llvm::Constant *C) {
551  StaticLocalDeclMap[D] = C;
552  }
553 
554  llvm::Constant *
556  llvm::GlobalValue::LinkageTypes Linkage);
557 
558  llvm::GlobalVariable *getStaticLocalDeclGuardAddress(const VarDecl *D) {
559  return StaticLocalDeclGuardMap[D];
560  }
562  llvm::GlobalVariable *C) {
563  StaticLocalDeclGuardMap[D] = C;
564  }
565 
566  bool lookupRepresentativeDecl(StringRef MangledName,
567  GlobalDecl &Result) const;
568 
569  llvm::Constant *getAtomicSetterHelperFnMap(QualType Ty) {
570  return AtomicSetterHelperFnMap[Ty];
571  }
573  llvm::Constant *Fn) {
574  AtomicSetterHelperFnMap[Ty] = Fn;
575  }
576 
577  llvm::Constant *getAtomicGetterHelperFnMap(QualType Ty) {
578  return AtomicGetterHelperFnMap[Ty];
579  }
581  llvm::Constant *Fn) {
582  AtomicGetterHelperFnMap[Ty] = Fn;
583  }
584 
585  llvm::Constant *getTypeDescriptorFromMap(QualType Ty) {
586  return TypeDescriptorMap[Ty];
587  }
588  void setTypeDescriptorInMap(QualType Ty, llvm::Constant *C) {
589  TypeDescriptorMap[Ty] = C;
590  }
591 
592  CGDebugInfo *getModuleDebugInfo() { return DebugInfo.get(); }
593 
595  if (!NoObjCARCExceptionsMetadata)
596  NoObjCARCExceptionsMetadata = llvm::MDNode::get(getLLVMContext(), None);
597  return NoObjCARCExceptionsMetadata;
598  }
599 
600  ASTContext &getContext() const { return Context; }
601  const LangOptions &getLangOpts() const { return LangOpts; }
603  const { return HeaderSearchOpts; }
605  const { return PreprocessorOpts; }
606  const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; }
607  llvm::Module &getModule() const { return TheModule; }
608  DiagnosticsEngine &getDiags() const { return Diags; }
609  const llvm::DataLayout &getDataLayout() const {
610  return TheModule.getDataLayout();
611  }
612  const TargetInfo &getTarget() const { return Target; }
613  const llvm::Triple &getTriple() const;
614  bool supportsCOMDAT() const;
615  void maybeSetTrivialComdat(const Decl &D, llvm::GlobalObject &GO);
616 
617  CGCXXABI &getCXXABI() const { return *ABI; }
618  llvm::LLVMContext &getLLVMContext() { return VMContext; }
619 
620  bool shouldUseTBAA() const { return TBAA != nullptr; }
621 
623 
624  CodeGenTypes &getTypes() { return Types; }
625 
626  CodeGenVTables &getVTables() { return VTables; }
627 
629  return VTables.getItaniumVTableContext();
630  }
631 
633  return VTables.getMicrosoftVTableContext();
634  }
635 
636  CtorList &getGlobalCtors() { return GlobalCtors; }
637  CtorList &getGlobalDtors() { return GlobalDtors; }
638 
639  llvm::MDNode *getTBAAInfo(QualType QTy);
640  llvm::MDNode *getTBAAInfoForVTablePtr();
641  llvm::MDNode *getTBAAStructInfo(QualType QTy);
642  /// Return the path-aware tag for given base type, access node and offset.
643  llvm::MDNode *getTBAAStructTagInfo(QualType BaseTy, llvm::MDNode *AccessN,
644  uint64_t O);
645 
646  bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor);
647 
649  bool isPaddedAtomicType(const AtomicType *type);
650 
651  /// Decorate the instruction with a TBAA tag. For scalar TBAA, the tag
652  /// is the same as the type. For struct-path aware TBAA, the tag
653  /// is different from the type: base type, access type and offset.
654  /// When ConvertTypeToTag is true, we create a tag based on the scalar type.
655  void DecorateInstructionWithTBAA(llvm::Instruction *Inst,
656  llvm::MDNode *TBAAInfo,
657  bool ConvertTypeToTag = true);
658 
659  /// Adds !invariant.barrier !tag to instruction
660  void DecorateInstructionWithInvariantGroup(llvm::Instruction *I,
661  const CXXRecordDecl *RD);
662 
663  /// Emit the given number of characters as a value of type size_t.
664  llvm::ConstantInt *getSize(CharUnits numChars);
665 
666  /// Set the visibility for the given LLVM GlobalValue.
667  void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const;
668 
669  /// Set the TLS mode for the given LLVM GlobalValue for the thread-local
670  /// variable declaration D.
671  void setTLSMode(llvm::GlobalValue *GV, const VarDecl &D) const;
672 
673  static llvm::GlobalValue::VisibilityTypes GetLLVMVisibility(Visibility V) {
674  switch (V) {
678  }
679  llvm_unreachable("unknown visibility!");
680  }
681 
682  llvm::Constant *GetAddrOfGlobal(GlobalDecl GD, bool IsForDefinition = false);
683 
684  /// Will return a global variable of the given type. If a variable with a
685  /// different type already exists then a new variable with the right type
686  /// will be created and all uses of the old variable will be replaced with a
687  /// bitcast to the new variable.
688  llvm::GlobalVariable *
690  llvm::GlobalValue::LinkageTypes Linkage);
691 
692  llvm::Function *
693  CreateGlobalInitOrDestructFunction(llvm::FunctionType *ty, const Twine &name,
694  const CGFunctionInfo &FI,
696  bool TLS = false);
697 
698  /// Return the address space of the underlying global variable for D, as
699  /// determined by its declaration. Normally this is the same as the address
700  /// space of D's type, but in CUDA, address spaces are associated with
701  /// declarations, not types.
702  unsigned GetGlobalVarAddressSpace(const VarDecl *D, unsigned AddrSpace);
703 
704  /// Return the llvm::Constant for the address of the given global variable.
705  /// If Ty is non-null and if the global doesn't exist, then it will be created
706  /// with the specified type instead of whatever the normal requested type
707  /// would be. If IsForDefinition is true, it is guranteed that an actual
708  /// global with type Ty will be returned, not conversion of a variable with
709  /// the same mangled name but some other type.
710  llvm::Constant *GetAddrOfGlobalVar(const VarDecl *D,
711  llvm::Type *Ty = nullptr,
712  bool IsForDefinition = false);
713 
714  /// Return the address of the given function. If Ty is non-null, then this
715  /// function will use the specified type if it has to create it.
716  llvm::Constant *GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty = nullptr,
717  bool ForVTable = false,
718  bool DontDefer = false,
719  bool IsForDefinition = false);
720 
721  /// Get the address of the RTTI descriptor for the given type.
722  llvm::Constant *GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH = false);
723 
724  /// Get the address of a uuid descriptor .
726 
727  /// Get the address of the thunk for the given global decl.
728  llvm::Constant *GetAddrOfThunk(GlobalDecl GD, const ThunkInfo &Thunk);
729 
730  /// Get a reference to the target of VD.
732 
733  /// Returns the assumed alignment of an opaque pointer to the given class.
735 
736  /// Returns the assumed alignment of a virtual base of a class.
738  const CXXRecordDecl *Derived,
739  const CXXRecordDecl *VBase);
740 
741  /// Given a class pointer with an actual known alignment, and the
742  /// expected alignment of an object at a dynamic offset w.r.t that
743  /// pointer, return the alignment to assume at the offset.
745  const CXXRecordDecl *Class,
746  CharUnits ExpectedTargetAlign);
747 
748  CharUnits
752 
753  /// Returns the offset from a derived class to a class. Returns null if the
754  /// offset is 0.
755  llvm::Constant *
759 
760  llvm::FoldingSet<BlockByrefHelpers> ByrefHelpersCache;
761 
762  /// Fetches the global unique block count.
763  int getUniqueBlockCount() { return ++Block.GlobalUniqueCount; }
764 
765  /// Fetches the type of a generic block descriptor.
767 
768  /// The type of a generic block literal.
770 
771  /// Gets the address of a block which requires no captures.
772  llvm::Constant *GetAddrOfGlobalBlock(const BlockExpr *BE, const char *);
773 
774  /// Return a pointer to a constant CFString object for the given string.
776 
777  /// Return a pointer to a constant NSString object for the given string. Or a
778  /// user defined String object as defined via
779  /// -fconstant-string-class=class_name option.
781 
782  /// Return a constant array for the given string.
783  llvm::Constant *GetConstantArrayFromStringLiteral(const StringLiteral *E);
784 
785  /// Return a pointer to a constant array for the given string literal.
788  StringRef Name = ".str");
789 
790  /// Return a pointer to a constant array for the given ObjCEncodeExpr node.
793 
794  /// Returns a pointer to a character array containing the literal and a
795  /// terminating '\0' character. The result has pointer to array type.
796  ///
797  /// \param GlobalName If provided, the name to use for the global (if one is
798  /// created).
800  GetAddrOfConstantCString(const std::string &Str,
801  const char *GlobalName = nullptr);
802 
803  /// Returns a pointer to a constant global variable for the given file-scope
804  /// compound literal expression.
806 
807  /// \brief Returns a pointer to a global variable representing a temporary
808  /// with static or thread storage duration.
810  const Expr *Inner);
811 
812  /// \brief Retrieve the record type that describes the state of an
813  /// Objective-C fast enumeration loop (for..in).
815 
816  // Produce code for this constructor/destructor. This method doesn't try
817  // to apply any ABI rules about which other constructors/destructors
818  // are needed or if they are alias to each other.
819  llvm::Function *codegenCXXStructor(const CXXMethodDecl *MD,
821 
822  /// Return the address of the constructor/destructor of the given type.
823  llvm::Constant *
825  const CGFunctionInfo *FnInfo = nullptr,
826  llvm::FunctionType *FnType = nullptr,
827  bool DontDefer = false, bool IsForDefinition = false);
828 
829  /// Given a builtin id for a function like "__builtin_fabsf", return a
830  /// Function* for "fabsf".
832  unsigned BuiltinID);
833 
834  llvm::Function *getIntrinsic(unsigned IID, ArrayRef<llvm::Type*> Tys = None);
835 
836  /// Emit code for a single top level declaration.
837  void EmitTopLevelDecl(Decl *D);
838 
839  /// \brief Stored a deferred empty coverage mapping for an unused
840  /// and thus uninstrumented top level declaration.
842 
843  /// \brief Remove the deferred empty coverage mapping as this
844  /// declaration is actually instrumented.
845  void ClearUnusedCoverageMapping(const Decl *D);
846 
847  /// \brief Emit all the deferred coverage mappings
848  /// for the uninstrumented functions.
850 
851  /// Tell the consumer that this variable has been instantiated.
853 
854  /// \brief If the declaration has internal linkage but is inside an
855  /// extern "C" linkage specification, prepare to emit an alias for it
856  /// to the expected name.
857  template<typename SomeDecl>
858  void MaybeHandleStaticInExternC(const SomeDecl *D, llvm::GlobalValue *GV);
859 
860  /// Add a global to a list to be added to the llvm.used metadata.
861  void addUsedGlobal(llvm::GlobalValue *GV);
862 
863  /// Add a global to a list to be added to the llvm.compiler.used metadata.
864  void addCompilerUsedGlobal(llvm::GlobalValue *GV);
865 
866  /// Add a destructor and object to add to the C++ global destructor function.
867  void AddCXXDtorEntry(llvm::Constant *DtorFn, llvm::Constant *Object) {
868  CXXGlobalDtors.emplace_back(DtorFn, Object);
869  }
870 
871  /// Create a new runtime function with the specified type and name.
872  llvm::Constant *CreateRuntimeFunction(llvm::FunctionType *Ty,
873  StringRef Name,
874  llvm::AttributeSet ExtraAttrs =
875  llvm::AttributeSet());
876  /// Create a new compiler builtin function with the specified type and name.
877  llvm::Constant *CreateBuiltinFunction(llvm::FunctionType *Ty,
878  StringRef Name,
879  llvm::AttributeSet ExtraAttrs =
880  llvm::AttributeSet());
881  /// Create a new runtime global variable with the specified type and name.
882  llvm::Constant *CreateRuntimeVariable(llvm::Type *Ty,
883  StringRef Name);
884 
885  ///@name Custom Blocks Runtime Interfaces
886  ///@{
887 
888  llvm::Constant *getNSConcreteGlobalBlock();
889  llvm::Constant *getNSConcreteStackBlock();
890  llvm::Constant *getBlockObjectAssign();
891  llvm::Constant *getBlockObjectDispose();
892 
893  ///@}
894 
895  llvm::Constant *getLLVMLifetimeStartFn();
896  llvm::Constant *getLLVMLifetimeEndFn();
897 
898  // Make sure that this type is translated.
899  void UpdateCompletedType(const TagDecl *TD);
900 
901  llvm::Constant *getMemberPointerConstant(const UnaryOperator *e);
902 
903  /// Try to emit the initializer for the given declaration as a constant;
904  /// returns 0 if the expression cannot be emitted as a constant.
905  llvm::Constant *EmitConstantInit(const VarDecl &D,
906  CodeGenFunction *CGF = nullptr);
907 
908  /// Try to emit the given expression as a constant; returns 0 if the
909  /// expression cannot be emitted as a constant.
910  llvm::Constant *EmitConstantExpr(const Expr *E, QualType DestType,
911  CodeGenFunction *CGF = nullptr);
912 
913  /// Emit the given constant value as a constant, in the type's scalar
914  /// representation.
915  llvm::Constant *EmitConstantValue(const APValue &Value, QualType DestType,
916  CodeGenFunction *CGF = nullptr);
917 
918  /// Emit the given constant value as a constant, in the type's memory
919  /// representation.
920  llvm::Constant *EmitConstantValueForMemory(const APValue &Value,
921  QualType DestType,
922  CodeGenFunction *CGF = nullptr);
923 
924  /// \brief Emit type info if type of an expression is a variably modified
925  /// type. Also emit proper debug info for cast types.
927  CodeGenFunction *CGF = nullptr);
928 
929  /// Return the result of value-initializing the given type, i.e. a null
930  /// expression of the given type. This is usually, but not always, an LLVM
931  /// null constant.
932  llvm::Constant *EmitNullConstant(QualType T);
933 
934  /// Return a null constant appropriate for zero-initializing a base class with
935  /// the given type. This is usually, but not always, an LLVM null constant.
936  llvm::Constant *EmitNullConstantForBase(const CXXRecordDecl *Record);
937 
938  /// Emit a general error that something can't be done.
939  void Error(SourceLocation loc, StringRef error);
940 
941  /// Print out an error that codegen doesn't support the specified stmt yet.
942  void ErrorUnsupported(const Stmt *S, const char *Type);
943 
944  /// Print out an error that codegen doesn't support the specified decl yet.
945  void ErrorUnsupported(const Decl *D, const char *Type);
946 
947  /// Set the attributes on the LLVM function for the given decl and function
948  /// info. This applies attributes necessary for handling the ABI as well as
949  /// user specified attributes like section.
950  void SetInternalFunctionAttributes(const Decl *D, llvm::Function *F,
951  const CGFunctionInfo &FI);
952 
953  /// Set the LLVM function attributes (sext, zext, etc).
954  void SetLLVMFunctionAttributes(const Decl *D,
955  const CGFunctionInfo &Info,
956  llvm::Function *F);
957 
958  /// Set the LLVM function attributes which only apply to a function
959  /// definition.
960  void SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F);
961 
962  /// Return true iff the given type uses 'sret' when used as a return type.
963  bool ReturnTypeUsesSRet(const CGFunctionInfo &FI);
964 
965  /// Return true iff the given type uses an argument slot when 'sret' is used
966  /// as a return type.
968 
969  /// Return true iff the given type uses 'fpret' when used as a return type.
970  bool ReturnTypeUsesFPRet(QualType ResultType);
971 
972  /// Return true iff the given type uses 'fp2ret' when used as a return type.
973  bool ReturnTypeUsesFP2Ret(QualType ResultType);
974 
975  /// Get the LLVM attributes and calling convention to use for a particular
976  /// function type.
977  ///
978  /// \param Name - The function name.
979  /// \param Info - The function type information.
980  /// \param CalleeInfo - The callee information these attributes are being
981  /// constructed for. If valid, the attributes applied to this decl may
982  /// contribute to the function attributes and calling convention.
983  /// \param PAL [out] - On return, the attribute list to use.
984  /// \param CallingConv [out] - On return, the LLVM calling convention to use.
985  void ConstructAttributeList(StringRef Name, const CGFunctionInfo &Info,
986  CGCalleeInfo CalleeInfo, AttributeListType &PAL,
987  unsigned &CallingConv, bool AttrOnCallSite);
988 
989  // Fills in the supplied string map with the set of target features for the
990  // passed in function.
991  void getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
992  const FunctionDecl *FD);
993 
994  StringRef getMangledName(GlobalDecl GD);
995  StringRef getBlockMangledName(GlobalDecl GD, const BlockDecl *BD);
996 
997  void EmitTentativeDefinition(const VarDecl *D);
998 
999  void EmitVTable(CXXRecordDecl *Class);
1000 
1001  void RefreshTypeCacheForClass(const CXXRecordDecl *Class);
1002 
1003  /// \brief Appends Opts to the "Linker Options" metadata value.
1004  void AppendLinkerOptions(StringRef Opts);
1005 
1006  /// \brief Appends a detect mismatch command to the linker options.
1007  void AddDetectMismatch(StringRef Name, StringRef Value);
1008 
1009  /// \brief Appends a dependent lib to the "Linker Options" metadata value.
1010  void AddDependentLib(StringRef Lib);
1011 
1012  llvm::GlobalVariable::LinkageTypes getFunctionLinkage(GlobalDecl GD);
1013 
1014  void setFunctionLinkage(GlobalDecl GD, llvm::Function *F) {
1015  F->setLinkage(getFunctionLinkage(GD));
1016  }
1017 
1018  /// Set the DLL storage class on F.
1019  void setFunctionDLLStorageClass(GlobalDecl GD, llvm::Function *F);
1020 
1021  /// Return the appropriate linkage for the vtable, VTT, and type information
1022  /// of the given class.
1023  llvm::GlobalVariable::LinkageTypes getVTableLinkage(const CXXRecordDecl *RD);
1024 
1025  /// Return the store size, in character units, of the given LLVM type.
1027 
1028  /// Returns LLVM linkage for a declarator.
1029  llvm::GlobalValue::LinkageTypes
1031  bool IsConstantVariable);
1032 
1033  /// Returns LLVM linkage for a declarator.
1034  llvm::GlobalValue::LinkageTypes
1035  getLLVMLinkageVarDefinition(const VarDecl *VD, bool IsConstant);
1036 
1037  /// Emit all the global annotations.
1038  void EmitGlobalAnnotations();
1039 
1040  /// Emit an annotation string.
1041  llvm::Constant *EmitAnnotationString(StringRef Str);
1042 
1043  /// Emit the annotation's translation unit.
1044  llvm::Constant *EmitAnnotationUnit(SourceLocation Loc);
1045 
1046  /// Emit the annotation line number.
1047  llvm::Constant *EmitAnnotationLineNo(SourceLocation L);
1048 
1049  /// Generate the llvm::ConstantStruct which contains the annotation
1050  /// information for a given GlobalValue. The annotation struct is
1051  /// {i8 *, i8 *, i8 *, i32}. The first field is a constant expression, the
1052  /// GlobalValue being annotated. The second field is the constant string
1053  /// created from the AnnotateAttr's annotation. The third field is a constant
1054  /// string containing the name of the translation unit. The fourth field is
1055  /// the line number in the file of the annotated value declaration.
1056  llvm::Constant *EmitAnnotateAttr(llvm::GlobalValue *GV,
1057  const AnnotateAttr *AA,
1058  SourceLocation L);
1059 
1060  /// Add global annotations that are set on D, for the global GV. Those
1061  /// annotations are emitted during finalization of the LLVM code.
1062  void AddGlobalAnnotations(const ValueDecl *D, llvm::GlobalValue *GV);
1063 
1064  bool isInSanitizerBlacklist(llvm::Function *Fn, SourceLocation Loc) const;
1065 
1066  bool isInSanitizerBlacklist(llvm::GlobalVariable *GV, SourceLocation Loc,
1067  QualType Ty,
1068  StringRef Category = StringRef()) const;
1069 
1071  return SanitizerMD.get();
1072  }
1073 
1075  DeferredVTables.push_back(RD);
1076  }
1077 
1078  /// Emit code for a singal global function or var decl. Forward declarations
1079  /// are emitted lazily.
1080  void EmitGlobal(GlobalDecl D);
1081 
1082  bool TryEmitDefinitionAsAlias(GlobalDecl Alias, GlobalDecl Target,
1083  bool InEveryTU);
1085 
1086  /// Set attributes for a global definition.
1088  llvm::Function *F);
1089 
1090  llvm::GlobalValue *GetGlobalValue(StringRef Ref);
1091 
1092  /// Set attributes which are common to any form of a global definition (alias,
1093  /// Objective-C method, function, global variable).
1094  ///
1095  /// NOTE: This should only be called for definitions.
1096  void SetCommonAttributes(const Decl *D, llvm::GlobalValue *GV);
1097 
1098  /// Set attributes which must be preserved by an alias. This includes common
1099  /// attributes (i.e. it includes a call to SetCommonAttributes).
1100  ///
1101  /// NOTE: This should only be called for definitions.
1102  void setAliasAttributes(const Decl *D, llvm::GlobalValue *GV);
1103 
1104  void addReplacement(StringRef Name, llvm::Constant *C);
1105 
1106  void addGlobalValReplacement(llvm::GlobalValue *GV, llvm::Constant *C);
1107 
1108  /// \brief Emit a code for threadprivate directive.
1109  /// \param D Threadprivate declaration.
1111 
1112  /// \brief Emit a code for declare reduction construct.
1114  CodeGenFunction *CGF = nullptr);
1115 
1116  /// Returns whether the given record has hidden LTO visibility and therefore
1117  /// may participate in (single-module) CFI and whole-program vtable
1118  /// optimization.
1119  bool HasHiddenLTOVisibility(const CXXRecordDecl *RD);
1120 
1121  /// Emit type metadata for the given vtable using the given layout.
1122  void EmitVTableTypeMetadata(llvm::GlobalVariable *VTable,
1123  const VTableLayout &VTLayout);
1124 
1125  /// Generate a cross-DSO type identifier for MD.
1126  llvm::ConstantInt *CreateCrossDsoCfiTypeId(llvm::Metadata *MD);
1127 
1128  /// Create a metadata identifier for the given type. This may either be an
1129  /// MDString (for external identifiers) or a distinct unnamed MDNode (for
1130  /// internal identifiers).
1131  llvm::Metadata *CreateMetadataIdentifierForType(QualType T);
1132 
1133  /// Create and attach type metadata to the given function.
1134  void CreateFunctionTypeMetadata(const FunctionDecl *FD, llvm::Function *F);
1135 
1136  /// Returns whether this module needs the "all-vtables" type identifier.
1137  bool NeedAllVtablesTypeId() const;
1138 
1139  /// Create and attach type metadata for the given vtable.
1140  void AddVTableTypeMetadata(llvm::GlobalVariable *VTable, CharUnits Offset,
1141  const CXXRecordDecl *RD);
1142 
1143  /// \breif Get the declaration of std::terminate for the platform.
1144  llvm::Constant *getTerminateFn();
1145 
1146  llvm::SanitizerStatReport &getSanStats();
1147 
1148 private:
1149  llvm::Constant *
1150  GetOrCreateLLVMFunction(StringRef MangledName, llvm::Type *Ty, GlobalDecl D,
1151  bool ForVTable, bool DontDefer = false,
1152  bool IsThunk = false,
1153  llvm::AttributeSet ExtraAttrs = llvm::AttributeSet(),
1154  bool IsForDefinition = false);
1155 
1156  llvm::Constant *GetOrCreateLLVMGlobal(StringRef MangledName,
1157  llvm::PointerType *PTy,
1158  const VarDecl *D,
1159  bool IsForDefinition = false);
1160 
1161  void setNonAliasAttributes(const Decl *D, llvm::GlobalObject *GO);
1162 
1163  /// Set function attributes for a function declaration.
1164  void SetFunctionAttributes(GlobalDecl GD, llvm::Function *F,
1165  bool IsIncompleteFunction, bool IsThunk);
1166 
1167  void EmitGlobalDefinition(GlobalDecl D, llvm::GlobalValue *GV = nullptr);
1168 
1169  void EmitGlobalFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV);
1170  void EmitGlobalVarDefinition(const VarDecl *D, bool IsTentative = false);
1171  void EmitAliasDefinition(GlobalDecl GD);
1172  void emitIFuncDefinition(GlobalDecl GD);
1173  void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D);
1174  void EmitObjCIvarInitializations(ObjCImplementationDecl *D);
1175 
1176  // C++ related functions.
1177 
1178  void EmitNamespace(const NamespaceDecl *D);
1179  void EmitLinkageSpec(const LinkageSpecDecl *D);
1180  void CompleteDIClassType(const CXXMethodDecl* D);
1181 
1182  /// \brief Emit the function that initializes C++ thread_local variables.
1183  void EmitCXXThreadLocalInitFunc();
1184 
1185  /// Emit the function that initializes C++ globals.
1186  void EmitCXXGlobalInitFunc();
1187 
1188  /// Emit the function that destroys C++ globals.
1189  void EmitCXXGlobalDtorFunc();
1190 
1191  /// Emit the function that initializes the specified global (if PerformInit is
1192  /// true) and registers its destructor.
1193  void EmitCXXGlobalVarDeclInitFunc(const VarDecl *D,
1194  llvm::GlobalVariable *Addr,
1195  bool PerformInit);
1196 
1197  void EmitPointerToInitFunc(const VarDecl *VD, llvm::GlobalVariable *Addr,
1198  llvm::Function *InitFunc, InitSegAttr *ISA);
1199 
1200  // FIXME: Hardcoding priority here is gross.
1201  void AddGlobalCtor(llvm::Function *Ctor, int Priority = 65535,
1202  llvm::Constant *AssociatedData = nullptr);
1203  void AddGlobalDtor(llvm::Function *Dtor, int Priority = 65535);
1204 
1205  /// Generates a global array of functions and priorities using the given list
1206  /// and name. This array will have appending linkage and is suitable for use
1207  /// as a LLVM constructor or destructor array.
1208  void EmitCtorList(const CtorList &Fns, const char *GlobalName);
1209 
1210  /// Emit any needed decls for which code generation was deferred.
1211  void EmitDeferred();
1212 
1213  /// Call replaceAllUsesWith on all pairs in Replacements.
1214  void applyReplacements();
1215 
1216  /// Call replaceAllUsesWith on all pairs in GlobalValReplacements.
1217  void applyGlobalValReplacements();
1218 
1219  void checkAliases();
1220 
1221  /// Emit any vtables which we deferred and still have a use for.
1222  void EmitDeferredVTables();
1223 
1224  /// Emit the llvm.used and llvm.compiler.used metadata.
1225  void emitLLVMUsed();
1226 
1227  /// \brief Emit the link options introduced by imported modules.
1228  void EmitModuleLinkOptions();
1229 
1230  /// \brief Emit aliases for internal-linkage declarations inside "C" language
1231  /// linkage specifications, giving them the "expected" name where possible.
1232  void EmitStaticExternCAliases();
1233 
1234  void EmitDeclMetadata();
1235 
1236  /// \brief Emit the Clang version as llvm.ident metadata.
1237  void EmitVersionIdentMetadata();
1238 
1239  /// Emits target specific Metadata for global declarations.
1240  void EmitTargetMetadata();
1241 
1242  /// Emit the llvm.gcov metadata used to tell LLVM where to emit the .gcno and
1243  /// .gcda files in a way that persists in .bc files.
1244  void EmitCoverageFile();
1245 
1246  /// Emits the initializer for a uuidof string.
1247  llvm::Constant *EmitUuidofInitializer(StringRef uuidstr);
1248 
1249  /// Determine whether the definition must be emitted; if this returns \c
1250  /// false, the definition can be emitted lazily if it's used.
1251  bool MustBeEmitted(const ValueDecl *D);
1252 
1253  /// Determine whether the definition can be emitted eagerly, or should be
1254  /// delayed until the end of the translation unit. This is relevant for
1255  /// definitions whose linkage can change, e.g. implicit function instantions
1256  /// which may later be explicitly instantiated.
1257  bool MayBeEmittedEagerly(const ValueDecl *D);
1258 
1259  /// Check whether we can use a "simpler", more core exceptions personality
1260  /// function.
1261  void SimplifyPersonality();
1262 };
1263 } // end namespace CodeGen
1264 } // end namespace clang
1265 
1266 #endif // LLVM_CLANG_LIB_CODEGEN_CODEGENMODULE_H
CGOpenCLRuntime & getOpenCLRuntime()
Return a reference to the configured OpenCL runtime.
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1561
llvm::Type * getGenericBlockLiteralType()
The type of a generic block literal.
Definition: CGBlocks.cpp:942
void EmitDeferredUnusedCoverageMappings()
Emit all the deferred coverage mappings for the uninstrumented functions.
void DecorateInstructionWithInvariantGroup(llvm::Instruction *I, const CXXRecordDecl *RD)
Adds !invariant.barrier !tag to instruction.
ObjCEntrypoints & getObjCEntrypoints() const
void Profile(llvm::FoldingSetNodeID &id) const
void setTypeDescriptorInMap(QualType Ty, llvm::Constant *C)
A (possibly-)qualified type.
Definition: Type.h:598
bool ReturnTypeUsesSRet(const CGFunctionInfo &FI)
Return true iff the given type uses 'sret' when used as a return type.
Definition: CGCall.cpp:1423
bool hasObjCRuntime()
Return true iff an Objective-C runtime has been configured.
llvm::Module & getModule() const
llvm::Constant * getMemberPointerConstant(const UnaryOperator *e)
llvm::LLVMContext & getLLVMContext()
ConstantAddress GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *)
Return a pointer to a constant array for the given ObjCEncodeExpr node.
CharUnits getClassPointerAlignment(const CXXRecordDecl *CD)
Returns the assumed alignment of an opaque pointer to the given class.
Definition: CGClass.cpp:36
Implements runtime-specific code generation functions.
Definition: CGObjCRuntime.h:63
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Definition: CharUnits.h:179
Defines the clang::Module class, which describes a module in the source code.
llvm::Constant * objc_autoreleaseReturnValue
id objc_autoreleaseReturnValue(id);
llvm::MDNode * getTBAAStructInfo(QualType QTy)
BlockByrefHelpers(CharUnits alignment)
void setAliasAttributes(const Decl *D, llvm::GlobalValue *GV)
Set attributes which must be preserved by an alias.
const llvm::DataLayout & getDataLayout() const
The base class of the type hierarchy.
Definition: Type.h:1281
void setFunctionLinkage(GlobalDecl GD, llvm::Function *F)
Stores additional source code information like skipped ranges which is required by the coverage mappi...
NamespaceDecl - Represent a C++ namespace.
Definition: Decl.h:471
llvm::Constant * objc_loadWeakRetained
id objc_loadWeakRetained(id*);
const PreprocessorOptions & getPreprocessorOpts() const
bool HasHiddenLTOVisibility(const CXXRecordDecl *RD)
Returns whether the given record has hidden LTO visibility and therefore may participate in (single-m...
Definition: CGVTables.cpp:906
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
bool operator==(const OrderGlobalInits &RHS) const
bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D)
Try to emit a base destructor as an alias to its primary base-class destructor.
Definition: CGCXX.cpp:34
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Definition: ExprCXX.h:3962
static llvm::GlobalValue::VisibilityTypes GetLLVMVisibility(Visibility V)
llvm::Constant * EmitConstantValue(const APValue &Value, QualType DestType, CodeGenFunction *CGF=nullptr)
Emit the given constant value as a constant, in the type's scalar representation. ...
const CXXBaseSpecifier *const * path_const_iterator
Definition: Expr.h:2697
void HandleCXXStaticMemberVarInstantiation(VarDecl *VD)
Tell the consumer that this variable has been instantiated.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:768
Objects with "hidden" visibility are not seen by the dynamic linker.
Definition: Visibility.h:35
CompoundLiteralExpr - [C99 6.5.2.5].
Definition: Expr.h:2562
void setFunctionDefinitionAttributes(const FunctionDecl *D, llvm::Function *F)
Set attributes for a global definition.
CGDebugInfo * getModuleDebugInfo()
void setFunctionDLLStorageClass(GlobalDecl GD, llvm::Function *F)
Set the DLL storage class on F.
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
Definition: CGDebugInfo.h:52
CharUnits GetTargetTypeStoreSize(llvm::Type *Ty) const
Return the store size, in character units, of the given LLVM type.
llvm::Constant * getAtomicSetterHelperFnMap(QualType Ty)
bool NeedAllVtablesTypeId() const
Returns whether this module needs the "all-vtables" type identifier.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
Definition: Linkage.h:25
llvm::Constant * EmitConstantValueForMemory(const APValue &Value, QualType DestType, CodeGenFunction *CGF=nullptr)
Emit the given constant value as a constant, in the type's memory representation. ...
llvm::Constant * objc_autorelease
id objc_autorelease(id);
llvm::GlobalVariable * getStaticLocalDeclGuardAddress(const VarDecl *D)
llvm::Constant * objc_copyWeak
void objc_copyWeak(id *dest, id *src);
llvm::Constant * getAtomicGetterHelperFnMap(QualType Ty)
One of these records is kept for each identifier that is lexed.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Definition: Type.h:4549
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
llvm::Constant * objc_loadWeak
id objc_loadWeak(id*);
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:92
llvm::Constant * objc_retainAutoreleasedReturnValue
id objc_retainAutoreleasedReturnValue(id);
int Category
Definition: Format.cpp:1197
llvm::Constant * CreateBuiltinFunction(llvm::FunctionType *Ty, StringRef Name, llvm::AttributeSet ExtraAttrs=llvm::AttributeSet())
Create a new compiler builtin function with the specified type and name.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:48
llvm::Function * codegenCXXStructor(const CXXMethodDecl *MD, StructorType Type)
Definition: CGCXX.cpp:217
The this pointer adjustment as well as an optional return adjustment for a thunk. ...
Definition: ABI.h:179
bool isPaddedAtomicType(QualType type)
Objects with "default" visibility are seen by the dynamic linker and act like normal objects...
Definition: Visibility.h:44
llvm::Constant * GetConstantArrayFromStringLiteral(const StringLiteral *E)
Return a constant array for the given string.
CharUnits getDynamicOffsetAlignment(CharUnits ActualAlign, const CXXRecordDecl *Class, CharUnits ExpectedTargetAlign)
Given a class pointer with an actual known alignment, and the expected alignment of an object at a dy...
Definition: CGClass.cpp:70
llvm::Constant * getLLVMLifetimeStartFn()
Lazily declare the .lifetime.start intrinsic.
Definition: CGDecl.cpp:1711
virtual void profileImpl(llvm::FoldingSetNodeID &id) const =0
bool operator<(const OrderGlobalInits &RHS) const
CGCUDARuntime & getCUDARuntime()
Return a reference to the configured CUDA runtime.
llvm::Constant * objc_initWeak
id objc_initWeak(id*, id);
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:38
uint32_t Offset
Definition: CacheTokens.cpp:44
void EmitOMPDeclareReduction(const OMPDeclareReductionDecl *D, CodeGenFunction *CGF=nullptr)
Emit a code for declare reduction construct.
Definition: CGDecl.cpp:1874
Structor(int Priority, llvm::Constant *Initializer, llvm::Constant *AssociatedData)
Visibility
Describes the different kinds of visibility that a declaration may have.
Definition: Visibility.h:32
void setStaticLocalDeclAddress(const VarDecl *D, llvm::Constant *C)
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:135
llvm::Constant * objc_release
void objc_release(id);
void addDeferredVTable(const CXXRecordDecl *RD)
void setAtomicGetterHelperFnMap(QualType Ty, llvm::Constant *Fn)
llvm::Constant * getTerminateFn()
Get the declaration of std::terminate for the platform.
Definition: CGException.cpp:50
void addMissing(bool MainFile)
Record that a function we've visited has no profile data.
void addCompilerUsedGlobal(llvm::GlobalValue *GV)
Add a global to a list to be added to the llvm.compiler.used metadata.
llvm::Constant * GetAddrOfGlobal(GlobalDecl GD, bool IsForDefinition=false)
Enums/classes describing ABI related information about constructors, destructors and thunks...
llvm::Constant * CreateRuntimeVariable(llvm::Type *Ty, StringRef Name)
Create a new runtime global variable with the specified type and name.
ItaniumVTableContext & getItaniumVTableContext()
Definition: CGVTables.h:71
void EmitTentativeDefinition(const VarDecl *D)
llvm::SanitizerStatReport & getSanStats()
Represents a linkage specification.
Definition: DeclCXX.h:2523
void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const
Set the visibility for the given LLVM GlobalValue.
detail::InMemoryDirectory::const_iterator I
llvm::Constant * getNSConcreteStackBlock()
Definition: CGBlocks.cpp:2367
InstrProfStats & getPGOStats()
bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor)
isTypeConstant - Determine whether an object of this type can be emitted as a constant.
const HeaderSearchOptions & getHeaderSearchOpts() const
llvm::Constant * getStaticLocalDeclAddress(const VarDecl *D)
const TargetCodeGenInfo & getTargetCodeGenInfo()
llvm::Constant * objc_storeStrong
id objc_storeStrong(id*, id);
virtual void emitCopy(CodeGenFunction &CGF, Address dest, Address src)=0
void AddDetectMismatch(StringRef Name, StringRef Value)
Appends a detect mismatch command to the linker options.
const TargetInfo & getTarget() const
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:646
StringRef getBlockMangledName(GlobalDecl GD, const BlockDecl *BD)
const SmallVectorImpl< AnnotatedLine * >::const_iterator End
void getFunctionFeatureMap(llvm::StringMap< bool > &FeatureMap, const FunctionDecl *FD)
Exposes information about the current target.
void DecorateInstructionWithTBAA(llvm::Instruction *Inst, llvm::MDNode *TBAAInfo, bool ConvertTypeToTag=true)
Decorate the instruction with a TBAA tag.
CGObjCRuntime & getObjCRuntime()
Return a reference to the configured Objective-C runtime.
void SetLLVMFunctionAttributes(const Decl *D, const CGFunctionInfo &Info, llvm::Function *F)
Set the LLVM function attributes (sext, zext, etc).
llvm::Constant * EmitAnnotationUnit(SourceLocation Loc)
Emit the annotation's translation unit.
CharUnits Alignment
The alignment of the field.
friend class ASTContext
Definition: Type.h:4178
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
Definition: Decl.h:3456
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Definition: Decl.h:590
Expr - This represents one expression.
Definition: Expr.h:105
Defines the clang::LangOptions interface.
llvm::Constant * objc_autoreleasePoolPop
void objc_autoreleasePoolPop(void*);
virtual bool needsCopy() const
CGCXXABI & getCXXABI() const
void AddGlobalAnnotations(const ValueDecl *D, llvm::GlobalValue *GV)
Add global annotations that are set on D, for the global GV.
void SetInternalFunctionAttributes(const Decl *D, llvm::Function *F, const CGFunctionInfo &FI)
Set the attributes on the LLVM function for the given decl and function info.
Organizes the cross-function state that is used while generating code coverage mapping data...
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:4567
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2414
void reportDiagnostics(DiagnosticsEngine &Diags, StringRef MainFile)
Report potential problems we've found to Diags.
void AddCXXDtorEntry(llvm::Constant *DtorFn, llvm::Constant *Object)
Add a destructor and object to add to the C++ global destructor function.
llvm::Constant * objc_retain
id objc_retain(id);
ASTContext & getContext() const
void setStaticLocalDeclGuardAddress(const VarDecl *D, llvm::GlobalVariable *C)
MicrosoftVTableContext & getMicrosoftVTableContext()
bool ReturnSlotInterferesWithArgs(const CGFunctionInfo &FI)
Return true iff the given type uses an argument slot when 'sret' is used as a return type...
Definition: CGCall.cpp:1427
llvm::GlobalValue::LinkageTypes getLLVMLinkageVarDefinition(const VarDecl *VD, bool IsConstant)
Returns LLVM linkage for a declarator.
Objects with "protected" visibility are seen by the dynamic linker but always dynamically resolve to ...
Definition: Visibility.h:40
void addMismatched(bool MainFile)
Record that a function we've visited has mismatched profile data.
llvm::Constant * EmitAnnotationString(StringRef Str)
Emit an annotation string.
ConstantAddress GetAddrOfUuidDescriptor(const CXXUuidofExpr *E)
Get the address of a uuid descriptor .
llvm::GlobalVariable::LinkageTypes getFunctionLinkage(GlobalDecl GD)
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Definition: Expr.h:1668
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type * > Tys=None)
CGOpenMPRuntime(CodeGenModule &CGM)
void AddVTableTypeMetadata(llvm::GlobalVariable *VTable, CharUnits Offset, const CXXRecordDecl *RD)
Create and attach type metadata for the given vtable.
bool lookupRepresentativeDecl(StringRef MangledName, GlobalDecl &Result) const
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:231
GlobalDecl - represents a global declaration.
Definition: GlobalDecl.h:29
llvm::GlobalVariable * CreateOrReplaceCXXRuntimeVariable(StringRef Name, llvm::Type *Ty, llvm::GlobalValue::LinkageTypes Linkage)
Will return a global variable of the given type.
llvm::Constant * EmitAnnotateAttr(llvm::GlobalValue *GV, const AnnotateAttr *AA, SourceLocation L)
Generate the llvm::ConstantStruct which contains the annotation information for a given GlobalValue...
llvm::Constant * GetAddrOfThunk(GlobalDecl GD, const ThunkInfo &Thunk)
Get the address of the thunk for the given global decl.
Definition: CGVTables.cpp:35
ConstantAddress GetAddrOfGlobalTemporary(const MaterializeTemporaryExpr *E, const Expr *Inner)
Returns a pointer to a global variable representing a temporary with static or thread storage duratio...
void addVisited(bool MainFile)
Record that we've visited a function and whether or not that function was in the main source file...
The l-value was considered opaque, so the alignment was determined from a type.
llvm::Constant * objc_retainBlock
id objc_retainBlock(id);
llvm::Constant * getOrCreateStaticVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage)
Definition: CGDecl.cpp:186
llvm::Constant * CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name, llvm::AttributeSet ExtraAttrs=llvm::AttributeSet())
Create a new runtime function with the specified type and name.
void RefreshTypeCacheForClass(const CXXRecordDecl *Class)
bool ReturnTypeUsesFPRet(QualType ResultType)
Return true iff the given type uses 'fpret' when used as a return type.
Definition: CGCall.cpp:1432
llvm::Constant * objc_storeWeak
id objc_storeWeak(id*, id);
void MaybeHandleStaticInExternC(const SomeDecl *D, llvm::GlobalValue *GV)
If the declaration has internal linkage but is inside an extern "C" linkage specification, prepare to emit an alias for it to the expected name.
llvm::Constant * EmitConstantExpr(const Expr *E, QualType DestType, CodeGenFunction *CGF=nullptr)
Try to emit the given expression as a constant; returns 0 if the expression cannot be emitted as a co...
Encodes a location in the source.
llvm::Constant * GetAddrOfGlobalVar(const VarDecl *D, llvm::Type *Ty=nullptr, bool IsForDefinition=false)
Return the llvm::Constant for the address of the given global variable.
llvm::Constant * getTypeDescriptorFromMap(QualType Ty)
This represents '#pragma omp declare reduction ...' directive.
Definition: DeclOpenMP.h:102
ConstantAddress GetAddrOfConstantCFString(const StringLiteral *Literal)
Return a pointer to a constant CFString object for the given string.
TagDecl - Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:2727
llvm::Metadata * CreateMetadataIdentifierForType(QualType T)
Create a metadata identifier for the given type.
llvm::Constant * objc_autoreleasePoolPush
void *objc_autoreleasePoolPush(void);
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1736
ConstantAddress GetAddrOfConstantStringFromLiteral(const StringLiteral *S, StringRef Name=".str")
Return a pointer to a constant array for the given string literal.
llvm::Constant * EmitNullConstantForBase(const CXXRecordDecl *Record)
Return a null constant appropriate for zero-initializing a base class with the given type...
This file defines OpenMP nodes for declarative directives.
llvm::Constant * GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH=false)
Get the address of the RTTI descriptor for the given type.
llvm::MDNode * getTBAAStructTagInfo(QualType BaseTy, llvm::MDNode *AccessN, uint64_t O)
Return the path-aware tag for given base type, access node and offset.
llvm::InlineAsm * retainAutoreleasedReturnValueMarker
A void(void) inline asm to use to mark that the return value of a call will be immediately retain...
const CodeGenOptions & getCodeGenOpts() const
void addGlobalValReplacement(llvm::GlobalValue *GV, llvm::Constant *C)
ConstantAddress GetWeakRefReference(const ValueDecl *VD)
Get a reference to the target of VD.
llvm::Constant * getBlockObjectDispose()
Definition: CGBlocks.cpp:2332
An aligned address.
Definition: Address.h:25
const LangOptions & getLangOpts() const
void SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F)
Set the LLVM function attributes which only apply to a function definition.
void EmitTopLevelDecl(Decl *D)
Emit code for a single top level declaration.
void CreateFunctionTypeMetadata(const FunctionDecl *FD, llvm::Function *F)
Create and attach type metadata to the given function.
llvm::Constant * EmitAnnotationLineNo(SourceLocation L)
Emit the annotation line number.
llvm::Constant * getAddrOfCXXStructor(const CXXMethodDecl *MD, StructorType Type, const CGFunctionInfo *FnInfo=nullptr, llvm::FunctionType *FnType=nullptr, bool DontDefer=false, bool IsForDefinition=false)
Return the address of the constructor/destructor of the given type.
Definition: CGCXX.cpp:242
virtual bool needsDispose() const
ItaniumVTableContext & getItaniumVTableContext()
TargetCodeGenInfo - This class organizes various target-specific codegeneration issues, like target-specific attributes, builtins and so on.
bool ReturnTypeUsesFP2Ret(QualType ResultType)
Return true iff the given type uses 'fp2ret' when used as a return type.
Definition: CGCall.cpp:1449
void Error(SourceLocation loc, StringRef error)
Emit a general error that something can't be done.
llvm::Constant * getLLVMLifetimeEndFn()
Lazily declare the .lifetime.end intrinsic.
Definition: CGDecl.cpp:1719
std::vector< Structor > CtorList
void addReplacement(StringRef Name, llvm::Constant *C)
llvm::Value * getBuiltinLibFunction(const FunctionDecl *FD, unsigned BuiltinID)
Given a builtin id for a function like "__builtin_fabsf", return a Function* for "fabsf".
Definition: CGBuiltin.cpp:38
ConstantAddress GetAddrOfConstantCString(const std::string &Str, const char *GlobalName=nullptr)
Returns a pointer to a character array containing the literal and a terminating '\0' character...
void addUsedGlobal(llvm::GlobalValue *GV)
Add a global to a list to be added to the llvm.used metadata.
void ErrorUnsupported(const Stmt *S, const char *Type)
Print out an error that codegen doesn't support the specified stmt yet.
CGFunctionInfo - Class to encapsulate the information about a function definition.
This class organizes the cross-function state that is used while generating LLVM code.
llvm::Constant * objc_unsafeClaimAutoreleasedReturnValue
id objc_unsafeClaimAutoreleasedReturnValue(id);
CGOpenMPRuntime & getOpenMPRuntime()
Return a reference to the configured OpenMP runtime.
llvm::GlobalValue * GetGlobalValue(StringRef Ref)
llvm::FoldingSet< BlockByrefHelpers > ByrefHelpersCache
int getUniqueBlockCount()
Fetches the global unique block count.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Definition: ASTMatchers.h:1983
The basic abstraction for the target Objective-C runtime.
Definition: ObjCRuntime.h:25
void EmitVTableTypeMetadata(llvm::GlobalVariable *VTable, const VTableLayout &VTLayout)
Emit type metadata for the given vtable using the given layout.
Definition: CGVTables.cpp:940
bool TryEmitDefinitionAsAlias(GlobalDecl Alias, GlobalDecl Target, bool InEveryTU)
Try to emit a definition as a global alias for another definition.
Definition: CGCXX.cpp:120
void setTLSMode(llvm::GlobalValue *GV, const VarDecl &D) const
Set the TLS mode for the given LLVM GlobalValue for the thread-local variable declaration D...
void EmitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *D)
Emit a code for threadprivate directive.
llvm::Constant * objc_destroyWeak
void objc_destroyWeak(id*);
llvm::Constant * clang_arc_use
void clang.arc.use(...);
ConstantAddress GetAddrOfConstantString(const StringLiteral *Literal)
Return a pointer to a constant NSString object for the given string.
llvm::Constant * EmitNullConstant(QualType T)
Return the result of value-initializing the given type, i.e.
void UpdateCompletedType(const TagDecl *TD)
detail::InMemoryDirectory::const_iterator E
unsigned GetGlobalVarAddressSpace(const VarDecl *D, unsigned AddrSpace)
Return the address space of the underlying global variable for D, as determined by its declaration...
const llvm::Triple & getTriple() const
ExplicitCastExpr - An explicit cast written in the source code.
Definition: Expr.h:2800
void maybeSetTrivialComdat(const Decl &D, llvm::GlobalObject &GO)
CharUnits getVBaseAlignment(CharUnits DerivedAlign, const CXXRecordDecl *Derived, const CXXRecordDecl *VBase)
Returns the assumed alignment of a virtual base of a class.
Definition: CGClass.cpp:55
bool isInSanitizerBlacklist(llvm::Function *Fn, SourceLocation Loc) const
void AddDeferredUnusedCoverageMapping(Decl *D)
Stored a deferred empty coverage mapping for an unused and thus uninstrumented top level declaration...
llvm::GlobalVariable::LinkageTypes getVTableLinkage(const CXXRecordDecl *RD)
Return the appropriate linkage for the vtable, VTT, and type information of the given class...
Definition: CGVTables.cpp:727
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2461
void EmitExplicitCastExprType(const ExplicitCastExpr *E, CodeGenFunction *CGF=nullptr)
Emit type info if type of an expression is a variably modified type.
Definition: CGExpr.cpp:804
void AppendLinkerOptions(StringRef Opts)
Appends Opts to the "Linker Options" metadata value.
Implements C++ ABI-specific code generation functions.
Definition: CGCXXABI.h:43
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:355
This class organizes the cross-module state that is used while lowering AST types to LLVM types...
Definition: CodeGenTypes.h:120
bool hasDiagnostics()
Whether or not the stats we've gathered indicate any potential problems.
This class records statistics on instrumentation based profiling.
llvm::Constant * objc_retainAutorelease
id objc_retainAutorelease(id);
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
llvm::Constant * GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl, CastExpr::path_const_iterator PathBegin, CastExpr::path_const_iterator PathEnd)
Returns the offset from a derived class to a class.
Definition: CGClass.cpp:175
llvm::Constant * GetAddrOfGlobalBlock(const BlockExpr *BE, const char *)
Gets the address of a block which requires no captures.
Definition: CGBlocks.cpp:1044
StringRef getMangledName(GlobalDecl GD)
virtual void emitDispose(CodeGenFunction &CGF, Address field)=0
llvm::Constant * getBlockObjectAssign()
Definition: CGBlocks.cpp:2344
void setAtomicSetterHelperFnMap(QualType Ty, llvm::Constant *Fn)
ConstantAddress GetAddrOfConstantCompoundLiteral(const CompoundLiteralExpr *E)
Returns a pointer to a constant global variable for the given file-scope compound literal expression...
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
Definition: APValue.h:38
llvm::Constant * EmitConstantInit(const VarDecl &D, CodeGenFunction *CGF=nullptr)
Try to emit the initializer for the given declaration as a constant; returns 0 if the expression cann...
llvm::MDNode * getNoObjCARCExceptionsMetadata()
llvm::Constant * objc_moveWeak
void objc_moveWeak(id *dest, id *src);
llvm::ConstantInt * getSize(CharUnits numChars)
Emit the given number of characters as a value of type size_t.
A pair of helper functions for a __block variable.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
MicrosoftVTableContext & getMicrosoftVTableContext()
Definition: CGVTables.h:75
DiagnosticsEngine & getDiags() const
Represents a C++ struct/union/class.
Definition: DeclCXX.h:263
llvm::Function * CreateGlobalInitOrDestructFunction(llvm::FunctionType *ty, const Twine &name, const CGFunctionInfo &FI, SourceLocation Loc=SourceLocation(), bool TLS=false)
Definition: CGDeclCXX.cpp:259
A specialization of Address that requires the address to be an LLVM Constant.
Definition: Address.h:75
void Release()
Finalize LLVM code generation.
void ClearUnusedCoverageMapping(const Decl *D)
Remove the deferred empty coverage mapping as this declaration is actually instrumented.
void EmitGlobalAnnotations()
Emit all the global annotations.
llvm::ConstantInt * CreateCrossDsoCfiTypeId(llvm::Metadata *MD)
Generate a cross-DSO type identifier for MD.
OrderGlobalInits(unsigned int p, unsigned int l)
void SetCommonAttributes(const Decl *D, llvm::GlobalValue *GV)
Set attributes which are common to any form of a global definition (alias, Objective-C method...
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1466
CharUnits computeNonVirtualBaseClassOffset(const CXXRecordDecl *DerivedClass, CastExpr::path_const_iterator Start, CastExpr::path_const_iterator End)
Definition: CGClass.cpp:147
llvm::MDNode * getTBAAInfo(QualType QTy)
HeaderSearchOptions - Helper class for storing options related to the initialization of the HeaderSea...
QualType getObjCFastEnumerationStateType()
Retrieve the record type that describes the state of an Objective-C fast enumeration loop (for...
GVALinkage
A more specific kind of linkage than enum Linkage.
Definition: Linkage.h:64
This structure provides a set of types that are commonly used during IR emission. ...
CoverageMappingModuleGen * getCoverageMapping() const
llvm::Constant * getNSConcreteGlobalBlock()
Definition: CGBlocks.cpp:2356
llvm::Type * getBlockDescriptorType()
Fetches the type of a generic block descriptor.
Definition: CGBlocks.cpp:909
CodeGenVTables & getVTables()
NamedDecl - This represents a decl with a name.
Definition: Decl.h:213
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:784
SanitizerMetadata * getSanitizerMetadata()
llvm::IndexedInstrProfReader * getPGOReader() const
void ConstructAttributeList(StringRef Name, const CGFunctionInfo &Info, CGCalleeInfo CalleeInfo, AttributeListType &PAL, unsigned &CallingConv, bool AttrOnCallSite)
Get the LLVM attributes and calling convention to use for a particular function type.
Definition: CGCall.cpp:1620
llvm::Constant * objc_retainAutoreleaseReturnValue
id objc_retainAutoreleaseReturnValue(id);
llvm::Constant * GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty=nullptr, bool ForVTable=false, bool DontDefer=false, bool IsForDefinition=false)
Return the address of the given function.
This represents '#pragma omp threadprivate ...' directive.
Definition: DeclOpenMP.h:39
void EmitGlobal(GlobalDecl D)
Emit code for a singal global function or var decl.
CGCalleeInfo - Class to encapsulate the information about a callee to be used during the generation o...
void AddDependentLib(StringRef Lib)
Appends a dependent lib to the "Linker Options" metadata value.
llvm::GlobalValue::LinkageTypes getLLVMLinkageForDeclarator(const DeclaratorDecl *D, GVALinkage Linkage, bool IsConstantVariable)
Returns LLVM linkage for a declarator.
void EmitVTable(CXXRecordDecl *Class)
This is a callback from Sema to tell us that that a particular vtable is required to be emitted in th...
Definition: CGVTables.cpp:818
llvm::MDNode * getTBAAInfoForVTablePtr()