clang API Documentation

Public Member Functions | Static Public Member Functions
clang::tooling::JSONCompilationDatabase Class Reference

A JSON based compilation database. More...

#include <JSONCompilationDatabase.h>

Inheritance diagram for clang::tooling::JSONCompilationDatabase:
Inheritance graph
[legend]
Collaboration diagram for clang::tooling::JSONCompilationDatabase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

std::vector< CompileCommandgetCompileCommands (StringRef FilePath) const override
 Returns all compile comamnds in which the specified file was compiled.
std::vector< std::string > getAllFiles () const override
 Returns the list of all files available in the compilation database.
std::vector< CompileCommandgetAllCompileCommands () const override
 Returns all compile commands for all the files in the compilation database.

Static Public Member Functions

static std::unique_ptr
< JSONCompilationDatabase
loadFromFile (StringRef FilePath, std::string &ErrorMessage)
 Loads a JSON compilation database from the specified file.
static std::unique_ptr
< JSONCompilationDatabase
loadFromBuffer (StringRef DatabaseString, std::string &ErrorMessage)
 Loads a JSON compilation database from a data buffer.

Detailed Description

A JSON based compilation database.

JSON compilation database files must contain a list of JSON objects which provide the command lines in the attributes 'directory', 'command' and 'file': [ { "directory": "<working directory of the compile>", "command": "<compile command line>", "file": "<path to source file>" }, ... ] Each object entry defines one compile action. The specified file is considered to be the main source file for the translation unit.

JSON compilation databases can for example be generated in CMake projects by setting the flag -DCMAKE_EXPORT_COMPILE_COMMANDS.

Definition at line 50 of file JSONCompilationDatabase.h.


Member Function Documentation

Returns all compile commands for all the files in the compilation database.

Implements clang::tooling::CompilationDatabase.

Definition at line 207 of file JSONCompilationDatabase.cpp.

std::vector< std::string > clang::tooling::JSONCompilationDatabase::getAllFiles ( ) const [override, virtual]

Returns the list of all files available in the compilation database.

These are the 'file' entries of the JSON objects.

Implements clang::tooling::CompilationDatabase.

Definition at line 192 of file JSONCompilationDatabase.cpp.

std::vector< CompileCommand > clang::tooling::JSONCompilationDatabase::getCompileCommands ( StringRef  FilePath) const [override, virtual]

Returns all compile comamnds in which the specified file was compiled.

FIXME: Currently FilePath must be an absolute path inside the source directory which does not have symlinks resolved.

Implements clang::tooling::CompilationDatabase.

Definition at line 173 of file JSONCompilationDatabase.cpp.

References clang::diag::Error, and clang::tooling::FileMatchTrie::findEquivalent().

std::unique_ptr< JSONCompilationDatabase > clang::tooling::JSONCompilationDatabase::loadFromBuffer ( StringRef  DatabaseString,
std::string &  ErrorMessage 
) [static]

Loads a JSON compilation database from a data buffer.

Returns NULL and sets ErrorMessage if the database could not be loaded.

Definition at line 161 of file JSONCompilationDatabase.cpp.

std::unique_ptr< JSONCompilationDatabase > clang::tooling::JSONCompilationDatabase::loadFromFile ( StringRef  FilePath,
std::string &  ErrorMessage 
) [static]

Loads a JSON compilation database from the specified file.

Returns NULL and sets ErrorMessage if the database could not be loaded from the given file.

Definition at line 145 of file JSONCompilationDatabase.cpp.


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