From 10aa77032de43681231e81ee3f2e7d232b16dc9c Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 16 Sep 2015 20:15:55 +0000 Subject: [WinEH] Pass the catch adjectives to catchpad directly This avoids building a fake LLVM IR global variable just to ferry an i32 down into LLVM codegen. It also puts a nail in the coffin of using MS ABI C++ EH with landingpads, since now we'll assert in the lpad code when flags are present. llvm-svn: 247843 --- clang/lib/CodeGen/CGCleanup.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'clang/lib/CodeGen/CGCleanup.h') diff --git a/clang/lib/CodeGen/CGCleanup.h b/clang/lib/CodeGen/CGCleanup.h index 5782343013c..51b33f43e90 100644 --- a/clang/lib/CodeGen/CGCleanup.h +++ b/clang/lib/CodeGen/CGCleanup.h @@ -33,6 +33,13 @@ namespace CodeGen { class CodeGenModule; class CodeGenFunction; +/// The MS C++ ABI needs a pointer to RTTI data plus some flags to describe the +/// type of a catch handler, so we use this wrapper. +struct CatchTypeInfo { + llvm::Constant *RTTI; + unsigned Flags; +}; + /// A protected scope for zero-cost EH handling. class EHScope { llvm::BasicBlock *CachedLandingPad; @@ -153,12 +160,12 @@ public: struct Handler { /// A type info value, or null (C++ null, not an LLVM null pointer) /// for a catch-all. - llvm::Constant *Type; + CatchTypeInfo Type; /// The catch handler for this type. llvm::BasicBlock *Block; - bool isCatchAll() const { return Type == nullptr; } + bool isCatchAll() const { return Type.RTTI == nullptr; } }; private: @@ -188,10 +195,16 @@ public: } void setCatchAllHandler(unsigned I, llvm::BasicBlock *Block) { - setHandler(I, /*catchall*/ nullptr, Block); + setHandler(I, CatchTypeInfo{nullptr, 0}, Block); } void setHandler(unsigned I, llvm::Constant *Type, llvm::BasicBlock *Block) { + assert(I < getNumHandlers()); + getHandlers()[I].Type = CatchTypeInfo{Type, 0}; + getHandlers()[I].Block = Block; + } + + void setHandler(unsigned I, CatchTypeInfo Type, llvm::BasicBlock *Block) { assert(I < getNumHandlers()); getHandlers()[I].Type = Type; getHandlers()[I].Block = Block; -- cgit v1.2.3