Commit Graph

10 Commits

Author SHA1 Message Date
David Majnemer f205f5324b [MS ABI] A pointer-to-function cannot be caught as a pointer-to-void
Don't assume that all pointers are convertible to void pointer.
Instead correctly respect [conv.ptr]p2; only allow pointer types with an
object pointee type to be caught as pointer-to-void.

llvm-svn: 234090
2015-04-04 05:37:48 +00:00
David Majnemer ba3e5ecf07 MS ABI: Implement __GetExceptionInfo for std::make_exception_ptr
std::make_exception_ptr calls std::__GetExceptionInfo in order to figure
out how to properly copy the exception object.

Differential Revision: http://reviews.llvm.org/D8280

llvm-svn: 232188
2015-03-13 18:26:17 +00:00
David Majnemer a1aea9aad4 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
2015-03-12 17:44:49 +00:00
David Majnemer 678732933f Don't overconstrain a FileCheck pattern
llvm-svn: 231971
2015-03-11 21:50:09 +00:00
David Majnemer dfa6d2067c MS ABI: Implement copy-ctor closures, finish implementing throw
This adds support for copy-constructor closures.  These are generated
when the C++ runtime has to call a copy-constructor with a particular
calling convention or with default arguments substituted in to the call.

Because the runtime has no mechanism to call the function with a
different calling convention or know-how to evaluate the default
arguments at run-time, we create a thunk which will do all the
appropriate work and package it in a way the runtime can use.

Differential Revision: http://reviews.llvm.org/D8225

llvm-svn: 231952
2015-03-11 18:36:39 +00:00
David Majnemer 999cbf9d21 MS ABI: Mangle the location of the catchable type into it's name
Because the catchable type has a reference to its name, mangle the
location to ensure that two catchable types with different locations are
distinct.

llvm-svn: 231819
2015-03-10 19:01:51 +00:00
David Majnemer 322fe4188f MS ABI: Stick throw-related data into the .xdata section
This is a little nicer as it keeps the contents of .xdata away from
normal .rdata; we expect .xdata to be far colder than .rdata.

llvm-svn: 231534
2015-03-06 23:45:23 +00:00
David Majnemer d3d7669ced MS ABI: Correctly generate throw-info for pointer to const qual types
We didn't create type info based on the unqualified pointee type,
causing RTTI mismatches.

llvm-svn: 231533
2015-03-06 23:45:20 +00:00
David Majnemer e7a818fec8 MS ABI: Insert copy-constructors into the CatchableType
Find all unambiguous public classes of the exception object's class type
and reference all of their copy constructors.  Yes, this is not
conforming but it is necessary in order to implement their ABI.  This is
because the copy constructor is actually referenced by the metadata
describing which catch handlers are eligible to handle the exception
object.

N.B.  This doesn't yet handle the copy constructor closure case yet,
that work is ongoing.

Differential Revision: http://reviews.llvm.org/D8101

llvm-svn: 231499
2015-03-06 18:53:55 +00:00
David Majnemer 7c23707174 MS ABI: Implement support for throwing a C++ exception
Throwing a C++ exception, under the MS ABI, is implemented using three
components:
- ThrowInfo structure which contains information like CV qualifiers,
  what destructor to call and a pointer to the CatchableTypeArray.
- In a significant departure from the Itanium ABI, copying by-value
  occurs in the runtime and not at the catch site.  This means we need
  to enumerate all possible types that this exception could be caught as
  and encode the necessary information to convert from the exception
  object's type to the catch handler's type.  This includes complicated
  derived to base conversions and the execution of copy-constructors.

N.B. This implementation doesn't support the execution of a
copy-constructor from within the runtime for now.  Adding support for
that functionality is quite difficult due to things like default
argument expressions which may evaluate arbitrary code hiding in the
copy-constructor's parameters.

Differential Revision: http://reviews.llvm.org/D8066

llvm-svn: 231328
2015-03-05 00:46:22 +00:00