ΒΆvoid clang_annotateTokens(CXTranslationUnit TU,
                          CXToken* Tokens,
                          unsigned int NumTokens,
                          CXCursor* Cursors)

Description

Annotate the given set of tokens by providing cursors for each token that can be mapped to a specific entity within the abstract syntax tree. This token-annotation routine is equivalent to invoking clang_getCursor() for the source locations of each of the tokens. The cursors provided are filtered, so that only those cursors that have a direct correspondence to the token are accepted. For example, given a function call \c f(x), clang_getCursor() would provide the following cursors: * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'. * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'. * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'. Only the first and last of these cursors will occur within the annotate, since the tokens "f" and "x' directly refer to a function and a variable, respectively, but the parentheses are just a small part of the full syntax of the function call expression, which is not provided as an annotation.

Declared at: clang/include/clang-c/Index.h:5151

Parameters

CXTranslationUnit TU
the translation unit that owns the given tokens.
CXToken* Tokens
the set of tokens to annotate.
unsigned int NumTokens
the number of tokens in \p Tokens.
CXCursor* Cursors
an array of \p NumTokens cursors, whose contents will be replaced with the cursors corresponding to each token.