Add a new libclang function clang_getTemplateCursorKind(), which
determines the kind of declaration that would be generated if the
given template were instantiated. This allows a client to distinguish
among class/struct/union templates and function/member function/static
member function templates.
Also, teach clang_CXXMethod_isStatic() about function templates.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112655 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CIndexCXX.cpp b/tools/libclang/CIndexCXX.cpp
index a168f16..ee83f98 100644
--- a/tools/libclang/CIndexCXX.cpp
+++ b/tools/libclang/CIndexCXX.cpp
@@ -15,6 +15,7 @@
#include "CXCursor.h"
#include "CXType.h"
#include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclTemplate.h"
using namespace clang;
using namespace clang::cxstring;
@@ -45,4 +46,36 @@
return CX_CXXInvalidAccessSpecifier;
}
+enum CXCursorKind clang_getTemplateCursorKind(CXCursor C) {
+ using namespace clang::cxcursor;
+
+ switch (C.kind) {
+ case CXCursor_ClassTemplate:
+ case CXCursor_FunctionTemplate:
+ if (TemplateDecl *Template
+ = dyn_cast_or_null<TemplateDecl>(getCursorDecl(C)))
+ return MakeCXCursor(Template->getTemplatedDecl(),
+ getCursorASTUnit(C)).kind;
+ break;
+
+ case CXCursor_ClassTemplatePartialSpecialization:
+ if (ClassTemplateSpecializationDecl *PartialSpec
+ = dyn_cast_or_null<ClassTemplatePartialSpecializationDecl>(
+ getCursorDecl(C))) {
+ switch (PartialSpec->getTagKind()) {
+ case TTK_Class: return CXCursor_ClassDecl;
+ case TTK_Struct: return CXCursor_StructDecl;
+ case TTK_Union: return CXCursor_UnionDecl;
+ case TTK_Enum: return CXCursor_NoDeclFound;
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return CXCursor_NoDeclFound;
+}
+
} // end extern "C"