[cfe-commits] r158184 - in /cfe/trunk: lib/AST/MicrosoftMangle.cpp test/CodeGenCXX/mangle-ms.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Thu Jun 7 17:37:04 PDT 2012
Author: rsmith
Date: Thu Jun 7 19:37:04 2012
New Revision: 158184
URL: http://llvm.org/viewvc/llvm-project?rev=158184&view=rev
Log:
PR13047: Fix various abuses of clang::Type in the MS mangler, to make it work
in the presence of type sugar.
Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=158184&r1=158183&r2=158184&view=diff
==============================================================================
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Thu Jun 7 19:37:04 2012
@@ -246,9 +246,9 @@
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::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 @@
// <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 @@
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'.
Modified: cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms.cpp?rev=158184&r1=158183&r2=158184&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-ms.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms.cpp Thu Jun 7 19:37:04 2012
@@ -12,6 +12,9 @@
// CHECK: @"\01?j@@3P6GHCE at ZA"
// CHECK: @"\01?k@@3PTfoo@@DA"
// CHECK: @"\01?l@@3P8foo@@AEHH at ZA"
+// CHECK: @"\01?color1@@3PANA"
+// CHECK: @"\01?color2@@3PBNA"
+// CHECK: @"\01?color3@@3PBY02NA"
int a;
@@ -41,6 +44,8 @@
//CHECK: @"\01??0foo@@QAE at PAD@Z"
}f,s1(1),s2((char*)0);
+typedef foo (foo2);
+
struct bar {
static int g;
};
@@ -72,9 +77,9 @@
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 (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]) = {};
More information about the cfe-commits
mailing list