clang 19.0.0git
Public Types | Public Member Functions | Friends | List of all members
clang::ObjCRuntime Class Reference

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)
 

Detailed Description

The basic abstraction for the target Objective-C runtime.

Definition at line 28 of file ObjCRuntime.h.

Member Enumeration Documentation

◆ Kind

The basic Objective-C runtimes that we know about.

Enumerator
MacOSX 

'macosx' is the Apple-provided NeXT-derived runtime on Mac OS X platforms that use the non-fragile ABI; the version is a release of that OS.

FragileMacOSX 

'macosx-fragile' is the Apple-provided NeXT-derived runtime on Mac OS X platforms that use the fragile ABI; the version is a release of that OS.

iOS 

'ios' is the Apple-provided NeXT-derived runtime on iOS or the iOS simulator; it is always non-fragile.

The version is a release version of iOS.

WatchOS 

'watchos' is a variant of iOS for Apple's watchOS.

The version is a release version of watchOS.

GCC 

'gcc' is the Objective-C runtime shipped with GCC, implementing a fragile Objective-C ABI

GNUstep 

'gnustep' is the modern non-fragile GNUstep runtime.

ObjFW 

'objfw' is the Objective-C runtime included in ObjFW

Definition at line 31 of file ObjCRuntime.h.

Constructor & Destructor Documentation

◆ ObjCRuntime() [1/2]

clang::ObjCRuntime::ObjCRuntime ( )
default

A bogus initialization of the runtime.

◆ ObjCRuntime() [2/2]

clang::ObjCRuntime::ObjCRuntime ( Kind  kind,
const VersionTuple &  version 
)
inline

Definition at line 69 of file ObjCRuntime.h.

Member Function Documentation

◆ allowsARC()

bool clang::ObjCRuntime::allowsARC ( ) const
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.

◆ allowsClassStubs()

bool clang::ObjCRuntime::allowsClassStubs ( ) const
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.

◆ allowsDirectDispatch()

bool clang::ObjCRuntime::allowsDirectDispatch ( ) const
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::Sema::CreatePropertyDecl(), handleObjCDirectAttr(), and handleObjCDirectMembersAttr().

◆ allowsPointerArithmetic()

bool clang::ObjCRuntime::allowsPointerArithmetic ( ) const
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().

◆ allowsSizeofAlignof()

bool clang::ObjCRuntime::allowsSizeofAlignof ( ) const
inline

Does this runtime allow sizeof or alignof on object types?

Definition at line 332 of file ObjCRuntime.h.

References isFragile().

Referenced by CheckObjCTraitOperandConstraints().

◆ allowsWeak()

bool clang::ObjCRuntime::allowsWeak ( ) const
inline

Does this runtime allow the use of __weak?

Definition at line 299 of file ObjCRuntime.h.

References hasNativeWeak().

Referenced by RenderObjCOptions().

◆ getAsString()

std::string ObjCRuntime::getAsString ( ) const

Definition at line 23 of file ObjCRuntime.cpp.

References clang::Result.

◆ getKind()

Kind clang::ObjCRuntime::getKind ( ) const
inline

◆ getVersion()

const VersionTuple & clang::ObjCRuntime::getVersion ( ) const
inline

◆ hasARCUnsafeClaimAutoreleasedReturnValue()

bool clang::ObjCRuntime::hasARCUnsafeClaimAutoreleasedReturnValue ( ) const
inline

Is objc_unsafeClaimAutoreleasedReturnValue available?

Definition at line 419 of file ObjCRuntime.h.

References FragileMacOSX, getKind(), getVersion(), GNUstep, iOS, MacOSX, and WatchOS.

◆ hasAtomicCopyHelper()

bool clang::ObjCRuntime::hasAtomicCopyHelper ( ) const
inline

Definition at line 405 of file ObjCRuntime.h.

References FragileMacOSX, getKind(), getVersion(), GNUstep, iOS, MacOSX, and WatchOS.

