|
clang 23.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 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. | |
Additional Inherited Members | |
| 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. | |
| std::shared_ptr< 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). | |
| std::shared_ptr< AnalyzerOptions > | 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. | |
| std::shared_ptr< ssaf::SSAFOptions > | SSAFOpts |
| Options controlling the Scalable Static Analysis Framework (SSAF). | |
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 229 of file CompilerInvocation.h.
|
default |
Referenced by checkCC1RoundTrip(), CompilerInvocation(), CompilerInvocation(), CreateFromArgs(), operator=(), and ~CompilerInvocation().
|
inline |
Definition at line 232 of file CompilerInvocation.h.
References CompilerInvocation(), clang::CompilerInvocationBase::CompilerInvocationBase(), clang::CompilerInvocationBase::deep_copy_assign(), and X.
|
default |
References CompilerInvocation().
|
default |
References CompilerInvocation(), clang::CompilerInvocationBase::getAnalyzerOpts(), clang::CompilerInvocationBase::getAPINotesOpts(), clang::CompilerInvocationBase::getCodeGenOpts(), clang::CompilerInvocationBase::getDependencyOutputOpts(), clang::CompilerInvocationBase::getDiagnosticOpts(), clang::CompilerInvocationBase::getFileSystemOpts(), clang::CompilerInvocationBase::getFrontendOpts(), clang::CompilerInvocationBase::getHeaderSearchOpts(), clang::CompilerInvocationBase::getLangOpts(), clang::CompilerInvocationBase::getMigratorOpts(), clang::CompilerInvocationBase::getPreprocessorOpts(), clang::CompilerInvocationBase::getPreprocessorOutputOpts(), clang::CompilerInvocationBase::getSSAFOpts(), clang::CompilerInvocationBase::getTargetOpts(), and X.
|
explicit |
Definition at line 182 of file CompilerInvocation.cpp.
References clang::CompilerInvocationBase::CompilerInvocationBase(), clang::CompilerInvocationBase::deep_copy_assign(), and X.
|
inlineexplicit |
Move-construct/move-assign from a CowCompilerInvocation.
Steals the (potentially copy-on-written) option group pointers without deep-copying; X is left empty. Useful to receive results of mutating a temporary Cow alias back into a CompilerInvocation.
Definition at line 474 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::CompilerInvocationBase(), 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 883 of file CompilerInvocation.cpp.
References CompilerInvocation(), 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 5496 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::dependencies::ModuleDepCollector::applyDiscoveredDependencies(), and makeCommonInvocationForModuleBuild().
| std::string CompilerInvocation::computeContextHash | ( | ) | const |
Compute the context hash - a string that uniquely identifies compiler settings.
This is currently used mainly for distinguishing different variants of the same implicitly-built Clang module.
Definition at line 5225 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::Macro, clang::Macros, 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::FrontendAction::BeginSourceFile().
|
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 5206 of file CompilerInvocation.cpp.
References CompilerInvocation(), clang::CompilerInvocationBase::generateCC1CommandLine(), and RoundTrip().
Referenced by clang::dependencies::createCompilerInvocation(), clang::createInvocation(), clang::tooling::newInvocation(), and clang::TestAST::TestAST().
|
inline |
Definition at line 282 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::AnalyzerOpts.
|
inline |
Const getters.
Definition at line 153 of file CompilerInvocation.h.
|
inline |
Definition at line 284 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::APINotesOpts.
Referenced by computeContextHash().
|
inline |
Definition at line 155 of file CompilerInvocation.h.
|
inline |
Definition at line 285 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::CodeGenOpts.
Referenced by clang::dependencies::ModuleDepCollector::applyDiscoveredDependencies(), computeContextHash(), FixupInvocation(), makeCommonInvocationForModuleBuild(), clang::tooling::newInvocation(), and resetNonModularOptions().
|
inline |
Definition at line 156 of file CompilerInvocation.h.
|
inline |
Definition at line 288 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::DependencyOutputOpts.
Referenced by clang::dependencies::ModuleDepCollector::applyDiscoveredDependencies(), clang::dependencies::createDependencyOutputOptions(), and makeCommonInvocationForModuleBuild().
|
inline |
Definition at line 159 of file CompilerInvocation.h.
|
inline |
Definition at line 279 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::DiagnosticOpts.
Referenced by computeContextHash(), FixupInvocation(), and makeCommonInvocationForModuleBuild().
|
inline |
Definition at line 150 of file CompilerInvocation.h.
|
inline |
Definition at line 286 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::FSOpts.
|
inline |
Definition at line 157 of file CompilerInvocation.h.
|
inline |
Definition at line 287 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::FrontendOpts.
Referenced by clang::dependencies::ModuleDepCollector::applyDiscoveredDependencies(), compileModuleAndReadAST(), computeContextHash(), clang::dependencies::createDependencyOutputOptions(), FixupInvocation(), makeCommonInvocationForModuleBuild(), and clang::tooling::newInvocation().
|
inline |
Definition at line 158 of file CompilerInvocation.h.
|
inline |
Definition at line 280 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::HSOpts.
Referenced by clearImplicitModuleBuildOptions(), computeContextHash(), clang::createVFSFromCompilerInvocation(), makeCommonInvocationForModuleBuild(), and resetNonModularOptions().
|
inline |
Definition at line 151 of file CompilerInvocation.h.
|
inline |
Mutable getters.
Definition at line 277 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::LangOpts.
Referenced by clang::dependencies::ModuleDepCollector::applyDiscoveredDependencies(), clearImplicitModuleBuildOptions(), computeContextHash(), FixupInvocation(), makeCommonInvocationForModuleBuild(), clang::PrecompiledPreamble::OverridePreamble(), and resetNonModularOptions().
|
inline |
Const getters.
Definition at line 148 of file CompilerInvocation.h.
|
inline |
Definition at line 283 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::MigratorOpts.
|
inline |
Definition at line 154 of file CompilerInvocation.h.
|
inline |
Definition at line 281 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::PPOpts.
Referenced by SingleModuleWithAsyncModuleCompiles::BeginSourceFileAction(), SingleTUWithAsyncModuleCompiles::BeginSourceFileAction(), computeContextHash(), getBufferForFileHandlingRemapping(), makeCommonInvocationForModuleBuild(), and resetNonModularOptions().
|
inline |
Definition at line 152 of file CompilerInvocation.h.
|
inline |
Definition at line 291 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::PreprocessorOutputOpts.
|
inline |
Definition at line 162 of file CompilerInvocation.h.
|
inline |
Definition at line 294 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::SSAFOpts.
|
inline |
Definition at line 165 of file CompilerInvocation.h.
|
inline |
Definition at line 278 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::TargetOpts.
Referenced by computeContextHash(), and FixupInvocation().
|
inline |
Definition at line 149 of file CompilerInvocation.h.
|
inline |
Definition at line 237 of file CompilerInvocation.h.
References CompilerInvocation(), clang::CompilerInvocationBase::deep_copy_assign(), and X.
| CompilerInvocation & CompilerInvocation::operator= | ( | const CowCompilerInvocation & | X | ) |
Definition at line 188 of file CompilerInvocation.cpp.
References clang::CompilerInvocationBase::deep_copy_assign(), and X.
|
inline |
Definition at line 478 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::operator=(), and X.
| void CompilerInvocation::resetNonModularOptions | ( | ) |
Reset all of the options that are not considered when building a module.
Definition at line 5490 of file CompilerInvocation.cpp.
References getCodeGenOpts(), getHeaderSearchOpts(), getLangOpts(), getPreprocessorOpts(), clang::CodeGenOptions::resetNonModularOptions(), clang::LangOptions::resetNonModularOptions(), and clang::PreprocessorOptions::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 1457 of file CompilerInvocation.cpp.
References clang::PointerAuthOptions::AArch64JumpTableHardening, clang::PointerAuthOptions::AuthTraps, clang::PointerAuthOptions::BlockByrefHelperFunctionPointers, clang::BlockDescriptorConstantDiscriminator, clang::PointerAuthOptions::BlockDescriptorPointers, clang::PointerAuthOptions::BlockHelperFunctionPointers, clang::PointerAuthOptions::BlockInvocationFunctionPointers, clang::ClassROConstantDiscriminator, 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, clang::IsaPointerConstantDiscriminator, clang::CompilerInvocationBase::LangOpts, clang::MethodListPointerConstantDiscriminator, clang::PointerAuthOptions::ObjCClassROPointers, clang::PointerAuthOptions::ObjCIsaPointers, clang::PointerAuthOptions::ObjCMethodListFunctionPointers, clang::PointerAuthOptions::ObjCMethodListPointer, clang::PointerAuthOptions::ObjCSuperPointers, clang::PointerAuthOptions::ReturnAddresses, clang::StdTypeInfoVTablePointerConstantDiscrimination, and clang::SuperPointerConstantDiscriminator.
Referenced by parsePointerAuthOptions().
| R clang::CompilerInvocation::withCowRef | ( | llvm::function_ref< R(const CowCompilerInvocation &)> | Fn | ) | const |
Definition at line 465 of file CompilerInvocation.h.
| R clang::CompilerInvocation::withCowRef | ( | llvm::function_ref< R(CowCompilerInvocation &)> | Fn | ) |
Invokes the Fn with CowCompilerInvocation representing this.
The Fn must not directly modify this. The provided CowCompilerInvocation must not escape Fn.
Definition at line 454 of file CompilerInvocation.h.
Referenced by clang::tooling::CompilerInstanceWithContext::computeDependencies().