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(
50 : Previous(Previous), DeletePrevious(DeletePrevious) {}
51 ~DelegatingDeserializationListener()
override {
56 void ReaderInitialized(
ASTReader *Reader)
override {
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");
124 << ND->getNameAsString();
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 (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
161 ie = FrontendPluginRegistry::end();
163 if (it->getName() == Arg)
168 FoundAllPlugins =
false;
171 if (!FoundAllPlugins)
175 if (FrontendPluginRegistry::begin() == FrontendPluginRegistry::end())
184 std::vector<std::unique_ptr<ASTConsumer>> Consumers;
185 std::vector<std::unique_ptr<ASTConsumer>> AfterConsumers;
186 for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
187 ie = FrontendPluginRegistry::end();
189 std::unique_ptr<PluginASTAction>
P = it->instantiate();
205 std::unique_ptr<ASTConsumer> PluginConsumer = P->CreateASTConsumer(CI, InFile);
207 Consumers.push_back(std::move(PluginConsumer));
209 AfterConsumers.push_back(std::move(PluginConsumer));
215 Consumers.push_back(std::move(Consumer));
216 for (
auto &
C : AfterConsumers) {
217 Consumers.push_back(std::move(
C));
220 return std::make_unique<MultiplexConsumer>(std::move(Consumers));
233 std::string &InputFile,
234 bool IsModuleMap =
false) {
238 bool Invalid =
false;
239 const auto *MainFileBuf = SourceMgr.getBuffer(MainFileID, &Invalid);
243 std::unique_ptr<Lexer> RawLexer(
252 if (RawLexer->LexFromRawLexer(T) || T.
getKind() != tok::hash)
255 T.
getKind() != tok::numeric_constant)
263 .getAsInteger(10, LineNo))
267 RawLexer->LexFromRawLexer(T);
272 if (Literal.hadError)
274 RawLexer->LexFromRawLexer(T);
277 InputFile = Literal.GetString().str();
281 LineNoLoc, LineNo, SourceMgr.getLineTableFilenameID(InputFile),
false,
289 Includes.append(RHS.begin(), RHS.end());
297 if (IsExternC && LangOpts.CPlusPlus)
298 Includes +=
"extern \"C\" {\n";
300 Includes +=
"#import \"";
302 Includes +=
"#include \"";
304 Includes += HeaderName;
307 if (IsExternC && LangOpts.CPlusPlus)
323 return std::error_code();
335 Diag.
Report(MissingHeader.FileNameLoc, diag::err_module_header_missing)
336 << MissingHeader.IsUmbrella << MissingHeader.FileName;
337 return std::error_code();
363 llvm::sys::path::native(UmbrellaDir.Entry->getName(), DirNative);
366 for (llvm::vfs::recursive_directory_iterator Dir(FS, DirNative, EC),
End;
367 Dir !=
End && !EC; Dir.increment(EC)) {
370 if (!llvm::StringSwitch<bool>(llvm::sys::path::extension(Dir->path()))
371 .Cases(
".h",
".H",
".hh",
".hpp",
true)
375 auto Header = FileMgr.
getFile(Dir->path());
388 auto PathIt = llvm::sys::path::rbegin(Dir->path());
389 for (
int I = 0; I != Dir.level() + 1; ++I, ++PathIt)
390 Components.push_back(*PathIt);
392 for (
auto It = Components.rbegin(),
End = Components.rend(); It !=
End;
394 llvm::sys::path::append(RelativeHeader, *It);
410 LangOpts, FileMgr, Diag, ModMap, *
Sub, Includes))
413 return std::error_code();
418 std::string &PresumedModuleMapFile,
424 FileID ModuleMapID = SrcMgr.getMainFileID();
430 if (IsPreprocessed) {
439 PresumedModuleMapFile))
442 if (SrcMgr.getBuffer(ModuleMapID)->getBufferSize() ==
Offset)
449 StringRef ModuleMapFilename) {
485 if (!OriginalModuleMapName.empty()) {
486 auto OriginalModuleMap =
489 if (!OriginalModuleMap) {
491 << OriginalModuleMapName;
513 static std::unique_ptr<llvm::MemoryBuffer>
519 std::error_code Err = std::error_code();
534 return llvm::MemoryBuffer::getMemBufferCopy(
541 assert(!Instance &&
"Already processing a source file!");
542 assert(!Input.
isEmpty() &&
"Unexpected empty filename!");
546 bool HasBegunSourceFile =
false;
560 &Diags->getDiagnosticOptions()));
561 ASTDiags->setClient(Diags->getClient(),
false);
564 StringRef InputFile = Input.
getFile();
587 if (
auto ASTReader = AST->getASTReader()) {
592 if (&MF != &PrimaryModule)
602 auto Kind = AST->getInputKind();
605 AST->getPreprocessor().getHeaderSearchInfo().lookupModule(
606 AST->getLangOpts().CurrentModule,
false);
607 assert(ASTModule &&
"module file does not define its own module");
610 auto &OldSM = AST->getSourceManager();
611 FileID ID = OldSM.getMainFileID();
612 if (
auto *File = OldSM.getFileEntryForID(ID))
625 "This action does not have AST file support!");
630 StringRef InputFile = Input.
getFile();
641 HasBegunSourceFile =
true;
690 "This action does not have IR file support!");
694 HasBegunSourceFile =
true;
717 llvm::sys::path::native((*PCHDir)->getName(), DirNative);
720 for (llvm::vfs::directory_iterator Dir = FS.dir_begin(DirNative, EC),
722 Dir != DirEnd && !EC; Dir.increment(EC)) {
727 SpecificModuleCachePath)) {
749 HasBegunSourceFile =
true;
760 std::string PresumedModuleMapFile;
761 unsigned OffsetToContents;
764 PresumedModuleMapFile, OffsetToContents))
773 if (OffsetToContents)
786 assert(BufferID.isValid() &&
"couldn't creaate module buffer ID");
787 SourceMgr.setMainFileID(BufferID);
824 std::unique_ptr<ASTConsumer> Consumer =
825 CreateWrappedASTConsumer(CI, PresumedInputFile);
844 assert(
hasPCHSupport() &&
"This action does not have PCH support!");
846 Consumer->GetASTDeserializationListener();
847 bool DeleteDeserialListener =
false;
849 DeserialListener =
new DeserializedDeclsDumper(DeserialListener,
850 DeleteDeserialListener);
851 DeleteDeserialListener =
true;
854 DeserialListener =
new DeserializedDeclsChecker(
857 DeserialListener, DeleteDeserialListener);
858 DeleteDeserialListener =
true;
865 DeleteDeserialListener);
875 CI.
getASTReader()->setDeserializationListener(DeserialListener,
876 DeleteDeserialListener);
896 "modules enabled but created an external source that " 897 "doesn't support modules");
920 if (HasBegunSourceFile)
944 if (!Cache.empty()) {
950 consumeError(std::move(Err));
955 return llvm::Error::success();
986 llvm::errs() <<
"\nSTATISTICS FOR '" <<
getCurrentFile() <<
"':\n";
991 llvm::errs() <<
"\n";
1003 llvm::BuryPointer(std::move(CurrentASTUnit));
1047 void PluginASTAction::anchor() { }
1049 std::unique_ptr<ASTConsumer>
1052 llvm_unreachable(
"Invalid CreateASTConsumer on preprocessor action!");
1056 return WrappedAction->PrepareToExecuteAction(CI);
1058 std::unique_ptr<ASTConsumer>
1061 return WrappedAction->CreateASTConsumer(CI, InFile);
1064 return WrappedAction->BeginInvocation(CI);
1068 WrappedAction->setCompilerInstance(&CI);
1069 auto Ret = WrappedAction->BeginSourceFileAction(CI);
1075 WrappedAction->ExecuteAction();
1078 WrappedAction->EndSourceFileAction();
1082 return WrappedAction->usesPreprocessorOnly();
1085 return WrappedAction->getTranslationUnitKind();
1088 return WrappedAction->hasPCHSupport();
1091 return WrappedAction->hasASTFileSupport();
1094 return WrappedAction->hasIRSupport();
1097 return WrappedAction->hasCodeCompletionSupport();
1101 std::unique_ptr<FrontendAction> WrappedAction)
1102 : 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?
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...
virtual void IdentifierRead(serialization::IdentID ID, IdentifierInfo *II)
An identifier was deserialized from the AST file.
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
ASTContext & getASTContext() const
void setModuleManager(IntrusiveRefCntPtr< ASTReader > Reader)
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()
virtual void ReaderInitialized(ASTReader *Reader)
The ASTReader was initialized.
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
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()
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, ArrayRef< RemappedFile > RemappedFiles=None, CaptureDiagsKind CaptureDiagnostics=CaptureDiagsKind::None, bool AllowPCHWithCompilerErrors=false, bool UserFilesAreVolatile=false)
Create a ASTUnit from an AST file.
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)
virtual void SelectorRead(serialization::SelectorID iD, Selector Sel)
A selector was read from the AST file.
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.
virtual void DeclRead(serialization::DeclID ID, const Decl *D)
A decl was deserialized from the AST file.
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?
std::string getSpecificModuleCachePath()
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.
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...
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.
virtual void MacroDefinitionRead(serialization::PreprocessedEntityID, MacroDefinitionRecord *MD)
A macro definition was read from the AST file.
static bool Ret(InterpState &S, CodePtr &PC, APValue &Result)
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
Information about a directory name as found in the module map file.
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...
virtual void TypeRead(serialization::TypeIdx Idx, QualType T)
A type was deserialized from the AST file.
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.
void addTopHeader(const FileEntry *File)
Add a top-level header associated with this module.
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)
DirectoryName getUmbrellaDir() const
Retrieve the directory for which this module serves as the umbrella.
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...
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< 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.