clang 10.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. More...
| 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? More...
bool | isFragile () const
| The inverse of isNonFragile(): does this runtime follow the set of implied behaviors for a "fragile" ABI? More...
bool | isLegacyDispatchDefaultForArch (llvm::Triple::ArchType Arch)
| The default dispatch mechanism to use for the specified architecture. More...
bool | isGNUFamily () const
| Is this runtime basically of the GNU family of runtimes? More...
bool | isNeXTFamily () const
| Is this runtime basically of the NeXT family of runtimes? More...
bool | allowsARC () const
| Does this runtime allow ARC at all? More...
bool | hasNativeARC () const
| Does this runtime natively provide the ARC entrypoints? More...
bool | shouldUseARCFunctionsForRetainRelease () const
| Does this runtime provide ARC entrypoints that are likely to be faster than an ordinary message send of the appropriate selector? More...
bool | shouldUseRuntimeFunctionsForAlloc () const
| Does this runtime provide entrypoints that are likely to be faster than an ordinary message send of the "alloc" selector? More...
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. More...
bool | hasOptimizedSetter () const
| Does this runtime supports optimized setter entrypoints? More...
bool | allowsWeak () const
| Does this runtime allow the use of __weak? More...
bool | hasNativeWeak () const
| Does this runtime natively provide ARC-compliant 'weak' entrypoints? More...
bool | hasSubscripting () const
| Does this runtime directly support the subscripting methods? More...
bool | allowsSizeofAlignof () const
| Does this runtime allow sizeof or alignof on object types? More...
bool | allowsPointerArithmetic () const
| Does this runtime allow pointer arithmetic on objects? More...
bool | isSubscriptPointerArithmetic () const
| Is subscripting pointer arithmetic? More...
bool | hasTerminate () const
| Does this runtime provide an objc_terminate function? More...
bool | hasWeakClassImport () const
| Does this runtime support weakly importing classes? More...
bool | hasUnwindExceptions () const
| Does this runtime use zero-cost exceptions? More...
bool | hasAtomicCopyHelper () const
bool | hasARCUnsafeClaimAutoreleasedReturnValue () const
| Is objc_unsafeClaimAutoreleasedReturnValue available? More...
bool | hasEmptyCollections () const
| Are the empty collection symbols available? More...
bool | allowsClassStubs () const
| Returns true if this Objective-C runtime supports Objective-C class stubs. More...
bool | allowsDirectDispatch () const
| Does this runtime supports direct dispatch. More...
bool | tryParse (StringRef input)
| Try to parse an Objective-C runtime specification from the given string. More...
std::string | getAsString () const

## Friends
bool | operator== (const ObjCRuntime &left, const ObjCRuntime &right)
bool | operator!= (const ObjCRuntime &left, const ObjCRuntime &right)

## Detailed Description

The basic abstraction for the target Objective-C runtime.

Definition at line 27 of file ObjCRuntime.h.

## Member Enumeration Documentation

## ◆ Kind

enum clang::ObjCRuntime::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 30 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 68 of file ObjCRuntime.h.

## Member Function Documentation

## ◆ allowsARC()

bool clang::ObjCRuntime::allowsARC | ( |  | ) | const
| inline

Does this runtime allow ARC at all?

Definition at line 141 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 434 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 450 of file ObjCRuntime.h.

References FragileMacOSX, GCC, getAsString(), getKind(), GNUstep, iOS, MacOSX, ObjFW, tryParse(), and WatchOS.

## ◆ 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 323 of file ObjCRuntime.h.

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

Referenced by isSubscriptPointerArithmetic().

## ◆ allowsSizeofAlignof()

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

Does this runtime allow sizeof or alignof on object types?

Definition at line 315 of file ObjCRuntime.h.

References isFragile().

## ◆ allowsWeak()

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

Does this runtime allow the use of __weak?

Definition at line 282 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.

Referenced by allowsDirectDispatch(), and clang::driver::tools::Clang::~Clang().

## ◆ getKind()

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

Definition at line 76 of file ObjCRuntime.h.

