Skip to content

libclang: declare blocks interfaces always #6833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions clang/include/clang-c/Index.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
#define CINDEX_VERSION_STRING \
CINDEX_VERSION_STRINGIZE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)

#ifndef __has_feature
#define __has_feature(feature) 0
#endif

LLVM_CLANG_C_EXTERN_C_BEGIN

/** \defgroup CINDEX libclang: C Interface to Clang
Expand Down Expand Up @@ -3687,8 +3691,6 @@ typedef enum CXChildVisitResult (*CXCursorVisitor)(CXCursor cursor,
CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
CXCursorVisitor visitor,
CXClientData client_data);
#ifdef __has_feature
#if __has_feature(blocks)
/**
* Visitor invoked for each cursor found by a traversal.
*
Expand All @@ -3699,17 +3701,19 @@ CINDEX_LINKAGE unsigned clang_visitChildren(CXCursor parent,
* The visitor should return one of the \c CXChildVisitResult values
* to direct clang_visitChildrenWithBlock().
*/
#if __has_feature(blocks)
typedef enum CXChildVisitResult (^CXCursorVisitorBlock)(CXCursor cursor,
CXCursor parent);
#else
typedef struct _CXChildVisitResult *CXCursorVisitorBlock;
#endif

/**
* Visits the children of a cursor using the specified block. Behaves
* identically to clang_visitChildren() in all other respects.
*/
CINDEX_LINKAGE unsigned
clang_visitChildrenWithBlock(CXCursor parent, CXCursorVisitorBlock block);
#endif
#endif

/**
* @}
Expand Down Expand Up @@ -5615,11 +5619,12 @@ CINDEX_LINKAGE CXResult clang_findReferencesInFile(
CINDEX_LINKAGE CXResult clang_findIncludesInFile(
CXTranslationUnit TU, CXFile file, CXCursorAndRangeVisitor visitor);

#ifdef __has_feature
#if __has_feature(blocks)

typedef enum CXVisitorResult (^CXCursorAndRangeVisitorBlock)(CXCursor,
CXSourceRange);
#else
typedef struct _CXCursorAndRangeVisitorBlock *CXCursorAndRangeVisitorBlock;
#endif

CINDEX_LINKAGE
CXResult clang_findReferencesInFileWithBlock(CXCursor, CXFile,
Expand All @@ -5629,9 +5634,6 @@ CINDEX_LINKAGE
CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit, CXFile,
CXCursorAndRangeVisitorBlock);

#endif
#endif

/**
* The client's data object that is associated with a CXFile.
*/
Expand Down