14#ifndef LLVM_CLANG_BASIC_OBJCRUNTIME_H
15#define LLVM_CLANG_BASIC_OBJCRUNTIME_H
18#include "llvm/ADT/StringRef.h"
19#include "llvm/Support/ErrorHandling.h"
20#include "llvm/Support/HashBuilder.h"
21#include "llvm/Support/VersionTuple.h"
22#include "llvm/TargetParser/Triple.h"
70 : TheKind(kind), Version(version) {}
72 void set(
Kind kind, VersionTuple version) {
78 const VersionTuple &
getVersion()
const {
return Version; }
85 case GCC:
return false;
88 case ObjFW:
return true;
89 case iOS:
return true;
92 llvm_unreachable(
"bad kind");
105 case llvm::Triple::arm:
106 case llvm::Triple::x86:
107 case llvm::Triple::x86_64:
109 case llvm::Triple::aarch64:
110 case llvm::Triple::mips64:
112 case llvm::Triple::riscv64:
120 return Arch != llvm::Triple::x86_64;
139 llvm_unreachable(
"bad kind");
156 case iOS:
return true;
158 case GCC:
return false;
160 case ObjFW:
return true;
162 llvm_unreachable(
"bad kind");
177 case GCC:
return false;
179 case ObjFW:
return true;
181 llvm_unreachable(
"bad kind");
224 llvm_unreachable(
"bad kind");
261 llvm_unreachable(
"bad kind");
270 return getVersion() >= VersionTuple(10, 14, 4);
324 case GCC:
return true;
326 case ObjFW:
return true;
328 llvm_unreachable(
"bad kind");
352 llvm_unreachable(
"bad kind");
370 case GCC:
return false;
372 case ObjFW:
return false;
374 llvm_unreachable(
"bad kind");
381 case iOS:
return true;
384 case GCC:
return true;
386 case ObjFW:
return true;
388 llvm_unreachable(
"bad kind");
395 case iOS:
return true;
398 case GCC:
return true;
400 case ObjFW:
return true;
402 llvm_unreachable(
"bad kind");
414 default:
return false;
463 llvm_unreachable(
"bad kind");
471 case iOS:
return true;
473 case GCC:
return false;
476 case ObjFW:
return false;
478 llvm_unreachable(
"bad kind");
495 return !(left == right);
502 template <
typename HasherT, llvm::endianness Endianness>
503 friend void addHash(llvm::HashBuilder<HasherT, Endianness> &HBuilder,
509raw_ostream &
operator<<(raw_ostream &out,
const ObjCRuntime &value);
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
The basic abstraction for the target Objective-C runtime.
bool allowsWeak() const
Does this runtime allow the use of __weak?
bool shouldUseRuntimeFunctionsForAlloc() const
Does this runtime provide entrypoints that are likely to be faster than an ordinary message send of t...
bool hasEmptyCollections() const
Are the empty collection symbols available?
friend bool operator!=(const ObjCRuntime &left, const ObjCRuntime &right)
bool hasAtomicCopyHelper() const
bool isSubscriptPointerArithmetic() const
Is subscripting pointer arithmetic?
bool shouldUseRuntimeFunctionForCombinedAllocInit() const
Does this runtime provide the objc_alloc_init entrypoint? This can apply the same optimization as obj...
bool hasUnwindExceptions() const
Does this runtime use zero-cost exceptions?
friend bool operator==(const ObjCRuntime &left, const ObjCRuntime &right)
bool allowsSizeofAlignof() const
Does this runtime allow sizeof or alignof on object types?
bool hasARCUnsafeClaimAutoreleasedReturnValue() const
Is objc_unsafeClaimAutoreleasedReturnValue available?
void set(Kind kind, VersionTuple version)
bool hasTerminate() const
Does this runtime provide an objc_terminate function?
ObjCRuntime()=default
A bogus initialization of the runtime.
bool hasNativeARC() const
Does this runtime natively provide the ARC entrypoints?
bool isLegacyDispatchDefaultForArch(llvm::Triple::ArchType Arch)
The default dispatch mechanism to use for the specified architecture.
bool isNeXTFamily() const
Is this runtime basically of the NeXT family of runtimes?
bool hasOptimizedSetter() const
Does this runtime supports optimized setter entrypoints?
bool hasNativeWeak() const
Does this runtime natively provide ARC-compliant 'weak' entrypoints?
ObjCRuntime(Kind kind, const VersionTuple &version)
bool allowsPointerArithmetic() const
Does this runtime allow pointer arithmetic on objects?
bool hasSubscripting() const
Does this runtime directly support the subscripting methods?
const VersionTuple & getVersion() const
bool tryParse(StringRef input)
Try to parse an Objective-C runtime specification from the given string.
bool isNonFragile() const
Does this runtime follow the set of implied behaviors for a "non-fragile" ABI?
std::string getAsString() const
friend llvm::hash_code hash_value(const ObjCRuntime &OCR)
bool hasWeakClassImport() const
Does this runtime support weakly importing classes?
bool isGNUFamily() const
Is this runtime basically of the GNU family of runtimes?
bool allowsARC() const
Does this runtime allow ARC at all?
bool allowsDirectDispatch() const
Does this runtime supports direct dispatch.
bool shouldUseARCFunctionsForRetainRelease() const
Does this runtime provide ARC entrypoints that are likely to be faster than an ordinary message send ...
friend void addHash(llvm::HashBuilder< HasherT, Endianness > &HBuilder, const ObjCRuntime &OCR)
Kind
The basic Objective-C runtimes that we know about.
@ MacOSX
'macosx' is the Apple-provided NeXT-derived runtime on Mac OS X platforms that use the non-fragile AB...
@ FragileMacOSX
'macosx-fragile' is the Apple-provided NeXT-derived runtime on Mac OS X platforms that use the fragil...
@ GNUstep
'gnustep' is the modern non-fragile GNUstep runtime.
@ ObjFW
'objfw' is the Objective-C runtime included in ObjFW
@ iOS
'ios' is the Apple-provided NeXT-derived runtime on iOS or the iOS simulator; it is always non-fragil...
@ GCC
'gcc' is the Objective-C runtime shipped with GCC, implementing a fragile Objective-C ABI
@ WatchOS
'watchos' is a variant of iOS for Apple's watchOS.
bool allowsClassStubs() const
Returns true if this Objective-C runtime supports Objective-C class stubs.
bool isFragile() const
The inverse of isNonFragile(): does this runtime follow the set of implied behaviors for a "fragile" ...
The JSON file list parser is used to communicate input to InstallAPI.
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.