aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-03-18 23:54:50 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-03-18 23:54:50 +0000
commit07c5908fa10c84144907bc699751dc16d4dcb1f8 (patch)
treee3c531d1265194d7b1a7e1170b00950a088a6971
parent2aa5cf412c9a56aba1e3a7b04ca18499a2b83b20 (diff)
[libclang] Modify clang_getCursorType to be able to handle a function template decl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177359 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/Index/print-type.cpp5
-rw-r--r--tools/libclang/CXType.cpp2
2 files changed, 7 insertions, 0 deletions
diff --git a/test/Index/print-type.cpp b/test/Index/print-type.cpp
index 876bda9dd2..b99d1cb02b 100644
--- a/test/Index/print-type.cpp
+++ b/test/Index/print-type.cpp
@@ -23,6 +23,9 @@ struct Bar {
}
}
+template <typename T>
+T tbar(int);
+
// RUN: c-index-test -test-print-type %s | FileCheck %s
// CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] [isPOD=0]
// CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid] [isPOD=0]
@@ -54,3 +57,5 @@ struct Bar {
// CHECK: DeclRefExpr=z:15:35 [type=FooType] [typekind=Typedef] [canonicaltype=int] [canonicaltypekind=Int] [isPOD=1]
// CHECK: TypedefDecl=OtherType:19:18 (Definition) [type=OtherType] [typekind=Typedef] [canonicaltype=double] [canonicaltypekind=Double] [isPOD=1]
// CHECK: TypedefDecl=ArrayType:20:15 (Definition) [type=ArrayType] [typekind=Typedef] [canonicaltype=int [5]] [canonicaltypekind=ConstantArray] [isPOD=1]
+// CHECK: FunctionTemplate=tbar:27:3 [type=T (int)] [typekind=FunctionProto] [canonicaltype=type-parameter-0-0 (int)] [canonicaltypekind=FunctionProto] [resulttype=T] [resulttypekind=Unexposed] [isPOD=0]
+// CHECK: TemplateTypeParameter=T:26:20 (Definition) [type=T] [typekind=Unexposed] [canonicaltype=type-parameter-0-0] [canonicaltypekind=Unexposed] [isPOD=0]
diff --git a/tools/libclang/CXType.cpp b/tools/libclang/CXType.cpp
index 945eb11427..6f87fc51a4 100644
--- a/tools/libclang/CXType.cpp
+++ b/tools/libclang/CXType.cpp
@@ -155,6 +155,8 @@ CXType clang_getCursorType(CXCursor C) {
return MakeCXType(PD->getType(), TU);
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
return MakeCXType(FD->getType(), TU);
+ if (const FunctionTemplateDecl *FTD = dyn_cast<FunctionTemplateDecl>(D))
+ return MakeCXType(FTD->getTemplatedDecl()->getType(), TU);
return MakeCXType(QualType(), TU);
}