|
clang 22.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 | |
| void | visitPathsImpl (llvm::function_ref< bool(std::string &)> Predicate) |
| Visits paths stored in the invocation. | |
| 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. | |
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::getTargetOpts(), and X.
|
explicit |
Definition at line 178 of file CompilerInvocation.cpp.
References clang::CompilerInvocationBase::CompilerInvocationBase(), 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 878 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 5375 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 5095 of file CompilerInvocation.cpp.
References CompilerInvocation(), clang::CompilerInvocationBase::generateCC1CommandLine(), and RoundTrip().
Referenced by clang::tooling::dependencies::createCompilerInvocation(), clang::createInvocation(), clang::tooling::dependencies::CompilerInstanceWithContext::initialize(), clang::tooling::newInvocation(), and clang::TestAST::TestAST().
|
inline |
Definition at line 272 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::AnalyzerOpts.
|
inline |
Definition at line 141 of file CompilerInvocation.h.
|
inline |
Definition at line 274 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::APINotesOpts.
Referenced by getModuleHash().
|
inline |
Definition at line 143 of file CompilerInvocation.h.
|
inline |
Definition at line 275 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 144 of file CompilerInvocation.h.
|
inline |
Definition at line 278 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::DependencyOutputOpts.
Referenced by makeCommonInvocationForModuleBuild(), and clang::tooling::dependencies::takeAndUpdateDependencyOutputOptionsFrom().
|
inline |
Definition at line 147 of file CompilerInvocation.h.
|
inline |
Definition at line 269 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::DiagnosticOpts.
Referenced by getModuleHash(), and makeCommonInvocationForModuleBuild().
|
inline |
Definition at line 138 of file CompilerInvocation.h.
|
inline |
Definition at line 276 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::FSOpts.
|
inline |
Definition at line 145 of file CompilerInvocation.h.
|
inline |
Definition at line 277 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::FrontendOpts.
Referenced by clang::tooling::dependencies::ModuleDepCollector::applyDiscoveredDependencies(), compileModuleAndReadAST(), FixupInvocation(), getModuleHash(), makeCommonInvocationForModuleBuild(), and clang::tooling::newInvocation().
|
inline |
Definition at line 146 of file CompilerInvocation.h.
|
inline |
Definition at line 270 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::HSOpts.
Referenced by clearImplicitModuleBuildOptions(), clang::createVFSFromCompilerInvocation(), getModuleHash(), makeCommonInvocationForModuleBuild(), and resetNonModularOptions().
|
inline |
Definition at line 139 of file CompilerInvocation.h.
|
inline |
Mutable getters.
Definition at line 267 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::LangOpts.
Referenced by clang::tooling::dependencies::ModuleDepCollector::applyDiscoveredDependencies(), clearImplicitModuleBuildOptions(), FixupInvocation(), getModuleHash(), makeCommonInvocationForModuleBuild(), clang::PrecompiledPreamble::OverridePreamble(), and resetNonModularOptions().
|
inline |
Const getters.
Definition at line 136 of file CompilerInvocation.h.
|
inline |
Definition at line 273 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::MigratorOpts.
|
inline |
Definition at line 142 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 5114 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::CompilerInstance::createPreprocessor().
|
inline |
Definition at line 271 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::PPOpts.
Referenced by getBufferForFileHandlingRemapping(), getModuleHash(), makeCommonInvocationForModuleBuild(), and resetNonModularOptions().
|
inline |
Definition at line 140 of file CompilerInvocation.h.
|
inline |
Definition at line 281 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::PreprocessorOutputOpts.
|
inline |
Definition at line 150 of file CompilerInvocation.h.
|
inline |
Definition at line 268 of file CompilerInvocation.h.
References clang::CompilerInvocationBase::TargetOpts.
Referenced by FixupInvocation(), and getModuleHash().
|
inline |
Definition at line 137 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 184 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 5369 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 1428 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().