From cddafd3969977630d9bbec724dd09b6cb97fd9fd Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Thu, 6 Oct 2011 07:00:54 +0000 Subject: [libclang] Introduce clang_findReferencesInFile which accepts a cursor, a file, and a callback and finds all identifier references of the cursor in the file. rdar://7948304 llvm-svn: 141277 --- clang/include/clang-c/Index.h | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'clang/include/clang-c') diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h index 65d05e50943..05ac19bb23d 100644 --- a/clang/include/clang-c/Index.h +++ b/clang/include/clang-c/Index.h @@ -1857,6 +1857,7 @@ enum CXCursorKind { */ typedef struct { enum CXCursorKind kind; + int xdata; void *data[3]; } CXCursor; @@ -3775,6 +3776,53 @@ CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index, */ CINDEX_LINKAGE void clang_remap_dispose(CXRemapping); +/** + * @} + */ + +/** \defgroup CINDEX_HIGH Higher level API functions + * + * @{ + */ + +enum CXVisitorResult { + CXVisit_Break, + CXVisit_Continue +}; + +typedef struct { + void *context; + enum CXVisitorResult (*visit)(void *context, CXCursor, CXSourceRange); +} CXCursorAndRangeVisitor; + +/** + * \brief Find references of a declaration in a specific file. + * + * \param cursor pointing to a declaration or a reference of one. + * + * \param file to search for references. + * + * \param visitor callback that will receive pairs of CXCursor/CXSourceRange for + * each reference found. + * The CXSourceRange will point inside the file; if the reference is inside + * a macro (and not a macro argument) the CXSourceRange will be invalid. + */ +CINDEX_LINKAGE void clang_findReferencesInFile(CXCursor cursor, CXFile file, + CXCursorAndRangeVisitor visitor); + +#ifdef __has_feature +# if __has_feature(blocks) + +typedef enum CXVisitorResult + (^CXCursorAndRangeVisitorBlock)(CXCursor, CXSourceRange); + +CINDEX_LINKAGE +void clang_findReferencesInFileWithBlock(CXCursor, CXFile, + CXCursorAndRangeVisitorBlock); + +# endif +#endif + /** * @} */ -- cgit v1.2.3