r190791 - Add a define for the ObjFW runtime ABI version.
Benjamin Kramer
benny.kra at googlemail.com
Mon Sep 16 09:31:50 PDT 2013
Author: d0k
Date: Mon Sep 16 11:31:49 2013
New Revision: 190791
URL: http://llvm.org/viewvc/llvm-project?rev=190791&view=rev
Log:
Add a define for the ObjFW runtime ABI version.
This removes __has_feature(objc_msg_lookup_stret), as it is not required
anymore after this patch.
Patch by Jonathan Schleifer!
Modified:
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/lib/Basic/ObjCRuntime.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/test/CodeGenObjC/stret_lookup.m
Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=190791&r1=190790&r2=190791&view=diff
==============================================================================
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Mon Sep 16 11:31:49 2013
@@ -1255,23 +1255,6 @@ Further examples of these attributes are
Query for these features with ``__has_attribute(ns_consumed)``,
``__has_attribute(ns_returns_retained)``, etc.
-objc_msg_lookup_stret
----------------------
-
-Traditionally, if a runtime is used that follows the GNU Objective-C ABI, a
-call to objc_msg_lookup() would be emitted for each message send, which would
-return a pointer to the actual implementation of the method. However,
-objc_msg_lookup() has no information at all about the method signature of the
-actual method. Therefore, certain features like forwarding messages cannot be
-correctly implemented for methods returning structs using objc_msg_lookup(), as
-methods returning structs use a slightly different calling convention.
-
-To work around this, Clang emits calls to objc_msg_lookup_stret() instead for
-methods that return structs if the runtime supports this, allowing the runtime
-to use a different forwarding handler for methods returning structs.
-
-To check if Clang emits calls to objc_msg_lookup_stret(),
-__has_feature(objc_msg_lookup_stret) can be used.
Function Overloading in C
=========================
Modified: cfe/trunk/lib/Basic/ObjCRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/ObjCRuntime.cpp?rev=190791&r1=190790&r2=190791&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/ObjCRuntime.cpp (original)
+++ cfe/trunk/lib/Basic/ObjCRuntime.cpp Mon Sep 16 11:31:49 2013
@@ -71,16 +71,20 @@ bool ObjCRuntime::tryParse(StringRef inp
kind = ObjCRuntime::GCC;
} else if (runtimeName == "objfw") {
kind = ObjCRuntime::ObjFW;
+ Version = VersionTuple(0, 8);
} else {
return true;
}
TheKind = kind;
-
+
if (dash != StringRef::npos) {
StringRef verString = input.substr(dash + 1);
- if (Version.tryParse(verString))
+ if (Version.tryParse(verString))
return true;
}
+ if (kind == ObjCRuntime::ObjFW && Version > VersionTuple(0, 8))
+ Version = VersionTuple(0, 8);
+
return false;
}
Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=190791&r1=190790&r2=190791&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Sep 16 11:31:49 2013
@@ -408,6 +408,22 @@ static void InitializePredefinedMacros(c
if (LangOpts.ObjCRuntime.isNeXTFamily())
Builder.defineMacro("__NEXT_RUNTIME__");
+ if (LangOpts.ObjCRuntime.getKind() == ObjCRuntime::ObjFW) {
+ VersionTuple tuple = LangOpts.ObjCRuntime.getVersion();
+
+ unsigned minor = 0;
+ if (tuple.getMinor().hasValue())
+ minor = tuple.getMinor().getValue();
+
+ unsigned subminor = 0;
+ if (tuple.getSubminor().hasValue())
+ subminor = tuple.getSubminor().getValue();
+
+ Builder.defineMacro("__OBJFW_RUNTIME_ABI__",
+ Twine(tuple.getMajor() * 10000 + minor * 100 +
+ subminor));
+ }
+
Builder.defineMacro("IBOutlet", "__attribute__((iboutlet))");
Builder.defineMacro("IBOutletCollection(ClassName)",
"__attribute__((iboutletcollection(ClassName)))");
Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=190791&r1=190790&r2=190791&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Mon Sep 16 11:31:49 2013
@@ -920,7 +920,6 @@ static bool HasFeature(const Preprocesso
.Case("objc_nonfragile_abi", LangOpts.ObjCRuntime.isNonFragile())
.Case("objc_property_explicit_atomic", true) // Does clang support explicit "atomic" keyword?
.Case("objc_weak_class", LangOpts.ObjCRuntime.hasWeakClassImport())
- .Case("objc_msg_lookup_stret", LangOpts.ObjCRuntime.getKind() == ObjCRuntime::ObjFW)
.Case("ownership_holds", true)
.Case("ownership_returns", true)
.Case("ownership_takes", true)
Modified: cfe/trunk/test/CodeGenObjC/stret_lookup.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/stret_lookup.m?rev=190791&r1=190790&r2=190791&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/stret_lookup.m (original)
+++ cfe/trunk/test/CodeGenObjC/stret_lookup.m Mon Sep 16 11:31:49 2013
@@ -11,8 +11,8 @@ struct test {
@end
void test0(void) {
struct test t;
-#if (defined(STRET) && __has_feature(objc_msg_lookup_stret)) || \
- (!defined(STRET) && !__has_feature(objc_msg_lookup_stret))
+#if (defined(STRET) && defined(__OBJFW_RUNTIME_ABI__)) || \
+ (!defined(STRET) && !defined(__OBJFW_RUNTIME_ABI__))
t = [Test0 test];
#endif
(void)t;
More information about the cfe-commits
mailing list