[cfe-commits] r97422 - in /cfe/trunk: lib/CodeGen/Mangle.cpp test/CodeGenCXX/mangle-template.cpp
Douglas Gregor
dgregor at apple.com
Sun Feb 28 14:05:49 PST 2010
Author: dgregor
Date: Sun Feb 28 16:05:49 2010
New Revision: 97422
URL: http://llvm.org/viewvc/llvm-project?rev=97422&view=rev
Log:
Improve name mangling for dependently-scoped declaration references.
Modified:
cfe/trunk/lib/CodeGen/Mangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-template.cpp
Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=97422&r1=97421&r2=97422&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Sun Feb 28 16:05:49 2010
@@ -1369,7 +1369,18 @@
case Expr::DependentScopeDeclRefExprClass: {
const DependentScopeDeclRefExpr *DRE = cast<DependentScopeDeclRefExpr>(E);
- const Type *QTy = DRE->getQualifier()->getAsType();
+ NestedNameSpecifier *NNS = DRE->getQualifier();
+ const Type *QTy = NNS->getAsType();
+
+ // When we're dealing with a nested-name-specifier that has just a
+ // dependent identifier in it, mangle that as a typename. FIXME:
+ // It isn't clear that we ever actually want to have such a
+ // nested-name-specifier; why not just represent it as a typename type?
+ if (!QTy && NNS->getAsIdentifier() && NNS->getPrefix()) {
+ QTy = getASTContext().getTypenameType(NNS->getPrefix(),
+ NNS->getAsIdentifier())
+ .getTypePtr();
+ }
assert(QTy && "Qualifier was not type!");
// ::= sr <type> <unqualified-name> # dependent name
Modified: cfe/trunk/test/CodeGenCXX/mangle-template.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-template.cpp?rev=97422&r1=97421&r2=97422&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-template.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-template.cpp Sun Feb 28 16:05:49 2010
@@ -85,3 +85,22 @@
// CHECK: define void @_ZN5test71XIiEC1IdEEPT_PNS_5int_cIXplL_ZNS_4metaIiE5valueEEsrNS6_IS3_EE5valueEE4typeE
template X<int>::X(double*, float*);
}
+
+namespace test8 {
+ template<typename T>
+ struct meta {
+ struct type {
+ static const unsigned value = sizeof(T);
+ };
+ };
+
+ template<unsigned> struct int_c {
+ typedef float type;
+ };
+
+ template<typename T>
+ void f(int_c<meta<T>::type::value>) { }
+
+ // CHECK: define void @_ZN5test81fIiEEvNS_5int_cIXsrNS_4metaIT_E4typeE5valueEEE
+ template void f<int>(int_c<sizeof(int)>);
+}
More information about the cfe-commits
mailing list