| 14 | : BuildDBPath(std::move(BuildDBPath)) {} |
| 15 | |
| 16 | std::unique_ptr<SourceCollection> BuildDBLoader::load() { |
| 17 | std::unique_ptr<const BuildDB> DB = BuildDB::fromJson(BuildDBPath); |
| 18 | assert(DB && "Failed to load Build DB"); |
| 19 | |
| 20 | // load AST |
| 21 | std::vector<std::unique_ptr<clang::ASTUnit>> ASTUnits; |
| 22 | for (auto ASTPath : DB->getASTPaths()) { |
| 23 | auto ASTUnit = clang::ASTUnit::LoadFromASTFile( |
| 24 | ASTPath, clang::RawPCHContainerReader(), clang::ASTUnit::LoadASTOnly, |
| 25 | clang::CompilerInstance::createDiagnostics( |
| 26 | new clang::DiagnosticOptions()), |
| 27 | clang::FileSystemOptions()); |
| 28 | assert(ASTUnit && "AST load failed"); |
| 29 | ASTUnits.push_back(std::move(ASTUnit)); |
| 30 | } |
| 31 | |
| 32 | // load IR |
| 33 | auto LLVMContext = std::make_unique<llvm::LLVMContext>(); |
| 34 | llvm::SMDiagnostic SmDiagnostic; |
| 35 | auto LLVMModule = |
| 36 | llvm::parseIRFile(DB->getBCPath(), SmDiagnostic, *LLVMContext); |
| 37 | assert((LLVMContext && LLVMModule) && "BC load failed"); |
| 38 | |
| 39 | return std::make_unique<SourceCollection>( |
| 40 | std::move(LLVMModule), std::move(LLVMContext), std::move(ASTUnits), |
| 41 | DB->getProjectDir()); |
| 42 | } |
nothing calls this directly
no test coverage detected