clang API Documentation

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

A compilation database that returns a single compile command line. More...

#include <CompilationDatabase.h>

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

List of all members.

Public Member Functions

 FixedCompilationDatabase (Twine Directory, ArrayRef< std::string > CommandLine)
 Constructs a compilation data base from a specified directory and command line.
std::vector< CompileCommandgetCompileCommands (StringRef FilePath) const override
 Returns the given compile command.
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 FixedCompilationDatabaseloadFromCommandLine (int &Argc, const char **Argv, Twine Directory=".")
 Creates a FixedCompilationDatabase from the arguments after "--".

Detailed Description

A compilation database that returns a single compile command line.

Useful when we want a tool to behave more like a compiler invocation.

Definition at line 152 of file CompilationDatabase.h.


Constructor & Destructor Documentation

clang::tooling::FixedCompilationDatabase::FixedCompilationDatabase ( Twine  Directory,
ArrayRef< std::string >  CommandLine 
)

Constructs a compilation data base from a specified directory and command line.

Definition at line 302 of file CompilationDatabase.cpp.

Referenced by loadFromCommandLine().


Member Function Documentation

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

Note: This is always an empty list for the fixed compilation database.

Implements clang::tooling::CompilationDatabase.

Definition at line 323 of file CompilationDatabase.cpp.

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

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

Note: This is always an empty list for the fixed compilation database.

Implements clang::tooling::CompilationDatabase.

Definition at line 318 of file CompilationDatabase.cpp.

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

Returns the given compile command.

Will always return a vector with one entry that contains the directory and command line specified at construction with "clang-tool" as argv[0] and 'FilePath' as positional argument.

Implements clang::tooling::CompilationDatabase.

Definition at line 311 of file CompilationDatabase.cpp.

FixedCompilationDatabase * clang::tooling::FixedCompilationDatabase::loadFromCommandLine ( int &  Argc,
const char **  Argv,
Twine  Directory = "." 
) [static]

Creates a FixedCompilationDatabase from the arguments after "--".

Parses the given command line for "--". If "--" is found, the rest of the arguments will make up the command line in the returned FixedCompilationDatabase. The arguments after "--" must not include positional parameters or the argv[0] of the tool. Those will be added by the FixedCompilationDatabase when a CompileCommand is requested. The argv[0] of the returned command line will be "clang-tool".

Returns NULL in case "--" is not found.

The argument list is meant to be compatible with normal llvm command line parsing in main methods. int main(int argc, char **argv) { std::unique_ptr<FixedCompilationDatabase> Compilations( FixedCompilationDatabase::loadFromCommandLine(argc, argv)); cl::ParseCommandLineOptions(argc, argv); ... }

Parameters:
ArgcThe number of command line arguments - will be changed to the number of arguments before "--", if "--" was found in the argument list.
ArgvPoints to the command line arguments.
DirectoryThe base directory used in the FixedCompilationDatabase.

Definition at line 286 of file CompilationDatabase.cpp.

References CommandLine, FixedCompilationDatabase(), and clang::tooling::stripPositionalArgs().

Referenced by clang::tooling::CommonOptionsParser::CommonOptionsParser().


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