◆ hasEmptyCollections()

bool clang::ObjCRuntime::hasEmptyCollections ( ) const
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().

◆ hasNativeARC()

bool clang::ObjCRuntime::hasNativeARC ( ) const
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().

◆ hasNativeWeak()

bool clang::ObjCRuntime::hasNativeWeak ( ) const
inline

Does this runtime natively provide ARC-compliant 'weak' entrypoints?

Definition at line 305 of file ObjCRuntime.h.

References hasNativeARC().

Referenced by allowsWeak().

◆ hasOptimizedSetter()

bool clang::ObjCRuntime::hasOptimizedSetter ( ) const
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().

◆ hasSubscripting()

bool clang::ObjCRuntime::hasSubscripting ( ) const
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().

◆ hasTerminate()

bool clang::ObjCRuntime::hasTerminate ( ) const
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().

◆ hasUnwindExceptions()

bool clang::ObjCRuntime::hasUnwindExceptions ( ) const
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().

◆ hasWeakClassImport()

bool clang::ObjCRuntime::hasWeakClassImport ( ) const
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().

◆ isFragile()

bool clang::ObjCRuntime::isFragile ( ) const
inline

◆ isGNUFamily()

bool clang::ObjCRuntime::isGNUFamily ( ) const
inline

◆ isLegacyDispatchDefaultForArch()

bool clang::ObjCRuntime::isLegacyDispatchDefaultForArch ( llvm::Triple::ArchType  Arch)
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().

◆ isNeXTFamily()

bool clang::ObjCRuntime::isNeXTFamily ( ) const
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().

◆ isNonFragile()

bool clang::ObjCRuntime::isNonFragile ( ) const
inline

◆ isSubscriptPointerArithmetic()

bool clang::ObjCRuntime::isSubscriptPointerArithmetic ( ) const
inline

Is subscripting pointer arithmetic?

Definition at line 356 of file ObjCRuntime.h.

References allowsPointerArithmetic().

Referenced by clang::LangOptions::isSubscriptPointerArithmetic().

◆ set()

void clang::ObjCRuntime::set ( Kind  kind,
VersionTuple  version 
)
inline

Definition at line 72 of file ObjCRuntime.h.

◆ shouldUseARCFunctionsForRetainRelease()

bool clang::ObjCRuntime::shouldUseARCFunctionsForRetainRelease ( ) const
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.

◆ shouldUseRuntimeFunctionForCombinedAllocInit()

bool clang::ObjCRuntime::shouldUseRuntimeFunctionForCombinedAllocInit ( ) const
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.

◆ shouldUseRuntimeFunctionsForAlloc()

bool clang::ObjCRuntime::shouldUseRuntimeFunctionsForAlloc ( ) const
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.

◆ tryParse()

bool ObjCRuntime::tryParse ( StringRef  input)

Try to parse an Objective-C runtime specification from the given string.

Returns
true on error.

Definition at line 48 of file ObjCRuntime.cpp.

References FragileMacOSX, GCC, GNUstep, iOS, MacOSX, ObjFW, and WatchOS.

Friends And Related Function Documentation

◆ addHash

template<typename HasherT , llvm::endianness Endianness>
void addHash ( llvm::HashBuilder< HasherT, Endianness > &  HBuilder,
const ObjCRuntime OCR 
)
friend

Definition at line 503 of file ObjCRuntime.h.

◆ hash_value

llvm::hash_code hash_value ( const ObjCRuntime OCR)
friend

Definition at line 498 of file ObjCRuntime.h.

◆ operator!=

bool operator!= ( const ObjCRuntime left,
const ObjCRuntime right 
)
friend

Definition at line 494 of file ObjCRuntime.h.

◆ operator==

bool operator== ( const ObjCRuntime left,
const ObjCRuntime right 
)
friend

Definition at line 489 of file ObjCRuntime.h.


The documentation for this class was generated from the following files: