Instantiator
Generate c++ template instantiations
Loading...
Searching...
No Matches
AllASTBuilderAction.cpp
Go to the documentation of this file.
2
3#include "spdlog/spdlog.h"
4
5#include "clang/Basic/Diagnostic.h"
6#include "clang/Basic/DiagnosticIDs.h"
7#include "clang/Basic/FileManager.h"
8#include "llvm/ADT/IntrusiveRefCntPtr.h"
9
10bool AllASTBuilderAction::runInvocation(std::shared_ptr<clang::CompilerInvocation> Invocation,
11 clang::FileManager* Files,
12 std::shared_ptr<clang::PCHContainerOperations> PCHContainerOps,
13 clang::DiagnosticConsumer* DiagConsumer)
14{
15#if INSTANTIATOR_LLVM_MAJOR < 20
16 std::unique_ptr<clang::ASTUnit> AST =
17 clang::ASTUnit::LoadFromCompilerInvocation(Invocation,
18 std::move(PCHContainerOps),
19 clang::CompilerInstance::createDiagnostics(&Invocation->getDiagnosticOpts(),
20 DiagConsumer,
21 /*ShouldOwnClient=*/false),
22 Files);
23#else
24 auto diag_ids = llvm::makeIntrusiveRefCnt<clang::DiagnosticIDs>();
25 auto diag_engine = clang::DiagnosticsEngine(diag_ids, Invocation->DiagnosticOpts);
26 std::unique_ptr<clang::ASTUnit> AST = clang::ASTUnit::LoadFromCompilerInvocation(
27 Invocation,
28 std::move(PCHContainerOps),
29 clang::CompilerInstance::createDiagnostics(*createVFSFromCompilerInvocation(*Invocation, diag_engine),
30 &Invocation->getDiagnosticOpts(),
31 DiagConsumer,
32 /*ShouldOwnClient=*/false),
33 Files);
34#endif
35 if(!AST or AST->getDiagnostics().hasUncompilableErrorOccurred()) return false;
36
37 spdlog::debug("Parsed AST for {}", AST->getOriginalSourceFileName().str());
38 ASTs.push_back(std::move(AST));
39 return true;
40}
std::vector< std::unique_ptr< clang::ASTUnit > > & ASTs
bool runInvocation(std::shared_ptr< clang::CompilerInvocation > Invocation, clang::FileManager *Files, std::shared_ptr< clang::PCHContainerOperations > PCHContainerOps, clang::DiagnosticConsumer *DiagConsumer) override