Skip to content

Commit acf7469

Browse files
committed
Apply feedback -- don't recompile test file, change callback function name.
1 parent 181b63f commit acf7469

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

compiler-rt/lib/asan/asan_mac.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ INTERCEPTOR(void, dispatch_group_async_f, dispatch_group_t group,
245245
asan_dispatch_call_block_and_release);
246246
}
247247

248-
extern "C" void asan_dispatch_apply_f_block(void *context, size_t iteration) {
248+
extern "C" void asan_dispatch_apply_f_work(void *context, size_t iteration) {
249249
GET_STACK_TRACE_THREAD;
250250
asan_block_context_t *asan_ctxt = (asan_block_context_t *)context;
251251
asan_register_worker_thread(asan_ctxt->parent_tid, &stack);
@@ -257,9 +257,8 @@ INTERCEPTOR(void, dispatch_apply_f, size_t iterations, dispatch_queue_t queue,
257257
GET_STACK_TRACE_THREAD;
258258
asan_block_context_t *asan_ctxt =
259259
alloc_asan_context(ctxt, (dispatch_function_t)work, &stack);
260-
261-
REAL(dispatch_apply_f)
262-
(iterations, queue, (void *)asan_ctxt, asan_dispatch_apply_f_block);
260+
REAL(dispatch_apply_f)(iterations, queue, (void *)asan_ctxt,
261+
asan_dispatch_apply_f_work);
263262
}
264263

265264
# if !defined(MISSING_BLOCKS_SUPPORT)
@@ -269,13 +268,13 @@ void dispatch_group_async(dispatch_group_t dg, dispatch_queue_t dq,
269268
void(^work)(void));
270269
void dispatch_after(dispatch_time_t when, dispatch_queue_t queue,
271270
void(^work)(void));
271+
void dispatch_apply(size_t iterations, dispatch_queue_t queue,
272+
void (^block)(size_t iteration));
272273
void dispatch_source_set_cancel_handler(dispatch_source_t ds,
273274
void(^work)(void));
274275
void dispatch_source_set_event_handler(dispatch_source_t ds, void(^work)(void));
275276
dispatch_mach_t dispatch_mach_create(const char *label, dispatch_queue_t queue,
276277
dispatch_mach_handler_t handler);
277-
void dispatch_apply(size_t iterations, dispatch_queue_t queue,
278-
void (^block)(size_t iteration));
279278
}
280279

281280
#define GET_ASAN_BLOCK(work) \

compiler-rt/test/asan/TestCases/Darwin/dispatch_apply_threadno.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
// with an empty stack.
33
// This tests that dispatch_apply blocks can capture valid thread number and stack.
44

5-
// RUN: %clang_asan -DDISPATCH_APPLY_F %s -o %t
6-
// RUN: not %run %t 2>&1 | FileCheck %s
7-
85
// RUN: %clang_asan %s -o %t
9-
// RUN: not %run %t 2>&1 | FileCheck %s
6+
// RUN: not %run %t func 2>&1 | FileCheck %s --check-prefixes=CHECK-FUNC,CHECK
7+
// RUN: not %run %t block 2>&1 | FileCheck %s --check-prefixes=CHECK-BLOCK,CHECK
108

119
#include <dispatch/dispatch.h>
10+
#include <stdio.h>
1211
#include <stdlib.h>
1312

1413
__attribute__((noinline)) void access_memory_frame(char *x) { *x = 0; }
@@ -36,14 +35,20 @@ __attribute__((noinline)) void test_dispatch_apply_f() {
3635
}
3736

3837
int main(int argc, const char *argv[]) {
39-
#if DISPATCH_APPLY_F
40-
test_dispatch_apply_f();
41-
#else
42-
test_dispatch_apply();
43-
#endif
38+
if (strcmp(argv[1], "func") == 0) {
39+
fprintf(stderr, "Test dispatch_apply with function\n");
40+
// CHECK-FUNC: dispatch_apply with function
41+
test_dispatch_apply_f();
42+
} else if (strcmp(argv[1], "block") == 0) {
43+
fprintf(stderr, "Test dispatch_apply with block\n");
44+
// CHECK-BLOCK: dispatch_apply with block
45+
test_dispatch_apply();
46+
} else {
47+
abort();
48+
}
4449
return 0;
4550
}
4651

4752
// CHECK: ERROR: AddressSanitizer: heap-buffer-overflow
4853
// CHECK: #0 0x{{.*}} in {{.*}}access_memory_frame
49-
// CHECK-NOT: T-1
54+
// CHECK-NOT: T-1

0 commit comments

Comments
 (0)