29 #include "llvm/Support/BuryPointer.h" 30 #include "llvm/Support/ErrorHandling.h" 31 #include "llvm/Support/FileSystem.h" 32 #include "llvm/Support/Path.h" 33 #include "llvm/Support/Timer.h" 34 #include "llvm/Support/raw_ostream.h" 35 #include <system_error> 36 using namespace clang;
47 explicit DelegatingDeserializationListener(
49 : Previous(Previous), DeletePrevious(DeletePrevious) {}
50 ~DelegatingDeserializationListener()
override {
55 void ReaderInitialized(
ASTReader *Reader)
override {
84 class DeserializedDeclsDumper :
public DelegatingDeserializationListener {
88 : DelegatingDeserializationListener(Previous, DeletePrevious) {}
92 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
93 llvm::outs() <<
" - ";
94 ND->printQualifiedName(llvm::outs());
98 DelegatingDeserializationListener::DeclRead(ID, D);
104 class DeserializedDeclsChecker :
public DelegatingDeserializationListener {
106 std::set<std::string> NamesToCheck;
110 const std::set<std::string> &NamesToCheck,
113 : DelegatingDeserializationListener(Previous, DeletePrevious), Ctx(Ctx),
114 NamesToCheck(NamesToCheck) {}
117 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(D))
118 if (NamesToCheck.find(ND->getNameAsString()) != NamesToCheck.end()) {
121 "%0 was deserialized");
123 << ND->getNameAsString();
126 DelegatingDeserializationListener::DeclRead(ID, D);
137 std::unique_ptr<ASTUnit> AST) {
138 this->CurrentInput = CurrentInput;
139 CurrentASTUnit = std::move(AST);
148 std::unique_ptr<ASTConsumer>
156 bool FoundAllPlugins =
true;
159 for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
160 ie = FrontendPluginRegistry::end();
162 if (it->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 (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
186 ie = FrontendPluginRegistry::end();
188 std::unique_ptr<PluginASTAction>
P = it->instantiate();
204 std::unique_ptr<ASTConsumer> PluginConsumer = P->CreateASTConsumer(CI, InFile);
206 Consumers.push_back(std::move(PluginConsumer));
208 AfterConsumers.push_back(std::move(PluginConsumer));
214 Consumers.push_back(std::move(Consumer));
215 for (
auto &
C : AfterConsumers) {
216 Consumers.push_back(std::move(
C));
219 return std::make_unique<MultiplexConsumer>(std::move(Consumers));
232 std::string &InputFile,
233 bool IsModuleMap =
false) {
237 bool Invalid =
false;
238 const auto *MainFileBuf = SourceMgr.getBuffer(MainFileID, &Invalid);
242 std::unique_ptr<Lexer> RawLexer(
251 if (RawLexer->LexFromRawLexer(T) || T.
getKind() != tok::hash)
254 T.
getKind() != tok::numeric_constant)
262 .getAsInteger(10, LineNo))
266 RawLexer->LexFromRawLexer(T);
271 if (Literal.hadError)
273 RawLexer->LexFromRawLexer(T);
276 InputFile = Literal.GetString().str();
280 LineNoLoc, LineNo, SourceMgr.getLineTableFilenameID(InputFile),
false,
288 Includes.append(RHS.begin(), RHS.end());
296 if (IsExternC && LangOpts.CPlusPlus)
297 Includes +=
"extern \"C\" {\n";
299 Includes +=
"#import \"";
301 Includes +=
"#include \"";
303 Includes += HeaderName;
306 if (IsExternC && LangOpts.CPlusPlus)
322 return std::error_code();
334 Diag.
Report(MissingHeader.FileNameLoc, diag::err_module_header_missing)
335 << MissingHeader.IsUmbrella << MissingHeader.FileName;
336 return std::error_code();
362 llvm::sys::path::native(UmbrellaDir.Entry->getName(), DirNative);
365 for (llvm::vfs::recursive_directory_iterator Dir(FS, DirNative, EC),
End;
366 Dir !=
End && !EC; Dir.increment(EC)) {
369 if (!llvm::StringSwitch<bool>(llvm::sys::path::extension(Dir->path()))
370 .Cases(
".h",
".H",
".hh",
".hpp",
true)
374 auto Header = FileMgr.
getFile(Dir->path());
387 auto PathIt = llvm::sys::path::rbegin(Dir->path());
388 for (
int I = 0; I != Dir.level() + 1; ++I, ++PathIt)
389 Components.push_back(*PathIt);
391 for (
auto It = Components.rbegin(),
End = Components.rend(); It !=
End;
393 llvm::sys::path::append(RelativeHeader, *It);
409 LangOpts, FileMgr, Diag, ModMap, *
Sub, Includes))
412 return std::error_code();
417 std::string &PresumedModuleMapFile,
423 FileID ModuleMapID = SrcMgr.getMainFileID();
429 if (IsPreprocessed) {
438 PresumedModuleMapFile))
441 if (SrcMgr.getBuffer(ModuleMapID)->getBufferSize() ==
Offset)
448 StringRef ModuleMapFilename) {
484 if (!OriginalModuleMapName.empty()) {
485 auto OriginalModuleMap =
488 if (!OriginalModuleMap) {
490 << OriginalModuleMapName;
512 static std::unique_ptr<llvm::MemoryBuffer>
518 std::error_code Err = std::error_code();
533 return llvm::MemoryBuffer::getMemBufferCopy(
540 assert(!Instance &&
"Already processing a source file!");
541 assert(!Input.
isEmpty() &&
"Unexpected empty filename!");
545 bool HasBegunSourceFile =
false;
559 &Diags->getDiagnosticOptions()));
560 ASTDiags->setClient(Diags->getClient(),
false);
563 StringRef InputFile = Input.
getFile();
586 if (
auto ASTReader = AST->getASTReader()) {
591 if (&MF != &PrimaryModule)
601 auto Kind = AST->getInputKind();
604 AST->getPreprocessor().getHeaderSearchInfo().lookupModule(
605 AST->getLangOpts().CurrentModule,
false);
606 assert(ASTModule &&
"module file does not define its own module");
609 auto &OldSM = AST->getSourceManager();
610 FileID ID = OldSM.getMainFileID();
611 if (
auto *File = OldSM.getFileEntryForID(ID))
624 "This action does not have AST file support!");
629 StringRef InputFile = Input.
getFile();
640 HasBegunSourceFile =
true;
689 "This action does not have IR file support!");
693 HasBegunSourceFile =
true;
716 llvm::sys::path::native((*PCHDir)->getName(), DirNative);
719 for (llvm::vfs::directory_iterator Dir = FS.dir_begin(DirNative, EC),
721 Dir != DirEnd && !EC; Dir.increment(EC)) {
726 SpecificModuleCachePath)) {
748 HasBegunSourceFile =
true;
759 std::string PresumedModuleMapFile;
760 unsigned OffsetToContents;
763 PresumedModuleMapFile, OffsetToContents))
772 if (OffsetToContents)
785 assert(BufferID.isValid() &&
"couldn't creaate module buffer ID");
786 SourceMgr.setMainFileID(BufferID);
823 std::unique_ptr<ASTConsumer> Consumer =
824 CreateWrappedASTConsumer(CI, PresumedInputFile);
843 assert(
hasPCHSupport() &&
"This action does not have PCH support!");
845 Consumer->GetASTDeserializationListener();
846 bool DeleteDeserialListener =
false;
848 DeserialListener =
new DeserializedDeclsDumper(DeserialListener,
849 DeleteDeserialListener);
850 DeleteDeserialListener =
true;
853 DeserialListener =
new DeserializedDeclsChecker(
856 DeserialListener, DeleteDeserialListener);
857 DeleteDeserialListener =
true;
864 DeleteDeserialListener);
875 DeleteDeserialListener);
895 "modules enabled but created an external source that " 896 "doesn't support modules");
919 if (HasBegunSourceFile)
943 if (!Cache.empty()) {
949 consumeError(std::move(Err));
954 return llvm::Error::success();
985 llvm::errs() <<
"\nSTATISTICS FOR '" <<
getCurrentFile() <<
"':\n";
990 llvm::errs() <<
"\n";
1002 llvm::BuryPointer(std::move(CurrentASTUnit));
1046 void PluginASTAction::anchor() { }
1048 std::unique_ptr<ASTConsumer>
1051 llvm_unreachable(
"Invalid CreateASTConsumer on preprocessor action!");
1055 return WrappedAction->PrepareToExecuteAction(CI);
1057 std::unique_ptr<ASTConsumer>
1060 return WrappedAction->CreateASTConsumer(CI, InFile);
1063 return WrappedAction->BeginInvocation(CI);
1067 WrappedAction->setCompilerInstance(&CI);
1068 auto Ret = WrappedAction->BeginSourceFileAction(CI);
1074 WrappedAction->ExecuteAction();
1077 WrappedAction->EndSourceFileAction();
1081 return WrappedAction->usesPreprocessorOnly();
1084 return WrappedAction->getTranslationUnitKind();
1087 return WrappedAction->hasPCHSupport();
1090 return WrappedAction->hasASTFileSupport();
1093 return WrappedAction->hasIRSupport();
1096 return WrappedAction->hasCodeCompletionSupport();
1100 std::unique_ptr<FrontendAction> WrappedAction)
1101 : 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?
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.
IntrusiveRefCntPtr< ASTReader > getModuleManager() const
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.
void createModuleManager()
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)
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.