From: Saleem Abdulrasool Date: Tue, 23 Jan 2018 19:17:25 +0000 (+0000) Subject: AST: adjust ObjC MS mangling to work with typedefs X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=72ae43d52f9eb11f4f1bab64866e75c1d04213d4;p=clang AST: adjust ObjC MS mangling to work with typedefs Rather than hardcode the pointerness of the `id` and `class` types, handle them generically. This allows for the template type specialization of `remove_pointer` which would look through the `id` type and deal with the `objc_object` structure without the pointer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@323241 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp index 0c55c1a922..e97e8bda96 100644 --- a/lib/AST/MicrosoftMangle.cpp +++ b/lib/AST/MicrosoftMangle.cpp @@ -1833,11 +1833,9 @@ void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T, Qualifiers, llvm_unreachable("placeholder types shouldn't get to name mangling"); case BuiltinType::ObjCId: - Out << "PA"; mangleArtificalTagType(TTK_Struct, "objc_object"); break; case BuiltinType::ObjCClass: - Out << "PA"; mangleArtificalTagType(TTK_Struct, "objc_class"); break; case BuiltinType::ObjCSel: @@ -2337,9 +2335,6 @@ void MicrosoftCXXNameMangler::mangleType(const PointerType *T, Qualifiers Quals, void MicrosoftCXXNameMangler::mangleType(const ObjCObjectPointerType *T, Qualifiers Quals, SourceRange Range) { - if (T->isObjCIdType() || T->isObjCClassType()) - return mangleType(T->getPointeeType(), Range, QMM_Drop); - QualType PointeeType = T->getPointeeType(); manglePointerCVQualifiers(Quals); manglePointerExtQualifiers(Quals, PointeeType); diff --git a/test/CodeGenObjCXX/msabi-objc-types.mm b/test/CodeGenObjCXX/msabi-objc-types.mm index 013a9c84da..42db40a351 100644 --- a/test/CodeGenObjCXX/msabi-objc-types.mm +++ b/test/CodeGenObjCXX/msabi-objc-types.mm @@ -33,7 +33,7 @@ void g(id &) {} // CHECK-LABEL: "\01?g@@YAXAAPAUobjc_object@@@Z" void g(const id &) {} -// CHECK-LABEL: "\01?g@@YAXABPAUobjc_object@@@Z" +// CHECK-LABEL: "\01?g@@YAXABQAUobjc_object@@@Z" void g(id &&) {} // CHECK-LABEL: "\01?g@@YAX$$QAPAUobjc_object@@@Z" @@ -45,7 +45,7 @@ void h(Class &) {} // CHECK-LABEL: "\01?h@@YAXAAPAUobjc_class@@@Z" void h(const Class &) {} -// CHECK-LABEL: "\01?h@@YAXABPAUobjc_class@@@Z" +// CHECK-LABEL: "\01?h@@YAXABQAUobjc_class@@@Z" void h(Class &&) {} // CHECK-LABEL: "\01?h@@YAX$$QAPAUobjc_class@@@Z" @@ -62,6 +62,12 @@ I &k() { return *kI; } const I &l() { return *kI; } // CHECK-LABEL: "\01?l@@YAABUI@@XZ" +void m(const id) {} +// CHECK-LABEL: "\01?m@@YAXQAUobjc_object@@@Z" + +void m(const I *) {} +// CHECK-LABEL: "\01?m@@YAXPBUI@@@Z" + struct __declspec(dllexport) s { struct s &operator=(const struct s &) = delete; @@ -93,16 +99,16 @@ struct __declspec(dllexport) s { // CHECK-LABEL: "\01?m@s@@QAAX$$QAPAUobjc_object@@@Z" void m(const id &) {} - // CHECK-LABEL: "\01?m@s@@QAAXABPAUobjc_object@@@Z" + // CHECK-LABEL: "\01?m@s@@QAAXABQAUobjc_object@@@Z" void m(const id &&) {} - // CHECK-LABEL: "\01?m@s@@QAAX$$QBPAUobjc_object@@@Z" + // CHECK-LABEL: "\01?m@s@@QAAX$$QBQAUobjc_object@@@Z" void m(Class *) {} // CHECK-LABEL: "\01?m@s@@QAAXPAPAUobjc_class@@@Z" void m(const Class *) {} - // CHECK-LABEL: "\01?m@s@@QAAXPBPAUobjc_class@@@Z" + // CHECK-LABEL: "\01?m@s@@QAAXPBQAUobjc_class@@@Z" void m(Class) {} // CHECK-LABEL: "\01?m@s@@QAAXPAUobjc_class@@@Z" @@ -111,12 +117,31 @@ struct __declspec(dllexport) s { // CHECK-LABEL: "\01?m@s@@QAAXAAPAUobjc_class@@@Z" void m(const Class &) {} - // CHECK-LABEL: "\01?m@s@@QAAXABPAUobjc_class@@@Z" + // CHECK-LABEL: "\01?m@s@@QAAXABQAUobjc_class@@@Z" void m(Class &&) {} // CHECK-LABEL: "\01?m@s@@QAAX$$QAPAUobjc_class@@@Z" void m(const Class &&) {} - // CHECK-LABEL: "\01?m@s@@QAAX$$QBPAUobjc_class@@@Z" + // CHECK-LABEL: "\01?m@s@@QAAX$$QBQAUobjc_class@@@Z" +}; + +template +struct remove_pointer { typedef T type; }; + +template +struct remove_pointer { + typedef T type; }; +template +struct t { + t() {} +}; + +template struct t; +// CHECK-LABEL: "\01??0?$t@PAUobjc_object@@@@QAA@XZ" + +template struct t::type>; +// CHECK-LABEL: "\01??0?$t@Uobjc_object@@@@QAA@XZ" +