diff options
author | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2018-09-07 13:23:51 +0000 |
---|---|---|
committer | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2018-09-07 13:23:51 +0000 |
commit | 4e24bae3a87ad427403ec1ecb539a42e2eb8a351 (patch) | |
tree | 416bc8fdd9d54f48cfae111c2cc97962de69ca8a | |
parent | 19c2c62f60a8ae740a62c16d1271177e3ed3d3f0 (diff) |
[libclang] Return the proper pointee type for 'auto' deduced to pointer
Currently the resulting type is always invalid in such case.
Differential Revision: https://reviews.llvm.org/D51281
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341656 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | test/Index/print-type.cpp | 3 | ||||
-rw-r--r-- | tools/libclang/CXType.cpp | 7 |
2 files changed, 10 insertions, 0 deletions
diff --git a/test/Index/print-type.cpp b/test/Index/print-type.cpp index e152a7ed3d..3c76c97cca 100644 --- a/test/Index/print-type.cpp +++ b/test/Index/print-type.cpp @@ -75,6 +75,8 @@ template<typename T> struct A {}; 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 @@ using baz = C<A<void>>; // 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] diff --git a/tools/libclang/CXType.cpp b/tools/libclang/CXType.cpp index 3e71435d22..d4bdebd7d8 100644 --- a/tools/libclang/CXType.cpp +++ b/tools/libclang/CXType.cpp @@ -442,6 +442,7 @@ CXType clang_getPointeeType(CXType CT) { if (!TP) return MakeCXType(QualType(), GetTU(CT)); +try_again: switch (TP->getTypeClass()) { case Type::Pointer: T = cast<PointerType>(TP)->getPointeeType(); @@ -459,6 +460,12 @@ CXType clang_getPointeeType(CXType CT) { 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; |