29 #include "llvm/Support/ErrorHandling.h"
30 #include "llvm/Support/FileSystem.h"
31 #include "llvm/Support/Path.h"
32 #include "llvm/Support/Timer.h"
33 #include "llvm/Support/raw_ostream.h"
34 #include <system_error>
35 using namespace clang;
46 explicit DelegatingDeserializationListener(
48 : Previous(Previous), DeletePrevious(DeletePrevious) {}
49 ~DelegatingDeserializationListener()
override {
54 void ReaderInitialized(
ASTReader *Reader)
override {
78 Previous->MacroDefinitionRead(PPID, MD);
83 class DeserializedDeclsDumper :
public DelegatingDeserializationListener {
87 : DelegatingDeserializationListener(Previous, DeletePrevious) {}
91 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(D))
92 llvm::outs() <<
" - " << *ND;
95 DelegatingDeserializationListener::DeclRead(ID, D);
101 class DeserializedDeclsChecker :
public DelegatingDeserializationListener {
103 std::set<std::string> NamesToCheck;
107 const std::set<std::string> &NamesToCheck,
110 : DelegatingDeserializationListener(Previous, DeletePrevious), Ctx(Ctx),
111 NamesToCheck(NamesToCheck) {}
114 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(D))
115 if (NamesToCheck.find(ND->getNameAsString()) != NamesToCheck.end()) {
118 "%0 was deserialized");
119 Ctx.getDiagnostics().Report(Ctx.getFullLoc(D->
getLocation()), DiagID)
120 << ND->getNameAsString();
123 DelegatingDeserializationListener::DeclRead(ID, D);
134 std::unique_ptr<ASTUnit> AST) {
135 this->CurrentInput = CurrentInput;
136 CurrentASTUnit = std::move(AST);
145 std::unique_ptr<ASTConsumer>
153 if (FrontendPluginRegistry::begin() == FrontendPluginRegistry::end())
158 std::vector<std::unique_ptr<ASTConsumer>> Consumers;
159 std::vector<std::unique_ptr<ASTConsumer>> AfterConsumers;
160 for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
161 ie = FrontendPluginRegistry::end();
163 std::unique_ptr<PluginASTAction>
P = it->instantiate();
179 std::unique_ptr<ASTConsumer> PluginConsumer = P->CreateASTConsumer(CI, InFile);
181 Consumers.push_back(std::move(PluginConsumer));
183 AfterConsumers.push_back(std::move(PluginConsumer));
189 Consumers.push_back(std::move(Consumer));
190 for (
auto &C : AfterConsumers) {
191 Consumers.push_back(std::move(C));
194 return llvm::make_unique<MultiplexConsumer>(std::move(Consumers));
207 std::string &InputFile,
208 bool IsModuleMap =
false) {
210 auto MainFileID =
SourceMgr.getMainFileID();
212 bool Invalid =
false;
213 const auto *MainFileBuf =
SourceMgr.getBuffer(MainFileID, &Invalid);
217 std::unique_ptr<Lexer> RawLexer(
226 if (RawLexer->LexFromRawLexer(T) || T.
getKind() != tok::hash)
229 T.
getKind() != tok::numeric_constant)
237 .getAsInteger(10, LineNo))
241 RawLexer->LexFromRawLexer(T);
246 if (Literal.hadError)
248 RawLexer->LexFromRawLexer(T);
251 InputFile = Literal.GetString().str();
255 LineNoLoc, LineNo,
SourceMgr.getLineTableFilenameID(InputFile),
false,
263 Includes.append(RHS.begin(), RHS.end());
271 if (IsExternC && LangOpts.CPlusPlus)
272 Includes +=
"extern \"C\" {\n";
274 Includes +=
"#import \"";
276 Includes +=
"#include \"";
278 Includes += HeaderName;
281 if (IsExternC && LangOpts.CPlusPlus)
297 return std::error_code();
309 Diag.
Report(MissingHeader.FileNameLoc, diag::err_module_header_missing)
310 << MissingHeader.IsUmbrella << MissingHeader.FileName;
311 return std::error_code();
337 llvm::sys::path::native(UmbrellaDir.Entry->getName(), DirNative);
341 Dir !=
End && !EC; Dir.increment(EC)) {
344 if (!llvm::StringSwitch<bool>(llvm::sys::path::extension(Dir->getName()))
345 .Cases(
".h",
".H",
".hh",
".hpp",
true)
362 auto PathIt = llvm::sys::path::rbegin(Dir->getName());
363 for (
int I = 0;
I != Dir.level() + 1; ++
I, ++PathIt)
364 Components.push_back(*PathIt);
366 for (
auto It = Components.rbegin(),
End = Components.rend(); It !=
End;
368 llvm::sys::path::append(RelativeHeader, *It);
382 Sub != SubEnd; ++Sub)
384 LangOpts, FileMgr, Diag, ModMap, *Sub, Includes))
387 return std::error_code();
392 std::string &PresumedModuleMapFile,
398 FileID ModuleMapID = SrcMgr.getMainFileID();
404 if (IsPreprocessed) {
413 PresumedModuleMapFile))
416 if (SrcMgr.getBuffer(ModuleMapID)->getBufferSize() ==
Offset)
423 StringRef ModuleMapFilename) {
459 if (!OriginalModuleMapName.empty()) {
460 auto *OriginalModuleMap =
463 if (!OriginalModuleMap) {
465 << OriginalModuleMapName;
487 static std::unique_ptr<llvm::MemoryBuffer>
493 std::error_code Err = std::error_code();
508 return llvm::MemoryBuffer::getMemBufferCopy(
515 assert(!Instance &&
"Already processing a source file!");
516 assert(!Input.
isEmpty() &&
"Unexpected empty filename!");
520 StringRef InputFile = Input.
getFile();
521 bool HasBegunSourceFile =
false;
535 &Diags->getDiagnosticOptions()));
536 ASTDiags->setClient(Diags->getClient(),
false);
559 if (
auto ASTReader = AST->getASTReader()) {
563 for (ModuleFile &MF : MM)
564 if (&MF != &PrimaryModule)
574 auto Kind = AST->getInputKind();
577 AST->getPreprocessor().getHeaderSearchInfo().lookupModule(
578 AST->getLangOpts().CurrentModule,
false);
579 assert(ASTModule &&
"module file does not define its own module");
597 "This action does not have AST file support!");
610 HasBegunSourceFile =
true;
665 "This action does not have IR file support!");
669 HasBegunSourceFile =
true;
692 llvm::sys::path::native(PCHDir->getName(), DirNative);
696 Dir != DirEnd && !EC; Dir.
increment(EC)) {
701 SpecificModuleCachePath)) {
723 HasBegunSourceFile =
true;
734 std::string PresumedModuleMapFile;
735 unsigned OffsetToContents;
738 PresumedModuleMapFile, OffsetToContents))
747 if (OffsetToContents)
759 CurrentModule->IsSystem)))
777 std::string PresumedInputFile = InputFile;
781 std::unique_ptr<ASTConsumer> Consumer =
782 CreateWrappedASTConsumer(CI, PresumedInputFile);
801 assert(
hasPCHSupport() &&
"This action does not have PCH support!");
803 Consumer->GetASTDeserializationListener();
804 bool DeleteDeserialListener =
false;
806 DeserialListener =
new DeserializedDeclsDumper(DeserialListener,
807 DeleteDeserialListener);
808 DeleteDeserialListener =
true;
811 DeserialListener =
new DeserializedDeclsChecker(
814 DeserialListener, DeleteDeserialListener);
815 DeleteDeserialListener =
true;
822 DeleteDeserialListener);
833 DeleteDeserialListener);
853 "modules enabled but created an external source that "
854 "doesn't support modules");
886 if (HasBegunSourceFile)
946 llvm::errs() <<
"\nSTATISTICS FOR '" <<
getCurrentFile() <<
"':\n";
951 llvm::errs() <<
"\n";
1007 void PluginASTAction::anchor() { }
1009 std::unique_ptr<ASTConsumer>
1012 llvm_unreachable(
"Invalid CreateASTConsumer on preprocessor action!");
1015 std::unique_ptr<ASTConsumer>
1018 return WrappedAction->CreateASTConsumer(CI, InFile);
1021 return WrappedAction->BeginInvocation(CI);
1025 WrappedAction->setCompilerInstance(&CI);
1026 auto Ret = WrappedAction->BeginSourceFileAction(CI);
1032 WrappedAction->ExecuteAction();
1035 WrappedAction->EndSourceFileAction();
1039 return WrappedAction->usesPreprocessorOnly();
1042 return WrappedAction->getTranslationUnitKind();
1045 return WrappedAction->hasPCHSupport();
1048 return WrappedAction->hasASTFileSupport();
1051 return WrappedAction->hasIRSupport();
1054 return WrappedAction->hasCodeCompletionSupport();
1058 std::unique_ptr<FrontendAction> WrappedAction)
1059 : WrappedAction(std::move(WrappedAction)) {}
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
void setExternalSource(IntrusiveRefCntPtr< ExternalASTSource > Source)
Attach an external AST source to the AST context.
Defines the clang::ASTContext interface.
virtual bool isModelParsingAction() const
Is this action invoked on a model file?
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...
LangOptions & getLangOpts()
void resetAndLeakFileManager()
bool hasFileManager() const
ASTContext & getASTContext() const
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.
CompilerInvocation & getInvocation()
PreprocessorOptions & getPreprocessorOpts()
Header getUmbrellaHeader() const
Retrieve the header that serves as the umbrella header for this module.
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...
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.
bool hasASTConsumer() const
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 EndSourceFile()
Perform any per-file post processing, deallocate per-file objects, and run statistics and output file...
submodule_iterator submodule_begin()
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 "...
uint32_t IdentID
An ID number that refers to an identifier in an AST file.
void createSema(TranslationUnitKind TUKind, CodeCompleteConsumer *CompletionConsumer)
Create the Sema object to be used for parsing.
Load everything, including Sema.
virtual bool hasCodeCompletionSupport() const
Does this action support use with code completion?
Decl - This represents one declaration (or definition), e.g.
CompilerInstance & getCompilerInstance() const
void EndSourceFile()
Inform the preprocessor callbacks that processing is complete.
bool hasCodeCompletionConsumer() const
virtual bool usesPreprocessorOnly() const =0
Does this action only use the preprocessor?
llvm::MemoryBuffer * getBuffer(FileID FID, SourceLocation Loc, bool *Invalid=nullptr) const
Return the buffer for the specified FileID.
bool hasErrorOccurred() const
llvm::Registry< PluginASTAction > FrontendPluginRegistry
The frontend plugin registry.
TypePropertyCache< Private > Cache
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...
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
std::unique_ptr< llvm::MemoryBuffer > Buffer
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...
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, bool CaptureDiagnostics=false, bool AllowPCHWithCompilerErrors=false, bool UserFilesAreVolatile=false)
Create a ASTUnit from an AST file.
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...
TargetInfo & getTarget() const
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.
SourceManager & getSourceManager() const
Return the current source manager.
virtual directory_iterator dir_begin(const Twine &Dir, std::error_code &EC)=0
Get a directory_iterator for Dir.
Builtin::Context & getBuiltinInfo()
bool isHeaderUnavailableInModule(const FileEntry *Header, const Module *RequestingModule) const
Determine whether the given header is unavailable as part of the specified module.
std::string PresumedModuleMapFile
The presumed file name for the module map defining this module.
The virtual file system interface.
One of these records is kept for each identifier that is lexed.
const FrontendInputFile & getCurrentInput() const
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 createFileManager()
Create the file manager and replace any existing one with it.
void createSourceManager(FileManager &FileMgr)
Create the source manager and replace any existing one with it.
virtual bool hasASTFileSupport() const
Does this action support use with AST files?
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override
Create the AST consumer object for this action, if supported.
const LangOptions & getLangOpts() const
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
Token - This structure provides full information about a lexed token.
void setASTContext(ASTContext *Value)
setASTContext - Replace the current AST context.
CodeGenOptions & getCodeGenOpts()
An input iterator over the recursive contents of a virtual path, similar to llvm::sys::fs::recursive_...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
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.
bool hasPCHSupport() const override
Does this action support use with PCH?
Action is determined by the cc1 command-line.
directory_iterator & increment(std::error_code &EC)
Equivalent to operator++, with an error code.
unsigned ShowStats
Show frontend performance metrics and statistics.
bool isAvailable() const
Determine whether this module is available for use within the current translation unit...
FrontendOptions & getFrontendOpts()
ModuleManager & getModuleManager()
Retrieve the module manager.
IntrusiveRefCntPtr< vfs::FileSystem > getVirtualFileSystem() const
Load options and the preprocessor state.
DiagnosticConsumer & getDiagnosticClient() const
Concrete class used by the front-end to report problems and issues.
HeaderSearch & getHeaderSearchInfo() const
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)
StringRef getName() const
Module * getCurrentModule() const
void setASTConsumer(std::unique_ptr< ASTConsumer > Value)
setASTConsumer - Replace the current AST consumer; the compiler instance takes ownership of Value...
unsigned SkipFunctionBodies
Emit ARC errors even if the migrator can fix them.
IntrusiveRefCntPtr< ASTReader > getModuleManager() const
submodule_iterator submodule_end()
virtual bool BeginInvocation(CompilerInstance &CI)
Callback before starting processing a single input, giving the opportunity to modify the CompilerInvo...
tok::TokenKind getKind() 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()
detail::InMemoryDirectory::const_iterator I
bool DisablePCHValidation
When true, disables most of the normal validation performed on precompiled headers.
Preprocessor & getPreprocessor() const
Return the current preprocessor.
DiagnosticsEngine & getDiagnostics() const
static bool loadModuleMapForModuleBuild(CompilerInstance &CI, bool IsSystem, bool IsPreprocessed, std::string &PresumedModuleMapFile, unsigned &Offset)
std::vector< Module * >::iterator submodule_iterator
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.
bool hasVirtualFileSystem() const
static ErrorCode writeIndex(FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, StringRef Path)
Write a global index into the given.
void initializeForReplay(const SourceManager &Old)
Initialize this source manager suitably to replay the compilation described by Old.
const FileEntry * getFile(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Lookup, cache, and verify the specified file (real or virtual).
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
bool hasCodeCompletionSupport() const override
Does this action support use with code completion?
void resolveHeaderDirectives(const FileEntry *File) const
Resolve all lazy header directives for the specified file.
std::string CurrentModule
The name of the current module, of which the main source file is a part.
const DirectoryEntry * getDirectory(StringRef DirName, bool CacheFailure=true)
Lookup, cache, and verify the specified directory (real or virtual).
void setVirtualFileSystem(IntrusiveRefCntPtr< vfs::FileSystem > FS)
Replace the current virtual file system.
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?
ModuleBuildStack getModuleBuildStack() const
Retrieve the module build stack.
std::string getSpecificModuleCachePath()
WrapperFrontendAction(std::unique_ptr< FrontendAction > WrappedAction)
Construct a WrapperFrontendAction from an existing action, taking ownership of it.
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 BeginSourceFileAction(CompilerInstance &CI) override
Callback at the start of processing a single input.
Defines the clang::Preprocessor interface.
IntrusiveRefCntPtr< vfs::FileSystem > createVFSFromCompilerInvocation(const CompilerInvocation &CI, DiagnosticsEngine &Diags)
Not compiling a module interface at all.
void createASTContext()
Create the AST context.
const char * getDeclKindName() const
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.
unsigned ModulesEmbedAllFiles
Whether we should embed all used files into the PCM file.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
void setSema(Sema *S)
Replace the current Sema; the compiler instance takes ownership of S.
bool isNot(tok::TokenKind K) const
virtual bool hasIRSupport() const
Does this action support use with IR files?
virtual std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, StringRef InFile)=0
Create the AST consumer object for this action, if supported.
DiagnosticsEngine & getDiagnostics() const
Get the current diagnostics engine.
DirectoryName getUmbrellaDir() const
Retrieve the directory for which this module serves as the umbrella.
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.
bool hasSourceManager() const
FileSystemOptions & getFileSystemOpts()
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
Encodes a location in the source.
const PCHContainerReader & getPCHContainerReader() const
Return the appropriate PCHContainerReader depending on the current CodeGenOptions.
void resetAndLeakSourceManager()
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
bool Execute()
Set the source manager's main input file, and run the action.
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.
bool isValid() const
Return true if this is a valid SourceLocation object.
void ExecuteAction() override
Callback to run the program action, using the initialized compiler instance.
const StringRef getCurrentFile() const
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...
std::unordered_map< std::string, std::vector< std::string > > PluginArgs
Args to pass to the plugins.
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.
FileID getMainFileID() const
Returns the FileID of the main source file.
void createPreprocessor(TranslationUnitKind TUKind)
Create the preprocessor, using the invocation, file, and source managers, and replace any existing on...
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 hasFrontendTimer() const
void setPreprocessor(std::shared_ptr< Preprocessor > Value)
Replace the current preprocessor.
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...
FileManager & getFileManager() const
Return the current file manager to the caller.
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.
bool isCurrentFileAST() const
void addTopHeader(const FileEntry *File)
Add a top-level header associated with this module.
virtual bool hasPCHSupport() const
Does this action support use with PCH?
void clearOutputFiles(bool EraseFiles)
clearOutputFiles - Clear the output file list.
void BuryPointer(const void *Ptr)
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)
void PrintStats() const
Print some statistics to stderr that indicate how well the hashing is doing.
CodeCompleteConsumer & getCodeCompletionConsumer() const
bool hasASTContext() const
std::vector< std::string > AddPluginActions
The list of plugin actions to run in addition to the normal action.
Cached information about one directory (either on disk or in the virtual file system).
unsigned DisableFree
Disable memory freeing on exit.
An input iterator over the entries in a virtual path, similar to llvm::sys::fs::directory_iterator.
An external AST source that overrides the layout of a specified set of record types.
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
bool shouldBuildGlobalModuleIndex() const
Indicates whether we should (re)build the global module index.
void resetAndLeakASTContext()
virtual bool BeginSourceFileAction(CompilerInstance &CI)
Callback at the start of processing a single input.
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
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...
llvm::Timer & getFrontendTimer() const
TranslationUnitKind
Describes the kind of translation unit being processed.
StringLiteralParser - This decodes string escape characters and performs wide string analysis and Tra...
void PrintStats() const
Print statistics to stderr.
A SourceLocation and its associated SourceManager.
bool hasPreprocessor() const
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.
SourceLocation getLocation() const
NamedDecl - This represents a decl with a name.
bool DumpDeserializedPCHDecls
Dump declarations that are deserialized from PCH, for testing.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
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)
void setInferredModuleAllowedBy(Module *M, const FileEntry *ModuleMap)
TargetOptions & getTargetOpts()
This class handles loading and caching of source files into memory.
static void addHeaderInclude(StringRef HeaderName, SmallVectorImpl< char > &Includes, const LangOptions &LangOpts, bool IsExternC)
A type index; the type ID with the qualifier bits removed.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
std::vector< std::string > ModuleMapFiles
The list of module map files to load before processing the input.