clang 20.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 void | setDefaultPointerAuthOptions (PointerAuthOptions &Opts, const LangOptions &LangOpts, const llvm::Triple &Triple) |
Populate Opts with the default set of pointer authentication-related options given LangOpts and Triple . | |
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 > | getLangOptsPtr () |
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 | |
Public Types inherited from clang::CompilerInvocationBase | |
using | StringAllocator = llvm::function_ref< const char *(const Twine &)> |
Command line generation. | |
using | ArgumentConsumer = llvm::function_ref< void(const Twine &)> |
Protected Member Functions inherited from clang::CompilerInvocationBase | |
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 | |
Protected Attributes inherited from clang::CompilerInvocationBase | |
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 211 of file CompilerInvocation.h.
|
default |
|
inline |
Definition at line 214 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::deep_copy_assign(), and X.
|
default |
|
default |
|
explicit |
Definition at line 194 of file CompilerInvocation.cpp.
References clang::CompilerInvocationBase::deep_copy_assign(), and X.
|
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 915 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 5102 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 4925 of file CompilerInvocation.cpp.
References clang::CompilerInvocationBase::generateCC1CommandLine(), and RoundTrip().
Referenced by clang::createInvocation(), clang::tooling::newInvocation(), and clang::TestAST::TestAST().
|
inline |
Definition at line 254 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::AnalyzerOpts.
|
inline |
Definition at line 136 of file CompilerInvocation.h.
|
inline |
Definition at line 256 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::APINotesOpts.
Referenced by getModuleHash().
|
inline |
Definition at line 138 of file CompilerInvocation.h.
|
inline |
Definition at line 257 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::CodeGenOpts.
Referenced by clang::tooling::dependencies::ModuleDepCollector::applyDiscoveredDependencies(), FixupInvocation(), getModuleHash(), makeCommonInvocationForModuleBuild(), clang::tooling::newInvocation(), and resetNonModularOptions().
|
inline |
Definition at line 139 of file CompilerInvocation.h.
|
inline |
Definition at line 260 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::DependencyOutputOpts.
Referenced by makeCommonInvocationForModuleBuild().
|
inline |
Definition at line 142 of file CompilerInvocation.h.
|
inline |
Definition at line 251 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 258 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::FSOpts.
Referenced by createInvocationForMigration().
|
inline |
Definition at line 140 of file CompilerInvocation.h.
|
inline |
Definition at line 259 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 252 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::HSOpts.
Referenced by clearImplicitModuleBuildOptions(), clang::createVFSFromCompilerInvocation(), getModuleHash(), makeCommonInvocationForModuleBuild(), and resetNonModularOptions().
|
inline |
Definition at line 134 of file CompilerInvocation.h.
|
inline |
Definition at line 273 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::HSOpts.
|
inline |
Mutable getters.
Definition at line 249 of file CompilerInvocation.h.
References LangOpts.
Referenced by clang::tooling::dependencies::ModuleDepCollector::applyDiscoveredDependencies(), 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 279 of file CompilerInvocation.h.
References LangOpts.
|
inline |
Definition at line 255 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 4944 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, clang::serialization::VERSION_MINOR, and clang::HeaderSearchOptions::VFSOverlayFiles.
Referenced by clang::CompilerInstance::createPreprocessor(), and clang::tooling::dependencies::ModuleDepCollectorPP::LexedFileChanged().
|
inline |
Definition at line 253 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 276 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::PPOpts.
|
inline |
Definition at line 263 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 3129 of file CompilerInvocation.cpp.
References clang::driver::Driver::GetResourcesPath().
Referenced by injectResourceDir().
|
inline |
Definition at line 250 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 219 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::deep_copy_assign(), and X.
CompilerInvocation & CompilerInvocation::operator= | ( | const CowCompilerInvocation & | X | ) |
Definition at line 200 of file CompilerInvocation.cpp.
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 5096 of file CompilerInvocation.cpp.
References getCodeGenOpts(), getHeaderSearchOpts(), getLangOpts(), getPreprocessorOpts(), clang::LangOptions::resetNonModularOptions(), clang::PreprocessorOptions::resetNonModularOptions(), and clang::CodeGenOptions::resetNonModularOptions().
Referenced by makeCommonInvocationForModuleBuild().
|
static |
Populate Opts
with the default set of pointer authentication-related options given LangOpts
and Triple
.
Note: This is intended to be used by tools which must be aware of pointer authentication-related code generation, e.g. lldb.
Definition at line 1474 of file CompilerInvocation.cpp.
References clang::PointerAuthOptions::AuthTraps, clang::PointerAuthOptions::CXXMemberFunctionPointers, clang::PointerAuthOptions::CXXTypeInfoVTablePointer, clang::PointerAuthOptions::CXXVirtualFunctionPointers, clang::PointerAuthOptions::CXXVirtualVariadicFunctionPointers, clang::PointerAuthOptions::CXXVTablePointers, clang::PointerAuthOptions::CXXVTTVTablePointers, clang::PointerAuthOptions::FunctionPointers, clang::PointerAuthOptions::IndirectGotos, clang::InitFiniPointerConstantDiscriminator, clang::PointerAuthOptions::InitFiniPointers, LangOpts, clang::PointerAuthOptions::ReturnAddresses, and clang::StdTypeInfoVTablePointerConstantDiscrimination.
Referenced by parsePointerAuthOptions().
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(), getLangOptsPtr(), and setDefaultPointerAuthOptions().
std::shared_ptr<TargetOptions> clang::CompilerInvocationBase::TargetOpts |
Options controlling the target.
Definition at line 80 of file CompilerInvocation.h.
Referenced by getTargetOpts().