Go to the documentation of this file.
30 #include "llvm/Support/BuryPointer.h"
31 #include "llvm/Support/ErrorHandling.h"
32 #include "llvm/Support/FileSystem.h"
33 #include "llvm/Support/Path.h"
34 #include "llvm/Support/Timer.h"
35 #include "llvm/Support/raw_ostream.h"
36 #include <system_error>
37 using namespace clang;
48 explicit DelegatingDeserializationListener(
51 ~DelegatingDeserializationListener()
override {
56 void ReaderInitialized(
ASTReader *Reader)
override {
80 Previous->MacroDefinitionRead(PPID, MD);
85 class DeserializedDeclsDumper :
public DelegatingDeserializationListener {
89 : DelegatingDeserializationListener(
Previous, DeletePrevious) {}
93 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
94 llvm::outs() <<
" - ";
95 ND->printQualifiedName(llvm::outs());
99 DelegatingDeserializationListener::DeclRead(
ID, D);
105 class DeserializedDeclsChecker :
public DelegatingDeserializationListener {
107 std::set<std::string> NamesToCheck;
111 const std::set<std::string> &NamesToCheck,
114 : DelegatingDeserializationListener(
Previous, DeletePrevious), Ctx(Ctx),
115 NamesToCheck(NamesToCheck) {}
118 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(D))
119 if (NamesToCheck.find(ND->getNameAsString()) != NamesToCheck.end()) {
122 "%0 was deserialized");
127 DelegatingDeserializationListener::DeclRead(
ID, D);
138 std::unique_ptr<ASTUnit> AST) {
139 this->CurrentInput = CurrentInput;
140 CurrentASTUnit = std::move(AST);
149 std::unique_ptr<ASTConsumer>
157 bool FoundAllPlugins =
true;
160 for (
const FrontendPluginRegistry::entry &Plugin :
161 FrontendPluginRegistry::entries()) {
162 if (Plugin.getName() == Arg)
167 FoundAllPlugins =
false;
170 if (!FoundAllPlugins)
174 if (FrontendPluginRegistry::begin() == FrontendPluginRegistry::end())
183 std::vector<std::unique_ptr<ASTConsumer>> Consumers;
184 std::vector<std::unique_ptr<ASTConsumer>> AfterConsumers;
185 for (
const FrontendPluginRegistry::entry &Plugin :
186 FrontendPluginRegistry::entries()) {
187 std::unique_ptr<PluginASTAction>
P = Plugin.instantiate();
194 return PluginAction == Plugin.getName();
203 std::unique_ptr<ASTConsumer> PluginConsumer =
P->CreateASTConsumer(CI, InFile);
205 Consumers.push_back(std::move(PluginConsumer));
207 AfterConsumers.push_back(std::move(PluginConsumer));
213 Consumers.push_back(std::move(Consumer));
214 for (
auto &C : AfterConsumers) {
215 Consumers.push_back(std::move(C));
218 return std::make_unique<MultiplexConsumer>(std::move(Consumers));
232 bool IsModuleMap =
false) {
236 auto MainFileBuf = SourceMgr.getBufferOrNone(MainFileID);
240 std::unique_ptr<Lexer> RawLexer(
249 if (RawLexer->LexFromRawLexer(T) || T.
getKind() != tok::hash)
252 T.
getKind() != tok::numeric_constant)
260 .getAsInteger(10, LineNo))
264 RawLexer->LexFromRawLexer(T);
271 RawLexer->LexFromRawLexer(T);
278 LineNoLoc, LineNo, SourceMgr.getLineTableFilenameID(InputFile),
false,
286 Includes.append(RHS.begin(), RHS.end());
294 if (IsExternC && LangOpts.CPlusPlus)
295 Includes +=
"extern \"C\" {\n";
297 Includes +=
"#import \"";
299 Includes +=
"#include \"";
301 Includes += HeaderName;
304 if (IsExternC && LangOpts.CPlusPlus)
320 return std::error_code();
332 Diag.Report(MissingHeader.FileNameLoc, diag::err_module_header_missing)
333 << MissingHeader.IsUmbrella << MissingHeader.FileName;
334 return std::error_code();
360 llvm::sys::path::native(UmbrellaDir.Entry->getName(), DirNative);
364 for (llvm::vfs::recursive_directory_iterator Dir(FS, DirNative, EC),
End;
365 Dir !=
End && !EC; Dir.increment(EC)) {
368 if (!llvm::StringSwitch<bool>(llvm::sys::path::extension(Dir->path()))
369 .Cases(
".h",
".H",
".hh",
".hpp",
true)
373 auto Header = FileMgr.
getFile(Dir->path());
386 auto PathIt = llvm::sys::path::rbegin(Dir->path());
387 for (
int I = 0; I != Dir.level() + 1; ++I, ++PathIt)
388 Components.push_back(*PathIt);
390 for (
auto It = Components.rbegin(),
End = Components.rend(); It !=
End;
392 llvm::sys::path::append(RelativeHeader, *It);
395 Headers.push_back(std::make_pair(RelName, *Header));
403 llvm::sort(Headers.begin(), Headers.end(), [](
404 const std::pair<std::string, const FileEntry *> &LHS,
405 const std::pair<std::string, const FileEntry *> &RHS) {
406 return LHS.first < RHS.first;
408 for (
auto &H : Headers) {
420 LangOpts, FileMgr,
Diag, ModMap, *
Sub, Includes))
423 return std::error_code();
434 FileID ModuleMapID = SrcMgr.getMainFileID();
440 if (IsPreprocessed) {
449 PresumedModuleMapFile))
452 if (SrcMgr.getBufferOrFake(ModuleMapID).getBufferSize() ==
Offset)
459 StringRef ModuleMapFilename) {
495 if (!OriginalModuleMapName.empty()) {
496 auto OriginalModuleMap =
499 if (!OriginalModuleMap) {
501 << OriginalModuleMapName;
523 static std::unique_ptr<llvm::MemoryBuffer>
529 std::error_code Err = std::error_code();
544 return llvm::MemoryBuffer::getMemBufferCopy(
551 assert(!Instance &&
"Already processing a source file!");
552 assert(!Input.
isEmpty() &&
"Unexpected empty filename!");
556 bool HasBegunSourceFile =
false;
570 &Diags->getDiagnosticOptions()));
571 ASTDiags->setClient(Diags->getClient(),
false);
574 StringRef InputFile = Input.
getFile();
598 if (
auto ASTReader = AST->getASTReader()) {
603 if (&MF != &PrimaryModule)
607 PrimaryModule, [&](
const FileEntry *FE) {
614 auto Kind = AST->getInputKind();
617 AST->getPreprocessor().getHeaderSearchInfo().lookupModule(
618 AST->getLangOpts().CurrentModule,
false);
619 assert(ASTModule &&
"module file does not define its own module");
622 auto &OldSM = AST->getSourceManager();
624 if (
auto *
File = OldSM.getFileEntryForID(
ID))
637 "This action does not have AST file support!");
642 StringRef InputFile = Input.
getFile();
654 HasBegunSourceFile =
true;
703 "This action does not have IR file support!");
707 HasBegunSourceFile =
true;
730 llvm::sys::path::native((*PCHDir)->getName(), DirNative);
733 for (llvm::vfs::directory_iterator Dir = FS.dir_begin(DirNative, EC),
735 Dir != DirEnd && !EC; Dir.increment(EC)) {
740 SpecificModuleCachePath)) {
762 HasBegunSourceFile =
true;
774 unsigned OffsetToContents;
777 PresumedModuleMapFile, OffsetToContents))
784 CurrentModule->PresumedModuleMapFile = PresumedModuleMapFile;
786 if (OffsetToContents)
799 assert(BufferID.isValid() &&
"couldn't create module buffer ID");
800 SourceMgr.setMainFileID(BufferID);
837 std::unique_ptr<ASTConsumer> Consumer =
838 CreateWrappedASTConsumer(CI, PresumedInputFile);
857 assert(
hasPCHSupport() &&
"This action does not have PCH support!");
859 Consumer->GetASTDeserializationListener();
860 bool DeleteDeserialListener =
false;
862 DeserialListener =
new DeserializedDeclsDumper(DeserialListener,
863 DeleteDeserialListener);
864 DeleteDeserialListener =
true;
867 DeserialListener =
new DeserializedDeclsChecker(
870 DeserialListener, DeleteDeserialListener);
871 DeleteDeserialListener =
true;
878 DeserialListener, DeleteDeserialListener);
888 CI.
getASTReader()->setDeserializationListener(DeserialListener,
889 DeleteDeserialListener);
909 "modules enabled but created an external source that "
910 "doesn't support modules");
933 if (HasBegunSourceFile)
957 if (!
Cache.empty()) {
963 consumeError(std::move(Err));
968 return llvm::Error::success();
999 llvm::errs() <<
"\nSTATISTICS FOR '" <<
getCurrentFile() <<
"':\n";
1004 llvm::errs() <<
"\n";
1016 llvm::BuryPointer(std::move(CurrentASTUnit));
1060 void PluginASTAction::anchor() { }
1062 std::unique_ptr<ASTConsumer>
1065 llvm_unreachable(
"Invalid CreateASTConsumer on preprocessor action!");
1069 return WrappedAction->PrepareToExecuteAction(CI);
1071 std::unique_ptr<ASTConsumer>
1074 return WrappedAction->CreateASTConsumer(CI, InFile);
1077 return WrappedAction->BeginInvocation(CI);
1081 WrappedAction->setCompilerInstance(&CI);
1082 auto Ret = WrappedAction->BeginSourceFileAction(CI);
1088 WrappedAction->ExecuteAction();
1091 WrappedAction->EndSourceFileAction();
1094 return WrappedAction->shouldEraseOutputFiles();
1098 return WrappedAction->usesPreprocessorOnly();
1101 return WrappedAction->getTranslationUnitKind();
1104 return WrappedAction->hasPCHSupport();
1107 return WrappedAction->hasASTFileSupport();
1110 return WrappedAction->hasIRSupport();
1113 return WrappedAction->hasCodeCompletionSupport();
1117 std::unique_ptr<FrontendAction> WrappedAction)
1118 : WrappedAction(
std::move(WrappedAction)) {}
void setASTConsumer(std::unique_ptr< ASTConsumer > Value)
setASTConsumer - Replace the current AST consumer; the compiler instance takes ownership of Value.
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
void finishModuleDeclarationScope()
Creates a new declaration scope for module names, allowing previously defined modules to shadow defin...
std::vector< std::string > ModuleMapFiles
The list of module map files to load before processing the input.
std::string CurrentModule
The name of the current module, of which the main source file is a part.
void setSkipMainFilePreamble(unsigned Bytes, bool StartOfLine)
Instruct the preprocessor to skip part of the main source file.
std::vector< std::string > AddPluginActions
The list of plugin actions to run in addition to the normal action.
A type index; the type ID with the qualifier bits removed.
static llvm::Error writeIndex(FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, llvm::StringRef Path)
Write a global index into the given.
bool hasASTConsumer() const
A SourceLocation and its associated SourceManager.
static bool loadModuleMapForModuleBuild(CompilerInstance &CI, bool IsSystem, bool IsPreprocessed, std::string &PresumedModuleMapFile, unsigned &Offset)
DirectoryName getUmbrellaDir() const
Retrieve the directory for which this module serves as the umbrella.
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
static bool Ret(InterpState &S, CodePtr &PC, APValue &Result)
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
@ AddAfterMainAction
Execute the action after the main action.
unsigned ShowStats
Show frontend performance metrics and statistics.
static unsigned getSpelling(const Token &Tok, const char *&Buffer, const SourceManager &SourceMgr, const LangOptions &LangOpts, bool *Invalid=nullptr)
getSpelling - This method is used to get the spelling of a token into a preallocated buffer,...
friend class WrapperFrontendAction
virtual bool isModelParsingAction() const
Is this action invoked on a model file?
Encodes a location in the source.
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
bool hasCodeCompletionSupport() const override
Does this action support use with code completion?
This represents a decl that may have a name.
void setSema(Sema *S)
Replace the current Sema; the compiler instance takes ownership of S.
uint32_t IdentID
An ID number that refers to an identifier in an AST file.
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Provide a default implementation which returns aborts; this method should never be called by Frontend...
static void addHeaderInclude(StringRef HeaderName, SmallVectorImpl< char > &Includes, const LangOptions &LangOpts, bool IsExternC)
std::map< std::string, std::vector< std::string > > PluginArgs
Args to pass to the plugins.
unsigned SkipFunctionBodies
Skip over function bodies to speed up parsing in cases you do not need them (e.g.
virtual bool hasIRSupport() const
Does this action support use with IR files?
FullSourceLoc getFullLoc(SourceLocation Loc) const
TranslationUnitKind getTranslationUnitKind() override
For AST-based actions, the kind of translation unit we're handling.
A (possibly-)qualified type.
void EndSourceFile()
Perform any per-file post processing, deallocate per-file objects, and run statistics and output file...
submodule_iterator submodule_begin()
bool InitializeSourceManager(const FrontendInputFile &Input)
InitializeSourceManager - Initialize the source manager to set InputFile as the main file.
LangOptions & getLangOpts()
bool hasPCHSupport() const override
Does this action support use with PCH?
Concrete class used by the front-end to report problems and issues.
Module * getCurrentModule() const
bool hasFrontendTimer() const
virtual bool hasCodeCompletionSupport() const
Does this action support use with code completion?
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
static std::error_code collectModuleHeaderIncludes(const LangOptions &LangOpts, FileManager &FileMgr, DiagnosticsEngine &Diag, ModuleMap &ModMap, clang::Module *Module, SmallVectorImpl< char > &Includes)
Collect the set of header includes needed to construct the given module and update the TopHeaders fil...
@ CMK_ModuleMap
Compiling a module from a module map.
virtual bool BeginInvocation(CompilerInstance &CI)
Callback before starting processing a single input, giving the opportunity to modify the CompilerInvo...
void PrintStats() const
Print statistics to stderr.
bool DumpDeserializedPCHDecls
Dump declarations that are deserialized from PCH, for testing.
FileSystemOptions & getFileSystemOpts()
void AddLineNote(SourceLocation Loc, unsigned LineNo, int FilenameID, bool IsFileEntry, bool IsFileExit, SrcMgr::CharacteristicKind FileKind)
Add a line note to the line table for the FileID and offset specified by Loc.
void pushModuleBuildStack(StringRef moduleName, FullSourceLoc importLoc)
Push an entry to the module build stack.
virtual void EndSourceFile()
Callback to inform the diagnostic client that processing of a source file has ended.
Token - This structure provides full information about a lexed token.
CodeGenOptions & getCodeGenOpts()
@ PluginAction
Run a plugin action,.
const PCHContainerReader & getPCHContainerReader() const
Return the appropriate PCHContainerReader depending on the current CodeGenOptions.
void createCodeCompletionConsumer()
Create a code completion consumer using the invocation; note that this will cause the source manager ...
IdentifierTable & getIdentifierTable()
bool isAvailable() const
Determine whether this module is available for use within the current translation unit.
virtual bool hasASTFileSupport() const
Does this action support use with AST files?
This class handles loading and caching of source files into memory.
void setInferredModuleAllowedBy(Module *M, const FileEntry *ModMap)
const LangOptions & getLangOpts() const
void resetAndLeakSourceManager()
Lexer - This provides a simple interface that turns a text buffer into a stream of tokens.
std::string OverrideRecordLayoutsFile
File name of the file that will provide record layouts (in the format produced by -fdump-record-layou...
void setAllFilesAreTransient(bool Transient)
Specify that all files that are read during this compilation are transient.
unsigned ModulesEmbedAllFiles
Whether we should embed all used files into the PCM file.
FileManager & getFileManager() const
Return the current file manager to the caller.
@ AddBeforeMainAction
Execute the action before the main action.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
Describes a module or submodule.
bool hasIRSupport() const override
Does this action support use with IR files?
llvm::vfs::FileSystem & getVirtualFileSystem() const
virtual ~FrontendAction()
StringRef getCurrentFileOrBufferName() const
void EndSourceFile()
Inform the preprocessor callbacks that processing is complete.
@ CMK_None
Not compiling a module interface at all.
void resetAndLeakFileManager()
ModuleManager & getModuleManager()
Retrieve the module manager.
static std::unique_ptr< ASTUnit > LoadFromASTFile(const std::string &Filename, const PCHContainerReader &PCHContainerRdr, WhatToLoad ToLoad, IntrusiveRefCntPtr< DiagnosticsEngine > Diags, const FileSystemOptions &FileSystemOpts, bool UseDebugInfo=false, bool OnlyLocalDecls=false, CaptureDiagsKind CaptureDiagnostics=CaptureDiagsKind::None, bool AllowASTWithCompilerErrors=false, bool UserFilesAreVolatile=false)
Create a ASTUnit from an AST file.
bool hasErrorOccurred() const
bool BeginSourceFile(CompilerInstance &CI, const FrontendInputFile &Input)
Prepare the action for processing the input file Input.
tok::TokenKind getKind() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
std::vector< std::string > ChainedIncludes
Headers that will be converted to chained PCHs in memory.
FileID getMainFileID() const
Returns the FileID of the main source file.
An external AST source that overrides the layout of a specified set of record types.
void setExternalSource(IntrusiveRefCntPtr< ExternalASTSource > Source)
Attach an external AST source to the AST context.
virtual bool hasPCHSupport() const
Does this action support use with PCH?
FileID createFileID(const FileEntry *SourceFile, SourceLocation IncludePos, SrcMgr::CharacteristicKind FileCharacter, int LoadedID=0, unsigned LoadedOffset=0)
Create a new FileID that represents the specified file being #included from the specified IncludePosi...
Record the location of a macro definition.
virtual std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile)=0
Create the AST consumer object for this action, if supported.
bool AllowPCHWithCompilerErrors
When true, a PCH with compiler errors will not be rejected.
CompilerInstance & getCompilerInstance() const
DisableValidationForModuleKind DisablePCHOrModuleValidation
Whether to disable most of the normal validation performed on precompiled headers and module files.
void resetAndLeakPreprocessor()
@ Cmdline
Action is determined by the cc1 command-line.
virtual bool shouldEraseOutputFiles()
Callback at the end of processing a single input, to determine if the output files should be erased o...
Preprocessor & getPreprocessor() const
Return the current preprocessor.
SmallVector< UnresolvedHeaderDirective, 1 > MissingHeaders
Headers that are mentioned in the module map file but could not be found on the file system.
virtual TranslationUnitKind getTranslationUnitKind()
For AST-based actions, the kind of translation unit we're handling.
std::vector< std::string > ModulesEmbedFiles
The list of files to embed into the compiled module file.
ASTContext & getASTContext() const
bool hasFileManager() const
void setCurrentInput(const FrontendInputFile &CurrentInput, std::unique_ptr< ASTUnit > AST=nullptr)
void visitTopLevelModuleMaps(serialization::ModuleFile &MF, llvm::function_ref< void(const FileEntry *)> Visitor)
Visit all the top-level module maps loaded when building the given module file.
static Module * prepareToBuildModule(CompilerInstance &CI, StringRef ModuleMapFilename)
bool isNot(tok::TokenKind K) const
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
Cached information about one file (either on disk or in the virtual file system).
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
PreprocessorOptions & getPreprocessorOpts()
bool BeginInvocation(CompilerInstance &CI) override
Callback before starting processing a single input, giving the opportunity to modify the CompilerInvo...
Module * Parent
The parent of this module.
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
std::string PresumedModuleMapFile
The presumed file name for the module map defining this module.
void setPreprocessor(std::shared_ptr< Preprocessor > Value)
Replace the current preprocessor.
void setASTReader(IntrusiveRefCntPtr< ASTReader > Reader)
const FrontendInputFile & getCurrentInput() const
virtual void EndSourceFileAction()
Callback at the end of processing a single input.
std::vector< Module * >::iterator submodule_iterator
TargetOptions & getTargetOpts()
std::unique_ptr< ASTConsumer > takeASTConsumer()
takeASTConsumer - Remove the current AST consumer and give ownership to the caller.
bool loadModuleFile(StringRef FileName)
const DirectoryEntry * Directory
The build directory of this module.
SmallVector< Header, 2 > Headers[5]
The headers that are part of this module.
virtual void BeginSourceFile(const LangOptions &LangOpts, const Preprocessor *PP=nullptr)
Callback to inform the diagnostic client that processing of a source file is beginning.
DiagnosticConsumer & getDiagnosticClient() const
Builtin::Context & getBuiltinInfo()
bool hasPreprocessor() const
bool BeginSourceFileAction(CompilerInstance &CI) override
Callback at the start of processing a single input.
bool usesPreprocessorOnly() const override
Does this action only use the preprocessor?
bool hasCodeCompletionConsumer() const
@ LLVM_IR
LLVM IR: we accept this so that we can run the optimizer on it, and compile it to assembly or object ...
Decl - This represents one declaration (or definition), e.g.
StringRef getCurrentFile() const
@ LoadPreprocessorOnly
Load options and the preprocessor state.
static std::unique_ptr< llvm::MemoryBuffer > getInputBufferForModule(CompilerInstance &CI, Module *M)
Compute the input buffer that should be used to build the specified module.
llvm::Timer & getFrontendTimer() const
StringRef GetString() const
llvm::Error Execute()
Set the source manager's main input file, and run the action.
Abstract interface for a consumer of code-completion information.
std::set< std::string > DeserializedPCHDeclsToErrorOn
This is a set of names for decls that we do not want to be deserialized, and we emit an error if they...
void resolveHeaderDirectives(const FileEntry *File) const
Resolve all lazy header directives for the specified file.
llvm::Registry< PluginASTAction > FrontendPluginRegistry
The frontend plugin registry.
ModuleFile & getPrimaryModule()
Returns the primary module associated with the manager, that is, the first module loaded.
void resetAndLeakASTContext()
bool hasSourceManager() const
bool shouldEraseOutputFiles() override
Callback at the end of processing a single input, to determine if the output files should be erased o...
virtual void ExecuteAction()=0
Callback to run the program action, using the initialized compiler instance.
bool isHeaderUnavailableInModule(const FileEntry *Header, const Module *RequestingModule) const
Determine whether the given header is unavailable as part of the specified module.
One of these records is kept for each identifier that is lexed.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Reads an AST files chain containing the contents of a translation unit.
TranslationUnitKind
Describes the kind of translation unit being processed.
std::vector< std::string > ModuleFiles
The list of additional prebuilt module files to load before processing the input.
std::string OriginalModuleMap
When the input is a module map, the original module map file from which that map was inferred,...
void initializeForReplay(const SourceManager &Old)
Initialize this source manager suitably to replay the compilation described by Old.
TargetInfo & getTarget() const
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
IntrusiveRefCntPtr< ExternalSemaSource > createChainedIncludesSource(CompilerInstance &CI, IntrusiveRefCntPtr< ExternalSemaSource > &Reader)
The ChainedIncludesSource class converts headers to chained PCHs in memory, mainly for testing.
Dataflow Directional Tag Classes.
Implements support for file system lookup, file system caching, and directory search management.
Smart pointer class that efficiently represents Objective-C method names.
static StringRef getModuleInputBufferName()
void PrintStats() const
Print some statistics to stderr that indicate how well the hashing is doing.
bool isCurrentFileAST() const
static SmallVectorImpl< char > & operator+=(SmallVectorImpl< char > &Includes, StringRef RHS)
CodeCompleteConsumer & getCodeCompletionConsumer() const
StringRef getName() const
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Header getUmbrellaHeader() const
Retrieve the header that serves as the umbrella header for this module.
bool isValid() const
Return true if this is a valid SourceLocation object.
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
void createASTContext()
Create the AST context.
unsigned IsExternC
Whether this is an 'extern "C"' module (which implicitly puts all headers in it within an 'extern "C"...
submodule_iterator submodule_end()
bool PrepareToExecuteAction(CompilerInstance &CI) override
Prepare to execute the action on the given CompilerInstance.
virtual bool BeginSourceFileAction(CompilerInstance &CI)
Callback at the start of processing a single input.
llvm::ErrorOr< const DirectoryEntry * > getDirectory(StringRef DirName, bool CacheFailure=true)
Lookup, cache, and verify the specified directory (real or virtual).
void setFileManager(FileManager *Value)
Replace the current file manager and virtual file system.
@ LoadEverything
Load everything, including Sema.
ModuleBuildStack getModuleBuildStack() const
Retrieve the module build stack.
llvm::ErrorOr< const FileEntry * > getFile(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Lookup, cache, and verify the specified file (real or virtual).
void ExecuteAction() override
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer.
FrontendOptions & getFrontendOpts()
bool hasASTFileSupport() const override
Does this action support use with AST files?
IntrusiveRefCntPtr< ASTReader > getASTReader() const
void setASTContext(ASTContext *Value)
setASTContext - Replace the current AST context.
unsigned DisableFree
Disable memory freeing on exit.
void addTopHeader(const FileEntry *File)
Add a top-level header associated with this module.
static bool checkModuleIsAvailable(const LangOptions &LangOpts, const TargetInfo &TargetInfo, DiagnosticsEngine &Diags, Module *M)
Check that the given module is available, producing a diagnostic if not.
DiagnosticsEngine & getDiagnostics() const
Get the current diagnostics engine.
SourceManager & getSourceManager() const
Return the current source manager.
void setCompilerInstance(CompilerInstance *Value)
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
FileManager * createFileManager(IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS=nullptr)
Create the file manager and replace any existing one with it.
std::string getSpecificModuleCachePath(StringRef ModuleHash)
void createSema(TranslationUnitKind TUKind, CodeCompleteConsumer *CompletionConsumer)
Create the Sema object to be used for parsing.
virtual bool usesPreprocessorOnly() const =0
Does this action only use the preprocessor?
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
void setSourceManager(SourceManager *Value)
setSourceManager - Replace the current source manager.
void createPreprocessor(TranslationUnitKind TUKind)
Create the preprocessor, using the invocation, file, and source managers, and replace any existing on...
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.
HeaderSearch & getHeaderSearchInfo() const
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
StringLiteralParser - This decodes string escape characters and performs wide string analysis and Tra...
static bool isAcceptableASTFile(StringRef Filename, FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, const LangOptions &LangOpts, const TargetOptions &TargetOpts, const PreprocessorOptions &PPOpts, StringRef ExistingModuleCachePath)
Determine whether the given AST file is acceptable to load into a translation unit with the given lan...
static SourceLocation ReadOriginalFileName(CompilerInstance &CI, std::string &InputFile, bool IsModuleMap=false)
For preprocessed files, if the first line is the linemarker and specifies the original source file na...
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
SourceLocation getLocation() const
void EndSourceFileAction() override
Callback at the end of processing a single input.
void clearOutputFiles(bool EraseFiles)
clearOutputFiles - Clear the output file list.
bool shouldBuildGlobalModuleIndex() const
Indicates whether we should (re)build the global module index.
void createSourceManager(FileManager &FileMgr)
Create the source manager and replace any existing one with it.
void initializeBuiltins(IdentifierTable &Table, const LangOptions &LangOpts)
Mark the identifiers for all the builtins with their appropriate builtin ID # and mark any non-portab...
Information about a module that has been loaded by the ASTReader.
bool Sub(InterpState &S, CodePtr OpPC)
ParsedSourceLocation CodeCompletionAt
If given, enable code completion at the provided location.
HeaderSearchOptions & getHeaderSearchOpts()
void createPCHExternalASTSource(StringRef Path, DisableValidationForModuleKind DisableValidation, bool AllowPCHWithCompilerErrors, void *DeserializationListener, bool OwnDeserializationListener)
Create an external AST source to read a PCH file and attach it to the AST context.
void setMainFileDir(const DirectoryEntry *Dir)
Set the directory in which the main file should be considered to have been found, if it is not a real...
unsigned IsInferred
Whether this is an inferred submodule (module * { ... }).
std::string ImplicitPCHInclude
The implicit PCH included at the start of the translation unit, or empty.
DiagnosticsEngine & getDiagnostics() const
void setASTMutationListener(ASTMutationListener *Listener)
Attach an AST mutation listener to the AST context.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
const char * getDeclKindName() const
bool hasASTContext() const
void setFileIsTransient(const FileEntry *SourceFile)
Specify that a file is transient.