[cfe-commits] r123848 - in /cfe/trunk: test/Index/usrs-cxx0x.cpp tools/libclang/CIndexUSRs.cpp
Douglas Gregor
dgregor at apple.com
Wed Jan 19 12:50:07 PST 2011
Author: dgregor
Date: Wed Jan 19 14:50:07 2011
New Revision: 123848
URL: http://llvm.org/viewvc/llvm-project?rev=123848&view=rev
Log:
Teach libclang to generate USRs containing parameter packs and pack expansions.
Added:
cfe/trunk/test/Index/usrs-cxx0x.cpp (with props)
Modified:
cfe/trunk/tools/libclang/CIndexUSRs.cpp
Added: cfe/trunk/test/Index/usrs-cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/usrs-cxx0x.cpp?rev=123848&view=auto
==============================================================================
--- cfe/trunk/test/Index/usrs-cxx0x.cpp (added)
+++ cfe/trunk/test/Index/usrs-cxx0x.cpp Wed Jan 19 14:50:07 2011
@@ -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 at tuple Extent=[1:1 - 2:17]
+// CHECK: usrs-cxx0x.cpp c:@F at f#$@S at tuple>#p3Ifd# Extent=[4:6 - 4:34]
Propchange: cfe/trunk/test/Index/usrs-cxx0x.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/test/Index/usrs-cxx0x.cpp
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cfe/trunk/test/Index/usrs-cxx0x.cpp
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: cfe/trunk/tools/libclang/CIndexUSRs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexUSRs.cpp?rev=123848&r1=123847&r2=123848&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexUSRs.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexUSRs.cpp Wed Jan 19 14:50:07 2011
@@ -523,6 +523,11 @@
// 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 @@
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 @@
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 @@
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:
More information about the cfe-commits
mailing list