Add clang_CXXMethod_isVirtual() to libclang, from Erik Verbruggen!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131230 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index 97c0c7c..c79475e 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -2267,6 +2267,13 @@
CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
/**
+ * \brief Determine if a C++ member function or member function template is
+ * explicitly declared 'virtual' or if it overrides a virtual method from
+ * one of the base classes.
+ */
+CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
+
+/**
* \brief Given a cursor that represents a template, determine
* the cursor kind of the specializations would be generated by instantiating
* the template.
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index eea078d..f1a37d6 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -5192,6 +5192,19 @@
return (Method && Method->isStatic()) ? 1 : 0;
}
+unsigned clang_CXXMethod_isVirtual(CXCursor C) {
+ if (!clang_isDeclaration(C.kind))
+ return 0;
+
+ CXXMethodDecl *Method = 0;
+ Decl *D = cxcursor::getCursorDecl(C);
+ if (FunctionTemplateDecl *FunTmpl = dyn_cast_or_null<FunctionTemplateDecl>(D))
+ Method = dyn_cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl());
+ else
+ Method = dyn_cast_or_null<CXXMethodDecl>(D);
+ return (Method && Method->isVirtual()) ? 1 : 0;
+}
+
} // end: extern "C"
//===----------------------------------------------------------------------===//
diff --git a/tools/libclang/libclang.darwin.exports b/tools/libclang/libclang.darwin.exports
index 7bba673..85dfcb6 100644
--- a/tools/libclang/libclang.darwin.exports
+++ b/tools/libclang/libclang.darwin.exports
@@ -1,6 +1,7 @@
_clang_CXCursorSet_contains
_clang_CXCursorSet_insert
_clang_CXXMethod_isStatic
+_clang_CXXMethod_isVirtual
_clang_annotateTokens
_clang_codeCompleteAt
_clang_codeCompleteGetDiagnostic
diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports
index 5f2c362..403cd67 100644
--- a/tools/libclang/libclang.exports
+++ b/tools/libclang/libclang.exports
@@ -1,6 +1,7 @@
clang_CXCursorSet_contains
clang_CXCursorSet_insert
clang_CXXMethod_isStatic
+clang_CXXMethod_isVirtual
clang_annotateTokens
clang_codeCompleteAt
clang_codeCompleteGetDiagnostic