diff options
Diffstat (limited to 'clang/lib/AST/MicrosoftMangle.cpp')
-rw-r--r-- | clang/lib/AST/MicrosoftMangle.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index f9cd24ce9ab..e45f9f7902e 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -337,6 +337,8 @@ private: void mangleArgumentType(QualType T, SourceRange Range); void manglePassObjectSizeArg(const PassObjectSizeAttr *POSA); + bool isArtificialTagType(QualType T) const; + // Declare manglers for every type class. #define ABSTRACT_TYPE(CLASS, PARENT) #define NON_CANONICAL_TYPE(CLASS, PARENT) @@ -1751,7 +1753,7 @@ void MicrosoftCXXNameMangler::mangleType(QualType T, SourceRange Range, Quals.removeUnaligned(); if (Quals.hasObjCLifetime()) Quals = Quals.withoutObjCLifetime(); - if ((!IsPointer && Quals) || isa<TagType>(T)) { + if ((!IsPointer && Quals) || isa<TagType>(T) || isArtificialTagType(T)) { Out << '?'; mangleQualifiers(Quals, false); } @@ -2280,6 +2282,8 @@ void MicrosoftCXXNameMangler::mangleType(const TagDecl *TD) { mangleTagTypeKind(TD->getTagKind()); mangleName(TD); } + +// If you add a call to this, consider updating isArtificialTagType() too. void MicrosoftCXXNameMangler::mangleArtificalTagType( TagTypeKind TK, StringRef UnqualifiedName, ArrayRef<StringRef> NestedNames) { // <name> ::= <unscoped-name> {[<named-scope>]+ | [<nested-name>]}? @ @@ -2468,6 +2472,26 @@ void MicrosoftCXXNameMangler::mangleType(const ComplexType *T, Qualifiers, mangleArtificalTagType(TTK_Struct, TemplateMangling, {"__clang"}); } +// Returns true for types that mangleArtificalTagType() gets called for with +// TTK_Union, TTK_Struct, TTK_Class and where compatibility with MSVC's +// mangling matters. +// (It doesn't matter for Objective-C types and the like that cl.exe doesn't +// support.) +bool MicrosoftCXXNameMangler::isArtificialTagType(QualType T) const { + const Type *ty = T.getTypePtr(); + switch (ty->getTypeClass()) { + default: + return false; + + case Type::Vector: { + // For ABI compatibility only __m64, __m128(id), and __m256(id) matter, + // but since mangleType(VectorType*) always calls mangleArtificalTagType() + // just always return true (the other vector types are clang-only). + return true; + } + } +} + void MicrosoftCXXNameMangler::mangleType(const VectorType *T, Qualifiers Quals, SourceRange Range) { const BuiltinType *ET = T->getElementType()->getAs<BuiltinType>(); |