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