[PATCH] D51281: [libclang] Return the proper pointee type for 'auto' deduced to pointer
Ivan Donchevskii via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 7 06:25:06 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL341656: [libclang] Return the proper pointee type for 'auto' deduced to pointer (authored by yvvan, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D51281?vs=164151&id=164399#toc
Repository:
rL LLVM
https://reviews.llvm.org/D51281
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
@@ -442,6 +442,7 @@
if (!TP)
return MakeCXType(QualType(), GetTU(CT));
+try_again:
switch (TP->getTypeClass()) {
case Type::Pointer:
T = cast<PointerType>(TP)->getPointeeType();
@@ -459,6 +460,12 @@
case Type::MemberPointer:
T = cast<MemberPointerType>(TP)->getPointeeType();
break;
+ case Type::Auto:
+ case Type::DeducedTemplateSpecialization:
+ TP = cast<DeducedType>(TP)->getDeducedType().getTypePtrOrNull();
+ if (TP)
+ goto try_again;
+ break;
default:
T = QualType();
break;
Index: cfe/trunk/test/Index/print-type.cpp
===================================================================
--- cfe/trunk/test/Index/print-type.cpp
+++ cfe/trunk/test/Index/print-type.cpp
@@ -75,6 +75,8 @@
template<typename T> using C = T;
using baz = C<A<void>>;
+auto autoTemplPointer = &autoTemplRefParam;
+
// 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]
@@ -182,3 +184,4 @@
// CHECK: UnexposedExpr=templRefParam:71: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:71: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]
// CHECK: TypeAliasDecl=baz:76:7 (Definition) [type=baz] [typekind=Typedef] [templateargs/1= [type=A<void>] [typekind=Unexposed]] [canonicaltype=A<void>] [canonicaltypekind=Record] [canonicaltemplateargs/1= [type=void] [typekind=Void]] [isPOD=0]
+// CHECK: VarDecl=autoTemplPointer:78:6 (Definition) [type=Specialization<Specialization<bool> &> *] [typekind=Auto] [canonicaltype=Specialization<Specialization<bool> &> *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=Specialization<Specialization<bool> &>] [pointeekind=Record]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51281.164399.patch
Type: text/x-patch
Size: 2611 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180907/3ea10c2b/attachment-0001.bin>
More information about the llvm-commits
mailing list