clang  14.0.0git
CGCleanup.h
Go to the documentation of this file.
1 //===-- CGCleanup.h - Classes for cleanups IR generation --------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // These classes support the generation of LLVM IR for cleanups.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_LIB_CODEGEN_CGCLEANUP_H
14 #define LLVM_CLANG_LIB_CODEGEN_CGCLEANUP_H
15 
16 #include "EHScopeStack.h"
17 
18 #include "Address.h"
19 #include "llvm/ADT/SmallPtrSet.h"
20 #include "llvm/ADT/SmallVector.h"
21 
22 namespace llvm {
23 class BasicBlock;
24 class Value;
25 class ConstantInt;
26 class AllocaInst;
27 }
28 
29 namespace clang {
30 class FunctionDecl;
31 namespace CodeGen {
32 class CodeGenModule;
33 class CodeGenFunction;
34 
35 /// The MS C++ ABI needs a pointer to RTTI data plus some flags to describe the
36 /// type of a catch handler, so we use this wrapper.
37 struct CatchTypeInfo {
38  llvm::Constant *RTTI;
39  unsigned Flags;
40 };
41 
42 /// A protected scope for zero-cost EH handling.
43 class EHScope {
44  llvm::BasicBlock *CachedLandingPad;
45  llvm::BasicBlock *CachedEHDispatchBlock;
46 
47  EHScopeStack::stable_iterator EnclosingEHScope;
48 
49  class CommonBitFields {
50  friend class EHScope;
51  unsigned Kind : 3;
52  };
53  enum { NumCommonBits = 3 };
54 
55 protected:
57  friend class EHCatchScope;
58  unsigned : NumCommonBits;
59 
60  unsigned NumHandlers : 32 - NumCommonBits;
61  };
62 
64  friend class EHCleanupScope;
65  unsigned : NumCommonBits;
66 
67  /// Whether this cleanup needs to be run along normal edges.
68  unsigned IsNormalCleanup : 1;
69 
70  /// Whether this cleanup needs to be run along exception edges.
71  unsigned IsEHCleanup : 1;
72 
73  /// Whether this cleanup is currently active.
74  unsigned IsActive : 1;
75 
76  /// Whether this cleanup is a lifetime marker
77  unsigned IsLifetimeMarker : 1;
78 
79  /// Whether the normal cleanup should test the activation flag.
80  unsigned TestFlagInNormalCleanup : 1;
81 
82  /// Whether the EH cleanup should test the activation flag.
83  unsigned TestFlagInEHCleanup : 1;
84 
85  /// The amount of extra storage needed by the Cleanup.
86  /// Always a multiple of the scope-stack alignment.
87  unsigned CleanupSize : 12;
88  };
89 
91  friend class EHFilterScope;
92  unsigned : NumCommonBits;
93 
94  unsigned NumFilters : 32 - NumCommonBits;
95  };
96 
97  union {
98  CommonBitFields CommonBits;
102  };
103 
104 public:
106 
108  : CachedLandingPad(nullptr), CachedEHDispatchBlock(nullptr),
109  EnclosingEHScope(enclosingEHScope) {
110  CommonBits.Kind = kind;
111  }
112 
113  Kind getKind() const { return static_cast<Kind>(CommonBits.Kind); }
114 
115  llvm::BasicBlock *getCachedLandingPad() const {
116  return CachedLandingPad;
117  }
118 
119  void setCachedLandingPad(llvm::BasicBlock *block) {
120  CachedLandingPad = block;
121  }
122 
123  llvm::BasicBlock *getCachedEHDispatchBlock() const {
124  return CachedEHDispatchBlock;
125  }
126 
127  void setCachedEHDispatchBlock(llvm::BasicBlock *block) {
128  CachedEHDispatchBlock = block;
129  }
130 
131  bool hasEHBranches() const {
132  if (llvm::BasicBlock *block = getCachedEHDispatchBlock())
133  return !block->use_empty();
134  return false;
135  }
136 
138  return EnclosingEHScope;
139  }
140 };
141 
142 /// A scope which attempts to handle some, possibly all, types of
143 /// exceptions.
144 ///
145 /// Objective C \@finally blocks are represented using a cleanup scope
146 /// after the catch scope.
147 class EHCatchScope : public EHScope {
148  // In effect, we have a flexible array member
149  // Handler Handlers[0];
150  // But that's only standard in C99, not C++, so we have to do
151  // annoying pointer arithmetic instead.
152 
153 public:
154  struct Handler {
155  /// A type info value, or null (C++ null, not an LLVM null pointer)
156  /// for a catch-all.
158 
159  /// The catch handler for this type.
160  llvm::BasicBlock *Block;
161 
162  bool isCatchAll() const { return Type.RTTI == nullptr; }
163  };
164 
165 private:
166  friend class EHScopeStack;
167 
168  Handler *getHandlers() {
169  return reinterpret_cast<Handler*>(this+1);
170  }
171 
172  const Handler *getHandlers() const {
173  return reinterpret_cast<const Handler*>(this+1);
174  }
175 
176 public:
177  static size_t getSizeForNumHandlers(unsigned N) {
178  return sizeof(EHCatchScope) + N * sizeof(Handler);
179  }
180 
181  EHCatchScope(unsigned numHandlers,
182  EHScopeStack::stable_iterator enclosingEHScope)
183  : EHScope(Catch, enclosingEHScope) {
184  CatchBits.NumHandlers = numHandlers;
185  assert(CatchBits.NumHandlers == numHandlers && "NumHandlers overflow?");
186  }
187 
188  unsigned getNumHandlers() const {
189  return CatchBits.NumHandlers;
190  }
191 
192  void setCatchAllHandler(unsigned I, llvm::BasicBlock *Block) {
193  setHandler(I, CatchTypeInfo{nullptr, 0}, Block);
194  }
195 
196  void setHandler(unsigned I, llvm::Constant *Type, llvm::BasicBlock *Block) {
197  assert(I < getNumHandlers());
198  getHandlers()[I].Type = CatchTypeInfo{Type, 0};
199  getHandlers()[I].Block = Block;
200  }
201 
202  void setHandler(unsigned I, CatchTypeInfo Type, llvm::BasicBlock *Block) {
203  assert(I < getNumHandlers());
204  getHandlers()[I].Type = Type;
205  getHandlers()[I].Block = Block;
206  }
207 
208  const Handler &getHandler(unsigned I) const {
209  assert(I < getNumHandlers());
210  return getHandlers()[I];
211  }
212 
213  // Clear all handler blocks.
214  // FIXME: it's better to always call clearHandlerBlocks in DTOR and have a
215  // 'takeHandler' or some such function which removes ownership from the
216  // EHCatchScope object if the handlers should live longer than EHCatchScope.
218  for (unsigned I = 0, N = getNumHandlers(); I != N; ++I)
219  delete getHandler(I).Block;
220  }
221 
222  typedef const Handler *iterator;
223  iterator begin() const { return getHandlers(); }
224  iterator end() const { return getHandlers() + getNumHandlers(); }
225 
226  static bool classof(const EHScope *Scope) {
227  return Scope->getKind() == Catch;
228  }
229 };
230 
231 /// A cleanup scope which generates the cleanup blocks lazily.
232 class alignas(8) EHCleanupScope : public EHScope {
233  /// The nearest normal cleanup scope enclosing this one.
234  EHScopeStack::stable_iterator EnclosingNormal;
235 
236  /// The nearest EH scope enclosing this one.
237  EHScopeStack::stable_iterator EnclosingEH;
238 
239  /// The dual entry/exit block along the normal edge. This is lazily
240  /// created if needed before the cleanup is popped.
241  llvm::BasicBlock *NormalBlock;
242 
243  /// An optional i1 variable indicating whether this cleanup has been
244  /// activated yet.
245  llvm::AllocaInst *ActiveFlag;
246 
247  /// Extra information required for cleanups that have resolved
248  /// branches through them. This has to be allocated on the side
249  /// because everything on the cleanup stack has be trivially
250  /// movable.
251  struct ExtInfo {
252  /// The destinations of normal branch-afters and branch-throughs.
254 
255  /// Normal branch-afters.
257  BranchAfters;
258  };
259  mutable struct ExtInfo *ExtInfo;
260 
261  /// The number of fixups required by enclosing scopes (not including
262  /// this one). If this is the top cleanup scope, all the fixups
263  /// from this index onwards belong to this scope.
264  unsigned FixupDepth;
265 
266  struct ExtInfo &getExtInfo() {
267  if (!ExtInfo) ExtInfo = new struct ExtInfo();
268  return *ExtInfo;
269  }
270 
271  const struct ExtInfo &getExtInfo() const {
272  if (!ExtInfo) ExtInfo = new struct ExtInfo();
273  return *ExtInfo;
274  }
275 
276 public:
277  /// Gets the size required for a lazy cleanup scope with the given
278  /// cleanup-data requirements.
279  static size_t getSizeForCleanupSize(size_t Size) {
280  return sizeof(EHCleanupScope) + Size;
281  }
282 
283  size_t getAllocatedSize() const {
284  return sizeof(EHCleanupScope) + CleanupBits.CleanupSize;
285  }
286 
287  EHCleanupScope(bool isNormal, bool isEH, unsigned cleanupSize,
288  unsigned fixupDepth,
289  EHScopeStack::stable_iterator enclosingNormal,
290  EHScopeStack::stable_iterator enclosingEH)
291  : EHScope(EHScope::Cleanup, enclosingEH),
292  EnclosingNormal(enclosingNormal), NormalBlock(nullptr),
293  ActiveFlag(nullptr), ExtInfo(nullptr), FixupDepth(fixupDepth) {
294  CleanupBits.IsNormalCleanup = isNormal;
295  CleanupBits.IsEHCleanup = isEH;
296  CleanupBits.IsActive = true;
297  CleanupBits.IsLifetimeMarker = false;
298  CleanupBits.TestFlagInNormalCleanup = false;
299  CleanupBits.TestFlagInEHCleanup = false;
300  CleanupBits.CleanupSize = cleanupSize;
301 
302  assert(CleanupBits.CleanupSize == cleanupSize && "cleanup size overflow");
303  }
304 
305  void Destroy() {
306  delete ExtInfo;
307  }
308  // Objects of EHCleanupScope are not destructed. Use Destroy().
309  ~EHCleanupScope() = delete;
310 
311  bool isNormalCleanup() const { return CleanupBits.IsNormalCleanup; }
312  llvm::BasicBlock *getNormalBlock() const { return NormalBlock; }
313  void setNormalBlock(llvm::BasicBlock *BB) { NormalBlock = BB; }
314 
315  bool isEHCleanup() const { return CleanupBits.IsEHCleanup; }
316 
317  bool isActive() const { return CleanupBits.IsActive; }
318  void setActive(bool A) { CleanupBits.IsActive = A; }
319 
320  bool isLifetimeMarker() const { return CleanupBits.IsLifetimeMarker; }
321  void setLifetimeMarker() { CleanupBits.IsLifetimeMarker = true; }
322 
323  bool hasActiveFlag() const { return ActiveFlag != nullptr; }
325  return Address(ActiveFlag, CharUnits::One());
326  }
327  void setActiveFlag(Address Var) {
328  assert(Var.getAlignment().isOne());
329  ActiveFlag = cast<llvm::AllocaInst>(Var.getPointer());
330  }
331 
333  CleanupBits.TestFlagInNormalCleanup = true;
334  }
336  return CleanupBits.TestFlagInNormalCleanup;
337  }
338 
340  CleanupBits.TestFlagInEHCleanup = true;
341  }
343  return CleanupBits.TestFlagInEHCleanup;
344  }
345 
346  unsigned getFixupDepth() const { return FixupDepth; }
348  return EnclosingNormal;
349  }
350 
351  size_t getCleanupSize() const { return CleanupBits.CleanupSize; }
352  void *getCleanupBuffer() { return this + 1; }
353 
355  return reinterpret_cast<EHScopeStack::Cleanup*>(getCleanupBuffer());
356  }
357 
358  /// True if this cleanup scope has any branch-afters or branch-throughs.
359  bool hasBranches() const { return ExtInfo && !ExtInfo->Branches.empty(); }
360 
361  /// Add a branch-after to this cleanup scope. A branch-after is a
362  /// branch from a point protected by this (normal) cleanup to a
363  /// point in the normal cleanup scope immediately containing it.
364  /// For example,
365  /// for (;;) { A a; break; }
366  /// contains a branch-after.
367  ///
368  /// Branch-afters each have their own destination out of the
369  /// cleanup, guaranteed distinct from anything else threaded through
370  /// it. Therefore branch-afters usually force a switch after the
371  /// cleanup.
372  void addBranchAfter(llvm::ConstantInt *Index,
373  llvm::BasicBlock *Block) {
374  struct ExtInfo &ExtInfo = getExtInfo();
375  if (ExtInfo.Branches.insert(Block).second)
376  ExtInfo.BranchAfters.push_back(std::make_pair(Block, Index));
377  }
378 
379  /// Return the number of unique branch-afters on this scope.
380  unsigned getNumBranchAfters() const {
381  return ExtInfo ? ExtInfo->BranchAfters.size() : 0;
382  }
383 
384  llvm::BasicBlock *getBranchAfterBlock(unsigned I) const {
385  assert(I < getNumBranchAfters());
386  return ExtInfo->BranchAfters[I].first;
387  }
388 
389  llvm::ConstantInt *getBranchAfterIndex(unsigned I) const {
390  assert(I < getNumBranchAfters());
391  return ExtInfo->BranchAfters[I].second;
392  }
393 
394  /// Add a branch-through to this cleanup scope. A branch-through is
395  /// a branch from a scope protected by this (normal) cleanup to an
396  /// enclosing scope other than the immediately-enclosing normal
397  /// cleanup scope.
398  ///
399  /// In the following example, the branch through B's scope is a
400  /// branch-through, while the branch through A's scope is a
401  /// branch-after:
402  /// for (;;) { A a; B b; break; }
403  ///
404  /// All branch-throughs have a common destination out of the
405  /// cleanup, one possibly shared with the fall-through. Therefore
406  /// branch-throughs usually don't force a switch after the cleanup.
407  ///
408  /// \return true if the branch-through was new to this scope
409  bool addBranchThrough(llvm::BasicBlock *Block) {
410  return getExtInfo().Branches.insert(Block).second;
411  }
412 
413  /// Determines if this cleanup scope has any branch throughs.
414  bool hasBranchThroughs() const {
415  if (!ExtInfo) return false;
416  return (ExtInfo->BranchAfters.size() != ExtInfo->Branches.size());
417  }
418 
419  static bool classof(const EHScope *Scope) {
420  return (Scope->getKind() == Cleanup);
421  }
422 };
423 // NOTE: there's a bunch of different data classes tacked on after an
424 // EHCleanupScope. It is asserted (in EHScopeStack::pushCleanup*) that
425 // they don't require greater alignment than ScopeStackAlignment. So,
426 // EHCleanupScope ought to have alignment equal to that -- not more
427 // (would be misaligned by the stack allocator), and not less (would
428 // break the appended classes).
429 static_assert(alignof(EHCleanupScope) == EHScopeStack::ScopeStackAlignment,
430  "EHCleanupScope expected alignment");
431 
432 /// An exceptions scope which filters exceptions thrown through it.
433 /// Only exceptions matching the filter types will be permitted to be
434 /// thrown.
435 ///
436 /// This is used to implement C++ exception specifications.
437 class EHFilterScope : public EHScope {
438  // Essentially ends in a flexible array member:
439  // llvm::Value *FilterTypes[0];
440 
441  llvm::Value **getFilters() {
442  return reinterpret_cast<llvm::Value**>(this+1);
443  }
444 
445  llvm::Value * const *getFilters() const {
446  return reinterpret_cast<llvm::Value* const *>(this+1);
447  }
448 
449 public:
450  EHFilterScope(unsigned numFilters)
451  : EHScope(Filter, EHScopeStack::stable_end()) {
452  FilterBits.NumFilters = numFilters;
453  assert(FilterBits.NumFilters == numFilters && "NumFilters overflow");
454  }
455 
456  static size_t getSizeForNumFilters(unsigned numFilters) {
457  return sizeof(EHFilterScope) + numFilters * sizeof(llvm::Value*);
458  }
459 
460  unsigned getNumFilters() const { return FilterBits.NumFilters; }
461 
462  void setFilter(unsigned i, llvm::Value *filterValue) {
463  assert(i < getNumFilters());
464  getFilters()[i] = filterValue;
465  }
466 
467  llvm::Value *getFilter(unsigned i) const {
468  assert(i < getNumFilters());
469  return getFilters()[i];
470  }
471 
472  static bool classof(const EHScope *scope) {
473  return scope->getKind() == Filter;
474  }
475 };
476 
477 /// An exceptions scope which calls std::terminate if any exception
478 /// reaches it.
479 class EHTerminateScope : public EHScope {
480 public:
482  : EHScope(Terminate, enclosingEHScope) {}
483  static size_t getSize() { return sizeof(EHTerminateScope); }
484 
485  static bool classof(const EHScope *scope) {
486  return scope->getKind() == Terminate;
487  }
488 };
489 
490 /// A non-stable pointer into the scope stack.
492  char *Ptr;
493 
494  friend class EHScopeStack;
495  explicit iterator(char *Ptr) : Ptr(Ptr) {}
496 
497 public:
498  iterator() : Ptr(nullptr) {}
499 
500  EHScope *get() const {
501  return reinterpret_cast<EHScope*>(Ptr);
502  }
503 
504  EHScope *operator->() const { return get(); }
505  EHScope &operator*() const { return *get(); }
506 
508  size_t Size;
509  switch (get()->getKind()) {
510  case EHScope::Catch:
512  static_cast<const EHCatchScope *>(get())->getNumHandlers());
513  break;
514 
515  case EHScope::Filter:
517  static_cast<const EHFilterScope *>(get())->getNumFilters());
518  break;
519 
520  case EHScope::Cleanup:
521  Size = static_cast<const EHCleanupScope *>(get())->getAllocatedSize();
522  break;
523 
524  case EHScope::Terminate:
525  Size = EHTerminateScope::getSize();
526  break;
527  }
528  Ptr += llvm::alignTo(Size, ScopeStackAlignment);
529  return *this;
530  }
531 
533  iterator copy = *this;
534  ++copy;
535  return copy;
536  }
537 
539  iterator copy = *this;
540  operator++();
541  return copy;
542  }
543 
544  bool encloses(iterator other) const { return Ptr >= other.Ptr; }
545  bool strictlyEncloses(iterator other) const { return Ptr > other.Ptr; }
546 
547  bool operator==(iterator other) const { return Ptr == other.Ptr; }
548  bool operator!=(iterator other) const { return Ptr != other.Ptr; }
549 };
550 
552  return iterator(StartOfData);
553 }
554 
556  return iterator(EndOfBuffer);
557 }
558 
559 inline void EHScopeStack::popCatch() {
560  assert(!empty() && "popping exception stack when not empty");
561 
562  EHCatchScope &scope = cast<EHCatchScope>(*begin());
563  InnermostEHScope = scope.getEnclosingEHScope();
565 }
566 
568  assert(!empty() && "popping exception stack when not empty");
569 
570  EHTerminateScope &scope = cast<EHTerminateScope>(*begin());
571  InnermostEHScope = scope.getEnclosingEHScope();
572  deallocate(EHTerminateScope::getSize());
573 }
574 
576  assert(sp.isValid() && "finding invalid savepoint");
577  assert(sp.Size <= stable_begin().Size && "finding savepoint after pop");
578  return iterator(EndOfBuffer - sp.Size);
579 }
580 
583  assert(StartOfData <= ir.Ptr && ir.Ptr <= EndOfBuffer);
584  return stable_iterator(EndOfBuffer - ir.Ptr);
585 }
586 
587 /// The exceptions personality for a function.
589  const char *PersonalityFn;
590 
591  // If this is non-null, this personality requires a non-standard
592  // function for rethrowing an exception after a catchall cleanup.
593  // This function must have prototype void(void*).
594  const char *CatchallRethrowFn;
595 
596  static const EHPersonality &get(CodeGenModule &CGM, const FunctionDecl *FD);
597  static const EHPersonality &get(CodeGenFunction &CGF);
598 
599  static const EHPersonality GNU_C;
600  static const EHPersonality GNU_C_SJLJ;
601  static const EHPersonality GNU_C_SEH;
602  static const EHPersonality GNU_ObjC;
606  static const EHPersonality GNU_ObjCXX;
607  static const EHPersonality NeXT_ObjC;
616 
617  /// Does this personality use landingpads or the family of pad instructions
618  /// designed to form funclets?
619  bool usesFuncletPads() const {
620  return isMSVCPersonality() || isWasmPersonality();
621  }
622 
623  bool isMSVCPersonality() const {
624  return this == &MSVC_except_handler || this == &MSVC_C_specific_handler ||
625  this == &MSVC_CxxFrameHandler3;
626  }
627 
628  bool isWasmPersonality() const { return this == &GNU_Wasm_CPlusPlus; }
629 
630  bool isMSVCXXPersonality() const { return this == &MSVC_CxxFrameHandler3; }
631 };
632 }
633 }
634 
635 #endif
clang::CodeGen::EHPersonality::isWasmPersonality
bool isWasmPersonality() const
Definition: CGCleanup.h:628
clang::CodeGen::CatchTypeInfo::RTTI
llvm::Constant * RTTI
Definition: CGCleanup.h:38
clang::CodeGen::EHPersonality::GNU_C_SJLJ
static const EHPersonality GNU_C_SJLJ
Definition: CGCleanup.h:600
clang::CharUnits::isOne
bool isOne() const
isOne - Test whether the quantity equals one.
Definition: CharUnits.h:119
clang::CodeGen::EHCleanupScope::setActive
void setActive(bool A)
Definition: CGCleanup.h:318
llvm
Definition: Dominators.h:30
clang::CodeGen::EHPersonality::NeXT_ObjC
static const EHPersonality NeXT_ObjC
Definition: CGCleanup.h:607
clang::CodeGen::CatchTypeInfo::Flags
unsigned Flags
Definition: CGCleanup.h:39
clang::CodeGen::EHCleanupScope::getSizeForCleanupSize
static size_t getSizeForCleanupSize(size_t Size)
Gets the size required for a lazy cleanup scope with the given cleanup-data requirements.
Definition: CGCleanup.h:279
clang::CodeGen::EHCleanupScope::setLifetimeMarker
void setLifetimeMarker()
Definition: CGCleanup.h:321
clang::CodeGen::EHScope::Cleanup
@ Cleanup
Definition: CGCleanup.h:105
clang::CodeGen::EHPersonality::isMSVCXXPersonality
bool isMSVCXXPersonality() const
Definition: CGCleanup.h:630
clang::CodeGen::EHPersonality::GNU_C
static const EHPersonality GNU_C
Definition: CGCleanup.h:599
clang::CodeGen::EHPersonality::GNUstep_ObjC
static const EHPersonality GNUstep_ObjC
Definition: CGCleanup.h:605
clang::CodeGen::EHPersonality::GNU_CPlusPlus_SEH
static const EHPersonality GNU_CPlusPlus_SEH
Definition: CGCleanup.h:610
clang::CodeGen::EHCleanupScope::~EHCleanupScope
~EHCleanupScope()=delete
clang::CodeGen::EHScope::CatchBitFields
Definition: CGCleanup.h:56
clang::CodeGen::EHScopeStack::stable_iterator::isValid
bool isValid() const
Definition: EHScopeStack.h:113
clang::CodeGen::EHCatchScope::Handler::isCatchAll
bool isCatchAll() const
Definition: CGCleanup.h:162
clang::CodeGen::Address::getAlignment
CharUnits getAlignment() const
Return the alignment of this pointer.
Definition: Address.h:66
clang::CodeGen::EHCatchScope::begin
iterator begin() const
Definition: CGCleanup.h:223
clang::CodeGen::EHCleanupScope::EHCleanupScope
EHCleanupScope(bool isNormal, bool isEH, unsigned cleanupSize, unsigned fixupDepth, EHScopeStack::stable_iterator enclosingNormal, EHScopeStack::stable_iterator enclosingEH)
Definition: CGCleanup.h:287
llvm::SmallVector
Definition: LLVM.h:38
clang::CodeGen::EHCatchScope::setCatchAllHandler
void setCatchAllHandler(unsigned I, llvm::BasicBlock *Block)
Definition: CGCleanup.h:192
clang::CodeGen::EHScopeStack::iterator::get
EHScope * get() const
Definition: CGCleanup.h:500
clang::CodeGen::EHScope::getCachedLandingPad
llvm::BasicBlock * getCachedLandingPad() const
Definition: CGCleanup.h:115
clang::CodeGen::EHCleanupScope::addBranchThrough
bool addBranchThrough(llvm::BasicBlock *Block)
Add a branch-through to this cleanup scope.
Definition: CGCleanup.h:409
clang::CodeGen::EHScopeStack::iterator::iterator
iterator()
Definition: CGCleanup.h:498
clang::CodeGen::EHFilterScope::EHFilterScope
EHFilterScope(unsigned numFilters)
Definition: CGCleanup.h:450
clang::CodeGen::EHScope
A protected scope for zero-cost EH handling.
Definition: CGCleanup.h:43
clang::CodeGen::EHScopeStack::iterator::encloses
bool encloses(iterator other) const
Definition: CGCleanup.h:544
clang::CodeGen::EHCatchScope::getHandler
const Handler & getHandler(unsigned I) const
Definition: CGCleanup.h:208
clang::CodeGen::EHCleanupScope
A cleanup scope which generates the cleanup blocks lazily.
Definition: CGCleanup.h:232
clang::CodeGen::EHPersonality::GNU_Wasm_CPlusPlus
static const EHPersonality GNU_Wasm_CPlusPlus
Definition: CGCleanup.h:614
clang::CodeGen::EHPersonality::GNU_ObjC_SEH
static const EHPersonality GNU_ObjC_SEH
Definition: CGCleanup.h:604
clang::CodeGen::EHScope::hasEHBranches
bool hasEHBranches() const
Definition: CGCleanup.h:131
clang::CodeGen::EHCleanupScope::getNormalBlock
llvm::BasicBlock * getNormalBlock() const
Definition: CGCleanup.h:312
clang::CodeGen::EHPersonality::CatchallRethrowFn
const char * CatchallRethrowFn
Definition: CGCleanup.h:594
llvm::SmallPtrSet< llvm::BasicBlock *, 4 >
clang::CodeGen::EHCleanupScope::classof
static bool classof(const EHScope *Scope)
Definition: CGCleanup.h:419
clang::CodeGen::EHPersonality::PersonalityFn
const char * PersonalityFn
Definition: CGCleanup.h:589
clang::CodeGen::EHPersonality::get
static const EHPersonality & get(CodeGenModule &CGM, const FunctionDecl *FD)
Definition: CGException.cpp:230
clang::CodeGen::EHPersonality::GNU_C_SEH
static const EHPersonality GNU_C_SEH
Definition: CGCleanup.h:601
clang::CodeGen::EHCatchScope::Handler::Block
llvm::BasicBlock * Block
The catch handler for this type.
Definition: CGCleanup.h:160
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1490
clang::CodeGen::EHScopeStack::iterator::operator++
iterator & operator++()
Definition: CGCleanup.h:507
clang::CodeGen::EHScope::setCachedLandingPad
void setCachedLandingPad(llvm::BasicBlock *block)
Definition: CGCleanup.h:119
clang::CodeGen::EHPersonality::usesFuncletPads
bool usesFuncletPads() const
Does this personality use landingpads or the family of pad instructions designed to form funclets?
Definition: CGCleanup.h:619
clang::CodeGen::EHFilterScope::classof
static bool classof(const EHScope *scope)
Definition: CGCleanup.h:472
clang::CodeGen::EHCleanupScope::getCleanupBuffer
void * getCleanupBuffer()
Definition: CGCleanup.h:352
clang::CodeGen::EHCatchScope::getNumHandlers
unsigned getNumHandlers() const
Definition: CGCleanup.h:188
clang::CodeGen::EHCatchScope
A scope which attempts to handle some, possibly all, types of exceptions.
Definition: CGCleanup.h:147
clang::CodeGen::EHCleanupScope::shouldTestFlagInNormalCleanup
bool shouldTestFlagInNormalCleanup() const
Definition: CGCleanup.h:335
clang::CodeGen::EHCleanupScope::getNumBranchAfters
unsigned getNumBranchAfters() const
Return the number of unique branch-afters on this scope.
Definition: CGCleanup.h:380
clang::CodeGen::EHScopeStack::Cleanup
Information for lazily generating a cleanup.
Definition: EHScopeStack.h:141
clang::CodeGen::EHCleanupScope::getFixupDepth
unsigned getFixupDepth() const
Definition: CGCleanup.h:346
clang::CodeGen::EHCleanupScope::hasActiveFlag
bool hasActiveFlag() const
Definition: CGCleanup.h:323
clang::CodeGen::EHCatchScope::end
iterator end() const
Definition: CGCleanup.h:224
clang::CodeGen::EHCleanupScope::getBranchAfterIndex
llvm::ConstantInt * getBranchAfterIndex(unsigned I) const
Definition: CGCleanup.h:389
clang::CodeGen::EHCleanupScope::setActiveFlag
void setActiveFlag(Address Var)
Definition: CGCleanup.h:327
clang::Scope
Scope - A scope is a transient data structure that is used while parsing the program.
Definition: Scope.h:40
clang::CodeGen::EHCatchScope::Handler::Type
CatchTypeInfo Type
A type info value, or null (C++ null, not an LLVM null pointer) for a catch-all.
Definition: CGCleanup.h:157
clang::CodeGen::EHScopeStack::stabilize
stable_iterator stabilize(iterator it) const
Translates an iterator into a stable_iterator.
Definition: CGCleanup.h:582
clang::CodeGen::EHScopeStack
A stack of scopes which respond to exceptions, including cleanups and catch blocks.
Definition: EHScopeStack.h:94
clang::CodeGen::EHTerminateScope
An exceptions scope which calls std::terminate if any exception reaches it.
Definition: CGCleanup.h:479
clang::CodeGen::EHPersonality::GNU_ObjCXX
static const EHPersonality GNU_ObjCXX
Definition: CGCleanup.h:606
clang::CodeGen::EHCleanupScope::getAllocatedSize
size_t getAllocatedSize() const
Definition: CGCleanup.h:283
clang::CodeGen::EHScopeStack::iterator::operator->
EHScope * operator->() const
Definition: CGCleanup.h:504
clang::CodeGen::EHScope::FilterBits
FilterBitFields FilterBits
Definition: CGCleanup.h:101
clang::CodeGen::EHCatchScope::setHandler
void setHandler(unsigned I, CatchTypeInfo Type, llvm::BasicBlock *Block)
Definition: CGCleanup.h:202
clang::CodeGen::EHScope::setCachedEHDispatchBlock
void setCachedEHDispatchBlock(llvm::BasicBlock *block)
Definition: CGCleanup.h:127
clang::CharUnits::One
static CharUnits One()
One - Construct a CharUnits quantity of one.
Definition: CharUnits.h:58
clang::CodeGen::EHScope::getEnclosingEHScope
EHScopeStack::stable_iterator getEnclosingEHScope() const
Definition: CGCleanup.h:137
clang::CodeGen::EHScopeStack::empty
bool empty() const
Determines whether the exception-scopes stack is empty.
Definition: EHScopeStack.h:350
clang::CodeGen::EHScope::getKind
Kind getKind() const
Definition: CGCleanup.h:113
clang::CodeGen::EHCleanupScope::setNormalBlock
void setNormalBlock(llvm::BasicBlock *BB)
Definition: CGCleanup.h:313
clang::CodeGen::EHScope::Terminate
@ Terminate
Definition: CGCleanup.h:105
clang::CodeGen::EHScopeStack::iterator::operator!=
bool operator!=(iterator other) const
Definition: CGCleanup.h:548
clang::CodeGen::EHCleanupScope::setTestFlagInNormalCleanup
void setTestFlagInNormalCleanup()
Definition: CGCleanup.h:332
clang::CodeGen::EHCatchScope::clearHandlerBlocks
void clearHandlerBlocks()
Definition: CGCleanup.h:217
clang::CodeGen::EHCatchScope::iterator
const typedef Handler * iterator
Definition: CGCleanup.h:222
clang::CodeGen::EHScopeStack::ScopeStackAlignment
@ ScopeStackAlignment
Definition: EHScopeStack.h:97
clang::CodeGen::EHScopeStack::end
iterator end() const
Returns an iterator pointing to the outermost EH scope.
Definition: CGCleanup.h:555
clang::CodeGen::Address
An aligned address.
Definition: Address.h:24
EHScopeStack.h
getKind
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:998
clang::CodeGen::EHScope::Catch
@ Catch
Definition: CGCleanup.h:105
clang::CodeGen::EHPersonality::GNU_CPlusPlus
static const EHPersonality GNU_CPlusPlus
Definition: CGCleanup.h:608
clang::CodeGen::EHScope::EHScope
EHScope(Kind kind, EHScopeStack::stable_iterator enclosingEHScope)
Definition: CGCleanup.h:107
clang::CodeGen::EHCatchScope::setHandler
void setHandler(unsigned I, llvm::Constant *Type, llvm::BasicBlock *Block)
Definition: CGCleanup.h:196
clang::CodeGen::EHCleanupScope::isLifetimeMarker
bool isLifetimeMarker() const
Definition: CGCleanup.h:320
Address.h
clang::CodeGen::EHScope::CommonBits
CommonBitFields CommonBits
Definition: CGCleanup.h:98
clang::CodeGen::EHCleanupScope::getCleanup
EHScopeStack::Cleanup * getCleanup()
Definition: CGCleanup.h:354
clang::CodeGen::EHScope::CleanupBitFields
Definition: CGCleanup.h:63
clang::CodeGen::Address::getPointer
llvm::Value * getPointer() const
Definition: Address.h:37
clang::CodeGen::EHScope::CleanupBits
CleanupBitFields CleanupBits
Definition: CGCleanup.h:100
clang::CodeGen::CodeGenFunction
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
Definition: CodeGenFunction.h:235
clang::CodeGen::EHScopeStack::iterator::strictlyEncloses
bool strictlyEncloses(iterator other) const
Definition: CGCleanup.h:545
clang::CodeGen::EHCleanupScope::getCleanupSize
size_t getCleanupSize() const
Definition: CGCleanup.h:351
clang::CodeGen::EHCatchScope::EHCatchScope
EHCatchScope(unsigned numHandlers, EHScopeStack::stable_iterator enclosingEHScope)
Definition: CGCleanup.h:181
clang::CodeGen::CodeGenModule
This class organizes the cross-function state that is used while generating LLVM code.
Definition: CodeGenModule.h:284
Value
Value
Definition: UninitializedValues.cpp:102
clang::CodeGen::EHScopeStack::iterator::next
iterator next()
Definition: CGCleanup.h:532
clang::CodeGen::EHCleanupScope::hasBranches
bool hasBranches() const
True if this cleanup scope has any branch-afters or branch-throughs.
Definition: CGCleanup.h:359
clang::CodeGen::EHScope::Kind
Kind
Definition: CGCleanup.h:105
clang::CodeGen::EHPersonality::MSVC_except_handler
static const EHPersonality MSVC_except_handler
Definition: CGCleanup.h:611
clang::CodeGen::EHCleanupScope::getEnclosingNormalCleanup
EHScopeStack::stable_iterator getEnclosingNormalCleanup() const
Definition: CGCleanup.h:347
clang::CodeGen::EHScope::getCachedEHDispatchBlock
llvm::BasicBlock * getCachedEHDispatchBlock() const
Definition: CGCleanup.h:123
clang::CodeGen::EHPersonality::MSVC_C_specific_handler
static const EHPersonality MSVC_C_specific_handler
Definition: CGCleanup.h:612
clang::CodeGen::EHFilterScope
An exceptions scope which filters exceptions thrown through it.
Definition: CGCleanup.h:437
clang::CodeGen::EHScopeStack::iterator::operator++
iterator operator++(int)
Definition: CGCleanup.h:538
clang::CodeGen::EHScopeStack::iterator::operator==
bool operator==(iterator other) const
Definition: CGCleanup.h:547
clang::CodeGen::EHCleanupScope::hasBranchThroughs
bool hasBranchThroughs() const
Determines if this cleanup scope has any branch throughs.
Definition: CGCleanup.h:414
clang::CodeGen::EHScopeStack::popCatch
void popCatch()
Pops a catch scope off the stack. This is private to CGException.cpp.
Definition: CGCleanup.h:559
clang::CodeGen::EHPersonality
The exceptions personality for a function.
Definition: CGCleanup.h:588
clang
Definition: CalledOnceCheck.h:17
clang::CodeGen::EHCleanupScope::Destroy
void Destroy()
Definition: CGCleanup.h:305
clang::CodeGen::EHTerminateScope::EHTerminateScope
EHTerminateScope(EHScopeStack::stable_iterator enclosingEHScope)
Definition: CGCleanup.h:481
clang::DeclaratorContext::Block
@ Block
clang::CodeGen::CatchTypeInfo
The MS C++ ABI needs a pointer to RTTI data plus some flags to describe the type of a catch handler,...
Definition: CGCleanup.h:37
clang::CodeGen::EHScopeStack::iterator
A non-stable pointer into the scope stack.
Definition: CGCleanup.h:491
clang::CodeGen::EHCleanupScope::shouldTestFlagInEHCleanup
bool shouldTestFlagInEHCleanup() const
Definition: CGCleanup.h:342
clang::CodeGen::EHCleanupScope::addBranchAfter
void addBranchAfter(llvm::ConstantInt *Index, llvm::BasicBlock *Block)
Add a branch-after to this cleanup scope.
Definition: CGCleanup.h:372
clang::CodeGen::EHCatchScope::getSizeForNumHandlers
static size_t getSizeForNumHandlers(unsigned N)
Definition: CGCleanup.h:177
clang::CodeGen::EHPersonality::MSVC_CxxFrameHandler3
static const EHPersonality MSVC_CxxFrameHandler3
Definition: CGCleanup.h:613
clang::CodeGen::EHCatchScope::Handler
Definition: CGCleanup.h:154
unsigned
clang::CodeGen::EHScope::Filter
@ Filter
Definition: CGCleanup.h:105
clang::CodeGen::EHScopeStack::stable_begin
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
Definition: EHScopeStack.h:384
clang::CodeGen::EHFilterScope::getNumFilters
unsigned getNumFilters() const
Definition: CGCleanup.h:460
clang::CodeGen::EHScope::FilterBitFields
Definition: CGCleanup.h:90
clang::CodeGen::EHPersonality::isMSVCPersonality
bool isMSVCPersonality() const
Definition: CGCleanup.h:623
clang::CodeGen::EHFilterScope::setFilter
void setFilter(unsigned i, llvm::Value *filterValue)
Definition: CGCleanup.h:462
clang::CodeGen::EHTerminateScope::classof
static bool classof(const EHScope *scope)
Definition: CGCleanup.h:485
clang::CodeGen::EHCatchScope::classof
static bool classof(const EHScope *Scope)
Definition: CGCleanup.h:226
clang::CodeGen::EHCleanupScope::setTestFlagInEHCleanup
void setTestFlagInEHCleanup()
Definition: CGCleanup.h:339
clang::CodeGen::EHScopeStack::begin
iterator begin() const
Returns an iterator pointing to the innermost EH scope.
Definition: CGCleanup.h:551
clang::CodeGen::EHScopeStack::iterator::operator*
EHScope & operator*() const
Definition: CGCleanup.h:505
clang::CodeGen::EHPersonality::XL_CPlusPlus
static const EHPersonality XL_CPlusPlus
Definition: CGCleanup.h:615
clang::CodeGen::EHFilterScope::getFilter
llvm::Value * getFilter(unsigned i) const
Definition: CGCleanup.h:467
clang::CodeGen::EHCleanupScope::isEHCleanup
bool isEHCleanup() const
Definition: CGCleanup.h:315
clang::CodeGen::EHCleanupScope::getActiveFlag
Address getActiveFlag() const
Definition: CGCleanup.h:324
clang::CodeGen::EHFilterScope::getSizeForNumFilters
static size_t getSizeForNumFilters(unsigned numFilters)
Definition: CGCleanup.h:456
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1857
clang::CodeGen::EHScopeStack::popTerminate
void popTerminate()
Pops a terminate handler off the stack.
Definition: CGCleanup.h:567
clang::diag::kind
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Definition: DiagnosticIDs.h:62
clang::CodeGen::EHScopeStack::find
iterator find(stable_iterator save) const
Turn a stable reference to a scope depth into a unstable pointer to the EH stack.
Definition: CGCleanup.h:575
clang::CodeGen::EHPersonality::GNU_CPlusPlus_SJLJ
static const EHPersonality GNU_CPlusPlus_SJLJ
Definition: CGCleanup.h:609
clang::CodeGen::EHScopeStack::stable_iterator
A saved depth on the scope stack.
Definition: EHScopeStack.h:101
clang::CodeGen::EHCleanupScope::getBranchAfterBlock
llvm::BasicBlock * getBranchAfterBlock(unsigned I) const
Definition: CGCleanup.h:384
clang::CodeGen::EHPersonality::GNU_ObjC_SJLJ
static const EHPersonality GNU_ObjC_SJLJ
Definition: CGCleanup.h:603
clang::CodeGen::EHPersonality::GNU_ObjC
static const EHPersonality GNU_ObjC
Definition: CGCleanup.h:602
clang::CodeGen::EHScope::CatchBits
CatchBitFields CatchBits
Definition: CGCleanup.h:99
Type
MatchType Type
Definition: ASTMatchFinder.cpp:70
clang::CodeGen::EHTerminateScope::getSize
static size_t getSize()
Definition: CGCleanup.h:483
clang::CodeGen::EHCleanupScope::isActive
bool isActive() const
Definition: CGCleanup.h:317
clang::CodeGen::EHCleanupScope::isNormalCleanup
bool isNormalCleanup() const
Definition: CGCleanup.h:311