Skip to content

Commit

Permalink
[MS ABI] Invent a mangling for reference temporaries
Browse files Browse the repository at this point in the history
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
  • Loading branch information
majnemer committed Dec 29, 2015
1 parent 90bee63 commit e77de75
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 6 additions & 6 deletions clang/lib/AST/MicrosoftMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions clang/test/CodeGenCXX/mangle-ms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit e77de75

Please sign in to comment.