Index: lib/AST/MicrosoftMangle.cpp =================================================================== --- lib/AST/MicrosoftMangle.cpp +++ lib/AST/MicrosoftMangle.cpp @@ -3001,6 +3001,11 @@ msvc_hashing_ostream MHO(Out); MicrosoftCXXNameMangler Mangler(*this, MHO); Mangler.getStream() << "??_R0"; + // Obj-C classes are mangled as C++ structs with the same name, but we want to + // be able to distinguish a C++ struct X from an Obj-C class X for the + // purposes of exception handling, so we add a discriminator. + if (T->isObjCObjectPointerType()) + Mangler.getStream() << "objc."; Mangler.mangleType(T, SourceRange(), MicrosoftCXXNameMangler::QMM_Result); Mangler.getStream() << "@8"; } @@ -3009,6 +3014,9 @@ raw_ostream &Out) { MicrosoftCXXNameMangler Mangler(*this, Out); Mangler.getStream() << '.'; + // See the comment in MicrosoftMangleContextImpl::mangleCXXRTTI. + if (T->isObjCObjectPointerType()) + Mangler.getStream() << "objc."; Mangler.mangleType(T, SourceRange(), MicrosoftCXXNameMangler::QMM_Result); } Index: test/CodeGenObjCXX/msabi-objc-exceptions-gnustep.mm =================================================================== --- /dev/null +++ test/CodeGenObjCXX/msabi-objc-exceptions-gnustep.mm @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -triple i686-windows-msvc -fobjc-runtime=gnustep-2.0 -fexceptions -fobjc-exceptions -emit-llvm -o - %s | FileCheck -check-prefix=X86 %s +// RUN: %clang_cc1 -triple x86_64-windows-msvc -fobjc-runtime=gnustep-2.0 -fexceptions -fobjc-exceptions -emit-llvm -o - %s | FileCheck -check-prefix=X64 %s + +// Ensure we have the .objc discriminator in the RTTI and the RTTI name. +// X86-DAG: @"??_R0objc.PAUobjc_object@@@8" = linkonce_odr global %{{[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [23 x i8] c".objc.PAUobjc_object@@\00" }, comdat +// X64-DAG: @"??_R0objc.PEAUobjc_object@@@8" = linkonce_odr global %{{[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [24 x i8] c".objc.PEAUobjc_object@@\00" }, comdat + +@class I; +// X86-DAG: @"??_R0objc.PAUI@@@8" = linkonce_odr global %{{[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [13 x i8] c".objc.PAUI@@\00" }, comdat +// X64-DAG: @"??_R0objc.PEAUI@@@8" = linkonce_odr global %{{[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [14 x i8] c".objc.PEAUI@@\00" }, comdat + +void f(); +void g() { + @try { + f(); + } @catch (I *) { + } @catch (id) { + } +}