clang 18.0.0git
|
Helper class for holding the data necessary to invoke the compiler. More...
#include "clang/Frontend/CompilerInvocation.h"
Static Public Member Functions | |
static bool | CreateFromArgs (CompilerInvocation &Res, ArrayRef< const char * > CommandLineArgs, DiagnosticsEngine &Diags, const char *Argv0=nullptr) |
Create a compiler invocation from a list of input options. | |
static std::string | GetResourcesPath (const char *Argv0, void *MainAddr) |
Get the directory where the compiler headers reside, relative to the compiler binary (found by the passed in arguments). | |
static bool | checkCC1RoundTrip (ArrayRef< const char * > Args, DiagnosticsEngine &Diags, const char *Argv0=nullptr) |
Check that Args can be parsed and re-serialized without change, emiting diagnostics for any differences. | |
std::shared_ptr< HeaderSearchOptions > | getHeaderSearchOptsPtr () |
std::shared_ptr< PreprocessorOptions > | getPreprocessorOptsPtr () |
std::shared_ptr< LangOptions > | LangOpts |
Base class internals. | |
std::shared_ptr< TargetOptions > | TargetOpts |
Options controlling the target. | |
IntrusiveRefCntPtr< DiagnosticOptions > | DiagnosticOpts |
Options controlling the diagnostic engine. | |
Additional Inherited Members | |
![]() | |
using | StringAllocator = llvm::function_ref< const char *(const Twine &)> |
Command line generation. | |
using | ArgumentConsumer = llvm::function_ref< void(const Twine &)> |
![]() | |
CompilerInvocationBase () | |
CompilerInvocationBase (EmptyConstructor) | |
CompilerInvocationBase (const CompilerInvocationBase &X)=delete | |
CompilerInvocationBase (CompilerInvocationBase &&X)=default | |
CompilerInvocationBase & | operator= (const CompilerInvocationBase &X)=delete |
CompilerInvocationBase & | deep_copy_assign (const CompilerInvocationBase &X) |
CompilerInvocationBase & | shallow_copy_assign (const CompilerInvocationBase &X) |
CompilerInvocationBase & | operator= (CompilerInvocationBase &&X)=default |
~CompilerInvocationBase ()=default | |
![]() | |
std::shared_ptr< LangOptions > | LangOpts |
Options controlling the language variant. | |
std::shared_ptr< TargetOptions > | TargetOpts |
Options controlling the target. | |
IntrusiveRefCntPtr< DiagnosticOptions > | DiagnosticOpts |
Options controlling the diagnostic engine. | |
std::shared_ptr< HeaderSearchOptions > | HSOpts |
Options controlling the #include directive. | |
std::shared_ptr< PreprocessorOptions > | PPOpts |
Options controlling the preprocessor (aside from #include handling). | |
AnalyzerOptionsRef | AnalyzerOpts |
Options controlling the static analyzer. | |
std::shared_ptr< MigratorOptions > | MigratorOpts |
std::shared_ptr< APINotesOptions > | APINotesOpts |
Options controlling API notes. | |
std::shared_ptr< CodeGenOptions > | CodeGenOpts |
Options controlling IRgen and the backend. | |
std::shared_ptr< FileSystemOptions > | FSOpts |
Options controlling file system operations. | |
std::shared_ptr< FrontendOptions > | FrontendOpts |
Options controlling the frontend itself. | |
std::shared_ptr< DependencyOutputOptions > | DependencyOutputOpts |
Options controlling dependency output. | |
std::shared_ptr< PreprocessorOutputOptions > | PreprocessorOutputOpts |
Options controlling preprocessed output. | |
Helper class for holding the data necessary to invoke the compiler.
This class is designed to represent an abstract "invocation" of the compiler, including data such as the include paths, the code generation options, the warning flags, and so on.
Definition at line 209 of file CompilerInvocation.h.
|
default |
|
inline |
Definition at line 212 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::deep_copy_assign(), and X.
|
default |
|
default |
|
static |
Check that Args
can be parsed and re-serialized without change, emiting diagnostics for any differences.
This check is only suitable for command-lines that are expected to already be canonical.
Definition at line 891 of file CompilerInvocation.cpp.
References clang::CompilerInvocationBase::generateCC1CommandLine(), and RoundTrip().
void CompilerInvocation::clearImplicitModuleBuildOptions | ( | ) |
Disable implicit modules and canonicalize options that are only used by implicit modules.
so use the default values so they may be dropped from the command-line.
Definition at line 4838 of file CompilerInvocation.cpp.
References clang::HeaderSearchOptions::BuildSessionTimestamp, getHeaderSearchOpts(), getLangOpts(), clang::HeaderSearchOptions::ImplicitModuleMaps, clang::HeaderSearchOptions::ModuleCachePath, clang::HeaderSearchOptions::ModuleCachePruneAfter, clang::HeaderSearchOptions::ModuleCachePruneInterval, and clang::HeaderSearchOptions::ModulesValidateOncePerBuildSession.
Referenced by clang::tooling::dependencies::ModuleDepCollector::applyDiscoveredDependencies(), and makeCommonInvocationForModuleBuild().
|
static |
Create a compiler invocation from a list of input options.
Res
will end up in one of the vaild-to-access (albeit arbitrary) states.[out] | Res | - The resulting invocation. |
[in] | CommandLineArgs | - Array of argument strings, this must not contain "-cc1". |
Definition at line 4676 of file CompilerInvocation.cpp.
References clang::CompilerInvocationBase::generateCC1CommandLine(), and RoundTrip().
Referenced by clang::createInvocation(), main(), clang::tooling::newInvocation(), and clang::TestAST::TestAST().
|
inline |
Definition at line 249 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::AnalyzerOpts.
|
inline |
Definition at line 136 of file CompilerInvocation.h.
|
inline |
Definition at line 251 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::APINotesOpts.
Referenced by getModuleHash().
|
inline |
Definition at line 138 of file CompilerInvocation.h.
|
inline |
Definition at line 252 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::CodeGenOpts.
Referenced by FixupInvocation(), getModuleHash(), makeCommonInvocationForModuleBuild(), and clang::tooling::newInvocation().
|
inline |
Definition at line 139 of file CompilerInvocation.h.
|
inline |
Definition at line 255 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::DependencyOutputOpts.
Referenced by makeCommonInvocationForModuleBuild().
|
inline |
Definition at line 142 of file CompilerInvocation.h.
|
inline |
Definition at line 246 of file CompilerInvocation.h.
References DiagnosticOpts.
Referenced by applyTransforms(), clang::arcmt::checkForManualIssues(), createInvocationForMigration(), getModuleHash(), makeCommonInvocationForModuleBuild(), and clang::arcmt::MigrationProcess::MigrationProcess().
|
inline |
Definition at line 133 of file CompilerInvocation.h.
|
inline |
Definition at line 253 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::FSOpts.
Referenced by createInvocationForMigration().
|
inline |
Definition at line 140 of file CompilerInvocation.h.
|
inline |
Definition at line 254 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::FrontendOpts.
Referenced by clang::tooling::dependencies::ModuleDepCollector::applyDiscoveredDependencies(), applyTransforms(), compileModuleAndReadAST(), FixupInvocation(), getModuleHash(), makeCommonInvocationForModuleBuild(), and clang::tooling::newInvocation().
|
inline |
Definition at line 141 of file CompilerInvocation.h.
|
inline |
Definition at line 247 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::HSOpts.
Referenced by clearImplicitModuleBuildOptions(), clang::createVFSFromCompilerInvocation(), getModuleHash(), and makeCommonInvocationForModuleBuild().
|
inline |
Definition at line 134 of file CompilerInvocation.h.
|
inline |
Definition at line 268 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::HSOpts.
|
inline |
Mutable getters.
Definition at line 244 of file CompilerInvocation.h.
References LangOpts.
Referenced by clang::arcmt::MigrationProcess::applyTransform(), applyTransforms(), clang::arcmt::checkForManualIssues(), clearImplicitModuleBuildOptions(), FixupInvocation(), getModuleHash(), makeCommonInvocationForModuleBuild(), clang::PrecompiledPreamble::OverridePreamble(), and resetNonModularOptions().
|
inline |
Const getters.
Definition at line 131 of file CompilerInvocation.h.
|
inline |
Definition at line 250 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::MigratorOpts.
Referenced by applyTransforms(), and clang::arcmt::checkForManualIssues().
|
inline |
Definition at line 137 of file CompilerInvocation.h.
std::string CompilerInvocation::getModuleHash | ( | ) | const |
Retrieve a module hash string that is suitable for uniquely identifying the conditions under which the module was built.
Definition at line 4695 of file CompilerInvocation.cpp.
References clang::CompilerInvocationBase::APINotesOpts, clang::SanitizerSet::clear(), clang::PreprocessorOptions::DetailedRecord, clang::SanitizerSet::empty(), getAPINotesOpts(), clang::getClangFullRepositoryVersion(), getCodeGenOpts(), getDiagnosticOpts(), getFrontendOpts(), getHeaderSearchOpts(), getLangOpts(), clang::getPPTransparentSanitizers(), getPreprocessorOpts(), getTargetOpts(), clang::SanitizerSet::Mask, clang::HeaderSearchOptions::ModuleFormat, clang::HeaderSearchOptions::ModulesIgnoreMacros, clang::HeaderSearchOptions::ModulesStrictContextHash, clang::HeaderSearchOptions::ModulesValidateDiagnosticOptions, clang::HeaderSearchOptions::ModuleUserBuildPath, clang::HeaderSearchOptions::ResourceDir, clang::Result, clang::LangOptions::Sanitize, clang::HeaderSearchOptions::Sysroot, clang::HeaderSearchOptions::SystemHeaderPrefixes, toString(), clang::HeaderSearchOptions::UseBuiltinIncludes, clang::HeaderSearchOptions::UseDebugInfo, clang::HeaderSearchOptions::UseLibcxx, clang::PreprocessorOptions::UsePredefines, clang::HeaderSearchOptions::UserEntries, clang::HeaderSearchOptions::UseStandardCXXIncludes, clang::HeaderSearchOptions::UseStandardSystemIncludes, clang::serialization::VERSION_MAJOR, and clang::serialization::VERSION_MINOR.
Referenced by clang::CompilerInstance::createPreprocessor(), and clang::tooling::dependencies::ModuleDepCollectorPP::LexedFileChanged().
|
inline |
Definition at line 248 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::PPOpts.
Referenced by getBufferForFileHandlingRemapping(), getModuleHash(), makeCommonInvocationForModuleBuild(), and resetNonModularOptions().
|
inline |
Definition at line 135 of file CompilerInvocation.h.
|
inline |
Definition at line 271 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::PPOpts.
|
inline |
Definition at line 258 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::PreprocessorOutputOpts.
|
inline |
Definition at line 145 of file CompilerInvocation.h.
|
static |
Get the directory where the compiler headers reside, relative to the compiler binary (found by the passed in arguments).
Argv0 | - The program path (from argv[0]), for finding the builtin compiler path. |
MainAddr | - The address of main (or some other function in the main executable), for finding the builtin compiler path. |
Definition at line 3028 of file CompilerInvocation.cpp.
References clang::driver::Driver::GetResourcesPath().
Referenced by injectResourceDir().
|
inline |
Definition at line 245 of file CompilerInvocation.h.
References TargetOpts.
Referenced by FixupInvocation(), getModuleHash(), and HasARCRuntime().
|
inline |
Definition at line 132 of file CompilerInvocation.h.
|
inline |
Definition at line 217 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::deep_copy_assign(), and X.
void CompilerInvocation::resetNonModularOptions | ( | ) |
Reset all of the options that are not considered when building a module.
Definition at line 4833 of file CompilerInvocation.cpp.
References getLangOpts(), getPreprocessorOpts(), clang::LangOptions::resetNonModularOptions(), and clang::PreprocessorOptions::resetNonModularOptions().
Referenced by makeCommonInvocationForModuleBuild().
IntrusiveRefCntPtr<DiagnosticOptions> clang::CompilerInvocationBase::DiagnosticOpts |
Options controlling the diagnostic engine.
Definition at line 83 of file CompilerInvocation.h.
Referenced by getDiagnosticOpts().
std::shared_ptr<LangOptions> clang::CompilerInvocationBase::LangOpts |
Base class internals.
Definition at line 77 of file CompilerInvocation.h.
Referenced by getLangOpts().
std::shared_ptr<TargetOptions> clang::CompilerInvocationBase::TargetOpts |
Options controlling the target.
Definition at line 80 of file CompilerInvocation.h.
Referenced by getTargetOpts().