2017-02-16 09:35:30 +00:00
|
|
|
#include "CompilationDatabase.h"
|
|
|
|
|
2017-02-22 08:52:00 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
clang::CompilationDatabase::CompilationDatabase(const std::string& project_path) {
|
2017-02-16 09:35:30 +00:00
|
|
|
CXCompilationDatabase_Error error;
|
|
|
|
cx_db = clang_CompilationDatabase_fromDirectory(project_path.c_str(), &error);
|
2017-02-22 08:52:00 +00:00
|
|
|
if (error == CXCompilationDatabase_CanNotLoadDatabase) {
|
|
|
|
std::cerr << "[FATAL]: Unable to load compile_commands.json located at \""
|
|
|
|
<< project_path << "\"";
|
|
|
|
exit(1);
|
2017-02-16 09:35:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
clang::CompilationDatabase::~CompilationDatabase() {
|
|
|
|
clang_CompilationDatabase_dispose(cx_db);
|
|
|
|
}
|