MS ABI: Don't use qualified pointee types for 'catch' EH TypeDescriptors
authorDavid Majnemer <david.majnemer@gmail.com>
Sun, 15 Mar 2015 07:10:01 +0000 (07:10 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Sun, 15 Mar 2015 07:10:01 +0000 (07:10 +0000)
commitad803d4b7625dbe67381ac8ab35dfeca3e995f51
treebc51d60ff004d23201b939b901321b67fca9f76a
parentfb4898e88136c319d949a88b2dde541de8802623
MS ABI: Don't use qualified pointee types for 'catch' EH TypeDescriptors

Qualifiers are located next to the TypeDescriptor in order to properly
ensure that a pointer type can only be caught by a more qualified catch
handler.  This means that a catch handler of type 'const int *' requires
an RTTI object for 'int *'.  We got this correct for 'throw' but not for
'catch'.

N.B.  We don't currently have the means to store the qualifiers because
LLVM's EH strategy is tailored to the Itanium scheme.  The Itanium ABI
stores qualifiers inside the type descriptor in such a way that the
manner of qualification is stored in addition to the pointee type's
descriptor.  Perhaps the best way of modeling this for the MS ABI is
using an aggregate type to bundle the qualifiers with the descriptor?
This is tricky because we want to make it clear to the optimization
passes which catch handlers invalidate other handlers.

My current thoughts on a design for this is along the lines of:
  { { TypeDescriptor* TD, i32 QualifierFlags }, i32 MiscFlags }

The idea is that the inner most aggregate is all that is needed to
communicate that one catch handler might supercede another.  The
'MiscFlags' field would be used to hold the bitpattern for the notion
that the 'catch' handler does not need to invoke a copy-constructor
because we are catching by reference.

llvm-svn: 232318
clang/lib/CodeGen/CGCXXABI.h
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/CodeGen/MicrosoftCXXABI.cpp
clang/test/CodeGenCXX/microsoft-abi-try-throw.cpp