<div dir="ltr">Hi,<div class="gmail_extra"><br><div class="gmail_quote">On 21 April 2017 at 12:55, Emilio Cobos Álvarez via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This allows us to get the default template parameters too.<br>
<br>
This patch was submitted also as <a href="https://reviews.llvm.org/D31732" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D31732</a>, but I see no<br>
reference to it in cfe-commits or llvm-commits, so I guess it got lost?<br></blockquote><div><br></div><div>You have to add cfe-commits as subscribers to the Phabricator patch, otherwise it won't show up in the mailing list. I would recommend you to close the old one revision and create a new one on Phabricator, this way we'll get the entire patch history on cfe-commits.</div><div><br></div><div>Alex</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
This fixes bug 32539.<br>
<br>
Signed-off-by: Emilio Cobos Álvarez <<a href="mailto:emilio@crisal.io">emilio@crisal.io</a>><br>
---<br>
clang/test/Index/print-type.<wbr>cpp | 8 +++++++-<br>
clang/tools/libclang/CXType.<wbr>cpp | 6 +++---<br>
2 files changed, 10 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/clang/test/Index/print-type.<wbr>cpp b/clang/test/Index/print-type.<wbr>cpp<br>
index 108ba53c80b..ff150f7dd61 100644<br>
--- a/clang/test/Index/print-type.<wbr>cpp<br>
+++ b/clang/test/Index/print-type.<wbr>cpp<br>
@@ -71,6 +71,11 @@ struct Specialization<int>;<br>
Specialization<Specialization<<wbr>bool>& > templRefParam;<br>
auto autoTemplRefParam = templRefParam;<br>
<br>
+template<typename T, typename U = int><br>
+struct DefaultedTypeExample {};<br>
+<br>
+typedef DefaultedTypeExample<int> DefaultedTypeAlias;<br>
+<br>
// RUN: c-index-test -test-print-type %s -std=c++14 | FileCheck %s<br>
// CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] [isPOD=0]<br>
// CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid] [isPOD=0]<br>
@@ -115,7 +120,7 @@ auto autoTemplRefParam = templRefParam;<br>
// CHECK: TemplateRef=Baz:9:8 [type=] [typekind=Invalid] [isPOD=0]<br>
// CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]<br>
// CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]<br>
-// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux<int, char *, Foo<int>, outer::inner::Bar::FooType>] [typekind=Unexposed] [templateargs/4= [type=int] [typekind=Int] [type=char *] [typekind=Pointer] [type=Foo<int>] [typekind=Unexposed] [type=outer::inner::Bar::<wbr>FooType] [typekind=Typedef]] [canonicaltype=outer::Qux<int, char *, outer::Foo<int>, int>] [canonicaltypekind=Record] [canonicaltemplateargs/4= [type=int] [typekind=Int] [type=char *] [typekind=Pointer] [type=outer::Foo<int>] [typekind=Record] [type=int] [typekind=Int]] [isPOD=1]<br>
+// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux<int, char *, Foo<int>, outer::inner::Bar::FooType>] [typekind=Unexposed] [templateargs/4= [type=int] [typekind=Int] [type=char *] [typekind=Pointer] [type=outer::Foo<int>] [typekind=Record] [type=int] [typekind=Int]] [canonicaltype=outer::Qux<int, char *, outer::Foo<int>, int>] [canonicaltypekind=Record] [canonicaltemplateargs/4= [type=int] [typekind=Int] [type=char *] [typekind=Pointer] [type=outer::Foo<int>] [typekind=Record] [type=int] [typekind=Int]] [isPOD=1]<br>
// CHECK: TemplateRef=Qux:12:8 [type=] [typekind=Invalid] [isPOD=0]<br>
// CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]<br>
// CHECK: FunctionTemplate=tbar:36:3 [type=T (int)] [typekind=FunctionProto] [canonicaltype=type-parameter-<wbr>0-0 (int)] [canonicaltypekind=<wbr>FunctionProto] [resulttype=T] [resulttypekind=Unexposed] [isPOD=0]<br>
@@ -177,3 +182,4 @@ auto autoTemplRefParam = templRefParam;<br>
// CHECK: VarDecl=autoTemplRefParam:72:6 (Definition) [type=Specialization<<wbr>Specialization<bool> &>] [typekind=Auto] [templateargs/1= [type=Specialization<bool> &] [typekind=LValueReference]] [canonicaltype=Specialization<<wbr>Specialization<bool> &>] [canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization<bool> &] [typekind=LValueReference]] [isPOD=1]<br>
// CHECK: UnexposedExpr=templRefParam:<wbr>71:40 [type=const Specialization<Specialization<<wbr>bool> &>] [typekind=Unexposed] const [templateargs/1= [type=Specialization<bool> &] [typekind=LValueReference]] [canonicaltype=const Specialization<Specialization<<wbr>bool> &>] [canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization<bool> &] [typekind=LValueReference]] [isPOD=1]<br>
// CHECK: DeclRefExpr=templRefParam:71:<wbr>40 [type=Specialization<<wbr>Specialization<bool> &>] [typekind=Unexposed] [templateargs/1= [type=Specialization<bool> &] [typekind=LValueReference]] [canonicaltype=Specialization<<wbr>Specialization<bool> &>] [canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization<bool> &] [typekind=LValueReference]] [isPOD=1]<br>
+// CHECK: TypedefDecl=<wbr>DefaultedTypeAlias:77:35 (Definition) [type=DefaultedTypeAlias] [typekind=Typedef] [templateargs/2= [type=int] [typekind=Int] [type=int] [typekind=Int]] [canonicaltype=<wbr>DefaultedTypeExample<int, int>] [canonicaltypekind=Record] [canonicaltemplateargs/2= [type=int] [typekind=Int] [type=int] [typekind=Int]] [isPOD=0]<br>
diff --git a/clang/tools/libclang/CXType.<wbr>cpp b/clang/tools/libclang/CXType.<wbr>cpp<br>
index 16e993e2ac0..fce7ef2c0d8 100644<br>
--- a/clang/tools/libclang/CXType.<wbr>cpp<br>
+++ b/clang/tools/libclang/CXType.<wbr>cpp<br>
@@ -147,9 +147,6 @@ static inline CXTranslationUnit GetTU(CXType CT) {<br>
static Optional<ArrayRef<<wbr>TemplateArgument>><br>
GetTemplateArguments(QualType Type) {<br>
assert(!Type.isNull());<br>
- if (const auto *Specialization = Type->getAs<<wbr>TemplateSpecializationType>())<br>
- return Specialization->template_<wbr>arguments();<br>
-<br>
if (const auto *RecordDecl = Type->getAsCXXRecordDecl()) {<br>
const auto *TemplateDecl =<br>
dyn_cast<<wbr>ClassTemplateSpecializationDec<wbr>l>(RecordDecl);<br>
@@ -157,6 +154,9 @@ GetTemplateArguments(QualType Type) {<br>
return TemplateDecl->getTemplateArgs(<wbr>).asArray();<br>
}<br>
<br>
+ if (const auto *Specialization = Type->getAs<<wbr>TemplateSpecializationType>())<br>
+ return Specialization->template_<wbr>arguments();<br>
+<br>
return None;<br>
}<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.12.2<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</font></span></blockquote></div><br></div></div>