[clang] [ObjCDirectPreconditionThunk] Adding a flag to with objc_direct symbols' prefix (PR #170616)
Peter Rong via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 17 11:42:36 PST 2025
================
@@ -717,6 +717,32 @@ class CodeGenModule : public CodeGenTypeCache {
/// Return true iff an Objective-C runtime has been configured.
bool hasObjCRuntime() { return !!ObjCRuntime; }
+ /// Check if a direct method should use precondition thunks (exposed symbols).
+ /// This applies to ALL direct methods (including variadic).
+ /// Returns false if OMD is null or not a direct method.
+ bool usePreconditionThunk(const ObjCMethodDecl *OMD) const {
+ return OMD && OMD->isDirectMethod() &&
+ getLangOpts().ObjCRuntime.isNeXTFamily() &&
----------------
DataCorrupted wrote:
https://clang.llvm.org/doxygen/ObjCRuntime_8h_source.html#l00467
I didn't realize that. It appears `clang::ObjCRuntime::allowsDirectDispatch` is the best source of truth whether the runtime supports `objc_direct`; it also specified that GNUStep 2.2+ supports it.
I'll use `allowsDirectDispatch` for clarity. But I'll keep the `isNeXTFamily` check to only support this feature in NeXT. The rational is that we want to validate the feature real quick but not worrying other runtimes, and migrate to GNU once we are confident.
https://github.com/llvm/llvm-project/pull/170616
More information about the cfe-commits
mailing list