[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-26 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio added a comment.

> FWIW when I wrote https://reviews.llvm.org/D26663, I did it because arguments 
> weren't inspectionable at all for `using` declarations. Actually both of them 
> would've worked for me.

Also, this bit was not completely accurate, and you could inspect ones, but not 
others (you could inspect the ones that desugared into a RecordDecl that 
happened to be a template specialization, as shown by the bug you pointed out).


Repository:
  rL LLVM

https://reviews.llvm.org/D32348



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-26 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio added a comment.

Revert + tests @ https://reviews.llvm.org/D32566


Repository:
  rL LLVM

https://reviews.llvm.org/D32348



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-26 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio added a comment.

In https://reviews.llvm.org/D32348#738704, @rsmith wrote:

> This change looks like it introduces a regression itself: given
>
>   template struct A {};
>   template using B = A;
>   B bi;
>
>
> ... requesting the template arguments for the type `B` changes from 
> producing  `int` to producing `int*` with this patch, which seems to directly 
> oppose the intentions of https://reviews.llvm.org/D26663.


FWIW when I wrote https://reviews.llvm.org/D26663, I did it because arguments 
weren't inspectionable at all for `using` declarations. Actually both of them 
would've worked for me.

>   template using C = T;
> 
> 
> With this patch, requesting the template arguments for `C` gives `int` 
> but requesting the template arguments of `C>` gives `void` rather 
> than `A`.

That being said, that is _specially_ annoying (good catch btw). Annoying enough 
to justify reverting this change I'd say...

I'll submit something with the test-cases. I guess people that depended on the 
old translation will just need to live with it... shrug.

I guess I could do something clever like: If it's both a 
`ClassTemplateSpecializationDecl`, and a `TemplateSpecializationType`, and the 
template arguments of the second happen to not be a template specialization, 
then use the `ClassTemplateSpecializationDecl`, otherwise the other, but that 
seems fairly tricky to maintain, so I'd rather just do the former.

Thanks for looking through it, btw.


Repository:
  rL LLVM

https://reviews.llvm.org/D32348



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-26 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

This change looks like it introduces a regression itself: given

  template struct A {};
  template using B = A;
  B bi;

... requesting the template arguments for the type `B` changes from 
producing  `int` to producing `int*` with this patch, which seems to directly 
oppose the intentions of https://reviews.llvm.org/D26663.

If the intent of this libclang function is to request the template arguments of 
the type as written, this change is wrong. If the intent is to request the 
template arguments of the desugared type, then https://reviews.llvm.org/D26663 
is wrong. But either way, it seems that reversing the order of these checks 
causes us to produce inconsistent results. Another example of the inconsistency:

  template using C = T;

With this patch, requesting the template arguments for `C` gives `int` but 
requesting the template arguments of `C>` gives `void` rather than 
`A`.


Repository:
  rL LLVM

https://reviews.llvm.org/D32348



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-25 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

@emilio, you can request to merge this into 4.0.1 by using a script called 
merge-request.sh 
(http://lists.llvm.org/pipermail/llvm-dev/2017-March/111530.html).


Repository:
  rL LLVM

https://reviews.llvm.org/D32348



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-25 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL301328: [libclang] Check for a record declaration before a 
template specialization (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D32348?vs=96130&id=96590#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32348

Files:
  cfe/trunk/test/Index/print-type.cpp
  cfe/trunk/tools/libclang/CXType.cpp


Index: cfe/trunk/tools/libclang/CXType.cpp
===
--- cfe/trunk/tools/libclang/CXType.cpp
+++ cfe/trunk/tools/libclang/CXType.cpp
@@ -147,16 +147,16 @@
 static Optional>
 GetTemplateArguments(QualType Type) {
   assert(!Type.isNull());
-  if (const auto *Specialization = Type->getAs())
-return Specialization->template_arguments();
-
   if (const auto *RecordDecl = Type->getAsCXXRecordDecl()) {
 const auto *TemplateDecl =
   dyn_cast(RecordDecl);
 if (TemplateDecl)
   return TemplateDecl->getTemplateArgs().asArray();
   }
 
+  if (const auto *Specialization = Type->getAs())
+return Specialization->template_arguments();
+
   return None;
 }
 
Index: cfe/trunk/test/Index/print-type.cpp
===
--- cfe/trunk/test/Index/print-type.cpp
+++ cfe/trunk/test/Index/print-type.cpp
@@ -71,6 +71,11 @@
 Specialization& > templRefParam;
 auto autoTemplRefParam = templRefParam;
 
+template
+struct DefaultedTypeExample {};
+
+typedef DefaultedTypeExample DefaultedTypeAlias;
+
 // RUN: c-index-test -test-print-type %s -std=c++14 | FileCheck %s
 // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
 // CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
@@ -115,7 +120,7 @@
 // CHECK: TemplateRef=Baz:9:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
-// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux, 
outer::inner::Bar::FooType>] [typekind=Unexposed] [templateargs/4= [type=int] 
[typekind=Int] [type=char *] [typekind=Pointer] [type=Foo] 
[typekind=Unexposed] [type=outer::inner::Bar::FooType] [typekind=Typedef]] 
[canonicaltype=outer::Qux, int>] 
[canonicaltypekind=Record] [canonicaltemplateargs/4= [type=int] [typekind=Int] 
[type=char *] [typekind=Pointer] [type=outer::Foo] [typekind=Record] 
[type=int] [typekind=Int]] [isPOD=1]
+// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux, 
outer::inner::Bar::FooType>] [typekind=Unexposed] [templateargs/4= [type=int] 
[typekind=Int] [type=char *] [typekind=Pointer] [type=outer::Foo] 
[typekind=Record] [type=int] [typekind=Int]] [canonicaltype=outer::Qux, int>] [canonicaltypekind=Record] 
[canonicaltemplateargs/4= [type=int] [typekind=Int] [type=char *] 
[typekind=Pointer] [type=outer::Foo] [typekind=Record] [type=int] 
[typekind=Int]] [isPOD=1]
 // CHECK: TemplateRef=Qux:12:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: FunctionTemplate=tbar:36:3 [type=T (int)] [typekind=FunctionProto] 
[canonicaltype=type-parameter-0-0 (int)] [canonicaltypekind=FunctionProto] 
[resulttype=T] [resulttypekind=Unexposed] [isPOD=0]
@@ -177,3 +182,4 @@
 // CHECK: VarDecl=autoTemplRefParam:72:6 (Definition) 
[type=Specialization &>] [typekind=Auto] [templateargs/1= 
[type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
 // CHECK: UnexposedExpr=templRefParam:71:40 [type=const 
Specialization &>] [typekind=Unexposed] const 
[templateargs/1= [type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=const Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
 // CHECK: DeclRefExpr=templRefParam:71:40 
[type=Specialization &>] [typekind=Unexposed] 
[templateargs/1= [type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
+// CHECK: TypedefDecl=DefaultedTypeAlias:77:35 (Definition) 
[type=DefaultedTypeAlias] [typekind=Typedef] [templateargs/2= [type=int] 
[typekind=Int] [type=int] [typekind=Int]] 
[canonicaltype=DefaultedTypeExample] [canonicaltypekind=Record] 
[canonicaltemplateargs/2= [type=int] [typekind=Int] [type=int] [typekind=Int]] 
[isPOD=0]


Index: cfe/trunk/tools/libclang/CXType.cpp
===
--- cfe/trunk/tools/libclang/CXType.cpp
+++ cfe/trunk/tools/libclang/CXType.cpp
@@ -147,16 +147,16 @@
 static Optional>
 GetTemplateArguments(QualType Type) {
   assert(!Type.isNull());
-  if (const auto *Specialization = Type->getAs())
-return Specialization->tem

[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-25 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Sure. You can ask Chris Lattner for commit access for future patches :)


https://reviews.llvm.org/D32348



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-25 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio added a comment.

Yes, please! I've submitted a few patches, but still no commit access.

Thanks!


https://reviews.llvm.org/D32348



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-24 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

I see, thanks for explaining. LGTM. Do you need someone to commit it?


https://reviews.llvm.org/D32348



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-21 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio added inline comments.



Comment at: clang/test/Index/print-type.cpp:118
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
-// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux, 
outer::inner::Bar::FooType>] [typekind=Unexposed] [templateargs/4= [type=int] 
[typekind=Int] [type=char *] [typekind=Pointer] [type=Foo] 
[typekind=Unexposed] [type=outer::inner::Bar::FooType] [typekind=Typedef]] 
[canonicaltype=outer::Qux, int>] 
[canonicaltypekind=Record] [canonicaltemplateargs/4= [type=int] [typekind=Int] 
[type=char *] [typekind=Pointer] [type=outer::Foo] [typekind=Record] 
[type=int] [typekind=Int]] [isPOD=1]
 // CHECK: TemplateRef=Qux:12:8 [type=] [typekind=Invalid] [isPOD=0]

arphaman wrote:
> Hmm, that's an interesting change. I assume the test passed prior to this 
> patch, right? Did this output change purely because of the change in 
> `GetTemplateArguments`?
Yup, that's right. This makes the type and the canonical type match in this 
case. In this case we lose a tiny bit of information (mainly, that the template 
argument was used through a typedef), but the alternative is to lose 
information about default template parameters, which seems worse to me (and is 
a regression, while template argument packs haven't been inspectionable until 
libclang 4.0).


https://reviews.llvm.org/D32348



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-21 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: clang/test/Index/print-type.cpp:118
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
-// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux, 
outer::inner::Bar::FooType>] [typekind=Unexposed] [templateargs/4= [type=int] 
[typekind=Int] [type=char *] [typekind=Pointer] [type=Foo] 
[typekind=Unexposed] [type=outer::inner::Bar::FooType] [typekind=Typedef]] 
[canonicaltype=outer::Qux, int>] 
[canonicaltypekind=Record] [canonicaltemplateargs/4= [type=int] [typekind=Int] 
[type=char *] [typekind=Pointer] [type=outer::Foo] [typekind=Record] 
[type=int] [typekind=Int]] [isPOD=1]
 // CHECK: TemplateRef=Qux:12:8 [type=] [typekind=Invalid] [isPOD=0]

Hmm, that's an interesting change. I assume the test passed prior to this 
patch, right? Did this output change purely because of the change in 
`GetTemplateArguments`?


https://reviews.llvm.org/D32348



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-21 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio updated this revision to Diff 96130.
emilio added a comment.

Full diff, thanks @arphaman :)


https://reviews.llvm.org/D32348

Files:
  clang/test/Index/print-type.cpp
  clang/tools/libclang/CXType.cpp


Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -147,16 +147,16 @@
 static Optional>
 GetTemplateArguments(QualType Type) {
   assert(!Type.isNull());
-  if (const auto *Specialization = Type->getAs())
-return Specialization->template_arguments();
-
   if (const auto *RecordDecl = Type->getAsCXXRecordDecl()) {
 const auto *TemplateDecl =
   dyn_cast(RecordDecl);
 if (TemplateDecl)
   return TemplateDecl->getTemplateArgs().asArray();
   }
 
+  if (const auto *Specialization = Type->getAs())
+return Specialization->template_arguments();
+
   return None;
 }
 
Index: clang/test/Index/print-type.cpp
===
--- clang/test/Index/print-type.cpp
+++ clang/test/Index/print-type.cpp
@@ -71,6 +71,11 @@
 Specialization& > templRefParam;
 auto autoTemplRefParam = templRefParam;
 
+template
+struct DefaultedTypeExample {};
+
+typedef DefaultedTypeExample DefaultedTypeAlias;
+
 // RUN: c-index-test -test-print-type %s -std=c++14 | FileCheck %s
 // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
 // CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
@@ -115,7 +120,7 @@
 // CHECK: TemplateRef=Baz:9:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
-// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux, 
outer::inner::Bar::FooType>] [typekind=Unexposed] [templateargs/4= [type=int] 
[typekind=Int] [type=char *] [typekind=Pointer] [type=Foo] 
[typekind=Unexposed] [type=outer::inner::Bar::FooType] [typekind=Typedef]] 
[canonicaltype=outer::Qux, int>] 
[canonicaltypekind=Record] [canonicaltemplateargs/4= [type=int] [typekind=Int] 
[type=char *] [typekind=Pointer] [type=outer::Foo] [typekind=Record] 
[type=int] [typekind=Int]] [isPOD=1]
+// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux, 
outer::inner::Bar::FooType>] [typekind=Unexposed] [templateargs/4= [type=int] 
[typekind=Int] [type=char *] [typekind=Pointer] [type=outer::Foo] 
[typekind=Record] [type=int] [typekind=Int]] [canonicaltype=outer::Qux, int>] [canonicaltypekind=Record] 
[canonicaltemplateargs/4= [type=int] [typekind=Int] [type=char *] 
[typekind=Pointer] [type=outer::Foo] [typekind=Record] [type=int] 
[typekind=Int]] [isPOD=1]
 // CHECK: TemplateRef=Qux:12:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: FunctionTemplate=tbar:36:3 [type=T (int)] [typekind=FunctionProto] 
[canonicaltype=type-parameter-0-0 (int)] [canonicaltypekind=FunctionProto] 
[resulttype=T] [resulttypekind=Unexposed] [isPOD=0]
@@ -177,3 +182,4 @@
 // CHECK: VarDecl=autoTemplRefParam:72:6 (Definition) 
[type=Specialization &>] [typekind=Auto] [templateargs/1= 
[type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
 // CHECK: UnexposedExpr=templRefParam:71:40 [type=const 
Specialization &>] [typekind=Unexposed] const 
[templateargs/1= [type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=const Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
 // CHECK: DeclRefExpr=templRefParam:71:40 
[type=Specialization &>] [typekind=Unexposed] 
[templateargs/1= [type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
+// CHECK: TypedefDecl=DefaultedTypeAlias:77:35 (Definition) 
[type=DefaultedTypeAlias] [typekind=Typedef] [templateargs/2= [type=int] 
[typekind=Int] [type=int] [typekind=Int]] 
[canonicaltype=DefaultedTypeExample] [canonicaltypekind=Record] 
[canonicaltemplateargs/2= [type=int] [typekind=Int] [type=int] [typekind=Int]] 
[isPOD=0]


Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -147,16 +147,16 @@
 static Optional>
 GetTemplateArguments(QualType Type) {
   assert(!Type.isNull());
-  if (const auto *Specialization = Type->getAs())
-return Specialization->template_arguments();
-
   if (const auto *RecordDecl = Type->getAsCXXRecordDecl()) {
 const auto *TemplateDecl =
   dyn_cast(RecordDecl);
 if (TemplateDecl)
   return TemplateDecl->getTemplateArgs().asArray();
   }
 
+  if (const auto 

[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-21 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Please post the diff with full context (git diff -U).


Repository:
  rL LLVM

https://reviews.llvm.org/D32348



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-21 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio created this revision.
emilio added a project: clang-c.

This allows us to see the default template parameters too.

This is a regression in clang 4.0, so uplifting to a dot release would be neat 
(but not required, I guess).

The regression was caused by https://reviews.llvm.org/D26663.

Fixes bug 32539 (https://bugs.llvm.org//show_bug.cgi?id=32539).


Repository:
  rL LLVM

https://reviews.llvm.org/D32348

Files:
  clang/test/Index/print-type.cpp
  clang/tools/libclang/CXType.cpp


Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -147,9 +147,6 @@
 static Optional>
 GetTemplateArguments(QualType Type) {
   assert(!Type.isNull());
-  if (const auto *Specialization = Type->getAs())
-return Specialization->template_arguments();
-
   if (const auto *RecordDecl = Type->getAsCXXRecordDecl()) {
 const auto *TemplateDecl =
   dyn_cast(RecordDecl);
@@ -157,6 +154,9 @@
   return TemplateDecl->getTemplateArgs().asArray();
   }
 
+  if (const auto *Specialization = Type->getAs())
+return Specialization->template_arguments();
+
   return None;
 }
 
Index: clang/test/Index/print-type.cpp
===
--- clang/test/Index/print-type.cpp
+++ clang/test/Index/print-type.cpp
@@ -71,6 +71,11 @@
 Specialization& > templRefParam;
 auto autoTemplRefParam = templRefParam;
 
+template
+struct DefaultedTypeExample {};
+
+typedef DefaultedTypeExample DefaultedTypeAlias;
+
 // RUN: c-index-test -test-print-type %s -std=c++14 | FileCheck %s
 // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
 // CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
@@ -115,7 +120,7 @@
 // CHECK: TemplateRef=Baz:9:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
-// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux, 
outer::inner::Bar::FooType>] [typekind=Unexposed] [templateargs/4= [type=int] 
[typekind=Int] [type=char *] [typekind=Pointer] [type=Foo] 
[typekind=Unexposed] [type=outer::inner::Bar::FooType] [typekind=Typedef]] 
[canonicaltype=outer::Qux, int>] 
[canonicaltypekind=Record] [canonicaltemplateargs/4= [type=int] [typekind=Int] 
[type=char *] [typekind=Pointer] [type=outer::Foo] [typekind=Record] 
[type=int] [typekind=Int]] [isPOD=1]
+// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux, 
outer::inner::Bar::FooType>] [typekind=Unexposed] [templateargs/4= [type=int] 
[typekind=Int] [type=char *] [typekind=Pointer] [type=outer::Foo] 
[typekind=Record] [type=int] [typekind=Int]] [canonicaltype=outer::Qux, int>] [canonicaltypekind=Record] 
[canonicaltemplateargs/4= [type=int] [typekind=Int] [type=char *] 
[typekind=Pointer] [type=outer::Foo] [typekind=Record] [type=int] 
[typekind=Int]] [isPOD=1]
 // CHECK: TemplateRef=Qux:12:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: FunctionTemplate=tbar:36:3 [type=T (int)] [typekind=FunctionProto] 
[canonicaltype=type-parameter-0-0 (int)] [canonicaltypekind=FunctionProto] 
[resulttype=T] [resulttypekind=Unexposed] [isPOD=0]
@@ -177,3 +182,4 @@
 // CHECK: VarDecl=autoTemplRefParam:72:6 (Definition) 
[type=Specialization &>] [typekind=Auto] [templateargs/1= 
[type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
 // CHECK: UnexposedExpr=templRefParam:71:40 [type=const 
Specialization &>] [typekind=Unexposed] const 
[templateargs/1= [type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=const Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
 // CHECK: DeclRefExpr=templRefParam:71:40 
[type=Specialization &>] [typekind=Unexposed] 
[templateargs/1= [type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
+// CHECK: TypedefDecl=DefaultedTypeAlias:77:35 (Definition) 
[type=DefaultedTypeAlias] [typekind=Typedef] [templateargs/2= [type=int] 
[typekind=Int] [type=int] [typekind=Int]] 
[canonicaltype=DefaultedTypeExample] [canonicaltypekind=Record] 
[canonicaltemplateargs/2= [type=int] [typekind=Int] [type=int] [typekind=Int]] 
[isPOD=0]


Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -147,9 +147,6 @@
 static Optional>
 GetTemplateArguments(QualType Type) {
   assert(!Type.isNull());
-  if (const auto *Specialization = Type->getAs())
-