summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/microsoft-abi-try-throw.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-03-15 07:10:01 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-03-15 07:10:01 +0000
commitf6927743caf979d65554d056d80a118e79e4e7d5 (patch)
tree195344a93eac6be2166a4e98c813815426dd97a1 /test/CodeGenCXX/microsoft-abi-try-throw.cpp
parent4e5b0884d2f8e2b5ab68e43f1b5dfea07c78d695 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@232318 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/microsoft-abi-try-throw.cpp')
-rw-r--r--test/CodeGenCXX/microsoft-abi-try-throw.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/CodeGenCXX/microsoft-abi-try-throw.cpp b/test/CodeGenCXX/microsoft-abi-try-throw.cpp
index 27c78d5a08..8aecab4f65 100644
--- a/test/CodeGenCXX/microsoft-abi-try-throw.cpp
+++ b/test/CodeGenCXX/microsoft-abi-try-throw.cpp
@@ -31,3 +31,15 @@ int main() {
#endif
return rv;
}
+
+#ifdef TRY
+// TRY-LABEL: define void @"\01?qual_catch@@YAXXZ"
+void qual_catch() {
+ try {
+ external();
+ } catch (const int *) {
+ }
+ // TRY: catch i8* bitcast (%rtti.TypeDescriptor4* @"\01??_R0PAH@8" to i8*)
+ // TRY: call i32 @llvm.eh.typeid.for(i8* bitcast (%rtti.TypeDescriptor4* @"\01??_R0PAH@8" to i8*))
+}
+#endif