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();
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));
231 std::string &InputFile,
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);
269 if (Literal.hadError)
271 RawLexer->LexFromRawLexer(T);
274 InputFile = Literal.GetString().str();
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);
394 std::string RelName = RelativeHeader.c_str();
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();
428 std::string &PresumedModuleMapFile,
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;
773 std::string PresumedModuleMapFile;
774 unsigned OffsetToContents;
777 PresumedModuleMapFile, OffsetToContents))
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);
852 CI.
setASTReader(static_cast<ASTReader *>(FinalReader.get()));
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 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 setExternalSource(IntrusiveRefCntPtr< ExternalASTSource > Source)
Attach an external AST source to the AST context.
Defines the clang::ASTContext interface.
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 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,...
void setInferredModuleAllowedBy(Module *M, const FileEntry *ModMap)
LangOptions & getLangOpts()
void resetAndLeakFileManager()
std::string OriginalModuleMap
When the input is a module map, the original module map file from which that map was inferred,...
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.
PreprocessorOptions & getPreprocessorOpts()
void createCodeCompletionConsumer()
Create a code completion consumer using the invocation; note that this will cause the source manager ...
Lexer - This provides a simple interface that turns a text buffer into a stream of tokens.
bool hasErrorOccurred() const
Smart pointer class that efficiently represents Objective-C method names.
SmallVector< UnresolvedHeaderDirective, 1 > MissingHeaders
Headers that are mentioned in the module map file but could not be found on the file system.
A (possibly-)qualified type.
const char * getDeclKindName() const
FileManager * createFileManager(IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS=nullptr)
Create the file manager and replace any existing one with it.
std::vector< Module * >::iterator submodule_iterator
Implements support for file system lookup, file system caching, and directory search management.
IntrusiveRefCntPtr< ExternalSemaSource > createChainedIncludesSource(CompilerInstance &CI, IntrusiveRefCntPtr< ExternalSemaSource > &Reader)
The ChainedIncludesSource class converts headers to chained PCHs in memory, mainly for testing.
void PrintStats() const
Print some statistics to stderr that indicate how well the hashing is doing.
void EndSourceFile()
Perform any per-file post processing, deallocate per-file objects, and run statistics and output file...
submodule_iterator submodule_begin()
TypePropertyCache< Private > Cache
virtual bool hasIRSupport() const
Does this action support use with IR files?
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...
void ExecuteAction() override
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer.
unsigned IsExternC
Whether this is an 'extern "C"' module (which implicitly puts all headers in it within an 'extern "C"...
void createSema(TranslationUnitKind TUKind, CodeCompleteConsumer *CompletionConsumer)
Create the Sema object to be used for parsing.
Load everything, including Sema.
Decl - This represents one declaration (or definition), e.g.
void EndSourceFile()
Inform the preprocessor callbacks that processing is complete.
virtual bool usesPreprocessorOnly() const =0
Does this action only use the preprocessor?
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...
virtual bool hasASTFileSupport() const
Does this action support use with AST files?
DiagnosticsEngine & getDiagnostics() const
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
bool InitializeSourceManager(const FrontendInputFile &Input)
InitializeSourceManager - Initialize the source manager to set InputFile as the main file.
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
ASTContext & getASTContext() const
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...
void setSourceManager(SourceManager *Value)
setSourceManager - Replace the current source manager.
virtual void EndSourceFile()
Callback to inform the diagnostic client that processing of a source file has ended.
Builtin::Context & getBuiltinInfo()
virtual bool hasCodeCompletionSupport() const
Does this action support use with code completion?
IntrusiveRefCntPtr< ASTReader > getASTReader() const
std::string PresumedModuleMapFile
The presumed file name for the module map defining this module.
tok::TokenKind getKind() const
One of these records is kept for each identifier that is lexed.
static StringRef getModuleInputBufferName()
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Record the location of a macro definition.
bool usesPreprocessorOnly() const override
Does this action only use the preprocessor?
bool BeginSourceFile(CompilerInstance &CI, const FrontendInputFile &Input)
Prepare the action for processing the input file Input.
void createSourceManager(FileManager &FileMgr)
Create the source manager and replace any existing one with it.
static llvm::Error writeIndex(FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, llvm::StringRef Path)
Write a global index into the given.
void resolveHeaderDirectives(const FileEntry *File) const
Resolve all lazy header directives for the specified file.
Module * getCurrentModule() const
bool shouldEraseOutputFiles() override
Callback at the end of processing a single input, to determine if the output files should be erased o...
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
Header getUmbrellaHeader() const
Retrieve the header that serves as the umbrella header for this module.
bool isHeaderUnavailableInModule(const FileEntry *Header, const Module *RequestingModule) const
Determine whether the given header is unavailable as part of the specified module.
Token - This structure provides full information about a lexed token.
void setASTContext(ASTContext *Value)
setASTContext - Replace the current AST context.
CodeGenOptions & getCodeGenOpts()
void finishModuleDeclarationScope()
Creates a new declaration scope for module names, allowing previously defined modules to shadow defin...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
const LangOptions & getLangOpts() const
Compiling a module from a module map.
std::vector< std::string > ModulesEmbedFiles
The list of files to embed into the compiled module file.
Describes a module or submodule.
Execute the action before the main action.
CompilerInstance & getCompilerInstance() const
bool hasPCHSupport() const override
Does this action support use with PCH?
llvm::ErrorOr< const DirectoryEntry * > getDirectory(StringRef DirName, bool CacheFailure=true)
Lookup, cache, and verify the specified directory (real or virtual).
Action is determined by the cc1 command-line.
unsigned ShowStats
Show frontend performance metrics and statistics.
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
ModuleBuildStack getModuleBuildStack() const
Retrieve the module build stack.
HeaderSearch & getHeaderSearchInfo() const
FrontendOptions & getFrontendOpts()
ModuleManager & getModuleManager()
Retrieve the module manager.
StringRef getCurrentFileOrBufferName() const
Load options and the preprocessor state.
bool hasFrontendTimer() const
Concrete class used by the front-end to report problems and issues.
virtual ~FrontendAction()
Module * Parent
The parent of this module.
unsigned IsInferred
Whether this is an inferred submodule (module * { ... }).
static Module * prepareToBuildModule(CompilerInstance &CI, StringRef ModuleMapFilename)
void setASTConsumer(std::unique_ptr< ASTConsumer > Value)
setASTConsumer - Replace the current AST consumer; the compiler instance takes ownership of Value.
unsigned SkipFunctionBodies
Skip over function bodies to speed up parsing in cases you do not need them (e.g.
submodule_iterator submodule_end()
virtual bool BeginInvocation(CompilerInstance &CI)
Callback before starting processing a single input, giving the opportunity to modify the CompilerInvo...
bool hasASTConsumer() const
void setFileManager(FileManager *Value)
Replace the current file manager and virtual file system.
bool BeginInvocation(CompilerInstance &CI) override
Callback before starting processing a single input, giving the opportunity to modify the CompilerInvo...
HeaderSearchOptions & getHeaderSearchOpts()
bool DisablePCHValidation
When true, disables most of the normal validation performed on precompiled headers.
CodeCompleteConsumer & getCodeCompletionConsumer() const
static bool loadModuleMapForModuleBuild(CompilerInstance &CI, bool IsSystem, bool IsPreprocessed, std::string &PresumedModuleMapFile, unsigned &Offset)
void createPCHExternalASTSource(StringRef Path, bool DisablePCHValidation, bool AllowPCHWithCompilerErrors, void *DeserializationListener, bool OwnDeserializationListener)
Create an external AST source to read a PCH file and attach it to the AST context.
void initializeForReplay(const SourceManager &Old)
Initialize this source manager suitably to replay the compilation described by Old.
llvm::Registry< PluginASTAction > FrontendPluginRegistry
The frontend plugin registry.
bool hasCodeCompletionSupport() const override
Does this action support use with code completion?
std::string CurrentModule
The name of the current module, of which the main source file is a part.
virtual bool shouldEraseOutputFiles()
Callback at the end of processing a single input, to determine if the output files should be erased o...
std::vector< std::string > ChainedIncludes
Headers that will be converted to chained PCHs in memory.
void resetAndLeakPreprocessor()
void setCurrentInput(const FrontendInputFile &CurrentInput, std::unique_ptr< ASTUnit > AST=nullptr)
void setFileIsTransient(const FileEntry *SourceFile)
Specify that a file is transient.
bool hasIRSupport() const override
Does this action support use with IR files?
WrapperFrontendAction(std::unique_ptr< FrontendAction > WrappedAction)
Construct a WrapperFrontendAction from an existing action, taking ownership of it.
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
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...
bool hasFileManager() const
bool BeginSourceFileAction(CompilerInstance &CI) override
Callback at the start of processing a single input.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
Defines the clang::Preprocessor interface.
Not compiling a module interface at all.
void createASTContext()
Create the AST context.
virtual void EndSourceFileAction()
Callback at the end of processing a single input.
TranslationUnitKind getTranslationUnitKind() override
For AST-based actions, the kind of translation unit we're handling.
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.
Information about a module that has been loaded by the ASTReader.
unsigned ModulesEmbedAllFiles
Whether we should embed all used files into the PCM file.
void setSema(Sema *S)
Replace the current Sema; the compiler instance takes ownership of S.
bool PrepareToExecuteAction(CompilerInstance &CI) override
Prepare to execute the action on the given CompilerInstance.
virtual std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile)=0
Create the AST consumer object for this action, if supported.
bool isAvailable() const
Determine whether this module is available for use within the current translation unit.
virtual void ExecuteAction()=0
Callback to run the program action, using the initialized compiler instance.
void EndSourceFileAction() override
Callback at the end of processing a single input.
bool AllowPCHWithCompilerErrors
When true, a PCH with compiler errors will not be rejected.
const DirectoryEntry * Directory
The build directory of this module.
virtual bool hasPCHSupport() const
Does this action support use with PCH?
FileSystemOptions & getFileSystemOpts()
bool hasPreprocessor() const
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
Encodes a location in the source.
void resetAndLeakSourceManager()
StringRef getName() const
std::vector< std::string > ModuleFiles
The list of additional prebuilt module files to load before processing the input.
ParsedSourceLocation CodeCompletionAt
If given, enable code completion at the provided location.
virtual TranslationUnitKind getTranslationUnitKind()
For AST-based actions, the kind of translation unit we're handling.
std::string ImplicitPCHInclude
The implicit PCH included at the start of the translation unit, or empty.
static bool Ret(InterpState &S, CodePtr &PC, APValue &Result)
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
IdentifierTable & getIdentifierTable()
Cached information about one file (either on disk or in the virtual file system).
SmallVector< Header, 2 > Headers[5]
The headers that are part of this module.
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.
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...
void initializeBuiltins(IdentifierTable &Table, const LangOptions &LangOpts)
Mark the identifiers for all the builtins with their appropriate builtin ID # and mark any non-portab...
bool hasSourceManager() const
std::unordered_map< std::string, std::vector< std::string > > PluginArgs
Args to pass to the plugins.
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
Execute the action after the main action.
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
void pushModuleBuildStack(StringRef moduleName, FullSourceLoc importLoc)
Push an entry to the module build stack.
void createPreprocessor(TranslationUnitKind TUKind)
Create the preprocessor, using the invocation, file, and source managers, and replace any existing on...
bool shouldBuildGlobalModuleIndex() const
Indicates whether we should (re)build the global module index.
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
std::string OverrideRecordLayoutsFile
File name of the file that will provide record layouts (in the format produced by -fdump-record-layou...
Abstract interface for a consumer of code-completion information.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
bool isNot(tok::TokenKind K) const
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
void setPreprocessor(std::shared_ptr< Preprocessor > Value)
Replace the current preprocessor.
FileManager & getFileManager() const
Return the current file manager to the caller.
llvm::Timer & getFrontendTimer() const
const FrontendInputFile & getCurrentInput() const
llvm::Error Execute()
Set the source manager's main input file, and run the action.
Reads an AST files chain containing the contents of a translation unit.
ModuleFile & getPrimaryModule()
Returns the primary module associated with the manager, that is, the first module loaded.
void PrintStats() const
Print statistics to stderr.
FileID getMainFileID() const
Returns the FileID of the main source file.
StringRef getCurrentFile() const
bool loadModuleFile(StringRef FileName)
void setASTMutationListener(ASTMutationListener *Listener)
Attach an AST mutation listener to the AST context.
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.
SourceManager & getSourceManager() const
Return the current source manager.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
void clearOutputFiles(bool EraseFiles)
clearOutputFiles - Clear the output file list.
llvm::ErrorOr< const FileEntry * > getFile(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Lookup, cache, and verify the specified file (real or virtual).
TargetInfo & getTarget() const
uint32_t IdentID
An ID number that refers to an identifier in an AST file.
bool hasASTFileSupport() const override
Does this action support use with AST files?
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.
void setCompilerInstance(CompilerInstance *Value)
std::string getSpecificModuleCachePath(StringRef ModuleHash)
DirectoryName getUmbrellaDir() const
Retrieve the directory for which this module serves as the umbrella.
void setASTReader(IntrusiveRefCntPtr< ASTReader > Reader)
std::vector< std::string > AddPluginActions
The list of plugin actions to run in addition to the normal action.
bool hasASTContext() const
unsigned DisableFree
Disable memory freeing on exit.
Preprocessor & getPreprocessor() const
Return the current preprocessor.
bool hasCodeCompletionConsumer() const
DiagnosticConsumer & getDiagnosticClient() const
An external AST source that overrides the layout of a specified set of record types.
void resetAndLeakASTContext()
virtual bool BeginSourceFileAction(CompilerInstance &CI)
Callback at the start of processing a single input.
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...
void addTopHeader(const FileEntry *File)
Add a top-level header associated with this module.
TranslationUnitKind
Describes the kind of translation unit being processed.
StringLiteralParser - This decodes string escape characters and performs wide string analysis and Tra...
const PCHContainerReader & getPCHContainerReader() const
Return the appropriate PCHContainerReader depending on the current CodeGenOptions.
A SourceLocation and its associated SourceManager.
DiagnosticsEngine & getDiagnostics() const
Get the current diagnostics engine.
bool isCurrentFileAST() const
LLVM IR: we accept this so that we can run the optimizer on it, and compile it to assembly or object ...
Defines the clang::FrontendAction interface and various convenience abstract classes (clang::ASTFront...
std::unique_ptr< ASTConsumer > takeASTConsumer()
takeASTConsumer - Remove the current AST consumer and give ownership to the caller.
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.
static std::unique_ptr< llvm::MemoryBuffer > getInputBufferForModule(CompilerInstance &CI, Module *M)
Compute the input buffer that should be used to build the specified module.
void setAllFilesAreTransient(bool Transient)
Specify that all files that are read during this compilation are transient.
void setSkipMainFilePreamble(unsigned Bytes, bool StartOfLine)
Instruct the preprocessor to skip part of the main source file.
This represents a decl that may have a name.
bool DumpDeserializedPCHDecls
Dump declarations that are deserialized from PCH, for testing.
virtual void BeginSourceFile(const LangOptions &LangOpts, const Preprocessor *PP=nullptr)
Callback to inform the diagnostic client that processing of a source file is beginning.
static SmallVectorImpl< char > & operator+=(SmallVectorImpl< char > &Includes, StringRef RHS)
TargetOptions & getTargetOpts()
FullSourceLoc getFullLoc(SourceLocation Loc) const
llvm::vfs::FileSystem & getVirtualFileSystem() const
This class handles loading and caching of source files into memory.
static void addHeaderInclude(StringRef HeaderName, SmallVectorImpl< char > &Includes, const LangOptions &LangOpts, bool IsExternC)
Defines enum values for all the target-independent builtin functions.
bool Sub(InterpState &S, CodePtr OpPC)
A type index; the type ID with the qualifier bits removed.
SourceLocation getLocation() const
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
virtual bool isModelParsingAction() const
Is this action invoked on a model file?
std::vector< std::string > ModuleMapFiles
The list of module map files to load before processing the input.