clang
19.0.0git
|
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that is accepted. More...
#include "clang/Basic/LangOptions.h"
Public Member Functions | |
LangOptions () | |
bool | isCompilingModule () const |
Are we compiling a module? More... | |
bool | isCompilingModuleImplementation () const |
Are we compiling a module implementation? More... | |
bool | trackLocalOwningModule () const |
Do we need to track the owning module for a local declaration? More... | |
bool | isSignedOverflowDefined () const |
bool | isSubscriptPointerArithmetic () const |
bool | isCompatibleWithMSVC (MSVCMajorVersion MajorVersion) const |
void | resetNonModularOptions () |
Reset all of the options that are not considered when building a module. More... | |
bool | isNoBuiltinFunc (StringRef Name) const |
Is this a libc/libm function that is no longer recognized as a builtin because a -fno-builtin-* option has been specified? More... | |
bool | allowsNonTrivialObjCLifetimeQualifiers () const |
True if any ObjC types may have non-trivial lifetime qualifiers. More... | |
bool | assumeFunctionsAreConvergent () const |
VersionTuple | getOpenCLVersionTuple () const |
Return the OpenCL C or C++ version as a VersionTuple. More... | |
unsigned | getOpenCLCompatibleVersion () const |
Return the OpenCL version that kernel language is compatible with. More... | |
std::string | getOpenCLVersionString () const |
Return the OpenCL C or C++ for OpenCL language name and version as a string. More... | |
bool | requiresStrictPrototypes () const |
Returns true if functions without prototypes or functions with an identifier list (aka K&R C functions) are not allowed. More... | |
bool | implicitFunctionsAllowed () const |
Returns true if implicit function declarations are allowed in the current language mode. More... | |
bool | hasAtExit () const |
Returns true if the language supports calling the 'atexit' function. More... | |
bool | isImplicitIntRequired () const |
Returns true if implicit int is part of the language requirements. More... | |
bool | isImplicitIntAllowed () const |
Returns true if implicit int is supported at all. More... | |
bool | hasSignReturnAddress () const |
Check if return address signing is enabled. More... | |
bool | isSignReturnAddressWithAKey () const |
Check if return address signing uses AKey. More... | |
bool | isSignReturnAddressScopeAll () const |
Check if leaf functions are also signed. More... | |
bool | hasSjLjExceptions () const |
bool | hasSEHExceptions () const |
bool | hasDWARFExceptions () const |
bool | hasWasmExceptions () const |
bool | isSYCL () const |
bool | hasDefaultVisibilityExportMapping () const |
bool | isExplicitDefaultVisibilityExportMapping () const |
bool | isAllDefaultVisibilityExportMapping () const |
bool | hasGlobalAllocationFunctionVisibility () const |
bool | hasDefaultGlobalAllocationFunctionVisibility () const |
bool | hasProtectedGlobalAllocationFunctionVisibility () const |
bool | hasHiddenGlobalAllocationFunctionVisibility () const |
void | remapPathPrefix (SmallVectorImpl< char > &Path) const |
Remap path prefix according to -fmacro-prefix-path option. More... | |
RoundingMode | getDefaultRoundingMode () const |
FPExceptionModeKind | getDefaultExceptionMode () const |
Static Public Member Functions | |
static void | setLangDefaults (LangOptions &Opts, Language Lang, const llvm::Triple &T, std::vector< std::string > &Includes, LangStandard::Kind LangStd=LangStandard::lang_unspecified) |
Set language defaults for the given input language and language standard in the given LangOptions object. More... | |
Public Attributes | |
LangStandard::Kind | LangStd |
The used language standard. More... | |
SanitizerSet | Sanitize |
Set of enabled sanitizers. More... | |
bool | SanitizeCoverage = false |
Is at least one coverage instrumentation type enabled. More... | |
std::vector< std::string > | NoSanitizeFiles |
Paths to files specifying which objects (files, functions, variables) should not be instrumented. More... | |
std::vector< std::string > | XRayAlwaysInstrumentFiles |
Paths to the XRay "always instrument" files specifying which objects (files, functions, variables) should be imbued with the XRay "always instrument" attribute. More... | |
std::vector< std::string > | XRayNeverInstrumentFiles |
Paths to the XRay "never instrument" files specifying which objects (files, functions, variables) should be imbued with the XRay "never instrument" attribute. More... | |
std::vector< std::string > | XRayAttrListFiles |
Paths to the XRay attribute list files, specifying which objects (files, functions, variables) should be imbued with the appropriate XRay attribute(s). More... | |
std::vector< std::string > | ProfileListFiles |
Paths to special case list files specifying which entities (files, functions) should or should not be instrumented. More... | |
clang::ObjCRuntime | ObjCRuntime |
CoreFoundationABI | CFRuntime = CoreFoundationABI::Unspecified |
std::string | ObjCConstantStringClass |
std::string | OverflowHandler |
The name of the handler function to be called when -ftrapv is specified. More... | |
std::string | ModuleName |
The module currently being compiled as specified by -fmodule-name. More... | |
std::string | CurrentModule |
The name of the current module, of which the main source file is a part. More... | |
std::vector< std::string > | ModuleFeatures |
The names of any features to enable in module 'requires' decls in addition to the hard-coded list in Module.cpp and the target features. More... | |
CommentOptions | CommentOpts |
Options for parsing comments. More... | |
std::vector< std::string > | NoBuiltinFuncs |
A list of all -fno-builtin-* function names (e.g., memset). More... | |
std::map< std::string, std::string, std::greater< std::string > > | MacroPrefixMap |
A prefix map for FILE, BASE_FILE and __builtin_FILE(). More... | |
std::vector< llvm::Triple > | OMPTargetTriples |
Triples of the OpenMP targets that the host code codegen should take into account in order to generate accurate offloading descriptors. More... | |
std::string | OMPHostIRFile |
Name of the IR file that contains the result of the OpenMP target host code generation. More... | |
std::string | CUID |
The user provided compilation unit ID, if non-empty. More... | |
std::optional< TargetCXXABI::Kind > | CXXABI |
C++ ABI to compile with, if specified by the frontend through -fc++-abi=. More... | |
bool | IsHeaderFile = false |
Indicates whether the front-end is explicitly told that the input is a header file (i.e. More... | |
std::string | SYCLIntHeader |
SYCL integration header to be generated by the device compiler. More... | |
std::string | SYCLIntFooter |
SYCL integration footer to be generated by the device compiler. More... | |
std::string | SYCLUniquePrefix |
A driver-provided unique string for this translation unit that is used to generate unique names for SYCL names. More... | |
GPUDefaultStreamKind | GPUDefaultStream |
The default stream kind used for HIP kernel launching. More... | |
std::string | RandstructSeed |
The seed used by the randomize structure layout feature. More... | |
bool | UseTargetPathSeparator = false |
Indicates whether to use target's platform-specific file separator when FILE macro is used and when concatenating filename with directory or to use build environment environment's platform-specific file separator. More... | |
std::string | OptRecordFile |
The name of the file to which the backend should save YAML optimization records. More... | |
std::string | FPAccuracyVal |
FPAccuracyFuncMapTy | FPAccuracyFuncMap |
bool | CheckNew = false |
std::string | OpenACCMacroOverride |
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that is accepted.
Definition at line 482 of file LangOptions.h.
using clang::LangOptions::FPAccuracyFuncMapTy = std::map<std::string, std::string> |
Definition at line 607 of file LangOptions.h.
LangOptions::LangOptions | ( | ) |
Definition at line 19 of file LangOptions.cpp.
|
inline |
True if any ObjC types may have non-trivial lifetime qualifiers.
Definition at line 679 of file LangOptions.h.
Referenced by clang::Sema::PerformImplicitConversion().
|
inline |
Definition at line 683 of file LangOptions.h.
|
inline |
Definition at line 794 of file LangOptions.h.
|
inline |
Definition at line 789 of file LangOptions.h.
Referenced by clang::CodeGen::CodeGenFunction::StartFunction().
unsigned LangOptions::getOpenCLCompatibleVersion | ( | ) | const |
Return the OpenCL version that kernel language is compatible with.
Definition at line 63 of file LangOptions.cpp.
Referenced by clang::TargetInfo::adjust(), clang::OpenCLOptions::areProgramScopeVariablesSupported(), clang::Sema::Initialize(), clang::OpenCLOptions::OpenCLOptionInfo::isAvailableIn(), clang::CodeGen::CodeGenModule::Release(), and setLangDefaults().
std::string LangOptions::getOpenCLVersionString | ( | ) | const |
Return the OpenCL C or C++ for OpenCL language name and version as a string.
Definition at line 79 of file LangOptions.cpp.
References getOpenCLVersionTuple().
VersionTuple LangOptions::getOpenCLVersionTuple | ( | ) | const |
Return the OpenCL C or C++ version as a VersionTuple.
Definition at line 56 of file LangOptions.cpp.
Referenced by getOpenCLVersionString().
|
inline |
Returns true if the language supports calling the 'atexit' function.
Definition at line 710 of file LangOptions.h.
|
inline |
Definition at line 771 of file LangOptions.h.
References clang::LangOptionsBase::ForceDefault.
|
inline |
Definition at line 751 of file LangOptions.h.
References clang::LangOptionsBase::None.
Referenced by clang::CodeGen::CodeGenModule::shouldMapVisibilityToDLLExport().
|
inline |
Definition at line 741 of file LangOptions.h.
References clang::LangOptionsBase::DwarfCFI.
Referenced by getCPersonality(), and getCXXPersonality().
|
inline |
Definition at line 766 of file LangOptions.h.
References clang::LangOptionsBase::Source.
|
inline |
Definition at line 781 of file LangOptions.h.
References clang::LangOptionsBase::ForceHidden.
|
inline |
Definition at line 776 of file LangOptions.h.
References clang::LangOptionsBase::ForceProtected.
|
inline |
Definition at line 737 of file LangOptions.h.
References clang::LangOptionsBase::WinEH.
Referenced by getCPersonality(), getCXXPersonality(), and getObjCPersonality().
|
inline |
Check if return address signing is enabled.
Definition at line 719 of file LangOptions.h.
References clang::LangOptionsBase::None.
Referenced by clang::CodeGen::CodeGenModule::Release().
|
inline |
Definition at line 733 of file LangOptions.h.
References clang::LangOptionsBase::SjLj.
Referenced by getCPersonality(), getCXXPersonality(), and getObjCPersonality().
|
inline |
Definition at line 745 of file LangOptions.h.
References clang::LangOptionsBase::Wasm.
Referenced by clang::CodeGen::CodeGenFunction::EmitEndEHSpec(), clang::CodeGen::CodeGenFunction::EmitStartEHSpec(), and getCXXPersonality().
|
inline |
Returns true if implicit function declarations are allowed in the current language mode.
Definition at line 705 of file LangOptions.h.
References clang::OpenCL, and requiresStrictPrototypes().
|
inline |
Definition at line 761 of file LangOptions.h.
References clang::LangOptionsBase::All.
Referenced by clang::CodeGen::CodeGenModule::shouldMapVisibilityToDLLExport().
|
inline |
Definition at line 666 of file LangOptions.h.
Referenced by clang::TextDiagnostic::emitDiagnosticLoc(), and clang::Sema::ShouldDeleteSpecialMember().
|
inline |
Are we compiling a module?
Definition at line 643 of file LangOptions.h.
References clang::LangOptionsBase::CMK_None.
Referenced by clang::ModuleMap::diagnoseHeaderInclusion(), clang::PCHGenerator::getEmittingModule(), isCompilingModuleImplementation(), clang::ASTUnit::isModuleFile(), and trackLocalOwningModule().
|
inline |
Are we compiling a module implementation?
Definition at line 648 of file LangOptions.h.
References isCompilingModule(), and ModuleName.
|
inline |
Definition at line 756 of file LangOptions.h.
References clang::LangOptionsBase::Explicit.
Referenced by clang::CodeGen::CodeGenModule::shouldMapVisibilityToDLLExport().
|
inline |
Returns true if implicit int is supported at all.
Definition at line 716 of file LangOptions.h.
References clang::C23, and clang::CPlusPlus.
|
inline |
Returns true if implicit int is part of the language requirements.
Definition at line 713 of file LangOptions.h.
References clang::C99, and clang::CPlusPlus.
bool LangOptions::isNoBuiltinFunc | ( | StringRef | Name | ) | const |
Is this a libc/libm function that is no longer recognized as a builtin because a -fno-builtin-* option has been specified?
Definition at line 49 of file LangOptions.cpp.
References NoBuiltinFuncs.
|
inline |
Definition at line 657 of file LangOptions.h.
References clang::LangOptionsBase::SOB_Defined.
Referenced by emitPointerArithmetic().
|
inline |
Check if leaf functions are also signed.
Definition at line 729 of file LangOptions.h.
References clang::LangOptionsBase::All.
Referenced by clang::CodeGen::CodeGenModule::Release().
|
inline |
Check if return address signing uses AKey.
Definition at line 724 of file LangOptions.h.
References clang::LangOptionsBase::AKey.
Referenced by clang::CodeGen::CodeGenModule::Release().
|
inline |
Definition at line 661 of file LangOptions.h.
References clang::ObjCRuntime::isSubscriptPointerArithmetic().
|
inline |
Definition at line 749 of file LangOptions.h.
Referenced by clang::CodeGen::CodeGenModule::EmitGlobal().
void LangOptions::remapPathPrefix | ( | SmallVectorImpl< char > & | Path | ) | const |
Remap path prefix according to -fmacro-prefix-path option.
Definition at line 73 of file LangOptions.cpp.
References MacroPrefixMap.
|
inline |
Returns true if functions without prototypes or functions with an identifier list (aka K&R C functions) are not allowed.
Definition at line 699 of file LangOptions.h.
References clang::C23, and clang::CPlusPlus.
Referenced by implicitFunctionsAllowed().
void LangOptions::resetNonModularOptions | ( | ) |
Reset all of the options that are not considered when building a module.
Definition at line 25 of file LangOptions.cpp.
References CurrentModule, IsHeaderFile, NoSanitizeFiles, XRayAlwaysInstrumentFiles, and XRayNeverInstrumentFiles.
Referenced by clang::CompilerInvocation::resetNonModularOptions().
|
static |
Set language defaults for the given input language and language standard in the given LangOptions object.
Opts | - The LangOptions object to set up. |
Lang | - The input language. |
T | - The target triple. |
Includes | - If the language requires extra headers to be implicitly included, they will be appended to this list. |
LangStd | - The input language standard. |
Definition at line 89 of file LangOptions.cpp.
References clang::Asm, clang::CUDA, clang::LangOptionsBase::FPM_Fast, clang::LangOptionsBase::FPM_FastHonorPragmas, clang::LangOptionsBase::FPM_On, clang::getDefaultLanguageStandard(), clang::LangStandard::getLangStandardForKind(), getOpenCLCompatibleVersion(), clang::HIP, clang::HLSL, clang::LangOptionsBase::HLSL_2015, clang::LangOptionsBase::HLSL_2016, clang::LangOptionsBase::HLSL_2017, clang::LangOptionsBase::HLSL_2018, clang::LangOptionsBase::HLSL_2021, clang::LangOptionsBase::HLSL_202x, clang::LangStandard::lang_unspecified, LangStd, clang::ObjC, clang::ObjCXX, clang::RenderScript, Std, and clang::T.
|
inline |
Do we need to track the owning module for a local declaration?
Definition at line 653 of file LangOptions.h.
References isCompilingModule().
Referenced by clang::Decl::hasLocalOwningModuleStorage().
CoreFoundationABI clang::LangOptions::CFRuntime = CoreFoundationABI::Unspecified |
Definition at line 519 of file LangOptions.h.
Referenced by clang::CodeGen::CodeGenModule::GetAddrOfConstantCFString().
Definition at line 612 of file LangOptions.h.
CommentOptions clang::LangOptions::CommentOpts |
Options for parsing comments.
Definition at line 546 of file LangOptions.h.
Referenced by clang::ASTContext::addComment(), clang::ASTContext::cacheRawCommentForDecl(), and clang::ASTContext::getRawCommentForDeclNoCacheImpl().
std::string clang::LangOptions::CUID |
The user provided compilation unit ID, if non-empty.
This is used to externalize static variables which is needed to support accessing static device variables in host code for single source offloading languages like CUDA/HIP.
Definition at line 566 of file LangOptions.h.
Referenced by clang::ASTContext::getCUIDHash(), and clang::CodeGen::CodeGenModule::printPostfixForExternalizedDecl().
std::string clang::LangOptions::CurrentModule |
The name of the current module, of which the main source file is a part.
If CompilingModule is set, we are compiling the interface of this module, otherwise we are compiling an implementation file of it. This starts as ModuleName in case -fmodule-name is provided and changes during compilation to reflect the current module.
Definition at line 537 of file LangOptions.h.
Referenced by clang::DumpModuleInfoAction::ExecuteAction(), clang::FrontendAction::getCurrentModule(), clang::PCHGenerator::getEmittingModule(), clang::Preprocessor::getModuleForLocation(), prepareToBuildModule(), and resetNonModularOptions().
std::optional<TargetCXXABI::Kind> clang::LangOptions::CXXABI |
C++ ABI to compile with, if specified by the frontend through -fc++-abi=.
This overrides the default ABI used by the target.
Definition at line 570 of file LangOptions.h.
Referenced by clang::ASTContext::getCXXABIKind().
FPAccuracyFuncMapTy clang::LangOptions::FPAccuracyFuncMap |
Definition at line 608 of file LangOptions.h.
std::string clang::LangOptions::FPAccuracyVal |
Definition at line 606 of file LangOptions.h.
GPUDefaultStreamKind clang::LangOptions::GPUDefaultStream |
The default stream kind used for HIP kernel launching.
Definition at line 589 of file LangOptions.h.
Indicates whether the front-end is explicitly told that the input is a header file (i.e.
-x c-header).
Definition at line 574 of file LangOptions.h.
Referenced by resetNonModularOptions().
LangStandard::Kind clang::LangOptions::LangStd |
The used language standard.
Definition at line 485 of file LangOptions.h.
Referenced by clang::CodeGen::CodeGenModule::Release(), and setLangDefaults().
std::map<std::string, std::string, std::greater<std::string> > clang::LangOptions::MacroPrefixMap |
A prefix map for FILE, BASE_FILE and __builtin_FILE().
Definition at line 552 of file LangOptions.h.
Referenced by remapPathPrefix().
std::vector<std::string> clang::LangOptions::ModuleFeatures |
The names of any features to enable in module 'requires' decls in addition to the hard-coded list in Module.cpp and the target features.
This list is sorted.
Definition at line 543 of file LangOptions.h.
std::string clang::LangOptions::ModuleName |
The module currently being compiled as specified by -fmodule-name.
Definition at line 530 of file LangOptions.h.
Referenced by isCompilingModuleImplementation(), loadModuleMapForModuleBuild(), and makeCommonInvocationForModuleBuild().
std::vector<std::string> clang::LangOptions::NoBuiltinFuncs |
A list of all -fno-builtin-* function names (e.g., memset).
Definition at line 549 of file LangOptions.h.
Referenced by isNoBuiltinFunc().
std::vector<std::string> clang::LangOptions::NoSanitizeFiles |
Paths to files specifying which objects (files, functions, variables) should not be instrumented.
Definition at line 494 of file LangOptions.h.
Referenced by resetNonModularOptions().
std::string clang::LangOptions::ObjCConstantStringClass |
Definition at line 521 of file LangOptions.h.
clang::ObjCRuntime clang::LangOptions::ObjCRuntime |
Definition at line 517 of file LangOptions.h.
Referenced by clang::RewriteObjCAction::CreateASTConsumer(), clang::CodeGen::CreateGNUObjCRuntime(), clang::CodeGen::CodeGenFunction::EmitARCReclaimReturnedObject(), clang::CodeGen::CodeGenModule::GetAddrOfRTTIDescriptor(), getObjCPersonality(), getObjCXXPersonality(), hasUnwindExceptions(), clang::Sema::MaybeBindToTemporary(), setARCRuntimeFunctionLinkage(), tryEmitSpecializedAllocInit(), tryGenerateSpecializedMessageSend(), and UseOptimizedSetter().
std::string clang::LangOptions::OMPHostIRFile |
Name of the IR file that contains the result of the OpenMP target host code generation.
Definition at line 560 of file LangOptions.h.
Referenced by clang::CodeGen::CGOpenMPRuntime::CGOpenMPRuntime(), and clang::CodeGen::CGOpenMPRuntimeGPU::CGOpenMPRuntimeGPU().
std::vector<llvm::Triple> clang::LangOptions::OMPTargetTriples |
Triples of the OpenMP targets that the host code codegen should take into account in order to generate accurate offloading descriptors.
Definition at line 556 of file LangOptions.h.
Referenced by clang::CodeGen::CGOpenMPRuntime::getAddrOfDeclareTargetVar().
std::string clang::LangOptions::OpenACCMacroOverride |
Definition at line 617 of file LangOptions.h.
std::string clang::LangOptions::OptRecordFile |
The name of the file to which the backend should save YAML optimization records.
Definition at line 604 of file LangOptions.h.
std::string clang::LangOptions::OverflowHandler |
The name of the handler function to be called when -ftrapv is specified.
If none is specified, abort (GCC-compatible behaviour).
Definition at line 527 of file LangOptions.h.
std::vector<std::string> clang::LangOptions::ProfileListFiles |
Paths to special case list files specifying which entities (files, functions) should or should not be instrumented.
Definition at line 515 of file LangOptions.h.
std::string clang::LangOptions::RandstructSeed |
The seed used by the randomize structure layout feature.
Definition at line 592 of file LangOptions.h.
SanitizerSet clang::LangOptions::Sanitize |
Set of enabled sanitizers.
Definition at line 488 of file LangOptions.h.
Referenced by clang::CodeGen::CodeGenModule::CreateFunctionTypeMetadataForIcall(), clang::CodeGen::CodeGenFunction::EmitCfiCheckFail(), clang::CompilerInvocation::getModuleHash(), clang::CodeGen::CodeGenModule::NeedAllVtablesTypeId(), clang::CodeGen::CodeGenModule::Release(), clang::CodeGen::CodeGenVTables::RemoveHwasanMetadata(), and clang::CodeGen::SanitizerMetadata::reportGlobal().
Is at least one coverage instrumentation type enabled.
Definition at line 490 of file LangOptions.h.
std::string clang::LangOptions::SYCLIntFooter |
SYCL integration footer to be generated by the device compiler.
Definition at line 580 of file LangOptions.h.
std::string clang::LangOptions::SYCLIntHeader |
SYCL integration header to be generated by the device compiler.
Definition at line 577 of file LangOptions.h.
std::string clang::LangOptions::SYCLUniquePrefix |
A driver-provided unique string for this translation unit that is used to generate unique names for SYCL names.
This is provided by the driver so that the case of multiple-offload can have each device compilation share a name.
Definition at line 586 of file LangOptions.h.
Indicates whether to use target's platform-specific file separator when FILE macro is used and when concatenating filename with directory or to use build environment environment's platform-specific file separator.
The plaform-specific path separator is the backslash() for Windows and forward slash (/) elsewhere.
Definition at line 600 of file LangOptions.h.
std::vector<std::string> clang::LangOptions::XRayAlwaysInstrumentFiles |
Paths to the XRay "always instrument" files specifying which objects (files, functions, variables) should be imbued with the XRay "always instrument" attribute.
WARNING: This is a deprecated field and will go away in the future.
Definition at line 500 of file LangOptions.h.
Referenced by resetNonModularOptions().
std::vector<std::string> clang::LangOptions::XRayAttrListFiles |
Paths to the XRay attribute list files, specifying which objects (files, functions, variables) should be imbued with the appropriate XRay attribute(s).
Definition at line 511 of file LangOptions.h.
std::vector<std::string> clang::LangOptions::XRayNeverInstrumentFiles |
Paths to the XRay "never instrument" files specifying which objects (files, functions, variables) should be imbued with the XRay "never instrument" attribute.
WARNING: This is a deprecated field and will go away in the future.
Definition at line 506 of file LangOptions.h.
Referenced by resetNonModularOptions().