Referenced by allowsARC(), allowsClassStubs(), allowsDirectDispatch(), allowsPointerArithmetic(), getObjCPersonality(), getObjCXXPersonality(), hasARCUnsafeClaimAutoreleasedReturnValue(), hasAtomicCopyHelper(), hasEmptyCollections(), hasNativeARC(), hasOptimizedSetter(), hasSubscripting(), hasTerminate(), hasUnwindExceptions(), hasWeakClassImport(), isGNUFamily(), isLegacyDispatchDefaultForArch(), isNonFragile(), clang::operator<<(), RenderObjCOptions(), shouldUseARCFunctionsForRetainRelease(), shouldUseRuntimeFunctionForCombinedAllocInit(), shouldUseRuntimeFunctionsForAlloc(), clang::driver::tools::Clang::~Clang(), and clang::CodeGen::CodeGenModule::~CodeGenModule().

## ◆ getVersion()

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

Definition at line 77 of file ObjCRuntime.h.

Referenced by allowsARC(), getObjCPersonality(), hasARCUnsafeClaimAutoreleasedReturnValue(), hasAtomicCopyHelper(), hasEmptyCollections(), hasNativeARC(), hasOptimizedSetter(), hasSubscripting(), hasTerminate(), isLegacyDispatchDefaultForArch(), clang::operator<<(), shouldUseARCFunctionsForRetainRelease(), shouldUseRuntimeFunctionForCombinedAllocInit(), shouldUseRuntimeFunctionsForAlloc(), and clang::driver::tools::Clang::~Clang().

## ◆ hasARCUnsafeClaimAutoreleasedReturnValue()

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

Is objc_unsafeClaimAutoreleasedReturnValue available?

Definition at line 402 of file ObjCRuntime.h.

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

Referenced by clang::CodeGen::CodeGenFunction::EmitARCReclaimReturnedObject().

## ◆ hasAtomicCopyHelper()

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

Definition at line 388 of file ObjCRuntime.h.

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

Referenced by clang::CodeGen::CodeGenFunction::GenerateObjCAtomicGetterCopyHelperFunction(), and clang::CodeGen::CodeGenFunction::GenerateObjCAtomicSetterCopyHelperFunction().

## ◆ hasEmptyCollections()

bool clang::ObjCRuntime::hasEmptyCollections | ( |  | ) | const
| inline

Are the empty collection symbols available?

Definition at line 419 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 161 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 288 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 266 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 297 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 347 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 375 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 361 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

The inverse of isNonFragile(): does this runtime follow the set of implied behaviors for a "fragile" ABI?

Definition at line 96 of file ObjCRuntime.h.

References isNonFragile().

Referenced by allowsSizeofAlignof().

## ◆ isGNUFamily()

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

Is this runtime basically of the GNU family of runtimes?

Definition at line 118 of file ObjCRuntime.h.

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

Referenced by clang::ASTNameGenerator::Implementation::getClassSymbolPrefix(), and isNeXTFamily().

## ◆ isLegacyDispatchDefaultForArch()

bool clang::ObjCRuntime::isLegacyDispatchDefaultForArch | ( | llvm::Triple::ArchType | Arch | ) |
| inline

The default dispatch mechanism to use for the specified architecture.

Definition at line 99 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 134 of file ObjCRuntime.h.

References isGNUFamily().

Referenced by PersonalityHasOnlyCXXUses(), and RenderObjCOptions().

## ◆ isNonFragile()

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

Does this runtime follow the set of implied behaviors for a "non-fragile" ABI?

Definition at line 81 of file ObjCRuntime.h.

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

Referenced by clang::Sema::CheckImplementationIvars(), clang::RewriteObjCAction::CreateASTConsumer(), FindIvarInterface(), isFragile(), isLegacyDispatchDefaultForArch(), clang::CodeGen::CGDebugInfo::remapDIPath(), RenderObjCOptions(), and shouldUseExceptionTablesForObjCExceptions().

## ◆ isSubscriptPointerArithmetic()

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

Is subscripting pointer arithmetic?

Definition at line 339 of file ObjCRuntime.h.

References allowsPointerArithmetic().

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

## ◆ set()

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

Definition at line 71 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 192 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 252 of file ObjCRuntime.h.

References getKind(), getVersion(), 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 228 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.

Referenced by allowsDirectDispatch(), and clang::driver::tools::Clang::~Clang().

## Friends And Related Function Documentation

## ◆ operator!=

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

Definition at line 476 of file ObjCRuntime.h.

## ◆ operator==

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

Definition at line 471 of file ObjCRuntime.h.

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

- include/clang/Basic/ObjCRuntime.h
- lib/Basic/ObjCRuntime.cpp