Skip to content

Commit 4a6d335

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. (cherry picked from commit ce5ad23)
1 parent 0c72892 commit 4a6d335

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
@@ -3687,8 +3691,6 @@ typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
36873691
CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
36883692
CXCursorVisitor visitor,
36893693
CXClientData client_data);
3690-
#ifdef __has_feature
3691-
#if __has_feature(blocks)
36923694
/**
36933695
* Visitor invoked for each cursor found by a traversal.
36943696
*
@@ -3699,17 +3701,19 @@ CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
36993701
* The visitor should return one of the \c CXChildVisitResult values
37003702
* to direct clang_visitChildrenWithBlock().
37013703
*/
3704+
#if __has_feature(blocks)
37023705
typedef enum CXChildVisitResult (^CXCursorVisitorBlock)(CXCursor cursor,
37033706
CXCursor parent);
3707+
#else
3708+
typedef _CXChildVisitResult *CXCursorVisitorBlock;
3709+
#endif
37043710

37053711
/**
37063712
* Visits the children of a cursor using the specified block. Behaves
37073713
* identically to clang_visitChildren() in all other respects.
37083714
*/
37093715
CINDEX_LINKAGE unsigned
37103716
clang_visitChildrenWithBlock(CXCursor parent, CXCursorVisitorBlock block);
3711-
#endif
3712-
#endif
37133717

37143718
/**
37153719
* @}
@@ -5615,11 +5619,12 @@ CINDEX_LINKAGE CXResult clang_findReferencesInFile(
56155619
CINDEX_LINKAGE CXResult clang_findIncludesInFile(
56165620
CXTranslationUnit TU, CXFile file, CXCursorAndRangeVisitor visitor);
56175621

5618-
#ifdef __has_feature
56195622
#if __has_feature(blocks)
5620-
56215623
typedef enum CXVisitorResult (^CXCursorAndRangeVisitorBlock)(CXCursor,
56225624
CXSourceRange);
5625+
#else
5626+
typedef struct _CXCursorAndRangeVisitorBlock *CXCursorAndRangeVisitorBlock;
5627+
#endif
56235628

56245629
CINDEX_LINKAGE
56255630
CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
@@ -5629,9 +5634,6 @@ CINDEX_LINKAGE
56295634
CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
56305635
CXCursorAndRangeVisitorBlock);
56315636

5632-
#endif
5633-
#endif
5634-
56355637
/**
56365638
* The client's data object that is associated with a CXFile.
56375639
*/

0 commit comments

Comments
 (0)