CGCleanup.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  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. class AllocaInst;
  23. }
  24. namespace clang {
  25. class FunctionDecl;
  26. namespace CodeGen {
  27. class CodeGenModule;
  28. class CodeGenFunction;
  29. /// The MS C++ ABI needs a pointer to RTTI data plus some flags to describe the
  30. /// type of a catch handler, so we use this wrapper.
  31. struct CatchTypeInfo {
  32. llvm::Constant *RTTI;
  33. unsigned Flags;
  34. };
  35. /// A protected scope for zero-cost EH handling.
  36. class EHScope {
  37. llvm::BasicBlock *CachedLandingPad;
  38. llvm::BasicBlock *CachedEHDispatchBlock;
  39. EHScopeStack::stable_iterator EnclosingEHScope;
  40. class CommonBitFields {
  41. friend class EHScope;
  42. unsigned Kind : 3;
  43. };
  44. enum { NumCommonBits = 3 };
  45. protected:
  46. class CatchBitFields {
  47. friend class EHCatchScope;
  48. unsigned : NumCommonBits;
  49. unsigned NumHandlers : 32 - NumCommonBits;
  50. };
  51. class CleanupBitFields {
  52. friend class EHCleanupScope;
  53. unsigned : NumCommonBits;
  54. /// Whether this cleanup needs to be run along normal edges.
  55. unsigned IsNormalCleanup : 1;
  56. /// Whether this cleanup needs to be run along exception edges.
  57. unsigned IsEHCleanup : 1;
  58. /// Whether this cleanup is currently active.
  59. unsigned IsActive : 1;
  60. /// Whether this cleanup is a lifetime marker
  61. unsigned IsLifetimeMarker : 1;
  62. /// Whether the normal cleanup should test the activation flag.
  63. unsigned TestFlagInNormalCleanup : 1;
  64. /// Whether the EH cleanup should test the activation flag.
  65. unsigned TestFlagInEHCleanup : 1;
  66. /// The amount of extra storage needed by the Cleanup.
  67. /// Always a multiple of the scope-stack alignment.
  68. unsigned CleanupSize : 12;
  69. };
  70. class FilterBitFields {
  71. friend class EHFilterScope;
  72. unsigned : NumCommonBits;
  73. unsigned NumFilters : 32 - NumCommonBits;
  74. };
  75. union {
  76. CommonBitFields CommonBits;
  77. CatchBitFields CatchBits;
  78. CleanupBitFields CleanupBits;
  79. FilterBitFields FilterBits;
  80. };
  81. public:
  82. enum Kind { Cleanup, Catch, Terminate, Filter, PadEnd };
  83. EHScope(Kind kind, EHScopeStack::stable_iterator enclosingEHScope)
  84. : CachedLandingPad(nullptr), CachedEHDispatchBlock(nullptr),
  85. EnclosingEHScope(enclosingEHScope) {
  86. CommonBits.Kind = kind;
  87. }
  88. Kind getKind() const { return static_cast<Kind>(CommonBits.Kind); }
  89. llvm::BasicBlock *getCachedLandingPad() const {
  90. return CachedLandingPad;
  91. }
  92. void setCachedLandingPad(llvm::BasicBlock *block) {
  93. CachedLandingPad = block;
  94. }
  95. llvm::BasicBlock *getCachedEHDispatchBlock() const {
  96. return CachedEHDispatchBlock;
  97. }
  98. void setCachedEHDispatchBlock(llvm::BasicBlock *block) {
  99. CachedEHDispatchBlock = block;
  100. }
  101. bool hasEHBranches() const {
  102. if (llvm::BasicBlock *block = getCachedEHDispatchBlock())
  103. return !block->use_empty();
  104. return false;
  105. }
  106. EHScopeStack::stable_iterator getEnclosingEHScope() const {
  107. return EnclosingEHScope;
  108. }
  109. };
  110. /// A scope which attempts to handle some, possibly all, types of
  111. /// exceptions.
  112. ///
  113. /// Objective C \@finally blocks are represented using a cleanup scope
  114. /// after the catch scope.
  115. class EHCatchScope : public EHScope {
  116. // In effect, we have a flexible array member
  117. // Handler Handlers[0];
  118. // But that's only standard in C99, not C++, so we have to do
  119. // annoying pointer arithmetic instead.
  120. public:
  121. struct Handler {
  122. /// A type info value, or null (C++ null, not an LLVM null pointer)
  123. /// for a catch-all.
  124. CatchTypeInfo Type;
  125. /// The catch handler for this type.
  126. llvm::BasicBlock *Block;
  127. bool isCatchAll() const { return Type.RTTI == nullptr; }
  128. };
  129. private:
  130. friend class EHScopeStack;
  131. Handler *getHandlers() {
  132. return reinterpret_cast<Handler*>(this+1);
  133. }
  134. const Handler *getHandlers() const {
  135. return reinterpret_cast<const Handler*>(this+1);
  136. }
  137. public:
  138. static size_t getSizeForNumHandlers(unsigned N) {
  139. return sizeof(EHCatchScope) + N * sizeof(Handler);
  140. }
  141. EHCatchScope(unsigned numHandlers,
  142. EHScopeStack::stable_iterator enclosingEHScope)
  143. : EHScope(Catch, enclosingEHScope) {
  144. CatchBits.NumHandlers = numHandlers;
  145. assert(CatchBits.NumHandlers == numHandlers && "NumHandlers overflow?");
  146. }
  147. unsigned getNumHandlers() const {
  148. return CatchBits.NumHandlers;
  149. }
  150. void setCatchAllHandler(unsigned I, llvm::BasicBlock *Block) {
  151. setHandler(I, CatchTypeInfo{nullptr, 0}, Block);
  152. }
  153. void setHandler(unsigned I, llvm::Constant *Type, llvm::BasicBlock *Block) {
  154. assert(I < getNumHandlers());
  155. getHandlers()[I].Type = CatchTypeInfo{Type, 0};
  156. getHandlers()[I].Block = Block;
  157. }
  158. void setHandler(unsigned I, CatchTypeInfo Type, llvm::BasicBlock *Block) {
  159. assert(I < getNumHandlers());
  160. getHandlers()[I].Type = Type;
  161. getHandlers()[I].Block = Block;
  162. }
  163. const Handler &getHandler(unsigned I) const {
  164. assert(I < getNumHandlers());
  165. return getHandlers()[I];
  166. }
  167. // Clear all handler blocks.
  168. // FIXME: it's better to always call clearHandlerBlocks in DTOR and have a
  169. // 'takeHandler' or some such function which removes ownership from the
  170. // EHCatchScope object if the handlers should live longer than EHCatchScope.
  171. void clearHandlerBlocks() {
  172. for (unsigned I = 0, N = getNumHandlers(); I != N; ++I)
  173. delete getHandler(I).Block;
  174. }
  175. typedef const Handler *iterator;
  176. iterator begin() const { return getHandlers(); }
  177. iterator end() const { return getHandlers() + getNumHandlers(); }
  178. static bool classof(const EHScope *Scope) {
  179. return Scope->getKind() == Catch;
  180. }
  181. };
  182. /// A cleanup scope which generates the cleanup blocks lazily.
  183. class alignas(8) EHCleanupScope : public EHScope {
  184. /// The nearest normal cleanup scope enclosing this one.
  185. EHScopeStack::stable_iterator EnclosingNormal;
  186. /// The nearest EH scope enclosing this one.
  187. EHScopeStack::stable_iterator EnclosingEH;
  188. /// The dual entry/exit block along the normal edge. This is lazily
  189. /// created if needed before the cleanup is popped.
  190. llvm::BasicBlock *NormalBlock;
  191. /// An optional i1 variable indicating whether this cleanup has been
  192. /// activated yet.
  193. llvm::AllocaInst *ActiveFlag;
  194. /// Extra information required for cleanups that have resolved
  195. /// branches through them. This has to be allocated on the side
  196. /// because everything on the cleanup stack has be trivially
  197. /// movable.
  198. struct ExtInfo {
  199. /// The destinations of normal branch-afters and branch-throughs.
  200. llvm::SmallPtrSet<llvm::BasicBlock*, 4> Branches;
  201. /// Normal branch-afters.
  202. SmallVector<std::pair<llvm::BasicBlock*,llvm::ConstantInt*>, 4>
  203. BranchAfters;
  204. };
  205. mutable struct ExtInfo *ExtInfo;
  206. /// The number of fixups required by enclosing scopes (not including
  207. /// this one). If this is the top cleanup scope, all the fixups
  208. /// from this index onwards belong to this scope.
  209. unsigned FixupDepth;
  210. struct ExtInfo &getExtInfo() {
  211. if (!ExtInfo) ExtInfo = new struct ExtInfo();
  212. return *ExtInfo;
  213. }
  214. const struct ExtInfo &getExtInfo() const {
  215. if (!ExtInfo) ExtInfo = new struct ExtInfo();
  216. return *ExtInfo;
  217. }
  218. public:
  219. /// Gets the size required for a lazy cleanup scope with the given
  220. /// cleanup-data requirements.
  221. static size_t getSizeForCleanupSize(size_t Size) {
  222. return sizeof(EHCleanupScope) + Size;
  223. }
  224. size_t getAllocatedSize() const {
  225. return sizeof(EHCleanupScope) + CleanupBits.CleanupSize;
  226. }
  227. EHCleanupScope(bool isNormal, bool isEH, bool isActive,
  228. unsigned cleanupSize, unsigned fixupDepth,
  229. EHScopeStack::stable_iterator enclosingNormal,
  230. EHScopeStack::stable_iterator enclosingEH)
  231. : EHScope(EHScope::Cleanup, enclosingEH),
  232. EnclosingNormal(enclosingNormal), NormalBlock(nullptr),
  233. ActiveFlag(nullptr), ExtInfo(nullptr), FixupDepth(fixupDepth) {
  234. CleanupBits.IsNormalCleanup = isNormal;
  235. CleanupBits.IsEHCleanup = isEH;
  236. CleanupBits.IsActive = isActive;
  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 != nullptr; }
  257. Address getActiveFlag() const {
  258. return Address(ActiveFlag, CharUnits::One());
  259. }
  260. void setActiveFlag(Address Var) {
  261. assert(Var.getAlignment().isOne());
  262. ActiveFlag = cast<llvm::AllocaInst>(Var.getPointer());
  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. class EHPadEndScope : public EHScope {
  399. public:
  400. EHPadEndScope(EHScopeStack::stable_iterator enclosingEHScope)
  401. : EHScope(PadEnd, enclosingEHScope) {}
  402. static size_t getSize() { return sizeof(EHPadEndScope); }
  403. static bool classof(const EHScope *scope) {
  404. return scope->getKind() == PadEnd;
  405. }
  406. };
  407. /// A non-stable pointer into the scope stack.
  408. class EHScopeStack::iterator {
  409. char *Ptr;
  410. friend class EHScopeStack;
  411. explicit iterator(char *Ptr) : Ptr(Ptr) {}
  412. public:
  413. iterator() : Ptr(nullptr) {}
  414. EHScope *get() const {
  415. return reinterpret_cast<EHScope*>(Ptr);
  416. }
  417. EHScope *operator->() const { return get(); }
  418. EHScope &operator*() const { return *get(); }
  419. iterator &operator++() {
  420. size_t Size;
  421. switch (get()->getKind()) {
  422. case EHScope::Catch:
  423. Size = EHCatchScope::getSizeForNumHandlers(
  424. static_cast<const EHCatchScope *>(get())->getNumHandlers());
  425. break;
  426. case EHScope::Filter:
  427. Size = EHFilterScope::getSizeForNumFilters(
  428. static_cast<const EHFilterScope *>(get())->getNumFilters());
  429. break;
  430. case EHScope::Cleanup:
  431. Size = static_cast<const EHCleanupScope *>(get())->getAllocatedSize();
  432. break;
  433. case EHScope::Terminate:
  434. Size = EHTerminateScope::getSize();
  435. break;
  436. case EHScope::PadEnd:
  437. Size = EHPadEndScope::getSize();
  438. break;
  439. }
  440. Ptr += llvm::alignTo(Size, ScopeStackAlignment);
  441. return *this;
  442. }
  443. iterator next() {
  444. iterator copy = *this;
  445. ++copy;
  446. return copy;
  447. }
  448. iterator operator++(int) {
  449. iterator copy = *this;
  450. operator++();
  451. return copy;
  452. }
  453. bool encloses(iterator other) const { return Ptr >= other.Ptr; }
  454. bool strictlyEncloses(iterator other) const { return Ptr > other.Ptr; }
  455. bool operator==(iterator other) const { return Ptr == other.Ptr; }
  456. bool operator!=(iterator other) const { return Ptr != other.Ptr; }
  457. };
  458. inline EHScopeStack::iterator EHScopeStack::begin() const {
  459. return iterator(StartOfData);
  460. }
  461. inline EHScopeStack::iterator EHScopeStack::end() const {
  462. return iterator(EndOfBuffer);
  463. }
  464. inline void EHScopeStack::popCatch() {
  465. assert(!empty() && "popping exception stack when not empty");
  466. EHCatchScope &scope = cast<EHCatchScope>(*begin());
  467. InnermostEHScope = scope.getEnclosingEHScope();
  468. deallocate(EHCatchScope::getSizeForNumHandlers(scope.getNumHandlers()));
  469. }
  470. inline void EHScopeStack::popTerminate() {
  471. assert(!empty() && "popping exception stack when not empty");
  472. EHTerminateScope &scope = cast<EHTerminateScope>(*begin());
  473. InnermostEHScope = scope.getEnclosingEHScope();
  474. deallocate(EHTerminateScope::getSize());
  475. }
  476. inline EHScopeStack::iterator EHScopeStack::find(stable_iterator sp) const {
  477. assert(sp.isValid() && "finding invalid savepoint");
  478. assert(sp.Size <= stable_begin().Size && "finding savepoint after pop");
  479. return iterator(EndOfBuffer - sp.Size);
  480. }
  481. inline EHScopeStack::stable_iterator
  482. EHScopeStack::stabilize(iterator ir) const {
  483. assert(StartOfData <= ir.Ptr && ir.Ptr <= EndOfBuffer);
  484. return stable_iterator(EndOfBuffer - ir.Ptr);
  485. }
  486. /// The exceptions personality for a function.
  487. struct EHPersonality {
  488. const char *PersonalityFn;
  489. // If this is non-null, this personality requires a non-standard
  490. // function for rethrowing an exception after a catchall cleanup.
  491. // This function must have prototype void(void*).
  492. const char *CatchallRethrowFn;
  493. static const EHPersonality &get(CodeGenModule &CGM, const FunctionDecl *FD);
  494. static const EHPersonality &get(CodeGenFunction &CGF);
  495. static const EHPersonality GNU_C;
  496. static const EHPersonality GNU_C_SJLJ;
  497. static const EHPersonality GNU_C_SEH;
  498. static const EHPersonality GNU_ObjC;
  499. static const EHPersonality GNU_ObjC_SJLJ;
  500. static const EHPersonality GNU_ObjC_SEH;
  501. static const EHPersonality GNUstep_ObjC;
  502. static const EHPersonality GNU_ObjCXX;
  503. static const EHPersonality NeXT_ObjC;
  504. static const EHPersonality GNU_CPlusPlus;
  505. static const EHPersonality GNU_CPlusPlus_SJLJ;
  506. static const EHPersonality GNU_CPlusPlus_SEH;
  507. static const EHPersonality MSVC_except_handler;
  508. static const EHPersonality MSVC_C_specific_handler;
  509. static const EHPersonality MSVC_CxxFrameHandler3;
  510. static const EHPersonality GNU_Wasm_CPlusPlus;
  511. /// Does this personality use landingpads or the family of pad instructions
  512. /// designed to form funclets?
  513. bool usesFuncletPads() const {
  514. return isMSVCPersonality() || isWasmPersonality();
  515. }
  516. bool isMSVCPersonality() const {
  517. return this == &MSVC_except_handler || this == &MSVC_C_specific_handler ||
  518. this == &MSVC_CxxFrameHandler3;
  519. }
  520. bool isWasmPersonality() const { return this == &GNU_Wasm_CPlusPlus; }
  521. bool isMSVCXXPersonality() const { return this == &MSVC_CxxFrameHandler3; }
  522. };
  523. }
  524. }
  525. #endif