Skip to content

Commit ce5ad23

Browse files
committed
libclang: declare blocks interfaces always
The implementation of these methods is not reliant on the availability of the Blocks extension in the compiler. However, when building on Windows, the interface declaration is important for the attribution of the DLL storage. Without the attribution, the method implementation is built but not made available as part of the ABI. Use a check for the blocks extension to determine how method signature is viewed rather than controlling whether it is part of the interface.
1 parent 9fb9c77 commit ce5ad23

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

clang/include/clang-c/Index.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
#define CINDEX_VERSION_STRING \
4949
CINDEX_VERSION_STRINGIZE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)
5050

51+
#ifndef __has_feature
52+
#define __has_feature(feature) 0
53+
#endif
54+
5155
LLVM_CLANG_C_EXTERN_C_BEGIN
5256

5357
/** \defgroup CINDEX libclang: C Interface to Clang
@@ -3856,8 +3860,6 @@ typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
38563860
CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
38573861
CXCursorVisitor visitor,
38583862
CXClientData client_data);
3859-
#ifdef __has_feature
3860-
#if __has_feature(blocks)
38613863
/**
38623864
* Visitor invoked for each cursor found by a traversal.
38633865
*
@@ -3868,17 +3870,19 @@ CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
38683870
* The visitor should return one of the \c CXChildVisitResult values
38693871
* to direct clang_visitChildrenWithBlock().
38703872
*/
3873+
#if __has_feature(blocks)
38713874
typedef enum CXChildVisitResult (^CXCursorVisitorBlock)(CXCursor cursor,
38723875
CXCursor parent);
3876+
#else
3877+
typedef _CXChildVisitResult *CXCursorVisitorBlock;
3878+
#endif
38733879

38743880
/**
38753881
* Visits the children of a cursor using the specified block. Behaves
38763882
* identically to clang_visitChildren() in all other respects.
38773883
*/
38783884
CINDEX_LINKAGE unsigned
38793885
clang_visitChildrenWithBlock(CXCursor parent, CXCursorVisitorBlock block);
3880-
#endif
3881-
#endif
38823886

38833887
/**
38843888
* @}
@@ -5879,11 +5883,12 @@ CINDEX_LINKAGE CXResult clang_findReferencesInFile(
58795883
CINDEX_LINKAGE CXResult clang_findIncludesInFile(
58805884
CXTranslationUnit TU, CXFile file, CXCursorAndRangeVisitor visitor);
58815885

5882-
#ifdef __has_feature
58835886
#if __has_feature(blocks)
5884-
58855887
typedef enum CXVisitorResult (^CXCursorAndRangeVisitorBlock)(CXCursor,
58865888
CXSourceRange);
5889+
#else
5890+
typedef struct _CXCursorAndRangeVisitorBlock *CXCursorAndRangeVisitorBlock;
5891+
#endif
58875892

58885893
CINDEX_LINKAGE
58895894
CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
@@ -5893,9 +5898,6 @@ CINDEX_LINKAGE
58935898
CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
58945899
CXCursorAndRangeVisitorBlock);
58955900

5896-
#endif
5897-
#endif
5898-
58995901
/**
59005902
* The client's data object that is associated with a CXFile.
59015903
*/

0 commit comments

Comments
 (0)