summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/bindings/python/clang/cindex.py2
-rw-r--r--clang/include/clang-c/Index.h5
-rw-r--r--clang/test/Index/visibility.c13
-rw-r--r--clang/tools/libclang/CIndex.cpp15
-rw-r--r--clang/tools/libclang/CXCursor.cpp1
5 files changed, 34 insertions, 2 deletions
diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py
index f5caca8572c..6a928c3f1dc 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -1100,6 +1100,8 @@ CursorKind.CUDAGLOBAL_ATTR = CursorKind(414)
CursorKind.CUDAHOST_ATTR = CursorKind(415)
CursorKind.CUDASHARED_ATTR = CursorKind(416)
+CursorKind.VISIBILITY_ATTR = CursorKind(417)
+
###
# Preprocessing
CursorKind.PREPROCESSING_DIRECTIVE = CursorKind(500)
diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 0c73855da8c..af5b93c733c 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -32,7 +32,7 @@
* compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
*/
#define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 30
+#define CINDEX_VERSION_MINOR 31
#define CINDEX_VERSION_ENCODE(major, minor) ( \
((major) * 10000) \
@@ -2279,7 +2279,8 @@ enum CXCursorKind {
CXCursor_CUDAGlobalAttr = 414,
CXCursor_CUDAHostAttr = 415,
CXCursor_CUDASharedAttr = 416,
- CXCursor_LastAttr = CXCursor_CUDASharedAttr,
+ CXCursor_VisibilityAttr = 417,
+ CXCursor_LastAttr = CXCursor_VisibilityAttr,
/* Preprocessing */
CXCursor_PreprocessingDirective = 500,
diff --git a/clang/test/Index/visibility.c b/clang/test/Index/visibility.c
new file mode 100644
index 00000000000..1a71ab9b611
--- /dev/null
+++ b/clang/test/Index/visibility.c
@@ -0,0 +1,13 @@
+// RUN: c-index-test -index-file %s -target i686-pc-linux \
+// RUN: | FileCheck %s -check-prefix CHECK -check-prefix CHECK-LINUX
+// RUN: c-index-test -index-file -Wno-unsupported-visibility %s -target i386-darwin \
+// RUN: | FileCheck %s -check-prefix CHECK -check-prefix CHECK-DARWIN
+
+void __attribute__ (( visibility("default") )) default_visibility();
+// CHECK: <attribute>: attribute(visibility)=default
+void __attribute__ (( visibility("hidden") )) hidden_visibility();
+// CHECK: <attribute>: attribute(visibility)=hidden
+void __attribute__ (( visibility("protected") )) protected_visibility();
+// CHECK-LINUX: <attribute>: attribute(visibility)=protected
+// CHECK-DARWIN: <attribute>: attribute(visibility)=default
+
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index cbba64a431a..2d25a3d7b81 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -3756,6 +3756,19 @@ CXString clang_getCursorSpelling(CXCursor C) {
return cxstring::createRef("packed");
}
+ if (C.kind == CXCursor_VisibilityAttr) {
+ const VisibilityAttr *AA = cast<VisibilityAttr>(cxcursor::getCursorAttr(C));
+ switch (AA->getVisibility()) {
+ case VisibilityAttr::VisibilityType::Default:
+ return cxstring::createRef("default");
+ case VisibilityAttr::VisibilityType::Hidden:
+ return cxstring::createRef("hidden");
+ case VisibilityAttr::VisibilityType::Protected:
+ return cxstring::createRef("protected");
+ }
+ llvm_unreachable("unknown visibility type");
+ }
+
return cxstring::createEmpty();
}
@@ -4237,6 +4250,8 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
return cxstring::createRef("attribute(host)");
case CXCursor_CUDASharedAttr:
return cxstring::createRef("attribute(shared)");
+ case CXCursor_VisibilityAttr:
+ return cxstring::createRef("attribute(visibility)");
case CXCursor_PreprocessingDirective:
return cxstring::createRef("preprocessing directive");
case CXCursor_MacroDefinition:
diff --git a/clang/tools/libclang/CXCursor.cpp b/clang/tools/libclang/CXCursor.cpp
index 257a1921d34..9a866c509dc 100644
--- a/clang/tools/libclang/CXCursor.cpp
+++ b/clang/tools/libclang/CXCursor.cpp
@@ -58,6 +58,7 @@ static CXCursorKind GetCursorKind(const Attr *A) {
case attr::CUDAGlobal: return CXCursor_CUDAGlobalAttr;
case attr::CUDAHost: return CXCursor_CUDAHostAttr;
case attr::CUDAShared: return CXCursor_CUDASharedAttr;
+ case attr::Visibility: return CXCursor_VisibilityAttr;
}
return CXCursor_UnexposedAttr;
OpenPOWER on IntegriCloud