Custom compilation database class. More...
Custom compilation database class.
This class provides custom specialization of Clang's CompilationDatabase, which provides the possibility of adjusting the compilation flags after they have been loaded from the compile_commands.json
file.
Definition at line 48 of file compilation_database.h.
#include <compilation_database.h>
Public Member Functions | |
compilation_database (std::unique_ptr< clang::tooling::CompilationDatabase > base, const clanguml::config::config &cfg, bool is_fixed) | |
~compilation_database () override=default | |
std::vector< clang::tooling::CompileCommand > | getCompileCommands (clang::StringRef FilePath) const override |
std::vector< std::string > | getAllFiles () const override |
std::vector< clang::tooling::CompileCommand > | getAllCompileCommands () const override |
const clanguml::config::config & | config () const |
const clang::tooling::CompilationDatabase & | base () const |
std::string | guess_language_from_filename (const std::string &filename) const |
size_t | count_matching_commands (const std::vector< std::string > &files) const |
bool | is_fixed () const |
Determines whether this is a fixed or regular compilation database. | |
Static Public Member Functions | |
static std::unique_ptr< compilation_database > | auto_detect_from_directory (const clanguml::config::config &cfg) |
Private Member Functions | |
bool | match_filename (const clang::tooling::CompileCommand &command, const std::string &file) const |
void | adjust_compilation_database (std::vector< clang::tooling::CompileCommand > &commands) const |
Private Attributes | |
std::unique_ptr< clang::tooling::CompilationDatabase > | base_ |
const clanguml::config::config & | config_ |
bool | is_fixed_ |
clanguml::common::compilation_database::compilation_database | ( | std::unique_ptr< clang::tooling::CompilationDatabase > | base, |
const clanguml::config::config & | cfg, | ||
bool | is_fixed | ||
) |
|
overridedefault |
|
private |
Definition at line 120 of file compilation_database.cc.
|
static |
Loads the compilation database from directory specified on command line or in the configuration file.
cfg | Reference to config instance |
Definition at line 26 of file compilation_database.cc.
const clang::tooling::CompilationDatabase & clanguml::common::compilation_database::base | ( | ) | const |
Returns reference to CompilationDatabase as was loaded from file.
Definition at line 66 of file compilation_database.cc.
const clanguml::config::config & clanguml::common::compilation_database::config | ( | ) | const |
Returns reference to clanguml's config instance.
Definition at line 61 of file compilation_database.cc.
size_t clanguml::common::compilation_database::count_matching_commands | ( | const std::vector< std::string > & | files | ) | const |
Definition at line 105 of file compilation_database.cc.
|
override |
Retrieves and adjusts all compilation commands from the database.
Definition at line 87 of file compilation_database.cc.
|
override |
Returns all files in the database.
Definition at line 71 of file compilation_database.cc.
|
override |
Retrieves and adjusts compilation commands from the database, for a given translation unit.
Definition at line 77 of file compilation_database.cc.
std::string clanguml::common::compilation_database::guess_language_from_filename | ( | const std::string & | filename | ) | const |
Definition at line 96 of file compilation_database.cc.
bool clanguml::common::compilation_database::is_fixed | ( | ) | const |
Determines whether this is a fixed or regular compilation database.
Fixed compilation database doesn't have any compilation commands attached to specific source files, just arguments that should be applied to any file.
Definition at line 59 of file compilation_database.cc.
|
private |
Definition at line 175 of file compilation_database.cc.
|
private |
Pointer to the Clang's original compilation database.
Actual instance of the compilation database is stored in here. The inheritance is just to keep the interface.
Definition at line 132 of file compilation_database.h.
|
private |
Reference to the instance of clanguml config.
Definition at line 137 of file compilation_database.h.
|
private |
True, if this is a fixed compilation database, e.g. loaded from compile_flags.txt
Definition at line 143 of file compilation_database.h.