
We have a new policy in place making links to private resources something we try to avoid in source and test files. Normally, we'd organically switch to the new policy rather than make a sweeping change across a project. However, Clang is in a somewhat special circumstance currently: recently, I've had several new contributors run into rdar links around test code which their patch was changing the behavior of. This turns out to be a surprisingly bad experience, especially for newer folks, for a handful of reasons: not understanding what the link is and feeling intimidated by it, wondering whether their changes are actually breaking something important to a downstream in some way, having to hunt down strangers not involved with the patch to impose on them for help, accidental pressure from asking for potentially private IP to be made public, etc. Because folks run into these links entirely by chance (through fixing bugs or working on new features), there's not really a set of problematic links to focus on -- all of the links have basically the same potential for causing these problems. As a result, this is an omnibus patch to remove all such links. This was not a mechanical change; it was done by manually searching for rdar, radar, radr, and other variants to find all the various problematic links. From there, I tried to retain or reword the surrounding comments so that we would lose as little context as possible. However, because most links were just a plain link with no supporting context, the majority of the changes are simple removals. Differential Review: https://reviews.llvm.org/D158071
94 lines
3.5 KiB
C
94 lines
3.5 KiB
C
// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin9 %s -emit-llvm -o - | FileCheck %s -check-prefix=X64
|
|
// RUN: %clang_cc1 -fblocks -triple i686-apple-darwin9 %s -emit-llvm -o - | FileCheck %s -check-prefix=X32
|
|
|
|
// X64: @.str = private unnamed_addr constant [6 x i8] c"v8@?0\00"
|
|
// X64: @__block_literal_global = internal constant {{.*}} { ptr @_NSConcreteGlobalBlock, i32 1342177280,
|
|
// X64: @.str.1 = private unnamed_addr constant [12 x i8] c"i16@?0c8f12\00"
|
|
// X64: store i32 1073741824, ptr
|
|
|
|
// X32: [[STR1:@.*]] = private unnamed_addr constant [6 x i8] c"v4@?0\00"
|
|
// X32: @__block_descriptor_tmp = internal constant [[FULL_DESCRIPTOR_T:.*]] { i32 0, i32 20, ptr [[STR1]], ptr null }
|
|
// X32: @__block_literal_global = internal constant [[GLOBAL_LITERAL_T:.*]] { ptr @_NSConcreteGlobalBlock, i32 1342177280, i32 0, ptr @global_block_invoke{{.*}}, ptr @__block_descriptor_tmp }
|
|
// X32: [[STR2:@.*]] = private unnamed_addr constant [11 x i8] c"i12@?0c4f8\00"
|
|
// X32: @__block_descriptor_tmp{{.*}} = internal constant [[FULL_DESCRIPTOR_T]] { i32 0, i32 24, ptr [[STR2]], ptr null }
|
|
// X32: store i32 1073741824, ptr
|
|
|
|
int globalInt;
|
|
void (^global)(void) = ^{ ++globalInt; };
|
|
|
|
|
|
void foo(int param) {
|
|
extern int rand(void);
|
|
extern void rand_r(int (^b)(char x, float y)); // name a function present at runtime
|
|
while (param--)
|
|
rand_r(^(char x, float y){ return x + (int)y + param + rand(); }); // generate a local block binding param
|
|
}
|
|
|
|
#if 0
|
|
#include <stdio.h>
|
|
enum {
|
|
BLOCK_HAS_COPY_DISPOSE = (1 << 25),
|
|
BLOCK_HAS_CXX_OBJ = (1 << 26),
|
|
BLOCK_IS_GLOBAL = (1 << 28),
|
|
BLOCK_HAS_DESCRIPTOR = (1 << 29),
|
|
BLOCK_HAS_OBJC_TYPE = (1 << 30)
|
|
};
|
|
|
|
struct block_descriptor_big {
|
|
unsigned long int reserved;
|
|
unsigned long int size;
|
|
void (*copy)(void *dst, void *src); // conditional on BLOCK_HAS_COPY_DISPOSE
|
|
void (*dispose)(void *); // conditional on BLOCK_HAS_COPY_DISPOSE
|
|
const char *signature; // conditional on BLOCK_HAS_OBJC
|
|
const char *layout; // conditional on BLOCK_HAS_OBJC
|
|
};
|
|
struct block_descriptor_small {
|
|
unsigned long int reserved;
|
|
unsigned long int size;
|
|
const char *signature; // conditional on BLOCK_HAS_OBJC
|
|
const char *layout; // conditional on BLOCK_HAS_OBJC
|
|
};
|
|
|
|
struct block_layout_abi { // can't change
|
|
void *isa;
|
|
int flags;
|
|
int reserved;
|
|
void (*invoke)(void *, ...);
|
|
struct block_descriptor_big *descriptor;
|
|
};
|
|
|
|
const char *getBlockSignature(void *block) {
|
|
struct block_layout_abi *layout = (struct block_layout_abi *)block;
|
|
if ((layout->flags & BLOCK_HAS_OBJC_TYPE) != BLOCK_HAS_OBJC_TYPE) return NULL;
|
|
if (layout->flags & BLOCK_HAS_COPY_DISPOSE)
|
|
return layout->descriptor->signature;
|
|
else
|
|
return ((struct block_descriptor_small *)layout->descriptor)->signature;
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
printf("desired global flags: %d\n", BLOCK_IS_GLOBAL | BLOCK_HAS_OBJC_TYPE);
|
|
printf("desired stack flags: %d\n", BLOCK_HAS_OBJC_TYPE);
|
|
|
|
printf("types for global: %s\n", getBlockSignature(global));
|
|
printf("types for local: %s\n", getBlockSignature(^int(char x, float y) { return (int)(y + x); }));
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
x86_64
|
|
desired global flags: 1342177280
|
|
desired stack flags: 1073741824
|
|
types for global: v8@?0
|
|
types for local: i16@?0c8f12
|
|
|
|
i386
|
|
desired global flags: 1342177280
|
|
desired stack flags: 1073741824
|
|
types for global: v4@?0
|
|
types for local: i12@?0c4f8
|
|
*/
|
|
#endif
|