[MS ABI] Add a mangling for _Complex

MSVC doesn't implement a mangling for C99's _Complex so we must invent
our own.

For now, treating it like a class type called _Complex in the __clang
namespace.

This means that 'void f(__Complex int))'
will demangle as: 'void f(struct __clang::_Complex<int>)'

llvm-svn: 256583
This commit is contained in:
David Majnemer 2015-12-29 22:02:15 +00:00
parent 53b60a1d26
commit 0b996dd634
2 changed files with 14 additions and 5 deletions

View File

@ -2207,11 +2207,16 @@ void MicrosoftCXXNameMangler::mangleType(const RValueReferenceType *T,
void MicrosoftCXXNameMangler::mangleType(const ComplexType *T, Qualifiers,
SourceRange Range) {
DiagnosticsEngine &Diags = Context.getDiags();
unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
"cannot mangle this complex number type yet");
Diags.Report(Range.getBegin(), DiagID)
<< Range;
QualType ElementType = T->getElementType();
llvm::SmallString<64> TemplateMangling;
llvm::raw_svector_ostream Stream(TemplateMangling);
MicrosoftCXXNameMangler Extra(Context, Stream);
Stream << "?$";
Extra.mangleSourceName("_Complex");
Extra.mangleType(ElementType, Range, QMM_Escape);
mangleArtificalTagType(TTK_Struct, TemplateMangling, {"__clang"});
}
void MicrosoftCXXNameMangler::mangleType(const VectorType *T, Qualifiers Quals,

View File

@ -442,3 +442,7 @@ namespace Atomic {
// CHECK-DAG: define void @"\01?f@Atomic@@YAXU?$_Atomic@H@__clang@@@Z"(
void f(_Atomic(int)) {}
}
namespace Complex {
// CHECK-DAG: define void @"\01?f@Complex@@YAXU?$_Complex@H@__clang@@@Z"(
void f(_Complex int) {}
}