diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-10-06 07:00:54 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-10-06 07:00:54 +0000 |
commit | aed123ec3cc37e457fe20a6158fdadf8849ad916 (patch) | |
tree | 3c966b7fabc78150142d829f20b4be00cceb3d0a /include/clang-c | |
parent | b11be041e4f05519a2eabf6a99429ba6110f1ca9 (diff) |
[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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141277 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang-c')
-rw-r--r-- | include/clang-c/Index.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 65d05e5094..05ac19bb23 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -1857,6 +1857,7 @@ enum CXCursorKind { */ typedef struct { enum CXCursorKind kind; + int xdata; void *data[3]; } CXCursor; @@ -3779,6 +3780,53 @@ 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 + +/** + * @} + */ + /** * @} */ |