clang 20.0.0git
|
The basic abstraction for the target Objective-C runtime. More...
#include "clang/Basic/ObjCRuntime.h"
Public Types | |
enum | Kind { MacOSX , FragileMacOSX , iOS , WatchOS , GCC , GNUstep , ObjFW } |
The basic Objective-C runtimes that we know about. More... | |
Public Member Functions | |
ObjCRuntime ()=default | |
A bogus initialization of the runtime. | |
ObjCRuntime (Kind kind, const VersionTuple &version) | |
void | set (Kind kind, VersionTuple version) |
Kind | getKind () const |
const VersionTuple & | getVersion () const |
bool | isNonFragile () const |
Does this runtime follow the set of implied behaviors for a "non-fragile" ABI? | |
bool | isFragile () const |
The inverse of isNonFragile(): does this runtime follow the set of implied behaviors for a "fragile" ABI? | |
bool | isLegacyDispatchDefaultForArch (llvm::Triple::ArchType Arch) |
The default dispatch mechanism to use for the specified architecture. | |
bool | isGNUFamily () const |
Is this runtime basically of the GNU family of runtimes? | |
bool | isNeXTFamily () const |
Is this runtime basically of the NeXT family of runtimes? | |
bool | allowsARC () const |
Does this runtime allow ARC at all? | |
bool | hasNativeARC () const |
Does this runtime natively provide the ARC entrypoints? | |
bool | shouldUseARCFunctionsForRetainRelease () const |
Does this runtime provide ARC entrypoints that are likely to be faster than an ordinary message send of the appropriate selector? | |
bool | shouldUseRuntimeFunctionsForAlloc () const |
Does this runtime provide entrypoints that are likely to be faster than an ordinary message send of the "alloc" selector? | |
bool | shouldUseRuntimeFunctionForCombinedAllocInit () const |
Does this runtime provide the objc_alloc_init entrypoint? This can apply the same optimization as objc_alloc, but also sends an -init message, reducing code size on the caller. | |
bool | hasOptimizedSetter () const |
Does this runtime supports optimized setter entrypoints? | |
bool | allowsWeak () const |
Does this runtime allow the use of __weak? | |
bool | hasNativeWeak () const |
Does this runtime natively provide ARC-compliant 'weak' entrypoints? | |
bool | hasSubscripting () const |
Does this runtime directly support the subscripting methods? | |
bool | allowsSizeofAlignof () const |
Does this runtime allow sizeof or alignof on object types? | |
bool | allowsPointerArithmetic () const |
Does this runtime allow pointer arithmetic on objects? | |
bool | isSubscriptPointerArithmetic () const |
Is subscripting pointer arithmetic? | |
bool | hasTerminate () const |
Does this runtime provide an objc_terminate function? | |
bool | hasWeakClassImport () const |
Does this runtime support weakly importing classes? | |
bool | hasUnwindExceptions () const |
Does this runtime use zero-cost exceptions? | |
bool | hasAtomicCopyHelper () const |
bool | hasARCUnsafeClaimAutoreleasedReturnValue () const |
Is objc_unsafeClaimAutoreleasedReturnValue available? | |
bool | hasEmptyCollections () const |
Are the empty collection symbols available? | |
bool | allowsClassStubs () const |
Returns true if this Objective-C runtime supports Objective-C class stubs. | |
bool | allowsDirectDispatch () const |
Does this runtime supports direct dispatch. | |
bool | tryParse (StringRef input) |
Try to parse an Objective-C runtime specification from the given string. | |
std::string | getAsString () const |
Friends | |
bool | operator== (const ObjCRuntime &left, const ObjCRuntime &right) |
bool | operator!= (const ObjCRuntime &left, const ObjCRuntime &right) |
llvm::hash_code | hash_value (const ObjCRuntime &OCR) |
template<typename HasherT , llvm::endianness Endianness> | |
void | addHash (llvm::HashBuilder< HasherT, Endianness > &HBuilder, const ObjCRuntime &OCR) |
The basic abstraction for the target Objective-C runtime.
Definition at line 28 of file ObjCRuntime.h.
The basic Objective-C runtimes that we know about.
Definition at line 31 of file ObjCRuntime.h.
|
default |
A bogus initialization of the runtime.
|
inline |
Definition at line 69 of file ObjCRuntime.h.
|
inline |
Does this runtime allow ARC at all?
Definition at line 150 of file ObjCRuntime.h.
References FragileMacOSX, GCC, getKind(), getVersion(), GNUstep, iOS, MacOSX, ObjFW, and WatchOS.
|
inline |
Returns true if this Objective-C runtime supports Objective-C class stubs.
Definition at line 451 of file ObjCRuntime.h.
References FragileMacOSX, GCC, getKind(), GNUstep, iOS, MacOSX, ObjFW, and WatchOS.
|
inline |
Does this runtime supports direct dispatch.
Definition at line 467 of file ObjCRuntime.h.
References FragileMacOSX, GCC, getKind(), getVersion(), GNUstep, iOS, MacOSX, ObjFW, and WatchOS.
Referenced by clang::SemaObjC::CreatePropertyDecl(), clang::SemaObjC::handleDirectAttr(), and clang::SemaObjC::handleDirectMembersAttr().
|
inline |
Does this runtime allow pointer arithmetic on objects?
This covers +, -, ++, –, and (if isSubscriptPointerArithmetic() yields true) [].
Definition at line 340 of file ObjCRuntime.h.
References FragileMacOSX, GCC, getKind(), GNUstep, iOS, MacOSX, ObjFW, and WatchOS.
Referenced by checkArithmeticOnObjCPointer(), and isSubscriptPointerArithmetic().
|
inline |
Does this runtime allow sizeof or alignof on object types?
Definition at line 332 of file ObjCRuntime.h.
References isFragile().
Referenced by CheckObjCTraitOperandConstraints().
|
inline |
Does this runtime allow the use of __weak?
Definition at line 299 of file ObjCRuntime.h.
References hasNativeWeak().
Referenced by RenderObjCOptions().
std::string ObjCRuntime::getAsString | ( | ) | const |
Definition at line 23 of file ObjCRuntime.cpp.
References clang::Result.
|
inline |
Definition at line 77 of file ObjCRuntime.h.
Referenced by allowsARC(), allowsClassStubs(), allowsDirectDispatch(), allowsPointerArithmetic(), getObjCPersonality(), getObjCXXPersonality(), hasARCUnsafeClaimAutoreleasedReturnValue(), hasAtomicCopyHelper(), hasEmptyCollections(), hasNativeARC(), hasOptimizedSetter(), hasSubscripting(), hasTerminate(), hasUnwindExceptions(), hasWeakClassImport(), InitializePredefinedMacros(), isGNUFamily(), isLegacyDispatchDefaultForArch(), isNonFragile(), clang::operator<<(), RenderObjCOptions(), shouldUseARCFunctionsForRetainRelease(), shouldUseRuntimeFunctionForCombinedAllocInit(), and shouldUseRuntimeFunctionsForAlloc().
|
inline |
Definition at line 78 of file ObjCRuntime.h.
Referenced by allowsARC(), allowsDirectDispatch(), getObjCPersonality(), hasARCUnsafeClaimAutoreleasedReturnValue(), hasAtomicCopyHelper(), hasEmptyCollections(), hasNativeARC(), hasOptimizedSetter(), hasSubscripting(), hasTerminate(), InitializePredefinedMacros(), isLegacyDispatchDefaultForArch(), clang::operator<<(), shouldUseARCFunctionsForRetainRelease(), shouldUseRuntimeFunctionForCombinedAllocInit(), and shouldUseRuntimeFunctionsForAlloc().
|
inline |
Is objc_unsafeClaimAutoreleasedReturnValue available?
Definition at line 419 of file ObjCRuntime.h.
References FragileMacOSX, getKind(), getVersion(), GNUstep, iOS, MacOSX, and WatchOS.
|
inline |
Definition at line 405 of file ObjCRuntime.h.
References FragileMacOSX, getKind(), getVersion(), GNUstep, iOS, MacOSX, and WatchOS.
|
inline |
Are the empty collection symbols available?
Definition at line 436 of file ObjCRuntime.h.
References getKind(), getVersion(), iOS, MacOSX, and WatchOS.
Referenced by clang::Sema::MaybeBindToTemporary().
|
inline |
Does this runtime natively provide the ARC entrypoints?
ARC cannot be directly supported on a platform that does not provide these entrypoints, although it may be supportable via a stub library.
Definition at line 170 of file ObjCRuntime.h.
References FragileMacOSX, GCC, getKind(), getVersion(), GNUstep, iOS, MacOSX, ObjFW, and WatchOS.
Referenced by clang::driver::toolchains::DarwinClang::AddLinkARCArgs(), hasNativeWeak(), and setARCRuntimeFunctionLinkage().
|
inline |
Does this runtime natively provide ARC-compliant 'weak' entrypoints?
Definition at line 305 of file ObjCRuntime.h.
References hasNativeARC().
Referenced by allowsWeak().
|
inline |
Does this runtime supports optimized setter entrypoints?
Definition at line 283 of file ObjCRuntime.h.
References getKind(), getVersion(), GNUstep, iOS, MacOSX, and WatchOS.
Referenced by UseOptimizedSetter().
|
inline |
Does this runtime directly support the subscripting methods?
This is really a property of the library, not the runtime.
Definition at line 314 of file ObjCRuntime.h.
References FragileMacOSX, GCC, getKind(), getVersion(), GNUstep, iOS, MacOSX, ObjFW, and WatchOS.
Referenced by clang::driver::toolchains::DarwinClang::AddLinkARCArgs().
|
inline |
Does this runtime provide an objc_terminate function?
This is used in handlers for exceptions during the unwind process; without it, abort() must be used in pure ObjC files.
Definition at line 364 of file ObjCRuntime.h.
References FragileMacOSX, GCC, getKind(), getVersion(), GNUstep, iOS, MacOSX, ObjFW, and WatchOS.
Referenced by clang::CodeGen::CodeGenModule::getTerminateFn().
|
inline |
Does this runtime use zero-cost exceptions?
Definition at line 392 of file ObjCRuntime.h.
References FragileMacOSX, GCC, getKind(), GNUstep, iOS, MacOSX, ObjFW, and WatchOS.
Referenced by hasUnwindExceptions().
|
inline |
Does this runtime support weakly importing classes?
Definition at line 378 of file ObjCRuntime.h.
References FragileMacOSX, GCC, getKind(), GNUstep, iOS, MacOSX, ObjFW, and WatchOS.
Referenced by clang::Decl::canBeWeakImported().
|
inline |
The inverse of isNonFragile(): does this runtime follow the set of implied behaviors for a "fragile" ABI?
Definition at line 97 of file ObjCRuntime.h.
References isNonFragile().
Referenced by clang::SemaObjC::ActOnIvar(), clang::Sema::ActOnLastBitfield(), clang::SemaObjC::ActOnPropertyImplDecl(), allowsSizeofAlignof(), clang::Sema::BuildExceptionDeclaration(), clang::SemaObjC::CheckImplementationIvars(), and clang::SemaObjC::DefaultSynthesizeProperties().
|
inline |
Is this runtime basically of the GNU family of runtimes?
Definition at line 127 of file ObjCRuntime.h.
References FragileMacOSX, GCC, getKind(), GNUstep, iOS, MacOSX, ObjFW, and WatchOS.
Referenced by EncodeBitField(), clang::CodeGen::CodeGenModule::GetAddrOfRTTIDescriptor(), clang::ASTNameGenerator::Implementation::getClassSymbolPrefix(), isNeXTFamily(), and clang::MangleContext::mangleObjCMethodName().
|
inline |
The default dispatch mechanism to use for the specified architecture.
Definition at line 100 of file ObjCRuntime.h.
References getKind(), getVersion(), GNUstep, isNonFragile(), and MacOSX.
Referenced by RenderObjCOptions().
|
inline |
Is this runtime basically of the NeXT family of runtimes?
Definition at line 143 of file ObjCRuntime.h.
References isGNUFamily().
Referenced by CheckProtocolMethodDefs(), clang::driver::tools::Clang::ConstructJob(), InitializePredefinedMacros(), and RenderObjCOptions().
|
inline |
Does this runtime follow the set of implied behaviors for a "non-fragile" ABI?
Definition at line 82 of file ObjCRuntime.h.
References FragileMacOSX, GCC, getKind(), GNUstep, iOS, MacOSX, ObjFW, and WatchOS.
Referenced by clang::SemaObjC::ActOnAtEnd(), clang::SemaObjC::ActOnDefs(), clang::SemaObjC::ActOnIvar(), clang::SemaObjC::ActOnPropertyImplDecl(), clang::SemaObjC::CheckImplementationIvars(), DiagnoseUnimplementedAccessor(), clang::SemaObjC::ImplMethodsVsClassMethods(), InitializePredefinedMacros(), isFragile(), isLegacyDispatchDefaultForArch(), RenderObjCOptions(), and shouldUseExceptionTablesForObjCExceptions().
|
inline |
Is subscripting pointer arithmetic?
Definition at line 356 of file ObjCRuntime.h.
References allowsPointerArithmetic().
Referenced by clang::LangOptions::isSubscriptPointerArithmetic().
|
inline |
Definition at line 72 of file ObjCRuntime.h.
|
inline |
Does this runtime provide ARC entrypoints that are likely to be faster than an ordinary message send of the appropriate selector?
The ARC entrypoints are guaranteed to be equivalent to just sending the corresponding message. If the entrypoint is implemented naively as just a message send, using it is a trade-off: it sacrifices a few cycles of overhead to save a small amount of code. However, it's possible for runtimes to detect and special-case classes that use "standard" retain/release behavior; if that's dynamically a large proportion of all retained objects, using the entrypoint will also be faster than using a message send.
When this method returns true, Clang will turn non-super message sends of certain selectors into calls to the correspond entrypoint: retain => objc_retain release => objc_release autorelease => objc_autorelease
Definition at line 201 of file ObjCRuntime.h.
References FragileMacOSX, GCC, getKind(), getVersion(), GNUstep, iOS, MacOSX, ObjFW, and WatchOS.
|
inline |
Does this runtime provide the objc_alloc_init entrypoint? This can apply the same optimization as objc_alloc, but also sends an -init message, reducing code size on the caller.
Definition at line 267 of file ObjCRuntime.h.
References getKind(), getVersion(), GNUstep, iOS, MacOSX, and WatchOS.
|
inline |
Does this runtime provide entrypoints that are likely to be faster than an ordinary message send of the "alloc" selector?
The "alloc" entrypoint is guaranteed to be equivalent to just sending the corresponding message. If the entrypoint is implemented naively as just a message send, using it is a trade-off: it sacrifices a few cycles of overhead to save a small amount of code. However, it's possible for runtimes to detect and special-case classes that use "standard" alloc behavior; if that's dynamically a large proportion of all objects, using the entrypoint will also be faster than using a message send.
When this method returns true, Clang will turn non-super message sends of certain selectors into calls to the corresponding entrypoint: alloc => objc_alloc allocWithZone:nil => objc_allocWithZone
Definition at line 243 of file ObjCRuntime.h.
References FragileMacOSX, GCC, getKind(), getVersion(), GNUstep, iOS, MacOSX, ObjFW, and WatchOS.
bool ObjCRuntime::tryParse | ( | StringRef | input | ) |
Try to parse an Objective-C runtime specification from the given string.
Definition at line 48 of file ObjCRuntime.cpp.
References FragileMacOSX, GCC, GNUstep, iOS, MacOSX, ObjFW, and WatchOS.
|
friend |
Definition at line 503 of file ObjCRuntime.h.
|
friend |
Definition at line 498 of file ObjCRuntime.h.
|
friend |
Definition at line 494 of file ObjCRuntime.h.
|
friend |
Definition at line 489 of file ObjCRuntime.h.