Teach libclang to generate USRs containing parameter packs and pack expansions.

llvm-svn: 123848
This commit is contained in:
Douglas Gregor 2011-01-19 20:50:07 +00:00
parent 557f05c2d2
commit 54bce44895
2 changed files with 26 additions and 3 deletions

View File

@ -0,0 +1,8 @@
template<typename ...Types>
struct tuple { };
void f(tuple<int, float, double>);
// RUN: c-index-test -test-load-source-usrs all -std=c++0x %s | FileCheck %s
// CHECK: usrs-cxx0x.cpp c:@ST>1#pT@tuple Extent=[1:1 - 2:17]
// CHECK: usrs-cxx0x.cpp c:@F@f#$@S@tuple>#p3Ifd# Extent=[4:6 - 4:34]

View File

@ -523,6 +523,11 @@ void USRGenerator::VisitType(QualType T) {
// Mangle in ObjC GC qualifiers?
if (const PackExpansionType *Expansion = T->getAs<PackExpansionType>()) {
Out << 'P';
T = Expansion->getPattern();
}
if (const BuiltinType *BT = T->getAs<BuiltinType>()) {
unsigned char c = '\0';
switch (BT->getKind()) {
@ -666,17 +671,23 @@ void USRGenerator::VisitTemplateParameterList(
P != PEnd; ++P) {
Out << '#';
if (isa<TemplateTypeParmDecl>(*P)) {
if (cast<TemplateTypeParmDecl>(*P)->isParameterPack())
Out<< 'p';
Out << 'T';
continue;
}
if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
if (NTTP->isParameterPack())
Out << 'p';
Out << 'N';
VisitType(NTTP->getType());
continue;
}
TemplateTemplateParmDecl *TTP = cast<TemplateTemplateParmDecl>(*P);
if (TTP->isParameterPack())
Out << 'p';
Out << 't';
VisitTemplateParameterList(TTP->getTemplateParameters());
}
@ -707,9 +718,10 @@ void USRGenerator::VisitTemplateArgument(const TemplateArgument &Arg) {
Visit(D);
break;
case TemplateArgument::Template:
case TemplateArgument::TemplateExpansion:
// FIXME: variadic templates
Out << 'P'; // pack expansion of...
// Fall through
case TemplateArgument::Template:
VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
break;
@ -718,7 +730,10 @@ void USRGenerator::VisitTemplateArgument(const TemplateArgument &Arg) {
break;
case TemplateArgument::Pack:
// FIXME: Variadic templates
Out << 'p' << Arg.pack_size();
for (TemplateArgument::pack_iterator P = Arg.pack_begin(), PEnd = Arg.pack_end();
P != PEnd; ++P)
VisitTemplateArgument(*P);
break;
case TemplateArgument::Type: