Skip to content

Commit

Permalink
Fixed handling of fixed compilation database on MSVC (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkryza committed Nov 21, 2024
1 parent 4b3d613 commit 1645621
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/common/compilation_database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ compilation_database::auto_detect_from_directory(
auto res = clang::tooling::CompilationDatabase::autoDetectFromDirectory(
cfg.compilation_database_dir(), error_message);

if (!error_message.empty())
if (!error_message.empty() || res.get() == nullptr)
throw error::compilation_database_error(error_message);

bool is_fixed{false};
if (dynamic_cast<clang::tooling::FixedCompilationDatabase *>(res.get()) !=
nullptr) {
is_fixed = true;
}
// This is a workaround to determine whether Clang loaded a fixed compilation
// database or proper. This cannot be done with dynamic_cast if RTTI was
// not enabled in the LLVM build
bool is_fixed{!res->getCompileCommands("no_such_file.no_such_extension").empty()};

return std::make_unique<compilation_database>(
std::move(res), cfg, is_fixed);
Expand Down

0 comments on commit 1645621

Please sign in to comment.