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");
104 if (Arch == llvm::Triple::arm ||
105 Arch == llvm::Triple::x86 ||
106 Arch == llvm::Triple::x86_64)
112 return Arch != llvm::Triple::x86_64;
131 llvm_unreachable(
"bad kind");
148 case iOS:
return true;
150 case GCC:
return false;
152 case ObjFW:
return true;
154 llvm_unreachable(
"bad kind");
169 case GCC:
return false;
171 case ObjFW:
return true;
173 llvm_unreachable(
"bad kind");
210 llvm_unreachable(
"bad kind");
247 llvm_unreachable(
"bad kind");
256 return getVersion() >= VersionTuple(10, 14, 4);
308 case GCC:
return true;
310 case ObjFW:
return true;
312 llvm_unreachable(
"bad kind");
336 llvm_unreachable(
"bad kind");
354 case GCC:
return false;
356 case ObjFW:
return false;
358 llvm_unreachable(
"bad kind");
365 case iOS:
return true;
368 case GCC:
return true;
370 case ObjFW:
return true;
372 llvm_unreachable(
"bad kind");
379 case iOS:
return true;
382 case GCC:
return true;
384 case ObjFW:
return true;
386 llvm_unreachable(
"bad kind");
398 default:
return false;
447 llvm_unreachable(
"bad kind");
455 case iOS:
return true;
457 case GCC:
return false;
459 case ObjFW:
return false;
461 llvm_unreachable(
"bad kind");
478 return !(left == right);
485 template <
typename HasherT, llvm::endianness Endianness>
486 friend void addHash(llvm::HashBuilder<HasherT, Endianness> &HBuilder,
492raw_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" ...
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.