diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-02-06 12:46:52 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-02-06 12:46:52 +0000 |
commit | 1e378e428b9763db461d95c75e671eb851e4961c (patch) | |
tree | 30f4a94aec17f92cf05989fc2d51c9550daac479 /clang/lib/AST/MicrosoftMangle.cpp | |
parent | 763584dc645151f2c9810f6d0fbd29118a44a659 (diff) | |
download | bcm5719-llvm-1e378e428b9763db461d95c75e671eb851e4961c.tar.gz bcm5719-llvm-1e378e428b9763db461d95c75e671eb851e4961c.zip |
MS ABI: Handle indirect field decls in template args
Properly support fields that come from anonymous unions and structs
when used as template arguments for pointer to data member params.
llvm-svn: 200921
Diffstat (limited to 'clang/lib/AST/MicrosoftMangle.cpp')
-rw-r--r-- | clang/lib/AST/MicrosoftMangle.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index f02dfc72ee9..4ecbab437bc 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -122,7 +122,7 @@ public: void mangleDeclaration(const NamedDecl *ND); void mangleFunctionEncoding(const FunctionDecl *FD); void mangleVariableEncoding(const VarDecl *VD); - void mangleMemberDataPointer(const CXXRecordDecl *RD, const FieldDecl *FD); + void mangleMemberDataPointer(const CXXRecordDecl *RD, const ValueDecl *VD); void mangleMemberFunctionPointer(const CXXRecordDecl *RD, const CXXMethodDecl *MD); void mangleVirtualMemPtrThunk( @@ -378,7 +378,7 @@ void MicrosoftCXXNameMangler::mangleVariableEncoding(const VarDecl *VD) { } void MicrosoftCXXNameMangler::mangleMemberDataPointer(const CXXRecordDecl *RD, - const FieldDecl *FD) { + const ValueDecl *VD) { // <member-data-pointer> ::= <integer-literal> // ::= $F <number> <number> // ::= $G <number> <number> <number> @@ -386,8 +386,8 @@ void MicrosoftCXXNameMangler::mangleMemberDataPointer(const CXXRecordDecl *RD, int64_t FieldOffset; int64_t VBTableOffset; MSInheritanceAttr::Spelling IM = RD->getMSInheritanceModel(); - if (FD) { - FieldOffset = getASTContext().getFieldOffset(FD); + if (VD) { + FieldOffset = getASTContext().getFieldOffset(VD); assert(FieldOffset % getASTContext().getCharWidth() == 0 && "cannot take address of bitfield"); FieldOffset /= getASTContext().getCharWidth(); @@ -1083,8 +1083,9 @@ void MicrosoftCXXNameMangler::mangleTemplateArg(const TemplateDecl *TD, } case TemplateArgument::Declaration: { const NamedDecl *ND = cast<NamedDecl>(TA.getAsDecl()); - if (const FieldDecl *FD = dyn_cast<FieldDecl>(ND)) { - mangleMemberDataPointer(cast<CXXRecordDecl>(FD->getParent()), FD); + if (isa<FieldDecl>(ND) || isa<IndirectFieldDecl>(ND)) { + mangleMemberDataPointer(cast<CXXRecordDecl>(ND->getDeclContext()), + cast<ValueDecl>(ND)); } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) { const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD); if (MD && MD->isInstance()) |