From: Douglas Gregor Date: Thu, 12 May 2011 15:17:24 +0000 (+0000) Subject: Add clang_CXXMethod_isVirtual() to libclang, from Erik Verbruggen! X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=211924b563aa31421836cee7655be729ad02733f;p=clang 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 97c0c7c0da..c79475eff4 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -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 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(D)) + Method = dyn_cast(FunTmpl->getTemplatedDecl()); + else + Method = dyn_cast_or_null(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