forked from OSchip/llvm-project
PR13047: Fix various abuses of clang::Type in the MS mangler, to make it work
in the presence of type sugar. llvm-svn: 158184
This commit is contained in:
parent
da6bd3e603
commit
f76568591c
|
@ -246,9 +246,9 @@ void MicrosoftCXXNameMangler::mangleVariableEncoding(const VarDecl *VD) {
|
|||
if (Ty->isPointerType() || Ty->isReferenceType()) {
|
||||
mangleType(Ty);
|
||||
Out << 'A';
|
||||
} else if (Ty->isArrayType()) {
|
||||
} else if (const ArrayType *AT = getASTContext().getAsArrayType(Ty)) {
|
||||
// Global arrays are funny, too.
|
||||
mangleType(cast<ArrayType>(Ty.getTypePtr()), true);
|
||||
mangleType(AT, true);
|
||||
Out << 'A';
|
||||
} else {
|
||||
mangleType(Ty.getLocalUnqualifiedType());
|
||||
|
@ -1082,9 +1082,8 @@ void MicrosoftCXXNameMangler::mangleType(const IncompleteArrayType *T) {
|
|||
void MicrosoftCXXNameMangler::mangleExtraDimensions(QualType ElementTy) {
|
||||
SmallVector<llvm::APInt, 3> Dimensions;
|
||||
for (;;) {
|
||||
if (ElementTy->isConstantArrayType()) {
|
||||
const ConstantArrayType *CAT =
|
||||
static_cast<const ConstantArrayType *>(ElementTy.getTypePtr());
|
||||
if (const ConstantArrayType *CAT =
|
||||
getASTContext().getAsConstantArrayType(ElementTy)) {
|
||||
Dimensions.push_back(CAT->getSize());
|
||||
ElementTy = CAT->getElementType();
|
||||
} else if (ElementTy->isVariableArrayType()) {
|
||||
|
@ -1113,13 +1112,13 @@ void MicrosoftCXXNameMangler::mangleExtraDimensions(QualType ElementTy) {
|
|||
// <class name> <type>
|
||||
void MicrosoftCXXNameMangler::mangleType(const MemberPointerType *T) {
|
||||
QualType PointeeType = T->getPointeeType();
|
||||
if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(PointeeType)) {
|
||||
if (const FunctionProtoType *FPT = PointeeType->getAs<FunctionProtoType>()) {
|
||||
Out << '8';
|
||||
mangleName(cast<RecordType>(T->getClass())->getDecl());
|
||||
mangleName(T->getClass()->castAs<RecordType>()->getDecl());
|
||||
mangleType(FPT, NULL, false, true);
|
||||
} else {
|
||||
mangleQualifiers(PointeeType.getQualifiers(), true);
|
||||
mangleName(cast<RecordType>(T->getClass())->getDecl());
|
||||
mangleName(T->getClass()->castAs<RecordType>()->getDecl());
|
||||
mangleType(PointeeType.getLocalUnqualifiedType());
|
||||
}
|
||||
}
|
||||
|
@ -1140,12 +1139,11 @@ void MicrosoftCXXNameMangler::mangleType(const PointerType *T) {
|
|||
QualType PointeeTy = T->getPointeeType();
|
||||
if (PointeeTy->isArrayType()) {
|
||||
// Pointers to arrays are mangled like arrays.
|
||||
mangleExtraDimensions(T->getPointeeType());
|
||||
} else if (PointeeTy->isFunctionType()) {
|
||||
mangleExtraDimensions(PointeeTy);
|
||||
} else if (const FunctionType *FT = PointeeTy->getAs<FunctionType>()) {
|
||||
// Function pointers are special.
|
||||
Out << '6';
|
||||
mangleType(static_cast<const FunctionType *>(PointeeTy.getTypePtr()),
|
||||
NULL, false, false);
|
||||
mangleType(FT, NULL, false, false);
|
||||
} else {
|
||||
if (!PointeeTy.hasQualifiers())
|
||||
// Lack of qualifiers is mangled as 'A'.
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
// CHECK: @"\01?j@@3P6GHCE@ZA"
|
||||
// CHECK: @"\01?k@@3PTfoo@@DA"
|
||||
// CHECK: @"\01?l@@3P8foo@@AEHH@ZA"
|
||||
// CHECK: @"\01?color1@@3PANA"
|
||||
// CHECK: @"\01?color2@@3PBNA"
|
||||
// CHECK: @"\01?color3@@3PBY02NA"
|
||||
|
||||
int a;
|
||||
|
||||
|
@ -41,6 +44,8 @@ public:
|
|||
//CHECK: @"\01??0foo@@QAE@PAD@Z"
|
||||
}f,s1(1),s2((char*)0);
|
||||
|
||||
typedef foo (foo2);
|
||||
|
||||
struct bar {
|
||||
static int g;
|
||||
};
|
||||
|
@ -72,9 +77,9 @@ int i[10][20];
|
|||
|
||||
int (__stdcall *j)(signed char, unsigned char);
|
||||
|
||||
const volatile char foo::*k;
|
||||
const volatile char foo2::*k;
|
||||
|
||||
int (foo::*l)(int);
|
||||
int (foo2::*l)(int);
|
||||
|
||||
// Static functions are mangled, too.
|
||||
// Also make sure calling conventions, arglists, and throw specs work.
|
||||
|
@ -121,3 +126,9 @@ void operator_new_delete() {
|
|||
void (redundant_parens)();
|
||||
void redundant_parens_use() { redundant_parens(); }
|
||||
// CHECK: @"\01?redundant_parens@@YAXXZ"
|
||||
|
||||
// PR13047
|
||||
typedef double RGB[3];
|
||||
RGB color1;
|
||||
extern const RGB color2 = {};
|
||||
extern RGB const ((color3)[5]) = {};
|
||||
|
|
Loading…
Reference in New Issue