Author: compnerd Date: Thu Dec 10 12:45:18 2015 New Revision: 255273 URL: http://llvm.org/viewvc/llvm-project?rev=255273&view=rev Log: libclang: expose dllexport, dllimport attributes
These attributes were previously unexposed. Expose them through the libclang interfaces. Add tests that cover both the MSVC spelling and the GNU spelling. Added: cfe/trunk/test/Index/index-attrs.c cfe/trunk/test/Index/index-attrs.cpp Modified: cfe/trunk/bindings/python/clang/cindex.py cfe/trunk/include/clang-c/Index.h cfe/trunk/tools/libclang/CIndex.cpp cfe/trunk/tools/libclang/CXCursor.cpp Modified: cfe/trunk/bindings/python/clang/cindex.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=255273&r1=255272&r2=255273&view=diff ============================================================================== --- cfe/trunk/bindings/python/clang/cindex.py (original) +++ cfe/trunk/bindings/python/clang/cindex.py Thu Dec 10 12:45:18 2015 @@ -1102,6 +1102,9 @@ CursorKind.CUDASHARED_ATTR = CursorKind( CursorKind.VISIBILITY_ATTR = CursorKind(417) +CursorKind.DLLEXPORT_ATTR = CursorKind(418) +CursorKind.DLLIMPORT_ATTR = CursorKind(419) + ### # Preprocessing CursorKind.PREPROCESSING_DIRECTIVE = CursorKind(500) Modified: cfe/trunk/include/clang-c/Index.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=255273&r1=255272&r2=255273&view=diff ============================================================================== --- cfe/trunk/include/clang-c/Index.h (original) +++ cfe/trunk/include/clang-c/Index.h Thu Dec 10 12:45:18 2015 @@ -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, Added: cfe/trunk/test/Index/index-attrs.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-attrs.c?rev=255273&view=auto ============================================================================== --- cfe/trunk/test/Index/index-attrs.c (added) +++ cfe/trunk/test/Index/index-attrs.c Thu Dec 10 12:45:18 2015 @@ -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) + Added: cfe/trunk/test/Index/index-attrs.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-attrs.cpp?rev=255273&view=auto ============================================================================== --- cfe/trunk/test/Index/index-attrs.cpp (added) +++ cfe/trunk/test/Index/index-attrs.cpp Thu Dec 10 12:45:18 2015 @@ -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) +} + Modified: cfe/trunk/tools/libclang/CIndex.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=255273&r1=255272&r2=255273&view=diff ============================================================================== --- cfe/trunk/tools/libclang/CIndex.cpp (original) +++ cfe/trunk/tools/libclang/CIndex.cpp Thu Dec 10 12:45:18 2015 @@ -4389,6 +4389,10 @@ CXString clang_getCursorKindSpelling(enu 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: Modified: cfe/trunk/tools/libclang/CXCursor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=255273&r1=255272&r2=255273&view=diff ============================================================================== --- cfe/trunk/tools/libclang/CXCursor.cpp (original) +++ cfe/trunk/tools/libclang/CXCursor.cpp Thu Dec 10 12:45:18 2015 @@ -59,6 +59,8 @@ static CXCursorKind GetCursorKind(const 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; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits