summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/bindings/python/clang/cindex.py3
-rw-r--r--clang/include/clang-c/Index.h6
-rw-r--r--clang/test/Index/index-attrs.c16
-rw-r--r--clang/test/Index/index-attrs.cpp50
-rw-r--r--clang/tools/libclang/CIndex.cpp4
-rw-r--r--clang/tools/libclang/CXCursor.cpp2
6 files changed, 79 insertions, 2 deletions
diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py
index 06a18934939..e4b38769b77 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -1102,6 +1102,9 @@ CursorKind.CUDASHARED_ATTR = CursorKind(416)
CursorKind.VISIBILITY_ATTR = CursorKind(417)
+CursorKind.DLLEXPORT_ATTR = CursorKind(418)
+CursorKind.DLLIMPORT_ATTR = CursorKind(419)
+
###
# Preprocessing
CursorKind.PREPROCESSING_DIRECTIVE = CursorKind(500)
diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 5541322ae8b..5aebf0973f5 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 31
+#define CINDEX_VERSION_MINOR 32
#define CINDEX_VERSION_ENCODE(major, minor) ( \
((major) * 10000) \
@@ -2297,7 +2297,9 @@ enum CXCursorKind {
CXCursor_CUDAHostAttr = 415,
CXCursor_CUDASharedAttr = 416,
CXCursor_VisibilityAttr = 417,
- CXCursor_LastAttr = CXCursor_VisibilityAttr,
+ CXCursor_DLLExport = 418,
+ CXCursor_DLLImport = 419,
+ CXCursor_LastAttr = CXCursor_DLLImport,
/* Preprocessing */
CXCursor_PreprocessingDirective = 500,
diff --git a/clang/test/Index/index-attrs.c b/clang/test/Index/index-attrs.c
new file mode 100644
index 00000000000..d526721f5b2
--- /dev/null
+++ b/clang/test/Index/index-attrs.c
@@ -0,0 +1,16 @@
+// RUN: c-index-test -index-file -check-prefix CHECK %s -target armv7-windows-gnu -fdeclspec
+
+void __declspec(dllexport) export_function(void) {}
+// CHECK: [indexDeclaraton]: kind: function | name: export_function | {{.*}} | lang: C
+// CHECK: <attribute>: attribute(dllexport)
+void __attribute__((dllexport)) export_gnu_attribute(void) {}
+// CHECK: [indexDeclaration] kind: function | name: export_gnu_attribute | {{.*}} | lang: C
+// CHECK: <attribute>: attribute(dllexport)
+
+void __declspec(dllimport) import_function(void);
+// CHECK: [indexDeclaration] kind: function | name: import_function | {{.*}} | lang: C
+// CHECK: <attribute>: attribute(dllimport)
+void __attribute__((dllimport)) import_gnu_attribute(void);
+// CHECK: [indexDeclaration] kind: function | name: import_gnu_function | {{.*}} | lang: C
+// CHECK: <attribute>: attribute(dllimport)
+
diff --git a/clang/test/Index/index-attrs.cpp b/clang/test/Index/index-attrs.cpp
new file mode 100644
index 00000000000..b6100acf880
--- /dev/null
+++ b/clang/test/Index/index-attrs.cpp
@@ -0,0 +1,50 @@
+// RUN: c-index-test -index-file -check-prefix CHECK %s -target armv7-windows-gnu -fdeclspec
+
+struct __declspec(dllexport) export_s {
+ void m();
+};
+// CHECK: [indexDeclaration]: kind: struct | name: export_s | {{.*}} | lang: C++
+// CHECK: <attribute>: attribute(dllexport)
+// CHECK: [indexDeclaration]: kind: c++-instance-method | name: m | {{.*}} | lang: C++
+// CHECK: <attribute>: attribute(dllexport)
+
+struct __declspec(dllimport) import_s {
+ void m();
+};
+// CHECK: [indexDeclaration]: kind: struct | name: import_s | {{.*}} | lang: C++
+// CHECK: <attribute>: attribute(dllimport)
+// CHECK: [indexDeclaration]: kind: c++-instance-method | name: m | {{.*}} | lang: C++
+// CHECK: <attribute>: attribute(dllimport)
+
+class __attribute__((dllexport)) export_gnu_s {
+ void m();
+};
+// CHECK: [indexDeclaration]: kind: struct | name: export_gnu_s | {{.*}} | lang: C++
+// CHECK: <attribute>: attribute(dllexport)
+// CHECK: [indexDeclaration]: kind: c++-instance-method | name: m | {{.*}} | lang: C++
+// CHECK: <attribute>: attribute(dllexport)
+
+class __attribute__((dllimport)) import_gnu_s {
+ void m();
+};
+// CHECK: [indexDeclaration]: kind: struct | name: import_gnu_s | {{.*}} | lang: C++
+// CHECK: <attribute>: attribute(dllimport)
+// CHECK: [indexDeclaration]: kind: c++-instance-method | name: m | {{.*}} | lang: C++
+// CHECK: <attribute>: attribute(dllimport)
+
+extern "C" void __declspec(dllexport) export_function(void) {}
+// CHECK: [indexDeclaraton]: kind: function | name: export_function | {{.*}} | lang: C
+// CHECK: <attribute>: attribute(dllexport)
+extern "C" void __attribute__((dllexport)) export_gnu_function(void) {}
+// CHECK: [indexDeclaraton]: kind: function | name: export_gnu_function | {{.*}} | lang: C
+// CHECK: <attribute>: attribute(dllexport)
+
+extern "C" {
+void __declspec(dllimport) import_function(void);
+// CHECK: [indexDeclaration] kind: function | name: import_function | {{.*}} | lang: C
+// CHECK: <attribute>: attribute(dllimport)
+void __attribute__((dllimport)) import_gnu_function(void);
+// CHECK: [indexDeclaration] kind: function | name: import_gnu_function | {{.*}} | lang: C
+// CHECK: <attribute>: attribute(dllimport)
+}
+
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index c1143715d65..486d24a5fb9 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -4389,6 +4389,10 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
return cxstring::createRef("attribute(shared)");
case CXCursor_VisibilityAttr:
return cxstring::createRef("attribute(visibility)");
+ case CXCursor_DLLExport:
+ return cxstring::createRef("attribute(dllexport)");
+ case CXCursor_DLLImport:
+ return cxstring::createRef("attribute(dllimport)");
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 fbf0aaf049d..a9809811663 100644
--- a/clang/tools/libclang/CXCursor.cpp
+++ b/clang/tools/libclang/CXCursor.cpp
@@ -59,6 +59,8 @@ static CXCursorKind GetCursorKind(const Attr *A) {
case attr::CUDAHost: return CXCursor_CUDAHostAttr;
case attr::CUDAShared: return CXCursor_CUDASharedAttr;
case attr::Visibility: return CXCursor_VisibilityAttr;
+ case attr::DLLExport: return CXCursor_DLLExport;
+ case attr::DLLImport: return CXCursor_DLLImport;
}
return CXCursor_UnexposedAttr;
OpenPOWER on IntegriCloud