]> granicus.if.org Git - clang/commitdiff
Add clang_CXXMethod_isVirtual() to libclang, from Erik Verbruggen!
authorDouglas Gregor <dgregor@apple.com>
Thu, 12 May 2011 15:17:24 +0000 (15:17 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 12 May 2011 15:17:24 +0000 (15:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131230 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang-c/Index.h
tools/libclang/CIndex.cpp
tools/libclang/libclang.darwin.exports
tools/libclang/libclang.exports

index 97c0c7c0daa1e90f1eecb47f85025a6986b85f14..c79475eff407c9ade13957923f1db1c053309334 100644 (file)
@@ -2266,6 +2266,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
index eea078dd47fe7886352ac573e462fdd34af4ffa5..f1a37d6906b04e56ddd371a19636cdf9969d65cf 100644 (file)
@@ -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"
 
 //===----------------------------------------------------------------------===//
index 7bba6739c56fc532f8ffda53d60e206072eaf833..85dfcb68685c61fc50032055dac12d2828c0970f 100644 (file)
@@ -1,6 +1,7 @@
 _clang_CXCursorSet_contains
 _clang_CXCursorSet_insert
 _clang_CXXMethod_isStatic
+_clang_CXXMethod_isVirtual
 _clang_annotateTokens
 _clang_codeCompleteAt
 _clang_codeCompleteGetDiagnostic
index 5f2c362f5b7e3fee312854af2037e338566a6fa1..403cd67538c5d11cb3d02867cd71d25043f95a3d 100644 (file)
@@ -1,6 +1,7 @@
 clang_CXCursorSet_contains
 clang_CXCursorSet_insert
 clang_CXXMethod_isStatic
+clang_CXXMethod_isVirtual
 clang_annotateTokens
 clang_codeCompleteAt
 clang_codeCompleteGetDiagnostic