[MS ABI] Invent a mangling for reference temporaries

MSVC is non-conforming and doesn't have a mangling for these.  Invent
our own to unblock folks using clang.

This fixes PR25795.

llvm-svn: 256589
This commit is contained in:
David Majnemer 2015-12-29 22:25:14 +00:00
parent 90bee6354d
commit e77de75d7e
2 changed files with 10 additions and 6 deletions

View File

@ -2760,12 +2760,12 @@ void MicrosoftMangleContextImpl::mangleCXXDtor(const CXXDestructorDecl *D,
mangler.mangle(D);
}
void MicrosoftMangleContextImpl::mangleReferenceTemporary(const VarDecl *VD,
unsigned,
raw_ostream &) {
unsigned DiagID = getDiags().getCustomDiagID(DiagnosticsEngine::Error,
"cannot mangle this reference temporary yet");
getDiags().Report(VD->getLocation(), DiagID);
void MicrosoftMangleContextImpl::mangleReferenceTemporary(
const VarDecl *VD, unsigned ManglingNumber, raw_ostream &Out) {
MicrosoftCXXNameMangler Mangler(*this, Out);
Mangler.getStream() << "\01?$RT" << ManglingNumber << '@';
Mangler.mangle(VD, "");
}
void MicrosoftMangleContextImpl::mangleThreadSafeStaticGuardVariable(

View File

@ -21,6 +21,10 @@ int _c(void) {return N::anonymous + c;}
// CHECK-DAG: @"\01?_c@@YAHXZ"
// X64-DAG: @"\01?_c@@YAHXZ"
const int &NeedsReferenceTemporary = 2;
// CHECK-DAG: @"\01?NeedsReferenceTemporary@@3ABHB" = constant i32* @"\01?$RT1@NeedsReferenceTemporary@@3ABHB"
// X64-DAG: @"\01?NeedsReferenceTemporary@@3AEBHEB" = constant i32* @"\01?$RT1@NeedsReferenceTemporary@@3AEBHEB"
class foo {
static const short d;
// CHECK-DAG: @"\01?d@foo@@0FB"