[libclang] Modify clang_getCursorType to be able to handle a function template decl.

llvm-svn: 177359
This commit is contained in:
Argyrios Kyrtzidis 2013-03-18 23:54:50 +00:00
parent abbcbaeb4c
commit 014349cc8c
2 changed files with 7 additions and 0 deletions

View File

@ -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]

View File

@ -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);
}