;
32ChainedIncludesSource(std::vector<std::unique_ptr<CompilerInstance>> CIs)
33: CIs(
std::move(CIs)) {}
43 for(
unsignedi = 0, e = CIs.size(); i != e; ++i) {
45CIs[i]->getASTContext().getExternalSource()) {
46eSrc->getMemoryBufferSizes(sizes);
52std::vector<std::unique_ptr<CompilerInstance>> CIs;
62std::unique_ptr<ASTReader> Reader;
66 "", DisableValidationForModuleKind::PCH));
67 for(
unsignedti = 0; ti < bufNames.size(); ++ti) {
68StringRef sr(bufNames[ti]);
69Reader->addInMemoryBuffer(sr, std::move(MemBufs[ti]));
71Reader->setDeserializationListener(deserialListener);
77 returnReader.release();
94assert(!includes.empty() &&
"No '-chain-include' in options!");
96std::vector<std::unique_ptr<CompilerInstance>> CIs;
102 for(
unsignedi = 0, e = includes.size(); i != e; ++i) {
103 boolfirstInclude = (i == 0);
104std::unique_ptr<CompilerInvocation> CInvok;
107CInvok->getPreprocessorOpts().ChainedIncludes.clear();
108CInvok->getPreprocessorOpts().ImplicitPCHInclude.clear();
109CInvok->getPreprocessorOpts().DisablePCHOrModuleValidation =
110DisableValidationForModuleKind::PCH;
111CInvok->getPreprocessorOpts().Includes.clear();
112CInvok->getPreprocessorOpts().MacroIncludes.clear();
113CInvok->getPreprocessorOpts().Macros.clear();
115CInvok->getFrontendOpts().Inputs.clear();
117CInvok->getFrontendOpts().Inputs.push_back(InputFile);
125std::unique_ptr<CompilerInstance> Clang(
127Clang->setInvocation(std::move(CInvok));
128Clang->setDiagnostics(Diags.get());
130Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
131Clang->createFileManager();
132Clang->createSourceManager(Clang->getFileManager());
134Clang->getDiagnosticClient().BeginSourceFile(Clang->getLangOpts(),
135&Clang->getPreprocessor());
136Clang->createASTContext();
138 autoBuffer = std::make_shared<PCHBuffer>();
140 autoconsumer = std::make_unique<PCHGenerator>(
141Clang->getPreprocessor(), Clang->getModuleCache(),
"-",
"",
142Buffer, Extensions,
true);
143Clang->getASTContext().setASTMutationListener(
144consumer->GetASTMutationListener());
145Clang->setASTConsumer(std::move(consumer));
146Clang->createSema(
TU_Prefix,
nullptr);
153assert(!SerialBufs.empty());
157 for(
auto&SB : SerialBufs)
158Bufs.push_back(llvm::MemoryBuffer::getMemBuffer(SB->getBuffer()));
159std::string pchName = includes[i-1];
160llvm::raw_string_ostream os(pchName);
162serialBufNames.push_back(pchName);
166*Clang, pchName, Bufs, serialBufNames,
167Clang->getASTConsumer().GetASTDeserializationListener());
170Clang->setASTReader(Reader);
171Clang->getASTContext().setExternalSource(Reader);
174 if(!Clang->InitializeSourceManager(InputFile))
178Clang->getDiagnosticClient().EndSourceFile();
179assert(Buffer->IsComplete &&
"serialization did not complete");
180 auto&serialAST = Buffer->Data;
181SerialBufs.push_back(llvm::MemoryBuffer::getMemBufferCopy(
182StringRef(serialAST.data(), serialAST.size())));
184CIs.push_back(std::move(Clang));
187assert(!SerialBufs.empty());
188std::string pchName = includes.back() +
".pch-final";
189serialBufNames.push_back(pchName);
195llvm::makeIntrusiveRefCnt<ChainedIncludesSource>(std::move(CIs));
196 returnllvm::makeIntrusiveRefCnt<MultiplexExternalSemaSource>(
197ChainedSrc.get(), Reader.get());
Defines enum values for all the target-independent builtin functions.
static ASTReader * createASTReader(CompilerInstance &CI, StringRef pchFile, SmallVectorImpl< std::unique_ptr< llvm::MemoryBuffer > > &MemBufs, SmallVectorImpl< std::string > &bufNames, ASTDeserializationListener *deserialListener=nullptr)
Defines the clang::Preprocessor interface.
Reads an AST files chain containing the contents of a translation unit.
@ ARR_None
The client can't handle any AST loading failures.
@ Success
The control block was read successfully.
@ ConfigurationMismatch
The AST file was written with a different language/target configuration.
@ OutOfDate
The AST file is out-of-date relative to its input files, and needs to be regenerated.
@ Failure
The AST file itself appears corrupted.
@ VersionMismatch
The AST file was written by a different version of Clang.
@ HadErrors
The AST file has errors.
@ Missing
The AST file was missing.
void initializeBuiltins(IdentifierTable &Table, const LangOptions &LangOpts)
Mark the identifiers for all the builtins with their appropriate builtin ID # and mark any non-portab...
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
const PCHContainerReader & getPCHContainerReader() const
Return the appropriate PCHContainerReader depending on the current CodeGenOptions.
InMemoryModuleCache & getModuleCache() const
Preprocessor & getPreprocessor() const
Return the current preprocessor.
ASTContext & getASTContext() const
FrontendOptions & getFrontendOpts()
CompilerInvocation & getInvocation()
PreprocessorOptions & getPreprocessorOpts()
std::shared_ptr< PCHContainerOperations > getPCHContainerOperations() const
DiagnosticOptions & getDiagnosticOpts()
Helper class for holding the data necessary to invoke the compiler.
Used for handling and querying diagnostic IDs.
Options for controlling the compiler diagnostics engine.
Concrete class used by the front-end to report problems and issues.
Abstract interface for external sources of AST nodes.
MemoryBufferSizes getMemoryBufferSizes() const
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memor...
An abstract interface that should be implemented by external AST sources that also provide informatio...
An input file for the front end.
SmallVector< FrontendInputFile, 0 > Inputs
The input files and their types.
The kind of a file that we've been handed as an input.
std::vector< std::string > ChainedIncludes
Headers that will be converted to chained PCHs in memory.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
void setPredefines(std::string P)
Set the predefines for this Preprocessor.
IdentifierTable & getIdentifierTable()
Builtin::Context & getBuiltinInfo()
const LangOptions & getLangOpts() const
Encodes a location in the source.
static TargetInfo * CreateTargetInfo(DiagnosticsEngine &Diags, const std::shared_ptr< TargetOptions > &Opts)
Construct a target for the given options.
Defines the clang::TargetInfo interface.
@ MK_PCH
File is a PCH file treated as such.
The JSON file list parser is used to communicate input to InstallAPI.
void ParseAST(Preprocessor &pp, ASTConsumer *C, ASTContext &Ctx, bool PrintStats=false, TranslationUnitKind TUKind=TU_Complete, CodeCompleteConsumer *CompletionConsumer=nullptr, bool SkipFunctionBodies=false)
Parse the entire file specified, notifying the ASTConsumer as the file is parsed.
IntrusiveRefCntPtr< ExternalSemaSource > createChainedIncludesSource(CompilerInstance &CI, IntrusiveRefCntPtr< ExternalSemaSource > &Reader)
The ChainedIncludesSource class converts headers to chained PCHs in memory, mainly for testing.
@ TU_Prefix
The translation unit is a prefix to a translation unit, and is not complete.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4