Improve name mangling for dependently-scoped declaration references.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97422 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Douglas Gregor 2010-02-28 22:05:49 +00:00
Родитель 5ed1bc351f
Коммит 4b2ccfc302
2 изменённых файлов: 31 добавлений и 1 удалений

Просмотреть файл

@ -1369,7 +1369,18 @@ void CXXNameMangler::mangleExpression(const Expr *E) {
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

Просмотреть файл

@ -85,3 +85,22 @@ namespace test7 {
// 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)>);
}