[cfe-commits] r107561 - in /cfe/trunk: lib/CodeGen/MicrosoftCXXABI.cpp test/CodeGenCXX/mangle-ms.cpp
Charles Davis
cdavis at mines.edu
Fri Jul 2 19:41:45 PDT 2010
Author: cdavis
Date: Fri Jul 2 21:41:45 2010
New Revision: 107561
URL: http://llvm.org/viewvc/llvm-project?rev=107561&view=rev
Log:
Fix mangling of array parameters for functions in the Microsoft C++ Mangler.
Only actual functions get mangled correctly; I don't know how to fix it for
function pointers yet. Thanks to John McCall for the hint.
Also, mangle anonymous tag types. I don't have a suitable testcase yet; I have
a feeling that that's going to need support for static locals, and I haven't
figured out exactly how MSVC's scheme for mangling those works.
Modified:
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=107561&r1=107560&r2=107561&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Fri Jul 2 21:41:45 2010
@@ -69,7 +69,8 @@
#include "clang/AST/TypeNodes.def"
void mangleType(const TagType*);
- void mangleType(const FunctionType *T, bool IsStructor, bool IsInstMethod);
+ void mangleType(const FunctionType *T, const FunctionDecl *D,
+ bool IsStructor, bool IsInstMethod);
void mangleType(const ArrayType *T, bool IsGlobal);
void mangleExtraDimensions(QualType T);
void mangleFunctionClass(const FunctionDecl *FD);
@@ -218,7 +219,7 @@
// First, the function class.
mangleFunctionClass(FD);
- mangleType(FT, InStructor, InInstMethod);
+ mangleType(FT, FD, InStructor, InInstMethod);
}
void MicrosoftCXXNameMangler::mangleVariableEncoding(const VarDecl *VD) {
@@ -339,8 +340,9 @@
break;
}
- // TODO: How does VC mangle anonymous structs?
- assert(false && "Don't know how to mangle anonymous types yet!");
+ // When VC encounters an anonymous type with no tag and no typedef,
+ // it literally emits '<unnamed-tag>'.
+ Out << "<unnamed-tag>";
break;
}
@@ -756,13 +758,14 @@
// structor type.
// I'll probably have mangleType(MemberPointerType) call the mangleType()
// method directly.
- mangleType(T, false, false);
+ mangleType(T, NULL, false, false);
}
void MicrosoftCXXNameMangler::mangleType(const FunctionNoProtoType *T) {
llvm_unreachable("Can't mangle K&R function prototypes");
}
void MicrosoftCXXNameMangler::mangleType(const FunctionType *T,
+ const FunctionDecl *D,
bool IsStructor,
bool IsInstMethod) {
// <function-type> ::= <this-cvr-qualifiers> <calling-convention>
@@ -789,11 +792,19 @@
if (Proto->getNumArgs() == 0 && !Proto->isVariadic()) {
Out << 'X';
} else {
- for (FunctionProtoType::arg_type_iterator Arg = Proto->arg_type_begin(),
- ArgEnd = Proto->arg_type_end();
- Arg != ArgEnd; ++Arg)
- mangleType(*Arg);
-
+ if (D) {
+ // If we got a decl, use the "types-as-written" to make sure arrays
+ // get mangled right.
+ for (FunctionDecl::param_const_iterator Parm = D->param_begin(),
+ ParmEnd = D->param_end();
+ Parm != ParmEnd; ++Parm)
+ mangleType((*Parm)->getTypeSourceInfo()->getType());
+ } else {
+ for (FunctionProtoType::arg_type_iterator Arg = Proto->arg_type_begin(),
+ ArgEnd = Proto->arg_type_end();
+ Arg != ArgEnd; ++Arg)
+ mangleType(*Arg);
+ }
// <builtin-type> ::= Z # ellipsis
if (Proto->isVariadic())
Out << 'Z';
Modified: cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms.cpp?rev=107561&r1=107560&r2=107561&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-ms.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms.cpp Fri Jul 2 21:41:45 2010
@@ -80,4 +80,4 @@
// Array mangling. (It should be mangled as a const pointer, but that needs
// to be fixed in Sema.)
void epsilon(int a[][10][20]) {}
-// CHECK: @"\01?epsilon@@YAXPAY19BD at H@Z"
+// CHECK: @"\01?epsilon@@YAXQAY19BD at H@Z"
More information about the cfe-commits
mailing list