diff options
author | Anders Carlsson <andersca@mac.com> | 2009-03-07 23:57:03 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-03-07 23:57:03 +0000 |
commit | 4ed74dd6b72ed29bc8f37ce23f8bdc852b1abe3f (patch) | |
tree | 35f103a9980ef98b80c60e623847140531e3b817 /clang/lib/CodeGen/Mangle.cpp | |
parent | c808fc34b3b9a39df77dd7cb431cd9301c3bf536 (diff) | |
download | bcm5719-llvm-4ed74dd6b72ed29bc8f37ce23f8bdc852b1abe3f.tar.gz bcm5719-llvm-4ed74dd6b72ed29bc8f37ce23f8bdc852b1abe3f.zip |
Make mangling work with anonymous tag types. Doug, please review
llvm-svn: 66353
Diffstat (limited to 'clang/lib/CodeGen/Mangle.cpp')
-rw-r--r-- | clang/lib/CodeGen/Mangle.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/Mangle.cpp b/clang/lib/CodeGen/Mangle.cpp index 490936f625d..34c88fbba5a 100644 --- a/clang/lib/CodeGen/Mangle.cpp +++ b/clang/lib/CodeGen/Mangle.cpp @@ -43,6 +43,7 @@ namespace { 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); @@ -329,16 +330,15 @@ void CXXNameMangler::mangleCVQualifiers(unsigned Quals) { } 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> - if (const BuiltinType *BT = dyn_cast<BuiltinType>(T.getTypePtr())) + else if (const BuiltinType *BT = dyn_cast<BuiltinType>(T.getTypePtr())) mangleType(BT); // ::= <function-type> else if (const FunctionType *FT = dyn_cast<FunctionType>(T.getTypePtr())) @@ -382,13 +382,27 @@ void CXXNameMangler::mangleType(QualType T) { } 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 |