diff options
author | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2016-05-31 15:55:51 +0000 |
---|---|---|
committer | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2016-05-31 15:55:51 +0000 |
commit | b743de7fb9dcd66815d66dc52874ee25c7c8f8cc (patch) | |
tree | 4e218b0f0a4bc109d7168277c04d7fcbd239f9c1 /clang/tools/libclang/CIndex.cpp | |
parent | 3a562e6f703a0eaeee7db3674baf7876ed954f91 (diff) | |
download | bcm5719-llvm-b743de7fb9dcd66815d66dc52874ee25c7c8f8cc.tar.gz bcm5719-llvm-b743de7fb9dcd66815d66dc52874ee25c7c8f8cc.zip |
clang-c: Add the clang_getCursorVisibility() API
This patch adds an API for querying the visibility of the entity
referred to by a cursor.
Patch by Michael Wu <mwu@mozilla.com>.
llvm-svn: 271292
Diffstat (limited to 'clang/tools/libclang/CIndex.cpp')
-rw-r--r-- | clang/tools/libclang/CIndex.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index 1aeb3a6397e..78df3ce264c 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -6817,6 +6817,27 @@ CXLinkageKind clang_getCursorLinkage(CXCursor cursor) { } // end: extern "C" //===----------------------------------------------------------------------===// +// Operations for querying visibility of a cursor. +//===----------------------------------------------------------------------===// + +extern "C" { +CXVisibilityKind clang_getCursorVisibility(CXCursor cursor) { + if (!clang_isDeclaration(cursor.kind)) + return CXVisibility_Invalid; + + const Decl *D = cxcursor::getCursorDecl(cursor); + if (const NamedDecl *ND = dyn_cast_or_null<NamedDecl>(D)) + switch (ND->getVisibility()) { + case HiddenVisibility: return CXVisibility_Hidden; + case ProtectedVisibility: return CXVisibility_Protected; + case DefaultVisibility: return CXVisibility_Default; + }; + + return CXVisibility_Invalid; +} +} // end: extern "C" + +//===----------------------------------------------------------------------===// // Operations for querying language of a cursor. //===----------------------------------------------------------------------===// |