diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2013-05-17 18:38:35 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2013-05-17 18:38:35 +0000 |
commit | 62770bea4b0bd203c7ad09f57cf68bfc16a58612 (patch) | |
tree | 4b5f7b8171e65861e90237aaf0842e9ca0f548e7 /clang/tools | |
parent | 858885578d6bdf82527c2d895368fc0140536b83 (diff) | |
download | bcm5719-llvm-62770bea4b0bd203c7ad09f57cf68bfc16a58612.tar.gz bcm5719-llvm-62770bea4b0bd203c7ad09f57cf68bfc16a58612.zip |
libclang: add a function to check whether a member function is pure virtual
Patch by Seth Fowler.
llvm-svn: 182139
Diffstat (limited to 'clang/tools')
-rw-r--r-- | clang/tools/c-index-test/c-index-test.c | 3 | ||||
-rw-r--r-- | clang/tools/libclang/CIndex.cpp | 14 | ||||
-rw-r--r-- | clang/tools/libclang/libclang.exports | 1 |
3 files changed, 17 insertions, 1 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c index e5752341679..a824a9f041a 100644 --- a/clang/tools/c-index-test/c-index-test.c +++ b/clang/tools/c-index-test/c-index-test.c @@ -694,7 +694,8 @@ static void PrintCursor(CXCursor Cursor, printf(" (static)"); if (clang_CXXMethod_isVirtual(Cursor)) printf(" (virtual)"); - + if (clang_CXXMethod_isPureVirtual(Cursor)) + printf(" (pure)"); if (clang_Cursor_isVariadic(Cursor)) printf(" (variadic)"); diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index db7faabbee3..bd20800993b 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -6118,6 +6118,20 @@ CXFile clang_Module_getTopLevelHeader(CXTranslationUnit TU, //===----------------------------------------------------------------------===// extern "C" { +unsigned clang_CXXMethod_isPureVirtual(CXCursor C) { + if (!clang_isDeclaration(C.kind)) + return 0; + + const CXXMethodDecl *Method = 0; + const Decl *D = cxcursor::getCursorDecl(C); + if (const 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() && Method->isPure()) ? 1 : 0; +} + unsigned clang_CXXMethod_isStatic(CXCursor C) { if (!clang_isDeclaration(C.kind)) return 0; diff --git a/clang/tools/libclang/libclang.exports b/clang/tools/libclang/libclang.exports index 0c9912e5202..4a134d9d246 100644 --- a/clang/tools/libclang/libclang.exports +++ b/clang/tools/libclang/libclang.exports @@ -2,6 +2,7 @@ clang_CXCursorSet_contains clang_CXCursorSet_insert clang_CXIndex_getGlobalOptions clang_CXIndex_setGlobalOptions +clang_CXXMethod_isPureVirtual clang_CXXMethod_isStatic clang_CXXMethod_isVirtual clang_Cursor_getArgument |