clang-tags
C/C++ source code indexing tool based on libclang
 All Classes Functions Variables Typedefs Groups Pages
Classes | Public Member Functions | Friends | List of all members
LibClang::TranslationUnit Class Reference

Translation unit. More...

#include <translationUnit.hxx>

Classes

struct  TranslationUnit_

Public Member Functions

void reparse ()
 Reparse the translation unit.
void reparse (UnsavedFiles &unsaved)
 Reparse the translation unit.
SourceLocation getLocation (const char *fileName, unsigned int offset)
 Get the source location for a file/offset in the translation unit.
Cursor cursor () const
 Get a cursor to the translation unit.
unsigned int numDiagnostics ()
 Get the number of diagnostic messages for the translation unit.
std::string diagnostic (unsigned int i)
 Get the i-th diagnostic message for the translation unit.
const CXTranslationUnit & raw () const

Friends

class Index
class Cursor

Detailed Description

Translation unit.

This class is a proxy for libclang's CXTranslationUnit type and should provide the same features, except its lifetime should not have to be explicitly managed.

The preferred way to create TranslationUnit objects is calling Index::parse.

Member Function Documentation

Cursor LibClang::TranslationUnit::cursor ( ) const

Get a cursor to the translation unit.

This cursor can be used to start traversing the Abstract Syntax Tree (AST) of the translation unit.

Returns
A Cursor representing the whole translation unit
std::string LibClang::TranslationUnit::diagnostic ( unsigned int  i)

Get the i-th diagnostic message for the translation unit.

These diagnostic messages are those emitted by the compiler when parsing the translation unit.

Parameters
iindex of the diagnostic message (must be less than numDiagnostics())
Returns
A string representing the message
SourceLocation LibClang::TranslationUnit::getLocation ( const char *  fileName,
unsigned int  offset 
)

Get the source location for a file/offset in the translation unit.

Retrieve the source location associated to a given source file and character offset in the translation unit.

Parameters
fileNameThe source file name
offsetThe offset, counted in characters from the file beginning
Returns
A SourceLocation object for the relevant location.
unsigned int LibClang::TranslationUnit::numDiagnostics ( )

Get the number of diagnostic messages for the translation unit.

These diagnostic messages are those emitted by the compiler when parsing the translation unit.

Returns
The number of diagnostic messages
void LibClang::TranslationUnit::reparse ( )

Reparse the translation unit.

Re-parse the source files used to create the translation unit, reading up-to-date source code from the file-system. The source code is re-parsed with the same command-line options than the first time.

void LibClang::TranslationUnit::reparse ( UnsavedFiles unsaved)

Reparse the translation unit.

Re-parse the source files used to create the translation unit, reading up-to-date content from the set of in-memory buffers in unsaved. The source code is re-parsed with the same command-line options than the first time.

Parameters
unsavedA set of unsaved contents for the source files

The documentation for this class was generated from the following files: