clang  3.7.0
Classes | Public Member Functions | List of all members
clang::CompilerInstance Class Reference

#include <CompilerInstance.h>

Inheritance diagram for clang::CompilerInstance:
[legend]
Collaboration diagram for clang::CompilerInstance:
[legend]

Public Member Functions

 CompilerInstance (std::shared_ptr< PCHContainerOperations > PCHContainerOps=std::make_shared< PCHContainerOperations >(), bool BuildingModule=false)
 
 ~CompilerInstance () override
 
High-Level Operations

{

bool ExecuteAction (FrontendAction &Act)
 
Compiler Invocation and Options

}

{

bool hasInvocation () const
 
CompilerInvocationgetInvocation ()
 
void setInvocation (CompilerInvocation *Value)
 setInvocation - Replace the current invocation. More...
 
bool shouldBuildGlobalModuleIndex () const
 Indicates whether we should (re)build the global module index. More...
 
void setBuildGlobalModuleIndex (bool Build)
 Set the flag indicating whether we should (re)build the global module index. More...
 
Forwarding Methods

}

{

AnalyzerOptionsRef getAnalyzerOpts ()
 
CodeGenOptionsgetCodeGenOpts ()
 
const CodeGenOptionsgetCodeGenOpts () const
 
DependencyOutputOptionsgetDependencyOutputOpts ()
 
const DependencyOutputOptionsgetDependencyOutputOpts () const
 
DiagnosticOptionsgetDiagnosticOpts ()
 
const DiagnosticOptionsgetDiagnosticOpts () const
 
FileSystemOptionsgetFileSystemOpts ()
 
const FileSystemOptionsgetFileSystemOpts () const
 
FrontendOptionsgetFrontendOpts ()
 
const FrontendOptionsgetFrontendOpts () const
 
HeaderSearchOptionsgetHeaderSearchOpts ()
 
const HeaderSearchOptionsgetHeaderSearchOpts () const
 
LangOptionsgetLangOpts ()
 
const LangOptionsgetLangOpts () const
 
PreprocessorOptionsgetPreprocessorOpts ()
 
const PreprocessorOptionsgetPreprocessorOpts () const
 
PreprocessorOutputOptionsgetPreprocessorOutputOpts ()
 
const PreprocessorOutputOptionsgetPreprocessorOutputOpts () const
 
TargetOptionsgetTargetOpts ()
 
const TargetOptionsgetTargetOpts () const
 
Diagnostics Engine

}

{

bool hasDiagnostics () const
 
DiagnosticsEnginegetDiagnostics () const
 Get the current diagnostics engine. More...
 
void setDiagnostics (DiagnosticsEngine *Value)
 setDiagnostics - Replace the current diagnostics engine. More...
 
DiagnosticConsumergetDiagnosticClient () const
 
Target Info

}

{

bool hasTarget () const
 
TargetInfogetTarget () const
 
void setTarget (TargetInfo *Value)
 Replace the current diagnostics engine. More...
 
Virtual File System

}

{

bool hasVirtualFileSystem () const
 
vfs::FileSystemgetVirtualFileSystem () const
 
void setVirtualFileSystem (IntrusiveRefCntPtr< vfs::FileSystem > FS)
 Replace the current virtual file system. More...
 
File Manager

}

{

bool hasFileManager () const
 
FileManagergetFileManager () const
 Return the current file manager to the caller. More...
 
void resetAndLeakFileManager ()
 
void setFileManager (FileManager *Value)
 Replace the current file manager and virtual file system. More...
 
Source Manager

}

{

bool hasSourceManager () const
 
SourceManagergetSourceManager () const
 Return the current source manager. More...
 
void resetAndLeakSourceManager ()
 
void setSourceManager (SourceManager *Value)
 setSourceManager - Replace the current source manager. More...
 
Preprocessor

}

{

bool hasPreprocessor () const
 
PreprocessorgetPreprocessor () const
 Return the current preprocessor. More...
 
void resetAndLeakPreprocessor ()
 
void setPreprocessor (Preprocessor *Value)
 Replace the current preprocessor. More...
 
ASTContext

}

{

bool hasASTContext () const
 
ASTContextgetASTContext () const
 
void resetAndLeakASTContext ()
 
void setASTContext (ASTContext *Value)
 setASTContext - Replace the current AST context. More...
 
void setSema (Sema *S)
 Replace the current Sema; the compiler instance takes ownership of S. More...
 
ASTConsumer

}

{

bool hasASTConsumer () const
 
ASTConsumergetASTConsumer () const
 
std::unique_ptr< ASTConsumertakeASTConsumer ()
 
void setASTConsumer (std::unique_ptr< ASTConsumer > Value)
 
Semantic analysis

}

{

bool hasSema () const
 
SemagetSema () const
 
std::unique_ptr< SematakeSema ()
 
void resetAndLeakSema ()
 
Module Management

}

{

IntrusiveRefCntPtr< ASTReadergetModuleManager () const
 
void setModuleManager (IntrusiveRefCntPtr< ASTReader > Reader)
 
std::shared_ptr
< ModuleDependencyCollector
getModuleDepCollector () const
 
void setModuleDepCollector (std::shared_ptr< ModuleDependencyCollector > Collector)
 
std::shared_ptr
< PCHContainerOperations
getPCHContainerOperations () const
 
const PCHContainerWritergetPCHContainerWriter () const
 
const PCHContainerReadergetPCHContainerReader () const
 
Code Completion

}

{

bool hasCodeCompletionConsumer () const
 
CodeCompleteConsumergetCodeCompletionConsumer () const
 
void setCodeCompletionConsumer (CodeCompleteConsumer *Value)
 
Frontend timer

}

{

bool hasFrontendTimer () const
 
llvm::Timer & getFrontendTimer () const
 
Output Files

}

{

void addOutputFile (OutputFile &&OutFile)
 
void clearOutputFiles (bool EraseFiles)
 
- Public Member Functions inherited from clang::ModuleLoader
 ModuleLoader (bool BuildingModule=false)
 
virtual ~ModuleLoader ()
 
bool buildingModule () const
 Returns true if this instance is building a module. More...
 
void setBuildingModule (bool BuildingModuleFlag)
 Flag indicating whether this instance is building a module. More...
 

Construction Utility Methods

}

{

void createDiagnostics (DiagnosticConsumer *Client=nullptr, bool ShouldOwnClient=true)
 
void createFileManager ()
 Create the file manager and replace any existing one with it. More...
 
void createSourceManager (FileManager &FileMgr)
 Create the source manager and replace any existing one with it. More...
 
void createPreprocessor (TranslationUnitKind TUKind)
 
std::string getSpecificModuleCachePath ()
 
void createASTContext ()
 Create the AST context. More...
 
void createPCHExternalASTSource (StringRef Path, bool DisablePCHValidation, bool AllowPCHWithCompilerErrors, void *DeserializationListener, bool OwnDeserializationListener)
 
void createCodeCompletionConsumer ()
 
void createSema (TranslationUnitKind TUKind, CodeCompleteConsumer *CompletionConsumer)
 Create the Sema object to be used for parsing. More...
 
void createFrontendTimer ()
 Create the frontend timer and replace any existing one with it. More...
 
raw_pwrite_stream * createDefaultOutputFile (bool Binary=true, StringRef BaseInput="", StringRef Extension="")
 
raw_pwrite_stream * createOutputFile (StringRef OutputPath, bool Binary, bool RemoveFileOnSignal, StringRef BaseInput, StringRef Extension, bool UseTemporary, bool CreateMissingDirectories=false)
 
std::unique_ptr
< raw_pwrite_stream > 
createOutputFile (StringRef OutputPath, std::error_code &Error, bool Binary, bool RemoveFileOnSignal, StringRef BaseInput, StringRef Extension, bool UseTemporary, bool CreateMissingDirectories, std::string *ResultPathName, std::string *TempPathName)
 
llvm::raw_null_ostream * createNullOutputFile ()
 
static IntrusiveRefCntPtr
< DiagnosticsEngine
createDiagnostics (DiagnosticOptions *Opts, DiagnosticConsumer *Client=nullptr, bool ShouldOwnClient=true, const CodeGenOptions *CodeGenOpts=nullptr)
 
static IntrusiveRefCntPtr
< ASTReader
createPCHExternalASTSource (StringRef Path, StringRef Sysroot, bool DisablePCHValidation, bool AllowPCHWithCompilerErrors, Preprocessor &PP, ASTContext &Context, const PCHContainerReader &PCHContainerRdr, void *DeserializationListener, bool OwnDeserializationListener, bool Preamble, bool UseGlobalModuleIndex)
 
static CodeCompleteConsumercreateCodeCompletionConsumer (Preprocessor &PP, StringRef Filename, unsigned Line, unsigned Column, const CodeCompleteOptions &Opts, raw_ostream &OS)
 

Initialization Utility Methods

}

{

bool InitializeSourceManager (const FrontendInputFile &Input)
 
void createModuleManager ()
 } More...
 
bool loadModuleFile (StringRef FileName)
 
ModuleLoadResult loadModule (SourceLocation ImportLoc, ModuleIdPath Path, Module::NameVisibilityKind Visibility, bool IsInclusionDirective) override
 Attempt to load the given module. More...
 
void makeModuleVisible (Module *Mod, Module::NameVisibilityKind Visibility, SourceLocation ImportLoc) override
 Make the given module visible. More...
 
bool hadModuleLoaderFatalFailure () const
 
GlobalModuleIndexloadGlobalModuleIndex (SourceLocation TriggerLoc) override
 Load, create, or return global module. This function returns an existing global module index, if one had already been loaded or created, or loads one if it exists, or creates one if it doesn't exist. Also, importantly, if the index doesn't cover all the modules in the module map, it will be update to do so here, because of its use in searching for needed module imports and associated fixit messages. More...
 
bool lookupMissingImports (StringRef Name, SourceLocation TriggerLoc) override
 
void addDependencyCollector (std::shared_ptr< DependencyCollector > Listener)
 
static bool InitializeSourceManager (const FrontendInputFile &Input, DiagnosticsEngine &Diags, FileManager &FileMgr, SourceManager &SourceMgr, const FrontendOptions &Opts)
 

Additional Inherited Members

- Public Attributes inherited from clang::ModuleLoader
bool HadFatalFailure
 

Detailed Description

CompilerInstance - Helper class for managing a single instance of the Clang compiler.

The CompilerInstance serves two purposes: (1) It manages the various objects which are necessary to run the compiler, for example the preprocessor, the target information, and the AST context. (2) It provides utility routines for constructing and manipulating the common Clang objects.

The compiler instance generally owns the instance of all the objects that it manages. However, clients can still share objects by manually setting the object and retaking ownership prior to destroying the CompilerInstance.

The compiler instance is intended to simplify clients, but not to lock them in to the compiler instance for everything. When possible, utility functions come in two forms; a short form that reuses the CompilerInstance objects, and a long form that takes explicit instances of any required objects.

Definition at line 71 of file CompilerInstance.h.

Constructor & Destructor Documentation

CompilerInstance::CompilerInstance ( std::shared_ptr< PCHContainerOperations PCHContainerOps = std::make_shared<PCHContainerOperations>(),
bool  BuildingModule = false 
)
explicit

Definition at line 54 of file CompilerInstance.cpp.

CompilerInstance::~CompilerInstance ( )
override

Definition at line 62 of file CompilerInstance.cpp.

Member Function Documentation

void clang::CompilerInstance::addDependencyCollector ( std::shared_ptr< DependencyCollector Listener)
inline

Definition at line 772 of file CompilerInstance.h.

void CompilerInstance::addOutputFile ( OutputFile &&  OutFile)

addOutputFile - Add an output file onto the list of tracked output files.

Parameters
OutFile- The output file info.

Definition at line 527 of file CompilerInstance.cpp.

Referenced by createNullOutputFile(), and createOutputFile().

void CompilerInstance::clearOutputFiles ( bool  EraseFiles)

clearOutputFiles - Clear the output file list, destroying the contained output streams.

Parameters
EraseFiles- If true, attempt to erase the files from disk.

Definition at line 532 of file CompilerInstance.cpp.

References getDiagnostics(), and clang::DiagnosticsEngine::Report().

Referenced by clang::FrontendAction::BeginSourceFile(), and clang::FrontendAction::EndSourceFile().

void CompilerInstance::createASTContext ( )
void CompilerInstance::createCodeCompletionConsumer ( )

Create a code completion consumer using the invocation; note that this will cause the source manager to truncate the input source file at the completion point.

Definition at line 476 of file CompilerInstance.cpp.

References clang::FrontendOptions::CodeCompletionAt, clang::ParsedSourceLocation::Column, EnableCodeCompletion(), clang::ParsedSourceLocation::FileName, clang::Preprocessor::getDiagnostics(), getFrontendOpts(), getPreprocessor(), clang::ParsedSourceLocation::Line, clang::DiagnosticsEngine::Report(), and setCodeCompletionConsumer().

Referenced by clang::ASTFrontendAction::ExecuteAction().

CodeCompleteConsumer * CompilerInstance::createCodeCompletionConsumer ( Preprocessor PP,
StringRef  Filename,
unsigned  Line,
unsigned  Column,
const CodeCompleteOptions Opts,
raw_ostream &  OS 
)
static

Create a code completion consumer to print code completion results, at Filename, Line, and Column, to the given output stream OS.

Definition at line 506 of file CompilerInstance.cpp.

References EnableCodeCompletion().

raw_pwrite_stream * CompilerInstance::createDefaultOutputFile ( bool  Binary = true,
StringRef  BaseInput = "",
StringRef  Extension = "" 
)

