From a1aea9aad4f99580939ca70125229dea3694e49c Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Thu, 12 Mar 2015 17:44:49 +0000 Subject: MS ABI: Allow a nullptr_t exception to be caught by void * catch handler A nullptr exception object can be caught by any pointer type catch handler. However, it is not possible to express this in the exception info for the MS ABI. As a middle ground, allow such exception objects to be caught with pointer-to-void catch handlers. llvm-svn: 232069 --- clang/lib/CodeGen/MicrosoftCXXABI.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'clang/lib/CodeGen/MicrosoftCXXABI.cpp') diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index 3bc9f64fe4b..1f5d678f4d6 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -3490,6 +3490,17 @@ llvm::GlobalVariable *MicrosoftCXXABI::getCatchableTypeArray(QualType T) { if (IsPointer) CatchableTypes.insert(getCatchableType(getContext().VoidPtrTy)); + // C++14 [except.handle]p3: + // A handler is a match for an exception object of type E if [...] + // - the handler is of type cv T or const T& where T is a pointer or + // pointer to member type and E is std::nullptr_t. + // + // We cannot possibly list all possible pointer types here, making this + // implementation incompatible with the standard. However, MSVC includes an + // entry for pointer-to-void in this case. Let's do the same. + if (T->isNullPtrType()) + CatchableTypes.insert(getCatchableType(getContext().VoidPtrTy)); + uint32_t NumEntries = CatchableTypes.size(); llvm::Type *CTType = getImageRelativeType(getCatchableTypeType()->getPointerTo()); -- cgit v1.2.3