ΒΆenum CXErrorCode clang_parseTranslationUnit2(
CXIndex CIdx,
const char* source_filename,
const char* const* command_line_args,
int num_command_line_args,
struct CXUnsavedFile* unsaved_files,
unsigned int num_unsaved_files,
unsigned int options,
CXTranslationUnit* out_TU)
enum CXErrorCode clang_parseTranslationUnit2(
CXIndex CIdx,
const char* source_filename,
const char* const* command_line_args,
int num_command_line_args,
struct CXUnsavedFile* unsaved_files,
unsigned int num_unsaved_files,
unsigned int options,
CXTranslationUnit* out_TU)
Description
Parse the given source file and the translation unit corresponding to that file. This routine is the main entry point for the Clang C API, providing the ability to parse a source file into a translation unit that can then be queried by other functions in the API. This routine accepts a set of command-line arguments so that the compilation can be configured in the same way that the compiler is configured on the command line.
Declared at: clang/include/clang-c/Index.h:1418
Parameters
- CXIndex CIdx
- The index object with which the translation unit will be associated.
- const char* source_filename
- The name of the source file to load, or NULL if the source file is included in \c command_line_args.
- const char* const* command_line_args
- The command-line arguments that would be passed to the \c clang executable if it were being invoked out-of-process. These command-line options will be parsed and will affect how the translation unit is parsed. Note that the following options are ignored: '-c', '-emit-ast', '-fsyntax-only' (which is the default), and '-o < output file>'.
- int num_command_line_args
- The number of command-line arguments in\c command_line_args.
- struct CXUnsavedFile* unsaved_files
- the files that have not yet been saved to disk but may be required for parsing, including the contents of those files. The contents and name of these files (as specified by CXUnsavedFile) are copied when necessary, so the client only needs to guarantee their validity until the call to this function returns.
- unsigned int num_unsaved_files
- the number of unsaved file entries in \p unsaved_files.
- unsigned int options
- A bitmask of options that affects how the translation unit is managed but not its compilation. This should be a bitwise OR of the CXTranslationUnit_XXX flags.
- CXTranslationUnit* out_TU
- A non-NULL pointer to store the created\c CXTranslationUnit, describing the parsed code and containing any diagnostics produced by the compiler.
Returns
Zero on success, otherwise returns an error code.