Create the default output file (from the invocation's options) and add it to the list of tracked output files.

The files created by this function always use temporary files to write to their result (that is, the data is written to a temporary file which will atomically replace the target output on success).

Returns
- Null on error.

Definition at line 563 of file CompilerInstance.cpp.

References createOutputFile(), and getFrontendOpts().

Referenced by clang::HTMLPrintAction::CreateASTConsumer(), clang::ASTPrintAction::CreateASTConsumer(), clang::RewriteMacrosAction::ExecuteAction(), clang::RewriteTestAction::ExecuteAction(), clang::RewriteIncludesAction::ExecuteAction(), clang::GeneratePTHAction::ExecuteAction(), clang::PrintPreprocessedAction::ExecuteAction(), and GetOutputStream().

void CompilerInstance::createDiagnostics ( DiagnosticConsumer Client = nullptr,
bool  ShouldOwnClient = true 
)

Create the diagnostics engine using the invocation's diagnostic options and replace any existing one with it.

Note that this routine also replaces the diagnostic client, allocating one if one is not provided.

Parameters
ClientIf non-NULL, a diagnostic client that will be attached to (and, then, owned by) the DiagnosticsEngine inside this AST unit.
ShouldOwnClientIf Client is non-NULL, specifies whether the diagnostic object should take ownership of the client.

Definition at line 182 of file CompilerInstance.cpp.

References getCodeGenOpts(), and getDiagnosticOpts().

Referenced by clang::createInvocationFromCommandLine(), and clang::tooling::FrontendActionFactory::runInvocation().

IntrusiveRefCntPtr< DiagnosticsEngine > CompilerInstance::createDiagnostics ( DiagnosticOptions Opts,
DiagnosticConsumer Client = nullptr,
bool  ShouldOwnClient = true,
const CodeGenOptions CodeGenOpts = nullptr 
)
static

Create a DiagnosticsEngine object with a the TextDiagnosticPrinter.

If no diagnostic client is provided, this creates a DiagnosticConsumer that is owned by the returned diagnostic object, if using directly the caller is responsible for releasing the returned DiagnosticsEngine's client eventually.

Parameters
Opts- The diagnostic options; note that the created text diagnostic object contains a reference to these options.
ClientIf non-NULL, a diagnostic client that will be attached to (and, then, owned by) the returned DiagnosticsEngine object.
CodeGenOptsIf non-NULL, the code gen options in use, which may be used by some diagnostics printers (for logging purposes only).
Returns
The new object on success, or null on failure.

Definition at line 189 of file CompilerInstance.cpp.

References clang::DiagnosticOptions::DiagnosticLogFile, clang::DiagnosticOptions::DiagnosticSerializationFile, clang::ProcessWarningOptions(), SetUpDiagnosticLog(), and SetupSerializedDiagnostics().

void CompilerInstance::createFileManager ( )

Create the file manager and replace any existing one with it.

Definition at line 224 of file CompilerInstance.cpp.

References getFileSystemOpts(), clang::vfs::getRealFileSystem(), hasVirtualFileSystem(), and setVirtualFileSystem().

Referenced by clang::FrontendAction::BeginSourceFile().

void CompilerInstance::createFrontendTimer ( )

Create the frontend timer and replace any existing one with it.

Definition at line 499 of file CompilerInstance.cpp.

Referenced by ExecuteAction().

void CompilerInstance::createModuleManager ( )
llvm::raw_null_ostream * CompilerInstance::createNullOutputFile ( )

Definition at line 570 of file CompilerInstance.cpp.

References addOutputFile().

Referenced by GetOutputStream().

raw_pwrite_stream * CompilerInstance::createOutputFile ( StringRef  OutputPath,
bool  Binary,
bool  RemoveFileOnSignal,
StringRef  BaseInput,
StringRef  Extension,
bool  UseTemporary,
bool  CreateMissingDirectories = false 
)

Create a new output file and add it to the list of tracked output files, optionally deriving the output path name.

Returns
- Null on error.

Definition at line 578 of file CompilerInstance.cpp.

References addOutputFile(), getDiagnostics(), and clang::DiagnosticsEngine::Report().

Referenced by clang::GeneratePCHAction::ComputeASTConsumerArguments(), clang::GenerateModuleAction::ComputeASTConsumerArguments(), and createDefaultOutputFile().

std::unique_ptr< llvm::raw_pwrite_stream > CompilerInstance::createOutputFile ( StringRef  OutputPath,
std::error_code &  Error,
bool  Binary,
bool  RemoveFileOnSignal,
StringRef  BaseInput,
StringRef  Extension,
bool  UseTemporary,
bool  CreateMissingDirectories,
std::string *  ResultPathName,
std::string *  TempPathName 
)

Create a new output file, optionally deriving the output path name.

If OutputPath is empty, then createOutputFile will derive an output path location as BaseInput, with any suffix removed, and Extension appended. If OutputPath is not stdout and UseTemporary is true, createOutputFile will create a new temporary file that must be renamed to OutputPath in the end.

Parameters
OutputPath- If given, the path to the output file.
Error[out] - On failure, the error.
BaseInput- If OutputPath is empty, the input path name to use for deriving the output path.
Extension- The extension to use for derived output names.
Binary- The mode to open the file in.
RemoveFileOnSignal- Whether the file should be registered with llvm::sys::RemoveFileOnSignal. Note that this is not safe for multithreaded use, as the underlying signal mechanism is not reentrant
UseTemporary- Create a new temporary file that must be renamed to OutputPath in the end.
CreateMissingDirectories- When UseTemporary is true, create missing directories in the output path.
ResultPathName[out] - If given, the result path name will be stored here on success.
TempPathName[out] - If given, the temporary file path name will be stored here on success.

Definition at line 602 of file CompilerInstance.cpp.

void CompilerInstance::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.

Definition at line 395 of file CompilerInstance.cpp.

References getASTContext(), getFrontendOpts(), getHeaderSearchOpts(), getPCHContainerReader(), getPreprocessor(), getPreprocessorOpts(), and clang::PreprocessorOptions::PrecompiledPreambleBytes.

Referenced by clang::FrontendAction::BeginSourceFile().

IntrusiveRefCntPtr< ASTReader > CompilerInstance::createPCHExternalASTSource ( StringRef  Path,
StringRef  Sysroot,
bool  DisablePCHValidation,
bool  AllowPCHWithCompilerErrors,
Preprocessor PP,
ASTContext Context,
const PCHContainerReader PCHContainerRdr,
void *  DeserializationListener,
bool  OwnDeserializationListener,
bool  Preamble,
bool  UseGlobalModuleIndex 
)
static
void CompilerInstance::createPreprocessor ( TranslationUnitKind  TUKind)
void CompilerInstance::createSema ( TranslationUnitKind  TUKind,
CodeCompleteConsumer CompletionConsumer 
)

Create the Sema object to be used for parsing.

Definition at line 519 of file CompilerInstance.cpp.

References getASTConsumer(), getASTContext(), and getPreprocessor().

Referenced by clang::ASTFrontendAction::ExecuteAction().

void CompilerInstance::createSourceManager ( FileManager FileMgr)

Create the source manager and replace any existing one with it.

Definition at line 234 of file CompilerInstance.cpp.

References getDiagnostics(), and SourceMgr.

Referenced by clang::FrontendAction::BeginSourceFile(), and clang::tooling::FrontendActionFactory::runInvocation().

bool CompilerInstance::ExecuteAction ( FrontendAction Act)

ExecuteAction - Execute the provided action against the compiler's CompilerInvocation object.

This function makes the following assumptions:

  • The invocation options should be initialized. This function does not handle the '-help' or '-version' options, clients should handle those directly.
  • The diagnostics engine should have already been created by the client.
  • No other CompilerInstance state should have been initialized (this is an unchecked error).
  • Clients should have initialized any LLVM target features that may be required.
  • Clients should eventually call llvm_shutdown() upon the completion of this routine to ensure that any managed objects are properly destroyed.

Note that this routine may write output to 'stderr'.

Parameters
Act- The action to execute.
Returns
- True on success.

Definition at line 776 of file CompilerInstance.cpp.

References clang::TargetInfo::adjust(), clang::FrontendAction::BeginSourceFile(), CLANG_VERSION_STRING, clang::SourceManager::clearIDTables(), createFrontendTimer(), clang::TargetInfo::CreateTargetInfo(), clang::FrontendAction::EndSourceFile(), clang::FrontendAction::Execute(), clang::DiagnosticConsumer::finish(), clang::DiagnosticsEngine::getClient(), getDiagnosticOpts(), getDiagnostics(), getFileManager(), getFrontendOpts(), getHeaderSearchOpts(), getInvocation(), getLangOpts(), clang::DiagnosticConsumer::getNumErrors(), clang::DiagnosticConsumer::getNumWarnings(), getSourceManager(), getTarget(), hasDiagnostics(), hasFileManager(), hasSourceManager(), hasTarget(), clang::FrontendAction::isModelParsingAction(), clang::TargetInfo::noSignedCharForObjCBool(), clang::FileManager::PrintStats(), clang::frontend::RewriteObjC, setTarget(), clang::FrontendOptions::ShowStats, and Verbose.

Referenced by clang::ExecuteCompilerInvocation(), and clang::tooling::FrontendActionFactory::runInvocation().

AnalyzerOptionsRef clang::CompilerInstance::getAnalyzerOpts ( )
inline
ASTConsumer& clang::CompilerInstance::getASTConsumer ( ) const
inline
ASTContext& clang::CompilerInstance::getASTContext ( ) const
inline
CodeCompleteConsumer& clang::CompilerInstance::getCodeCompletionConsumer ( ) const
inline

Definition at line 545 of file CompilerInstance.h.

Referenced by clang::ASTFrontendAction::ExecuteAction().

CodeGenOptions& clang::CompilerInstance::getCodeGenOpts ( )
inline
const CodeGenOptions& clang::CompilerInstance::getCodeGenOpts ( ) const
inline

Definition at line 259 of file CompilerInstance.h.

DependencyOutputOptions& clang::CompilerInstance::getDependencyOutputOpts ( )
inline

Definition at line 263 of file CompilerInstance.h.

Referenced by createPreprocessor().

const DependencyOutputOptions& clang::CompilerInstance::getDependencyOutputOpts ( ) const
inline

Definition at line 266 of file CompilerInstance.h.

DiagnosticConsumer& clang::CompilerInstance::getDiagnosticClient ( ) const
inline
DiagnosticOptions& clang::CompilerInstance::getDiagnosticOpts ( )
inline
const DiagnosticOptions& clang::CompilerInstance::getDiagnosticOpts ( ) const
inline

Definition at line 273 of file CompilerInstance.h.

DiagnosticsEngine& clang::CompilerInstance::getDiagnostics ( ) const
inline
FileManager& clang::CompilerInstance::getFileManager ( ) const
inline
FileSystemOptions& clang::CompilerInstance::getFileSystemOpts ( )
inline
const FileSystemOptions& clang::CompilerInstance::getFileSystemOpts ( ) const
inline

Definition at line 280 of file CompilerInstance.h.

FrontendOptions& clang::CompilerInstance::getFrontendOpts ( )
inline
const FrontendOptions& clang::CompilerInstance::getFrontendOpts ( ) const
inline

Definition at line 287 of file CompilerInstance.h.

llvm::Timer& clang::CompilerInstance::getFrontendTimer ( ) const
inline

Definition at line 561 of file CompilerInstance.h.

Referenced by clang::FrontendAction::Execute().

HeaderSearchOptions& clang::CompilerInstance::getHeaderSearchOpts ( )
inline
const HeaderSearchOptions& clang::CompilerInstance::getHeaderSearchOpts ( ) const
inline

Definition at line 294 of file CompilerInstance.h.

CompilerInvocation& clang::CompilerInstance::getInvocation ( )
inline
LangOptions& clang::CompilerInstance::getLangOpts ( )
inline
const LangOptions& clang::CompilerInstance::getLangOpts ( ) const
inline

Definition at line 301 of file CompilerInstance.h.

std::shared_ptr< ModuleDependencyCollector > CompilerInstance::getModuleDepCollector ( ) const

Definition at line 125 of file CompilerInstance.cpp.

Referenced by compileModuleImpl().

IntrusiveRefCntPtr< ASTReader > CompilerInstance::getModuleManager ( ) const
std::shared_ptr<PCHContainerOperations> clang::CompilerInstance::getPCHContainerOperations ( ) const
inline
const PCHContainerReader& clang::CompilerInstance::getPCHContainerReader ( ) const
inline
const PCHContainerWriter& clang::CompilerInstance::getPCHContainerWriter ( ) const
inline
Preprocessor& clang::CompilerInstance::getPreprocessor ( ) const
inline
PreprocessorOptions& clang::CompilerInstance::getPreprocessorOpts ( )
inline
const PreprocessorOptions& clang::CompilerInstance::getPreprocessorOpts ( ) const
inline

Definition at line 308 of file CompilerInstance.h.

PreprocessorOutputOptions& clang::CompilerInstance::getPreprocessorOutputOpts ( )
inline
const PreprocessorOutputOptions& clang::CompilerInstance::getPreprocessorOutputOpts ( ) const
inline

Definition at line 315 of file CompilerInstance.h.

Sema& clang::CompilerInstance::getSema ( ) const
inline
SourceManager& clang::CompilerInstance::getSourceManager ( ) const
inline
std::string CompilerInstance::getSpecificModuleCachePath ( )
TargetInfo& clang::CompilerInstance::getTarget ( ) const
inline
TargetOptions& clang::CompilerInstance::getTargetOpts ( )
inline
const TargetOptions& clang::CompilerInstance::getTargetOpts ( ) const
inline

Definition at line 322 of file CompilerInstance.h.

vfs::FileSystem& clang::CompilerInstance::getVirtualFileSystem ( ) const
inline

Definition at line 367 of file CompilerInstance.h.

References hasVirtualFileSystem().

Referenced by compileModuleImpl().

bool clang::CompilerInstance::hadModuleLoaderFatalFailure ( ) const
inline

Definition at line 764 of file CompilerInstance.h.

References clang::ModuleLoader::HadFatalFailure.

bool clang::CompilerInstance::hasASTConsumer ( ) const
inline
bool clang::CompilerInstance::hasASTContext ( ) const
inline
bool clang::CompilerInstance::hasCodeCompletionConsumer ( ) const
inline

Definition at line 543 of file CompilerInstance.h.

Referenced by clang::ASTFrontendAction::ExecuteAction().

bool clang::CompilerInstance::hasDiagnostics ( ) const
inline
bool clang::CompilerInstance::hasFileManager ( ) const
inline
bool clang::CompilerInstance::hasFrontendTimer ( ) const
inline

Definition at line 559 of file CompilerInstance.h.

Referenced by clang::FrontendAction::Execute().

bool clang::CompilerInstance::hasInvocation ( ) const
inline

Definition at line 229 of file CompilerInstance.h.

bool clang::CompilerInstance::hasPreprocessor ( ) const
inline
bool clang::CompilerInstance::hasSema ( ) const
inline
bool clang::CompilerInstance::hasSourceManager ( ) const
inline

Definition at line 405 of file CompilerInstance.h.

Referenced by clang::FrontendAction::BeginSourceFile(), and ExecuteAction().

bool clang::CompilerInstance::hasTarget ( ) const
inline

Definition at line 351 of file CompilerInstance.h.

Referenced by ExecuteAction().

bool clang::CompilerInstance::hasVirtualFileSystem ( ) const
inline
bool CompilerInstance::InitializeSourceManager ( const FrontendInputFile Input)

InitializeSourceManager - Initialize the source manager to set InputFile as the main file.

Returns
True on success.

Definition at line 701 of file CompilerInstance.cpp.

References getDiagnostics(), getFileManager(), getFrontendOpts(), and getSourceManager().

Referenced by clang::FrontendAction::BeginSourceFile().

bool CompilerInstance::InitializeSourceManager ( const FrontendInputFile Input,
DiagnosticsEngine Diags,
FileManager FileMgr,
SourceManager SourceMgr,
const FrontendOptions Opts 
)
static
GlobalModuleIndex * CompilerInstance::loadGlobalModuleIndex ( SourceLocation  TriggerLoc)
overridevirtual

Load, create, or return global module. This function returns an existing global module index, if one had already been loaded or created, or loads one if it exists, or creates one if it doesn't exist. Also, importantly, if the index doesn't cover all the modules in the module map, it will be update to do so here, because of its use in searching for needed module imports and associated fixit messages.

Parameters
TriggerLocThe location for what triggered the load.
Returns
Returns null if load failed.

Implements clang::ModuleLoader.

Definition at line 1653 of file CompilerInstance.cpp.

References clang::ModuleLoader::buildingModule(), createModuleManager(), clang::Module::DefinitionLoc, clang::Module::getASTFile(), getFileManager(), clang::Preprocessor::getHeaderSearchInfo(), clang::HeaderSearch::getModuleMap(), getPCHContainerReader(), getPreprocessor(), hasFileManager(), hasPreprocessor(), clang::Module::Hidden, loadModule(), clang::ModuleMap::module_begin(), clang::ModuleMap::module_end(), clang::Module::Name, shouldBuildGlobalModuleIndex(), and clang::GlobalModuleIndex::writeIndex().

Referenced by lookupMissingImports().

ModuleLoadResult CompilerInstance::loadModule ( SourceLocation  ImportLoc,
ModuleIdPath  Path,
Module::NameVisibilityKind  Visibility,
bool  IsInclusionDirective 
)
overridevirtual

Attempt to load the given module.

This routine attempts to load the module described by the given parameters.

Parameters
ImportLocThe location of the 'import' keyword.
PathThe identifiers (and their locations) of the module "path", e.g., "std.vector" would be split into "std" and "vector".
VisibilityThe visibility provided for the names in the loaded module.
IsInclusionDirectiveIndicates that this module is being loaded implicitly, due to the presence of an inclusion directive. Otherwise, it is being loaded due to an import declaration.
Returns
If successful, returns the loaded module. Otherwise, returns NULL to indicate that the module could not be loaded.

Implements clang::ModuleLoader.

Definition at line 1363 of file CompilerInstance.cpp.

References clang::ASTReader::ARR_Missing, clang::ASTReader::ARR_OutOfDate, BestEditDistance, checkConfigMacro(), compileAndLoadModule(), clang::Module::ConfigMacros, clang::ASTReader::ConfigurationMismatch, createModuleManager(), clang::FixItHint::CreateReplacement(), clang::LangOptions::CurrentModule, clang::PreprocessorOptions::FailedModules, clang::ASTReader::Failure, clang::Module::UnresolvedHeaderDirective::FileName, clang::Module::UnresolvedHeaderDirective::FileNameLoc, clang::Module::findSubmodule(), getDiagnostics(), clang::Module::getFullModuleName(), getLangOpts(), clang::SourceManager::getModuleBuildStack(), getPreprocessor(), getPreprocessorOpts(), getSourceManager(), getTarget(), clang::Module::getTopLevelModule(), clang::ASTReader::HadErrors, clang::ModuleLoader::HadFatalFailure, clang::LangOptions::ImplementationOfModule, clang::Module::isAvailable(), clang::Module::IsFromModuleFile, clang::SourceLocation::isInvalid(), clang::Module::UnresolvedHeaderDirective::IsUmbrella, clang::SourceLocation::isValid(), clang::ASTReader::Missing, clang::serialization::MK_ExplicitModule, clang::serialization::MK_ImplicitModule, clang::ASTReader::OutOfDate, clang::DiagnosticsEngine::Report(), clang::Module::submodule_begin(), clang::Module::submodule_end(), clang::ASTReader::Success, and clang::ASTReader::VersionMismatch.

Referenced by loadGlobalModuleIndex().

bool CompilerInstance::loadModuleFile ( StringRef  FileName)
bool CompilerInstance::lookupMissingImports ( StringRef  Name,
SourceLocation  TriggerLoc 
)
overridevirtual

Check global module index for missing imports.

Parameters
NameThe symbol name to look for.
TriggerLocThe location for what triggered the load.
Returns
Returns true if any modules with that symbol found.

Implements clang::ModuleLoader.

Definition at line 1711 of file CompilerInstance.cpp.

References clang::ModuleLoader::buildingModule(), loadGlobalModuleIndex(), and clang::GlobalModuleIndex::lookupIdentifier().

void CompilerInstance::makeModuleVisible ( Module Mod,
Module::NameVisibilityKind  Visibility,
SourceLocation  ImportLoc 
)
overridevirtual

Make the given module visible.

Implements clang::ModuleLoader.

Definition at line 1642 of file CompilerInstance.cpp.

References createModuleManager().

void clang::CompilerInstance::resetAndLeakASTContext ( )
inline

Definition at line 452 of file CompilerInstance.h.

References clang::BuryPointer().

Referenced by clang::FrontendAction::EndSourceFile().

void clang::CompilerInstance::resetAndLeakFileManager ( )
inline

Definition at line 393 of file CompilerInstance.h.

References clang::BuryPointer().

Referenced by clang::FrontendAction::EndSourceFile().

void clang::CompilerInstance::resetAndLeakPreprocessor ( )
inline

Definition at line 433 of file CompilerInstance.h.

References clang::BuryPointer().

Referenced by clang::FrontendAction::EndSourceFile().

void CompilerInstance::resetAndLeakSema ( )

Definition at line 1734 of file CompilerInstance.cpp.

References clang::BuryPointer(), and takeSema().

Referenced by clang::FrontendAction::EndSourceFile().

void clang::CompilerInstance::resetAndLeakSourceManager ( )
inline

Definition at line 413 of file CompilerInstance.h.

References clang::BuryPointer().

Referenced by clang::FrontendAction::EndSourceFile().

void CompilerInstance::setASTConsumer ( std::unique_ptr< ASTConsumer Value)

setASTConsumer - Replace the current AST consumer; the compiler instance takes ownership of Value.

Definition at line 105 of file CompilerInstance.cpp.

Referenced by clang::FrontendAction::BeginSourceFile(), and clang::FrontendAction::EndSourceFile().

void CompilerInstance::setASTContext ( ASTContext Value)

setASTContext - Replace the current AST context.

Definition at line 99 of file CompilerInstance.cpp.

References Context.

Referenced by clang::FrontendAction::BeginSourceFile(), and clang::FrontendAction::EndSourceFile().

void clang::CompilerInstance::setBuildGlobalModuleIndex ( bool  Build)
inline

Set the flag indicating whether we should (re)build the global module index.

Definition at line 244 of file CompilerInstance.h.

Referenced by compileModuleImpl().

void CompilerInstance::setCodeCompletionConsumer ( CodeCompleteConsumer Value)

setCodeCompletionConsumer - Replace the current code completion consumer; the compiler instance takes ownership of Value.

Definition at line 109 of file CompilerInstance.cpp.

Referenced by createCodeCompletionConsumer().

void CompilerInstance::setDiagnostics ( DiagnosticsEngine Value)

setDiagnostics - Replace the current diagnostics engine.

Definition at line 77 of file CompilerInstance.cpp.

void CompilerInstance::setFileManager ( FileManager Value)
void CompilerInstance::setInvocation ( CompilerInvocation Value)

setInvocation - Replace the current invocation.

Definition at line 66 of file CompilerInstance.cpp.

Referenced by compileModuleImpl(), and clang::tooling::FrontendActionFactory::runInvocation().

void CompilerInstance::setModuleDepCollector ( std::shared_ptr< ModuleDependencyCollector Collector)

Definition at line 129 of file CompilerInstance.cpp.

void CompilerInstance::setModuleManager ( IntrusiveRefCntPtr< ASTReader Reader)

Definition at line 120 of file CompilerInstance.cpp.

Referenced by clang::FrontendAction::BeginSourceFile().

void CompilerInstance::setPreprocessor ( Preprocessor Value)

Replace the current preprocessor.

Definition at line 97 of file CompilerInstance.cpp.

Referenced by clang::FrontendAction::BeginSourceFile(), and clang::FrontendAction::EndSourceFile().

void CompilerInstance::setSema ( Sema S)

Replace the current Sema; the compiler instance takes ownership of S.

Definition at line 101 of file CompilerInstance.cpp.

Referenced by clang::FrontendAction::EndSourceFile().

void CompilerInstance::setSourceManager ( SourceManager Value)

setSourceManager - Replace the current source manager.

Definition at line 93 of file CompilerInstance.cpp.

References SourceMgr.

Referenced by clang::FixItRecompile::BeginInvocation(), clang::FrontendAction::BeginSourceFile(), and clang::FrontendAction::EndSourceFile().

void CompilerInstance::setTarget ( TargetInfo Value)

Replace the current diagnostics engine.

Definition at line 81 of file CompilerInstance.cpp.

Referenced by ExecuteAction().

void clang::CompilerInstance::setVirtualFileSystem ( IntrusiveRefCntPtr< vfs::FileSystem FS)
inline

Replace the current virtual file system.

Note
Most clients should use setFileManager, which will implicitly reset the virtual file system to the one contained in the file manager.

Definition at line 377 of file CompilerInstance.h.

Referenced by clang::FrontendAction::BeginSourceFile(), and createFileManager().

bool CompilerInstance::shouldBuildGlobalModuleIndex ( ) const

Indicates whether we should (re)build the global module index.

Definition at line 70 of file CompilerInstance.cpp.

References clang::FrontendOptions::GenerateGlobalModuleIndex, and getFrontendOpts().

Referenced by clang::FrontendAction::Execute(), and loadGlobalModuleIndex().

std::unique_ptr<ASTConsumer> clang::CompilerInstance::takeASTConsumer ( )
inline

takeASTConsumer - Remove the current AST consumer and give ownership to the caller.

Definition at line 477 of file CompilerInstance.h.

Referenced by clang::FrontendAction::EndSourceFile().

std::unique_ptr< Sema > CompilerInstance::takeSema ( )

Definition at line 113 of file CompilerInstance.cpp.

Referenced by resetAndLeakSema().


The documentation for this class was generated from the following files: