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