diff options
author | John McCall <rjmccall@apple.com> | 2011-07-01 02:19:08 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-07-01 02:19:08 +0000 |
commit | 2de1c33f77d7fe8ac9d5476dd77efd65f5c9e90f (patch) | |
tree | 7beceae72608d92d6ed29479e1f8ec93a984a6dd /clang | |
parent | 39af582c570c38eca888738378372b1fbeb2eef8 (diff) | |
download | bcm5719-llvm-2de1c33f77d7fe8ac9d5476dd77efd65f5c9e90f.tar.gz bcm5719-llvm-2de1c33f77d7fe8ac9d5476dd77efd65f5c9e90f.zip |
Just mangle substituted template parameter types as unresolved types.
This is kindof questionable but seems to do more-or-less the right thing.
This is not a particularly friendly part of the ABI.
llvm-svn: 134227
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/AST/ItaniumMangle.cpp | 13 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/mangle.cpp | 32 |
2 files changed, 35 insertions, 10 deletions
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp index 205e887fea4..9d9cc3ed4f9 100644 --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -818,28 +818,21 @@ void CXXNameMangler::mangleUnresolvedPrefix(NestedNameSpecifier *qualifier, case Type::Decltype: case Type::TemplateTypeParm: case Type::UnaryTransform: + case Type::SubstTemplateTypeParm: unresolvedType: assert(!qualifier->getPrefix()); // We only get here recursively if we're followed by identifiers. if (recursive) Out << 'N'; - // This seems to do everything we want. + // This seems to do everything we want. It's not really + // sanctioned for a substituted template parameter, though. mangleType(QualType(type, 0)); // We never want to print 'E' directly after an unresolved-type, // so we return directly. return; - // Substituted template type parameters should only come up with - // enclosing templates. - // <unresolved-type> ::= <existing-substitution> [ <template-args> ] - case Type::SubstTemplateTypeParm: { - if (recursive) Out << 'N'; - mangleExistingSubstitution(QualType(type, 0)); - return; - } - case Type::Typedef: mangleSourceName(cast<TypedefType>(type)->getDecl()->getIdentifier()); break; diff --git a/clang/test/CodeGenCXX/mangle.cpp b/clang/test/CodeGenCXX/mangle.cpp index 83635285707..dd10ca4a211 100644 --- a/clang/test/CodeGenCXX/mangle.cpp +++ b/clang/test/CodeGenCXX/mangle.cpp @@ -770,3 +770,35 @@ namespace test31 { // instantiation-dependent mangling of decltype // CHECK: define weak_odr void @_ZN6test312f3IiEEDTcl1gfp_EET_ template void f3(int); } + +// PR10205 +namespace test32 { + template<typename T, int=T::value> struct A { + typedef int type; + }; + struct B { enum { value = 4 }; }; + + template <class T> typename A<T>::type foo() { return 0; } + void test() { + foo<B>(); + // CHECK: call i32 @_ZN6test323fooINS_1BEEENS_1AIT_XsrS3_5valueEE4typeEv() + } +} + +namespace test33 { + template <class T> struct X { + enum { value = T::value }; + }; + + template<typename T, int=X<T>::value> struct A { + typedef int type; + }; + struct B { enum { value = 4 }; }; + + template <class T> typename A<T>::type foo() { return 0; } + + void test() { + foo<B>(); + // CHECK: call i32 @_ZN6test333fooINS_1BEEENS_1AIT_Xsr1XIS3_EE5valueEE4typeEv() + } +} |