[cfe-commits] r98707 - in /cfe/trunk: lib/CodeGen/Mangle.cpp test/CodeGenCXX/mangle.cpp
Rafael Espindola
rafael.espindola at gmail.com
Tue Mar 16 21:28:12 PDT 2010
Author: rafael
Date: Tue Mar 16 23:28:11 2010
New Revision: 98707
URL: http://llvm.org/viewvc/llvm-project?rev=98707&view=rev
Log:
Correctly mangle dependent TypenameType.
Fixes PR6625.
Modified:
cfe/trunk/lib/CodeGen/Mangle.cpp
cfe/trunk/test/CodeGenCXX/mangle.cpp
Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=98707&r1=98706&r2=98707&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Tue Mar 16 23:28:11 2010
@@ -469,8 +469,26 @@
mangleName(Qualifier->getAsNamespace());
break;
case NestedNameSpecifier::TypeSpec:
- case NestedNameSpecifier::TypeSpecWithTemplate:
- mangleType(QualType(Qualifier->getAsType(), 0));
+ case NestedNameSpecifier::TypeSpecWithTemplate: {
+ const Type *QTy = Qualifier->getAsType();
+
+ if (const TemplateSpecializationType *TST =
+ dyn_cast<TemplateSpecializationType>(QTy)) {
+ if (!mangleSubstitution(QualType(TST, 0))) {
+ TemplateDecl *TD = TST->getTemplateName().getAsTemplateDecl();
+ assert(TD && "FIXME: Support dependent template names");
+ mangleTemplatePrefix(TD);
+ TemplateParameterList *TemplateParameters = TD->getTemplateParameters();
+ mangleTemplateArgs(*TemplateParameters, TST->getArgs(),
+ TST->getNumArgs());
+ addSubstitution(QualType(TST, 0));
+ }
+ } else {
+ // We use the QualType mangle type variant here because it handles
+ // substitutions.
+ mangleType(QualType(QTy, 0));
+ }
+ }
break;
case NestedNameSpecifier::Identifier:
// Member expressions can have these without prefixes.
@@ -1144,29 +1162,8 @@
void CXXNameMangler::mangleType(const TypenameType *T) {
// Typename types are always nested
Out << 'N';
-
- const Type *QTy = T->getQualifier()->getAsType();
- if (const TemplateSpecializationType *TST =
- dyn_cast<TemplateSpecializationType>(QTy)) {
- if (!mangleSubstitution(QualType(TST, 0))) {
- TemplateDecl *TD = TST->getTemplateName().getAsTemplateDecl();
- assert(TD && "FIXME: Support dependent template names");
- mangleTemplatePrefix(TD);
- TemplateParameterList *TemplateParameters = TD->getTemplateParameters();
- mangleTemplateArgs(*TemplateParameters, TST->getArgs(),
- TST->getNumArgs());
- addSubstitution(QualType(TST, 0));
- }
- } else if (const TemplateTypeParmType *TTPT =
- dyn_cast<TemplateTypeParmType>(QTy)) {
- // We use the QualType mangle type variant here because it handles
- // substitutions.
- mangleType(QualType(TTPT, 0));
- } else
- assert(false && "Unhandled type!");
-
+ mangleUnresolvedScope(T->getQualifier());
mangleSourceName(T->getIdentifier());
-
Out << 'E';
}
Modified: cfe/trunk/test/CodeGenCXX/mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle.cpp?rev=98707&r1=98706&r2=98707&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle.cpp Tue Mar 16 23:28:11 2010
@@ -453,3 +453,18 @@
class B { static int value; };
template class A<B::value>;
}
+// CHECK: declare void @_ZN5test91fIiNS_3barEEEvRKNT0_3baz1XE
+namespace test9 {
+ template<class T>
+ struct foo {
+ typedef T X;
+ };
+ struct bar {
+ typedef foo<int> baz;
+ };
+ template <class zaz, class zed>
+ void f(const typename zed::baz::X&);
+ void g() {
+ f<int, bar>( 0);
+ }
+}
More information about the cfe-commits
mailing list