16 clang::FileManager* Files,
17 std::shared_ptr<clang::PCHContainerOperations> PCHContainerOps,
18 clang::DiagnosticConsumer* DiagConsumer)
20 spdlog::debug(
"Processing {}",
file);
22 spdlog::debug(
"cached={}", is_cached_on_disk);
23#if INSTANTIATOR_LLVM_MAJOR > 19
24 auto diag_ids = llvm::makeIntrusiveRefCnt<clang::DiagnosticIDs>();
25 auto diag_engine = clang::DiagnosticsEngine(diag_ids, Invocation->DiagnosticOpts);
27 if(is_cached_on_disk) {
28 clang::CompilerInstance CI;
29 CI.setInvocation(Invocation);
30#if INSTANTIATOR_LLVM_MAJOR < 20
31 CI.createDiagnostics(DiagConsumer,
false);
33 CI.createDiagnostics(*createVFSFromCompilerInvocation(*Invocation, diag_engine), DiagConsumer,
false);
36 clang::DiagnosticsEngine* DiagEngine = &CI.getDiagnostics();
37#if INSTANTIATOR_LLVM_MAJOR > 16
38 AST = clang::ASTUnit::LoadFromASTFile((
tmpdir /
file.filename().replace_extension(
"ast")).string(),
39 CI.getPCHContainerReader(),
40 clang::ASTUnit::WhatToLoad::LoadEverything,
41 llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine>(DiagEngine),
42 CI.getFileSystemOpts(),
43 CI.getHeaderSearchOptsPtr());
45 AST = clang::ASTUnit::LoadFromASTFile((
tmpdir /
file.filename().replace_extension(
"ast")).string(),
46 CI.getPCHContainerReader(),
47 clang::ASTUnit::WhatToLoad::LoadEverything,
48 llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine>(DiagEngine),
49 CI.getFileSystemOpts());
52#if INSTANTIATOR_LLVM_MAJOR < 20
53 AST = clang::ASTUnit::LoadFromCompilerInvocation(Invocation,
54 std::move(PCHContainerOps),
55 clang::CompilerInstance::createDiagnostics(&Invocation->getDiagnosticOpts(),
60 AST = clang::ASTUnit::LoadFromCompilerInvocation(
62 std::move(PCHContainerOps),
63 clang::CompilerInstance::createDiagnostics(*createVFSFromCompilerInvocation(*Invocation, diag_engine),
64 &Invocation->getDiagnosticOpts(),
69 AST->Save((
tmpdir /
file.filename().replace_extension(
"ast")).string());
71 if(!
AST or
AST->getDiagnostics().hasUncompilableErrorOccurred())
return false;