MCPcopy Create free account
hub / github.com/Samsung/UTopia / load

Method load

lib/sourceloader/BuildDBLoader.cpp:16–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14 : BuildDBPath(std::move(BuildDBPath)) {}
15
16std::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}

Callers

nothing calls this directly

Calls 3

getASTPathsMethod · 0.80
getBCPathMethod · 0.80
getProjectDirMethod · 0.80

Tested by

no test coverage detected