diff options
author | Shoaib Meenai <smeenai@fb.com> | 2018-10-04 19:50:14 +0000 |
---|---|---|
committer | Shoaib Meenai <smeenai@fb.com> | 2018-10-04 19:50:14 +0000 |
commit | c8714d284a5aab04d829caeec54adcacb7a91cfc (patch) | |
tree | 7ffdf70ccb3f02e6a4d624c81046c938d3dc114d /clang/lib/AST/MicrosoftMangle.cpp | |
parent | 07dd5af6dfae6ff11d1c79dca892bf6277bd86c0 (diff) | |
download | bcm5719-llvm-c8714d284a5aab04d829caeec54adcacb7a91cfc.tar.gz bcm5719-llvm-c8714d284a5aab04d829caeec54adcacb7a91cfc.zip |
[AST] Revert mangling changes from r339428
As discussed in https://reviews.llvm.org/D50144, we want Obj-C classes
to have the same mangling as C++ structs, to support headers like the
following:
```
@class I;
struct I;
void f(I *);
```
since the header can be used from both C++ and Obj-C++ TUs, and we want
a consistent mangling across the two to prevent link errors. Itanium
mangles both the same way, and so should the MS ABI.
The main concern with having the same mangling for C++ structs and Obj-C
classes was that we want to treat them differently for the purposes of
exception handling, e.g. we don't want a C++ catch statement for a
struct to be able to catch an Obj-C class with the same name as the
struct. We can accomplish this by mangling Obj-C class names differently
in their RTTI, which I'll do in a follow-up patch.
Differential Revision: https://reviews.llvm.org/D52581
llvm-svn: 343808
Diffstat (limited to 'clang/lib/AST/MicrosoftMangle.cpp')
-rw-r--r-- | clang/lib/AST/MicrosoftMangle.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index 1d4bdaa760c..072184d82e8 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -482,7 +482,7 @@ void MicrosoftCXXNameMangler::mangle(const NamedDecl *D, StringRef Prefix) { mangleFunctionEncoding(FD, Context.shouldMangleDeclName(FD)); else if (const VarDecl *VD = dyn_cast<VarDecl>(D)) mangleVariableEncoding(VD); - else if (!isa<ObjCInterfaceDecl>(D)) + else llvm_unreachable("Tried to mangle unexpected NamedDecl!"); } @@ -1951,13 +1951,13 @@ void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T, Qualifiers, llvm_unreachable("placeholder types shouldn't get to name mangling"); case BuiltinType::ObjCId: - mangleArtificalTagType(TTK_Struct, ".objc_object"); + mangleArtificalTagType(TTK_Struct, "objc_object"); break; case BuiltinType::ObjCClass: - mangleArtificalTagType(TTK_Struct, ".objc_class"); + mangleArtificalTagType(TTK_Struct, "objc_class"); break; case BuiltinType::ObjCSel: - mangleArtificalTagType(TTK_Struct, ".objc_selector"); + mangleArtificalTagType(TTK_Struct, "objc_selector"); break; #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ @@ -2637,10 +2637,9 @@ void MicrosoftCXXNameMangler::mangleType(const DependentAddressSpaceType *T, void MicrosoftCXXNameMangler::mangleType(const ObjCInterfaceType *T, Qualifiers, SourceRange) { - // ObjC interfaces are mangled as if they were structs with a name that is - // not a valid C/C++ identifier + // ObjC interfaces have structs underlying them. mangleTagTypeKind(TTK_Struct); - mangle(T->getDecl(), ".objc_cls_"); + mangleName(T->getDecl()); } void MicrosoftCXXNameMangler::mangleType(const ObjCObjectType *T, @@ -2661,11 +2660,11 @@ void MicrosoftCXXNameMangler::mangleType(const ObjCObjectType *T, Out << "?$"; if (T->isObjCId()) - mangleSourceName(".objc_object"); + mangleSourceName("objc_object"); else if (T->isObjCClass()) - mangleSourceName(".objc_class"); + mangleSourceName("objc_class"); else - mangleSourceName((".objc_cls_" + T->getInterface()->getName()).str()); + mangleSourceName(T->getInterface()->getName()); for (const auto &Q : T->quals()) mangleObjCProtocol(Q); |