Skip to content

Commit b9d4b7e

Browse files
authored
Merge branch 'master' into rfm-patch-1
2 parents 6602082 + 0c1a893 commit b9d4b7e

File tree

6 files changed

+26
-7
lines changed

6 files changed

+26
-7
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ set(libobjc_HDRS
9999
objc/objc.h
100100
objc/runtime-deprecated.h
101101
objc/runtime.h
102-
objc/slot.h)
102+
objc/slot.h
103+
${PROJECT_BINARY_DIR}/objc/objc-config.h)
103104

104105
set(libobjc_CXX_SRCS
105106
selector_table.cc
@@ -150,6 +151,9 @@ add_compile_definitions($<$<BOOL:${ENABLE_TRACING}>:WITH_TRACING=1>)
150151
add_compile_definitions($<$<BOOL:${DEBUG_ARC_COMPAT}>:DEBUG_ARC_COMPAT>)
151152
add_compile_definitions($<$<BOOL:${STRICT_APPLE_COMPATIBILITY}>:STRICT_APPLE_COMPATIBILITY>)
152153

154+
configure_file(objc/objc-config.h.in objc/objc-config.h @ONLY)
155+
include_directories("${PROJECT_BINARY_DIR}/objc/")
156+
153157
if (OLDABI_COMPAT)
154158
list(APPEND libobjc_C_SRCS legacy.c abi_version.c statics_loader.c)
155159
add_definitions(-DOLDABI_COMPAT=1)

Test/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ remove_definitions(-D__OBJC_RUNTIME_INTERNAL__=1)
9898

9999
add_library(test_runtime_legacy OBJECT Test.m)
100100
set_target_properties(test_runtime_legacy PROPERTIES
101-
INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}"
101+
INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR};${PROJECT_BINARY_DIR}/objc/"
102102
COMPILE_FLAGS "-Xclang -fblocks -fobjc-runtime=gnustep-1.7"
103103
LINKER_LANGUAGE C
104104
)
105105

106106
add_library(test_runtime OBJECT Test.m)
107107
set_target_properties(test_runtime PROPERTIES
108-
INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}"
108+
INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR};${PROJECT_BINARY_DIR}/objc/"
109109
COMPILE_FLAGS "-Xclang -fblocks -fobjc-runtime=gnustep-2.0"
110110
LINKER_LANGUAGE C
111111
)
@@ -123,7 +123,7 @@ function(addtest_flags TEST_NAME FLAGS TEST_SOURCE)
123123
add_test(${TEST_NAME} ${TEST_NAME})
124124
set(ARC "")
125125
set_target_properties(${TEST_NAME} PROPERTIES
126-
INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}"
126+
INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR};${PROJECT_BINARY_DIR}/objc/"
127127
COMPILE_FLAGS "-Xclang -fblocks -Xclang -fobjc-exceptions ${FLAGS}"
128128
LINK_FLAGS ${INCREMENTAL}
129129
LINKER_LANGUAGE C

Test/FastPathAlloc.m

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ @interface NoAlloc : Test @end
2121
@interface NoInit : Test @end
2222
@interface NoInit2 : NoInit @end
2323

24+
@interface ShouldInitSubclassed : NoInit @end
25+
2426
@implementation ShouldAlloc
2527
+ (instancetype)alloc
2628
{
@@ -91,6 +93,13 @@ + (instancetype)alloc
9193
}
9294
@end
9395

96+
@implementation ShouldInitSubclassed
97+
+ (instancetype) alloc
98+
{
99+
return [ShouldInit alloc];
100+
}
101+
@end
102+
94103
Class getClassNamed(char *name)
95104
{
96105
return nil;
@@ -114,6 +123,10 @@ int main(void)
114123
[[ShouldInit2 alloc] init];
115124
assert(called);
116125

126+
called = NO;
127+
[[ShouldInitSubclassed alloc] init];
128+
assert(called);
129+
117130
called = NO;
118131
[NoAlloc alloc];
119132
assert(!called);

fast_paths.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ - (id)init;
99
@end
1010
#include <stdio.h>
1111

12-
/**
13-
* Equivalent to [cls alloc]. If there's a fast path opt-in, then this skips the message send.
14-
*/
1512
OBJC_PUBLIC
1613
id
1714
objc_alloc(Class cls)
@@ -66,6 +63,9 @@ - (id)init;
6663
return nil;
6764
}
6865
id instance = objc_alloc(cls);
66+
// If +alloc was overwritten, it is not guaranteed that it returns
67+
// an instance of cls.
68+
cls = classForObject(instance);
6969
if (objc_test_class_flag(cls, objc_class_flag_fast_alloc_init))
7070
{
7171
return instance;

objc/objc-config.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#cmakedefine STRICT_APPLE_COMPATIBILITY @STRICT_APPLE_COMPATIBILITY@

objc/runtime.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#pragma clang system_header
33
#endif
44
#include "objc-visibility.h"
5+
#include "objc-config.h"
56

67
#ifndef __LIBOBJC_RUNTIME_H_INCLUDED__
78
#define __LIBOBJC_RUNTIME_H_INCLUDED__

0 commit comments

Comments
 (0)