If QMM_Result is set (which it is for return types, RTTI descriptors, and exception type descriptors), tag types (structs, enums, classes, unions) get their qualifiers mangled in.
__m64 and friends is a struct/union thingy in MSVC, but not in clang's headers. To make mangling work, we call mangleArtificalTagType(TTK_Union/TTK_Struct for the vector types to mangle them as tag types -- but the isa<TagType> check when mangling in QMM_Result mode isn't true these vector types. Add an isArtificialTagType() function and check for that too. Fixes PR37276 and some other issues.
I tried to audit all references to TagDecl and TagType in MicrosoftMangle.cpp to see if there are other places where we need to call mangleArtificalTagType(), but I couldn't find other places.
I tried to audit all calls to mangleArtificalTagType() to see if isArtificialTagType() needs to handle more than just the vector types, but as far as I can tell all other types we use it for are types that MSVC can't handle at all (Objective-C types etc).
I think we might as well mangle qualifiers into all vector types. Ultimately, they are all mangled as artificial tag types, and MSVC mangles qualifiers into tag return types. I don't think it's worth the code complexity to distinguish between the m64 / m128* vector types that require ABI compatibility and those that don't.