Address Doug's comments wrt the mangler and fix Eli's test case
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66549 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp
index 34c88fb..92eeb5d 100644
--- a/lib/CodeGen/Mangle.cpp
+++ b/lib/CodeGen/Mangle.cpp
@@ -43,7 +43,6 @@
void mangleOperatorName(OverloadedOperatorKind OO, unsigned Arity);
void mangleCVQualifiers(unsigned Quals);
void mangleType(QualType T);
- void mangleType(const TypedefType *T);
void mangleType(const BuiltinType *T);
void mangleType(const FunctionType *T);
void mangleBareFunctionType(const FunctionType *T, bool MangleReturnType);
@@ -330,15 +329,16 @@
}
void CXXNameMangler::mangleType(QualType T) {
+ // Only operate on the canonical type!
+ T = Context.getCanonicalType(T);
+
// FIXME: Should we have a TypeNodes.def to make this easier? (YES!)
// <type> ::= <CV-qualifiers> <type>
mangleCVQualifiers(T.getCVRQualifiers());
- if (const TypedefType *TT = dyn_cast<TypedefType>(T.getTypePtr()))
- mangleType(TT);
// ::= <builtin-type>
- else if (const BuiltinType *BT = dyn_cast<BuiltinType>(T.getTypePtr()))
+ if (const BuiltinType *BT = dyn_cast<BuiltinType>(T.getTypePtr()))
mangleType(BT);
// ::= <function-type>
else if (const FunctionType *FT = dyn_cast<FunctionType>(T.getTypePtr()))
@@ -382,27 +382,13 @@
} else if (const ObjCInterfaceType *IT =
dyn_cast<ObjCInterfaceType>(T.getTypePtr())) {
mangleType(IT);
- }
+ }
// FIXME: ::= G <type> # imaginary (C 2000)
// FIXME: ::= U <source-name> <type> # vendor extended type qualifier
else
assert(false && "Cannot mangle unknown type");
}
-void CXXNameMangler::mangleType(const TypedefType *T) {
- QualType DeclTy = T->getDecl()->getUnderlyingType();
-
- if (const TagType *TT = dyn_cast<TagType>(DeclTy)) {
- // If the tag type is anonymous, use the name of the typedef.
- if (!TT->getDecl()->getIdentifier()) {
- mangleName(T->getDecl());
- return;
- }
- }
-
- mangleType(DeclTy);
-}
-
void CXXNameMangler::mangleType(const BuiltinType *T) {
// <builtin-type> ::= v # void
// ::= w # wchar_t
@@ -488,7 +474,11 @@
void CXXNameMangler::mangleType(const TagType *T) {
// <class-enum-type> ::= <name>
- mangleName(T->getDecl());
+
+ if (!T->getDecl()->getIdentifier())
+ mangleName(T->getDecl()->getTypedefForAnonDecl());
+ else
+ mangleName(T->getDecl());
}
void CXXNameMangler::mangleType(const ArrayType *T) {