CGCleanup.h 19 KB

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