summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/MicrosoftMangle.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-06-11 04:55:08 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-06-11 04:55:08 +0000
commit6a729c64e0eb168e26f6377002b884f748d48333 (patch)
tree684a70acdaeadf4d8ff518551b4eddece28265e8 /clang/lib/AST/MicrosoftMangle.cpp
parentace0080a4a0e95bad681f5d5c1bcca9d43a5f05b (diff)
downloadbcm5719-llvm-6a729c64e0eb168e26f6377002b884f748d48333.tar.gz
bcm5719-llvm-6a729c64e0eb168e26f6377002b884f748d48333.zip
MS ABI: Mangle null pointer-to-member-functions compatibly
Summary: Previously, we would mangle nullptr pointer-to-member-functions in class templates with a mangling we invented because contemporary versions of MSVC would crash when trying to compile such code. However, VS "14" can successfully compile these sorts of template instantiations. This commit updates our mangling to be compatible with theirs. Reviewers: rnk Reviewed By: rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4059 llvm-svn: 210637
Diffstat (limited to 'clang/lib/AST/MicrosoftMangle.cpp')
-rw-r--r--clang/lib/AST/MicrosoftMangle.cpp49
1 files changed, 25 insertions, 24 deletions
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp
index a02402580d9..481ed44347e 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -495,18 +495,9 @@ MicrosoftCXXNameMangler::mangleMemberFunctionPointer(const CXXRecordDecl *RD,
// ::= $H? <name> <number>
// ::= $I? <name> <number> <number>
// ::= $J? <name> <number> <number> <number>
- // ::= $0A@
MSInheritanceAttr::Spelling IM = RD->getMSInheritanceModel();
- // The null member function pointer is $0A@ in function templates and crashes
- // MSVC when used in class templates, so we don't know what they really look
- // like.
- if (!MD) {
- Out << "$0A@";
- return;
- }
-
char Code = '\0';
switch (IM) {
case MSInheritanceAttr::Keyword_single_inheritance: Code = '1'; break;
@@ -515,28 +506,38 @@ MicrosoftCXXNameMangler::mangleMemberFunctionPointer(const CXXRecordDecl *RD,
case MSInheritanceAttr::Keyword_unspecified_inheritance: Code = 'J'; break;
}
- Out << '$' << Code << '?';
-
// If non-virtual, mangle the name. If virtual, mangle as a virtual memptr
// thunk.
uint64_t NVOffset = 0;
uint64_t VBTableOffset = 0;
uint64_t VBPtrOffset = 0;
- if (MD->isVirtual()) {
- MicrosoftVTableContext *VTContext =
- cast<MicrosoftVTableContext>(getASTContext().getVTableContext());
- const MicrosoftVTableContext::MethodVFTableLocation &ML =
- VTContext->getMethodVFTableLocation(GlobalDecl(MD));
- mangleVirtualMemPtrThunk(MD, ML);
- NVOffset = ML.VFPtrOffset.getQuantity();
- VBTableOffset = ML.VBTableIndex * 4;
- if (ML.VBase) {
- const ASTRecordLayout &Layout = getASTContext().getASTRecordLayout(RD);
- VBPtrOffset = Layout.getVBPtrOffset().getQuantity();
+ if (MD) {
+ Out << '$' << Code << '?';
+ if (MD->isVirtual()) {
+ MicrosoftVTableContext *VTContext =
+ cast<MicrosoftVTableContext>(getASTContext().getVTableContext());
+ const MicrosoftVTableContext::MethodVFTableLocation &ML =
+ VTContext->getMethodVFTableLocation(GlobalDecl(MD));
+ mangleVirtualMemPtrThunk(MD, ML);
+ NVOffset = ML.VFPtrOffset.getQuantity();
+ VBTableOffset = ML.VBTableIndex * 4;
+ if (ML.VBase) {
+ const ASTRecordLayout &Layout = getASTContext().getASTRecordLayout(RD);
+ VBPtrOffset = Layout.getVBPtrOffset().getQuantity();
+ }
+ } else {
+ mangleName(MD);
+ mangleFunctionEncoding(MD);
}
} else {
- mangleName(MD);
- mangleFunctionEncoding(MD);
+ // Null single inheritance member functions are encoded as a simple nullptr.
+ if (IM == MSInheritanceAttr::Keyword_single_inheritance) {
+ Out << "$0A@";
+ return;
+ }
+ if (IM == MSInheritanceAttr::Keyword_unspecified_inheritance)
+ VBTableOffset = -1;
+ Out << '$' << Code;
}
if (MSInheritanceAttr::hasNVOffsetField(/*IsMemberFunction=*/true, IM))
OpenPOWER on IntegriCloud