r289995 - [libclang] Restore the CXXRecordDecl path for clang_Type_getNumTemplateArguments and clang_Type_getTemplateArgumentAsType
Argyrios Kyrtzidis via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 16 16:56:41 PST 2016
Yes, I see, thanks Reid!
I’d just remove the 'extern "C” {‘ from the cpp file, which is not really necessary, I’ll do it in a subsequent commit anyway.
> On Dec 16, 2016, at 4:48 PM, Yung, Douglas <douglas.yung at sony.com> wrote:
>
> I think Reid already fixed the problem in r290009.
>
> Douglas Yung
>
>> -----Original Message-----
>> From: Argyrios Kyrtzidis [mailto:akyrtzi at gmail.com]
>> Sent: Friday, December 16, 2016 16:46
>> To: Yung, Douglas
>> Cc: cfe-commits at lists.llvm.org
>> Subject: Re: r289995 - [libclang] Restore the CXXRecordDecl path for
>> clang_Type_getNumTemplateArguments and
>> clang_Type_getTemplateArgumentAsType
>>
>> Looking into..
>>
>>> On Dec 16, 2016, at 3:13 PM, Yung, Douglas <douglas.yung at sony.com>
>> wrote:
>>>
>>> Hi, this change seems to be causing the PS4 Windows build bot to be
>> red, can you take a look?
>>>
>>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-
>> windo
>>> ws10pro-fast/builds/2784
>>>
>>> C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe /nologo /TP -
>> DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_OBJC_REWRITER -
>> DCLANG_ENABLE_STATIC_ANALYZER -DCLANG_TOOL_EXTRA_BUILD -
>> DGTEST_HAS_RTTI=0 -DUNICODE -D_CINDEX_LIB_ -D_CRT_NONSTDC_NO_DEPRECATE
>> -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -
>> D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0 -
>> D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -
>> D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -
>> Itools\clang\tools\libclang -IC:\Buildbot\Slave\llvm-clang-lld-x86_64-
>> scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\libclang -
>> IC:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\include -Itools\clang\include -Iinclude -
>> IC:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\include /DWIN32 /D_WINDOWS /W4 -wd4141 -wd4146 -wd4180
>> -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351 -wd4355 -wd4456 -wd4457
>> -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4800 -wd4100 -wd4127 -wd4512
>> -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703
>> -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4324
>> -w14062 -we4238 /Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast /MD /O2
>> /Ob2 -UNDEBUG /EHs-c- /GR- /showIncludes
>> /Fotools\clang\tools\libclang\CMakeFiles\libclang.dir\CXType.cpp.obj
>> /Fdtools\clang\tools\libclang\CMakeFiles\libclang.dir\ /FS -c
>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(924): error C2526:
>> 'GetTemplateArguments': C linkage function cannot return C++ class
>> 'llvm::Optional<llvm::ArrayRef<clang::TemplateArgument>>'
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llv
>>> m.src\tools\clang\tools\libclang\CXType.cpp(927): error C2562:
>>> 'GetTemplateArguments': 'void' function returning a value
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(924): note: see
>> declaration of 'GetTemplateArguments'
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llv
>>> m.src\tools\clang\tools\libclang\CXType.cpp(933): error C2562:
>>> 'GetTemplateArguments': 'void' function returning a value
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(924): note: see
>> declaration of 'GetTemplateArguments'
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llv
>>> m.src\tools\clang\tools\libclang\CXType.cpp(936): error C2562:
>>> 'GetTemplateArguments': 'void' function returning a value
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(924): note: see
>> declaration of 'GetTemplateArguments'
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(926): warning
>> C4390: ';': empty controlled statement found; is this the intent?
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(932): warning
>> C4390: ';': empty controlled statement found; is this the intent?
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(952): error C3313:
>> 'TA': variable cannot have the type 'void'
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llv
>>> m.src\tools\clang\tools\libclang\CXType.cpp(953): error C3536: 'TA':
>>> cannot be used before it is initialized
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llv
>>> m.src\tools\clang\tools\libclang\CXType.cpp(956): error C2228: left
>> of
>>> '.getValue' must have class/struct/union
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(956): note: type is
>> 'int'
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(959): error C2526:
>> 'TemplateArgumentToQualType': C linkage function cannot return C++
>> class 'llvm::Optional<clang::QualType>'
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llv
>>> m.src\tools\clang\tools\libclang\CXType.cpp(961): error C2562:
>>> 'TemplateArgumentToQualType': 'void' function returning a value
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(959): note: see
>> declaration of 'TemplateArgumentToQualType'
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llv
>>> m.src\tools\clang\tools\libclang\CXType.cpp(962): error C2562:
>>> 'TemplateArgumentToQualType': 'void' function returning a value
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(959): note: see
>> declaration of 'TemplateArgumentToQualType'
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(960): warning
>> C4390: ';': empty controlled statement found; is this the intent?
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(966): error C2526:
>> 'FindTemplateArgumentTypeAt': C linkage function cannot return C++
>> class 'llvm::Optional<clang::QualType>'
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llv
>>> m.src\tools\clang\tools\libclang\CXType.cpp(979): error C2562:
>>> 'FindTemplateArgumentTypeAt': 'void' function returning a value
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(966): note: see
>> declaration of 'FindTemplateArgumentTypeAt'
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(987): error C3313:
>> 'TA': variable cannot have the type 'void'
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llv
>>> m.src\tools\clang\tools\libclang\CXType.cpp(988): error C3536: 'TA':
>>> cannot be used before it is initialized
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llv
>>> m.src\tools\clang\tools\libclang\CXType.cpp(991): error C2228: left
>> of
>>> '.getValue' must have class/struct/union
>>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-
>> fast\llvm.src\tools\clang\tools\libclang\CXType.cpp(991): note: type is
>> 'int'
>>>
>>>
>>> Douglas Yung
>>>
>>>> -----Original Message-----
>>>> From: cfe-commits [mailto:cfe-commits-bounces at lists.llvm.org] On
>>>> Behalf Of Argyrios Kyrtzidis via cfe-commits
>>>> Sent: Friday, December 16, 2016 13:40
>>>> To: cfe-commits at lists.llvm.org
>>>> Subject: r289995 - [libclang] Restore the CXXRecordDecl path for
>>>> clang_Type_getNumTemplateArguments and
>>>> clang_Type_getTemplateArgumentAsType
>>>>
>>>> Author: akirtzidis
>>>> Date: Fri Dec 16 15:40:16 2016
>>>> New Revision: 289995
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=289995&view=rev
>>>> Log:
>>>> [libclang] Restore the CXXRecordDecl path for
>>>> clang_Type_getNumTemplateArguments and
>>>> clang_Type_getTemplateArgumentAsType
>>>>
>>>> Patch by Emilio Cobos Álvarez!
>>>> See https://reviews.llvm.org/D26907
>>>>
>>>> Modified:
>>>> cfe/trunk/test/Index/keep-going.cpp
>>>> cfe/trunk/test/Index/print-type.cpp
>>>> cfe/trunk/tools/c-index-test/c-index-test.c
>>>> cfe/trunk/tools/libclang/CXType.cpp
>>>>
>>>> Modified: cfe/trunk/test/Index/keep-going.cpp
>>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/keep-
>>>> going.cpp?rev=289995&r1=289994&r2=289995&view=diff
>>>>
>> =====================================================================
>>>> ==
>>>> =======
>>>> --- cfe/trunk/test/Index/keep-going.cpp (original)
>>>> +++ cfe/trunk/test/Index/keep-going.cpp Fri Dec 16 15:40:16 2016
>>>> @@ -19,10 +19,10 @@ class C : public A<float> { }; // CHECK:
>>>> FieldDecl=a:4:13 (Definition) [type=T] [typekind=Unexposed]
>>>> [canonicaltype=type-parameter-0-0] [canonicaltypekind=Unexposed]
>>>> [isPOD=0] // CHECK: TypeRef=T:3:16 [type=T] [typekind=Unexposed]
>>>> [canonicaltype=type-parameter-0-0] [canonicaltypekind=Unexposed]
>>>> [isPOD=0] // CHECK: ClassDecl=B:6:7 (Definition) [type=B]
>>>> [typekind=Record] [isPOD=0] -// CHECK: C++ base class
>>>> specifier=A<int>:4:7 [access=public isVirtual=false] [type=A<int>]
>>>> [typekind=Unexposed] [canonicaltype=A<int>]
>>>> [canonicaltypekind=Record] [templateargs/1= [type=int]
>>>> [typekind=Int]] [isPOD=0] [nbFields=1]
>>>> +// CHECK: C++ base class specifier=A<int>:4:7 [access=public
>>>> +isVirtual=false] [type=A<int>] [typekind=Unexposed]
>> [templateargs/1=
>>>> +[type=int] [typekind=Int]] [canonicaltype=A<int>]
>>>> +[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=int]
>>>> +[typekind=Int]] [isPOD=0] [nbFields=1]
>>>> // CHECK: TemplateRef=A:4:7 [type=] [typekind=Invalid] [isPOD=0] //
>>>> CHECK: ClassDecl=C:10:7 (Definition) [type=C] [typekind=Record]
>>>> [isPOD=0] -// CHECK: C++ base class specifier=A<float>:4:7
>>>> [access=public isVirtual=false] [type=A<float>] [typekind=Unexposed]
>>>> [canonicaltype=A<float>] [canonicaltypekind=Record] [templateargs/1=
>>>> [type=float] [typekind=Float]] [isPOD=0] [nbFields=1]
>>>> +// CHECK: C++ base class specifier=A<float>:4:7 [access=public
>>>> +isVirtual=false] [type=A<float>] [typekind=Unexposed]
>>>> +[templateargs/1= [type=float] [typekind=Float]]
>>>> +[canonicaltype=A<float>] [canonicaltypekind=Record]
>>>> +[canonicaltemplateargs/1= [type=float] [typekind=Float]] [isPOD=0]
>>>> +[nbFields=1]
>>>> // CHECK: TemplateRef=A:4:7 [type=] [typekind=Invalid] [isPOD=0]
>>>>
>>>> // CHECK-DIAG: keep-going.cpp:1:10: error: 'missing1.h' file not
>>>> found
>>>>
>>>> Modified: cfe/trunk/test/Index/print-type.cpp
>>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-
>>>> type.cpp?rev=289995&r1=289994&r2=289995&view=diff
>>>>
>> =====================================================================
>>>> ==
>>>> =======
>>>> --- cfe/trunk/test/Index/print-type.cpp (original)
>>>> +++ cfe/trunk/test/Index/print-type.cpp Fri Dec 16 15:40:16 2016
>>>> @@ -61,6 +61,15 @@ using TypeAlias = outer::Qux<T>;
>>>>
>>>> struct TypeAliasUser { TypeAlias<int> foo; };
>>>>
>>>> +template<typename T>
>>>> +struct Specialization {};
>>>> +
>>>> +template<>
>>>> +struct Specialization<int>;
>>>> +
>>>> +Specialization<Specialization<bool>& > templRefParam; auto
>>>> +autoTemplRefParam = templRefParam;
>>>> +
>>>> // 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] @@ -100,11 +109,11 @@ struct
>>>> TypeAliasUser { TypeAlias<int> fo // CHECK:
>>>> TypedefDecl=OtherType:25:18 (Definition) [type=OtherType]
>>>> [typekind=Typedef] [canonicaltype=double] [canonicaltypekind=Double]
>> [isPOD=1] // CHECK:
>>>> TypedefDecl=ArrayType:26:15 (Definition) [type=ArrayType]
>>>> [typekind=Typedef] [canonicaltype=int [5]]
>>>> [canonicaltypekind=ConstantArray] [isPOD=1] // CHECK:
>>>> IntegerLiteral= [type=int] [typekind=Int] [isPOD=1] -// CHECK:
>>>> FieldDecl=baz:27:20
>>>> (Definition) [type=Baz<int, 1, Foo>] [typekind=Unexposed]
>>>> [canonicaltype=outer::Baz<int, 1, Foo>] [canonicaltypekind=Record]
>>>> [templateargs/3= [type=int] [typekind=Int]] [isPOD=1]
>>>> +// CHECK: FieldDecl=baz:27:20 (Definition) [type=Baz<int, 1, Foo>]
>>>> +[typekind=Unexposed] [templateargs/3= [type=int] [typekind=Int]]
>>>> +[canonicaltype=outer::Baz<int, 1, Foo>] [canonicaltypekind=Record]
>>>> +[canonicaltemplateargs/3= [type=int] [typekind=Int]] [isPOD=1]
>>>> // 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:28:29 (Definition) [type=Qux<int, char *, Foo<int> >]
>>>> [typekind=Unexposed] [canonicaltype=outer::Qux<int, char *,
>>>> outer::Foo<int> >] [canonicaltypekind=Record] [templateargs/3=
>>>> [type=int] [typekind=Int] [type=char *] [typekind=Pointer]
>>>> [type=Foo<int>] [typekind=Unexposed]] [isPOD=1]
>>>> +// CHECK: FieldDecl=qux:28:29 (Definition) [type=Qux<int, char *,
>>>> +Foo<int> >] [typekind=Unexposed] [templateargs/3= [type=int]
>>>> +[typekind=Int] [type=char *] [typekind=Pointer] [type=Foo<int>]
>>>> +[typekind=Unexposed]] [canonicaltype=outer::Qux<int, char *,
>>>> +outer::Foo<int> >] [canonicaltypekind=Record]
>>>> [canonicaltemplateargs/3=
>>>> +[type=int] [typekind=Int] [type=char *] [typekind=Pointer]
>>>> +[type=outer::Foo<int>] [typekind=Record]] [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:35:3 [type=T (int)]
>>>> [typekind=FunctionProto] [canonicaltype=type-parameter-0-0 (int)]
>>>> [canonicaltypekind=FunctionProto] [resulttype=T]
>>>> [resulttypekind=Unexposed] [isPOD=0] @@ -155,5 +164,14 @@ struct
>>>> TypeAliasUser { TypeAlias<int> fo // CHECK: IntegerLiteral=
>>>> [type=int] [typekind=Int] [isPOD=1] // CHECK:
>>>> TypeAliasTemplateDecl=TypeAlias:60:1 (Definition) [type=]
>>>> [typekind=Invalid] [isPOD=0] // CHECK:
>> TemplateTypeParameter=T:59:20
>>>> (Definition) [type=T] [typekind=Unexposed] [canonicaltype=type-
>>>> parameter-0-0] [canonicaltypekind=Unexposed] [isPOD=0] -// CHECK:
>>>> FieldDecl=foo:62:39 (Definition) [type=TypeAlias<int>]
>>>> [typekind=Unexposed] [canonicaltype=outer::Qux<int>]
>>>> [canonicaltypekind=Record] [templateargs/1= [type=int]
>>>> [typekind=Int]] [isPOD=1]
>>>> +// CHECK: FieldDecl=foo:62:39 (Definition) [type=TypeAlias<int>]
>>>> +[typekind=Unexposed] [templateargs/1= [type=int] [typekind=Int]]
>>>> +[canonicaltype=outer::Qux<int>] [canonicaltypekind=Record]
>>>> +[canonicaltemplateargs/1= [type=int] [typekind=Int]] [isPOD=1]
>>>> // CHECK: TemplateRef=TypeAlias:60:1 [type=] [typekind=Invalid]
>>>> [isPOD=0]
>>>> +// CHECK: ClassTemplate=Specialization:65:8 (Definition) [type=]
>>>> +[typekind=Invalid] [isPOD=0] // CHECK:
>> TemplateTypeParameter=T:64:19
>>>> +(Definition) [type=T] [typekind=Unexposed]
>>>> +[canonicaltype=type-parameter-0-0] [canonicaltypekind=Unexposed]
>>>> +[isPOD=0] // CHECK: StructDecl=Specialization:68:8 [Specialization
>>>> +of Specialization:65:8] [type=Specialization<int>]
>> [typekind=Record]
>>>> +[templateargs/1= [type=int] [typekind=Int]] [isPOD=0] // CHECK:
>>>> +VarDecl=templRefParam:70:40 (Definition)
>>>> +[type=Specialization<Specialization<bool> &>] [typekind=Unexposed]
>>>> +[templateargs/1= [type=Specialization<bool> &]
>>>> +[typekind=LValueReference]]
>>>> +[canonicaltype=Specialization<Specialization<bool> &>]
>>>> +[canonicaltypekind=Record] [canonicaltemplateargs/1=
>>>> +[type=Specialization<bool> &] [typekind=LValueReference]] [isPOD=1]
>>>> +//
>>>> +CHECK: TemplateRef=Specialization:65:8 [type=] [typekind=Invalid]
>>>> +[isPOD=0] // CHECK: CallExpr=Specialization:65:8
>>>> +[type=Specialization<Specialization<bool> &>] [typekind=Unexposed]
>>>> +[templateargs/1= [type=Specialization<bool> &]
>>>> +[typekind=LValueReference]]
>>>> +[canonicaltype=Specialization<Specialization<bool> &>]
>>>> +[canonicaltypekind=Record] [canonicaltemplateargs/1=
>>>> +[type=Specialization<bool> &] [typekind=LValueReference]] [isPOD=1]
>>>> +//
>>>> +CHECK: VarDecl=autoTemplRefParam:71:6 (Definition)
>>>> +[type=Specialization<Specialization<bool> &>] [typekind=Auto]
>>>> +[templateargs/1= [type=Specialization<bool> &]
>>>> +[typekind=LValueReference]]
>>>> +[canonicaltype=Specialization<Specialization<bool> &>]
>>>> +[canonicaltypekind=Record] [canonicaltemplateargs/1=
>>>> +[type=Specialization<bool> &] [typekind=LValueReference]] [isPOD=1]
>>>> +//
>>>> +CHECK: UnexposedExpr=templRefParam:70:40 [type=const
>>>> +Specialization<Specialization<bool> &>] [typekind=Unexposed] const
>>>> +[templateargs/1= [type=Specialization<bool> &]
>>>> +[typekind=LValueReference]] [canonicaltype=const
>>>> +Specialization<Specialization<bool> &>] [canonicaltypekind=Record]
>>>> +[canonicaltemplateargs/1= [type=Specialization<bool> &]
>>>> +[typekind=LValueReference]] [isPOD=1] // CHECK:
>>>> +DeclRefExpr=templRefParam:70:40
>>>> +[type=Specialization<Specialization<bool> &>] [typekind=Unexposed]
>>>> +[templateargs/1= [type=Specialization<bool> &]
>>>> +[typekind=LValueReference]]
>>>> +[canonicaltype=Specialization<Specialization<bool> &>]
>>>> +[canonicaltypekind=Record] [canonicaltemplateargs/1=
>>>> +[type=Specialization<bool> &] [typekind=LValueReference]] [isPOD=1]
>>>>
>>>> Modified: cfe/trunk/tools/c-index-test/c-index-test.c
>>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-
>>>> test/c-index-test.c?rev=289995&r1=289994&r2=289995&view=diff
>>>>
>> =====================================================================
>>>> ==
>>>> =======
>>>> --- cfe/trunk/tools/c-index-test/c-index-test.c (original)
>>>> +++ cfe/trunk/tools/c-index-test/c-index-test.c Fri Dec 16 15:40:16
>>>> 2016
>>>> @@ -1316,6 +1316,25 @@ static enum CXVisitorResult FieldVisitor
>>>> return CXVisit_Continue;
>>>> }
>>>>
>>>> +static void PrintTypeTemplateArgs(CXType T, const char *Format) {
>>>> + int NumTArgs = clang_Type_getNumTemplateArguments(T);
>>>> + if (NumTArgs != -1 && NumTArgs != 0) {
>>>> + int i;
>>>> + CXType TArg;
>>>> + printf(Format, NumTArgs);
>>>> + for (i = 0; i < NumTArgs; ++i) {
>>>> + TArg = clang_Type_getTemplateArgumentAsType(T, i);
>>>> + if (TArg.kind != CXType_Invalid) {
>>>> + PrintTypeAndTypeKind(TArg, " [type=%s] [typekind=%s]");
>>>> + }
>>>> + }
>>>> + /* Ensure that the returned type is invalid when indexing
>>>> +off-by-
>>>> one. */
>>>> + TArg = clang_Type_getTemplateArgumentAsType(T, i);
>>>> + assert(TArg.kind == CXType_Invalid);
>>>> + printf("]");
>>>> + }
>>>> +}
>>>> +
>>>> static enum CXChildVisitResult PrintType(CXCursor cursor, CXCursor
>> p,
>>>> CXClientData d) {
>>>> if (!clang_isInvalid(clang_getCursorKind(cursor))) { @@ -1333,11
>>>> +1352,14 @@ static enum CXChildVisitResult PrintType
>>>> printf(" lvalue-ref-qualifier");
>>>> if (RQ == CXRefQualifier_RValue)
>>>> printf(" rvalue-ref-qualifier");
>>>> + /* Print the template argument types if they exist. */
>>>> + PrintTypeTemplateArgs(T, " [templateargs/%d=");
>>>> /* Print the canonical type if it is different. */
>>>> {
>>>> CXType CT = clang_getCanonicalType(T);
>>>> if (!clang_equalTypes(T, CT)) {
>>>> PrintTypeAndTypeKind(CT, " [canonicaltype=%s]
>>>> [canonicaltypekind=%s]");
>>>> + PrintTypeTemplateArgs(CT, " [canonicaltemplateargs/%d=");
>>>> }
>>>> }
>>>> /* Print the return type if it exists. */ @@ -1360,21 +1382,6 @@
>>>> static enum CXChildVisitResult PrintType
>>>> }
>>>> }
>>>> printf("]");
>>>> - }
>>>> - }
>>>> - /* Print the template argument types if they exist. */
>>>> - {
>>>> - int NumTArgs = clang_Type_getNumTemplateArguments(T);
>>>> - if (NumTArgs != -1 && NumTArgs != 0) {
>>>> - int i;
>>>> - printf(" [templateargs/%d=", NumTArgs);
>>>> - for (i = 0; i < NumTArgs; ++i) {
>>>> - CXType TArg = clang_Type_getTemplateArgumentAsType(T, i);
>>>> - if (TArg.kind != CXType_Invalid) {
>>>> - PrintTypeAndTypeKind(TArg, " [type=%s] [typekind=%s]");
>>>> - }
>>>> - }
>>>> - printf("]");
>>>> }
>>>> }
>>>> /* Print if this is a non-POD type. */
>>>>
>>>> Modified: cfe/trunk/tools/libclang/CXType.cpp
>>>> URL: http://llvm.org/viewvc/llvm-
>>>>
>> project/cfe/trunk/tools/libclang/CXType.cpp?rev=289995&r1=289994&r2=2
>>>> 89
>>>> 995&view=diff
>>>>
>> =====================================================================
>>>> ==
>>>> =======
>>>> --- cfe/trunk/tools/libclang/CXType.cpp (original)
>>>> +++ cfe/trunk/tools/libclang/CXType.cpp Fri Dec 16 15:40:16 2016
>>>> @@ -920,33 +920,76 @@ CXString clang_getDeclObjCTypeEncoding(C
>>>> return cxstring::createDup(encoding); }
>>>>
>>>> +static Optional<ArrayRef<TemplateArgument>>
>>>> +GetTemplateArguments(QualType Type) {
>>>> + assert(!Type.isNull());
>>>> + if (const auto *Specialization = Type-
>>>>> getAs<TemplateSpecializationType>())
>>>> + return Specialization->template_arguments();
>>>> +
>>>> + if (const auto *RecordDecl = Type->getAsCXXRecordDecl()) {
>>>> + const auto *TemplateDecl =
>>>> + dyn_cast<ClassTemplateSpecializationDecl>(RecordDecl);
>>>> + if (TemplateDecl)
>>>> + return TemplateDecl->getTemplateArgs().asArray();
>>>> + }
>>>> +
>>>> + return None;
>>>> +}
>>>> +
>>>> +static unsigned
>>>> GetTemplateArgumentArraySize(ArrayRef<TemplateArgument>
>>>> +TA) {
>>>> + unsigned size = TA.size();
>>>> + for (const auto &Arg : TA)
>>>> + if (Arg.getKind() == TemplateArgument::Pack)
>>>> + size += Arg.pack_size() - 1;
>>>> + return size;
>>>> +}
>>>> +
>>>> int clang_Type_getNumTemplateArguments(CXType CT) {
>>>> QualType T = GetQualType(CT);
>>>> if (T.isNull())
>>>> return -1;
>>>> - const TemplateSpecializationType *Specialization =
>>>> - T->getAs<TemplateSpecializationType>();
>>>> - if (!Specialization)
>>>> +
>>>> + auto TA = GetTemplateArguments(T); if (!TA)
>>>> return -1;
>>>> - return Specialization->template_arguments().size();
>>>> +
>>>> + return GetTemplateArgumentArraySize(TA.getValue());
>>>> }
>>>>
>>>> -CXType clang_Type_getTemplateArgumentAsType(CXType CT, unsigned i)
>> {
>>>> +static Optional<QualType> TemplateArgumentToQualType(const
>>>> +TemplateArgument &A) {
>>>> + if (A.getKind() == TemplateArgument::Type)
>>>> + return A.getAsType();
>>>> + return None;
>>>> +}
>>>> +
>>>> +static Optional<QualType>
>>>> +FindTemplateArgumentTypeAt(ArrayRef<TemplateArgument> TA, unsigned
>>>> +index) {
>>>> + unsigned current = 0;
>>>> + for (const auto &A : TA) {
>>>> + if (A.getKind() == TemplateArgument::Pack) {
>>>> + if (index < current + A.pack_size())
>>>> + return TemplateArgumentToQualType(A.getPackAsArray()[index
>> -
>>>> current]);
>>>> + current += A.pack_size();
>>>> + continue;
>>>> + }
>>>> + if (current == index)
>>>> + return TemplateArgumentToQualType(A);
>>>> + current++;
>>>> + }
>>>> + return None;
>>>> +}
>>>> +
>>>> +CXType clang_Type_getTemplateArgumentAsType(CXType CT, unsigned
>>>> +index) {
>>>> QualType T = GetQualType(CT);
>>>> if (T.isNull())
>>>> return MakeCXType(QualType(), GetTU(CT));
>>>>
>>>> - const TemplateSpecializationType *Specialization =
>>>> - T->getAs<TemplateSpecializationType>();
>>>> - if (!Specialization)
>>>> + auto TA = GetTemplateArguments(T); if (!TA)
>>>> return MakeCXType(QualType(), GetTU(CT));
>>>> - auto TA = Specialization->template_arguments();
>>>> - if (TA.size() <= i)
>>>> - return MakeCXType(QualType(), GetTU(CT));
>>>> - const TemplateArgument &A = TA[i];
>>>> - if (A.getKind() != TemplateArgument::Type)
>>>> - return MakeCXType(QualType(), GetTU(CT));
>>>> - return MakeCXType(A.getAsType(), GetTU(CT));
>>>> +
>>>> + Optional<QualType> QT = FindTemplateArgumentTypeAt(TA.getValue(),
>>>> + index); return MakeCXType(QT.getValueOr(QualType()), GetTU(CT));
>>>> }
>>>>
>>>> unsigned clang_Type_visitFields(CXType PT,
>>>>
>>>>
>>>> _______________________________________________
>>>> cfe-commits mailing list
>>>> cfe-commits at lists.llvm.org
>>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
More information about the cfe-commits
mailing list