aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-05-12 15:17:24 +0000
committerDouglas Gregor <dgregor@apple.com>2011-05-12 15:17:24 +0000
commit211924b563aa31421836cee7655be729ad02733f (patch)
tree50514b53107a7f325db8dc47a5085a6d1c62416e
parente4246a633b13197634225971b25df0cbdcec0c5d (diff)
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
-rw-r--r--include/clang-c/Index.h7
-rw-r--r--tools/libclang/CIndex.cpp13
-rw-r--r--tools/libclang/libclang.darwin.exports1
-rw-r--r--tools/libclang/libclang.exports1
4 files changed, 22 insertions, 0 deletions
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index 97c0c7c0da..c79475eff4 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -2267,6 +2267,13 @@ CINDEX_LINKAGE CXCursor clang_getCanonicalCursor(CXCursor);
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 eea078dd47..f1a37d6906 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -5192,6 +5192,19 @@ unsigned clang_CXXMethod_isStatic(CXCursor C) {
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 7bba6739c5..85dfcb6868 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 5f2c362f5b..403cd67538 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