Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@@ -0,0 +1,25 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// testfilerunner CONFIG
#include <stdio.h>
int main(int argc, char **argv) {
static int numberOfSquesals = 5;
^{ numberOfSquesals = 6; }();
if (numberOfSquesals == 6) {
printf("%s: success\n", argv[0]);
return 0;
}
printf("**** did not update static local, rdar://6177162\n");
return 1;
}

View File

@@ -0,0 +1,51 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
/*
* blockimport.c
* testObjects
*
* Created by Blaine Garst on 10/13/08.
*
*/
//
// pure C nothing more needed
// CONFIG rdar://6289344
#include <stdio.h>
#include <Block.h>
#include <Block_private.h>
int main(int argc, char *argv[]) {
int i = 1;
int (^intblock)(void) = ^{ return i*10; };
void (^vv)(void) = ^{
if (argc > 0) {
printf("intblock returns %d\n", intblock());
}
};
#if 0
//printf("Block dump %s\n", _Block_dump(vv));
{
struct Block_layout *layout = (struct Block_layout *)(void *)vv;
printf("isa %p\n", layout->isa);
printf("flags %x\n", layout->flags);
printf("descriptor %p\n", layout->descriptor);
printf("descriptor->size %d\n", layout->descriptor->size);
}
#endif
void (^vvcopy)(void) = Block_copy(vv);
Block_release(vvcopy);
printf("%s: success\n", argv[0]);
return 0;
}

View File

@@ -0,0 +1,34 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
// byrefaccess.m
// test that byref access to locals is accurate
// testObjects
//
// Created by Blaine Garst on 5/13/08.
//
// CONFIG
#include <stdio.h>
void callVoidVoid(void (^closure)(void)) {
closure();
}
int main(int argc, char *argv[]) {
__block int i = 10;
callVoidVoid(^{ ++i; });
if (i != 11) {
printf("*** %s didn't update i\n", argv[0]);
return 1;
}
printf("%s: success\n", argv[0]);
return 0;
}

View File

@@ -0,0 +1,41 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
// byrefcopy.m
// testObjects
//
// Created by Blaine Garst on 5/13/08.
//
#include <stdio.h>
#include <Block.h>
#include <Block_private.h>
// CONFIG
void callVoidVoid(void (^closure)(void)) {
closure();
}
int main(int argc, char *argv[]) {
int __block i = 10;
void (^block)(void) = ^{ ++i; };
//printf("original (old style) is %s\n", _Block_dump_old(block));
//printf("original (new style) is %s\n", _Block_dump(block));
void (^blockcopy)(void) = Block_copy(block);
//printf("copy is %s\n", _Block_dump(blockcopy));
// use a copy & see that it updates i
callVoidVoid(block);
if (i != 11) {
printf("*** %s didn't update i\n", argv[0]);
return 1;
}
printf("%s: success\n", argv[0]);
return 0;
}

View File

@@ -0,0 +1,46 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// CONFIG rdar://6255170
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <Block.h>
#include <Block_private.h>
#include <assert.h>
int
main(int argc, char *argv[])
{
__block int var = 0;
int shouldbe = 0;
void (^b)(void) = ^{ var++; /*printf("var is at %p with value %d\n", &var, var);*/ };
__typeof(b) _b;
//printf("before copy...\n");
b(); ++shouldbe;
size_t i;
for (i = 0; i < 10; i++) {
_b = Block_copy(b); // make a new copy each time
assert(_b);
++shouldbe;
_b(); // should still update the stack
Block_release(_b);
}
//printf("after...\n");
b(); ++shouldbe;
if (var != shouldbe) {
printf("Hmm, var is %d but should be %d\n", var, shouldbe);
return 1;
}
printf("%s: Success!!\n", argv[0]);
return 0;
}

View File

@@ -0,0 +1,32 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
#include <Block.h>
#include <stdio.h>
// CONFIG rdar://6225809
// fixed in 5623
int main(int argc, char *argv[]) {
__block int a = 42;
int* ap = &a; // just to keep the address on the stack.
void (^b)(void) = ^{
//a; // workaround, a should be implicitly imported
Block_copy(^{
a = 2;
});
};
Block_copy(b);
if(&a == ap) {
printf("**** __block heap storage should have been created at this point\n");
return 1;
}
printf("%s: Success\n", argv[0]);
return 0;
}

View File

@@ -0,0 +1,69 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
/*
* byrefcopyint.c
* testObjects
*
* Created by Blaine Garst on 12/1/08.
*
*/
//
// byrefcopyid.m
// testObjects
//
// Created by Blaine Garst on 5/13/08.
//
// Tests copying of blocks with byref ints
// CONFIG rdar://6414583 -C99
#include <stdio.h>
#include <string.h>
#include <Block.h>
#include <Block_private.h>
typedef void (^voidVoid)(void);
voidVoid dummy;
void callVoidVoid(voidVoid closure) {
closure();
}
voidVoid testRoutine(const char *whoami) {
__block int dumbo = strlen(whoami);
dummy = ^{
//printf("incring dumbo from %d\n", dumbo);
++dumbo;
};
voidVoid copy = Block_copy(dummy);
return copy;
}
int main(int argc, char *argv[]) {
voidVoid array[100];
for (int i = 0; i < 100; ++i) {
array[i] = testRoutine(argv[0]);
array[i]();
}
for (int i = 0; i < 100; ++i) {
Block_release(array[i]);
}
printf("%s: success\n", argv[0]);
return 0;
}

View File

@@ -0,0 +1,41 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
// byrefcopystack.m
// testObjects
//
// Created by Blaine Garst on 5/13/08.
//
#include <stdio.h>
#include <Block.h>
// CONFIG rdar://6255170
void (^bumpi)(void);
int (^geti)(void);
void setClosures() {
int __block i = 10;
bumpi = Block_copy(^{ ++i; });
geti = Block_copy(^{ return i; });
}
int main(int argc, char *argv[]) {
setClosures();
bumpi();
int i = geti();
if (i != 11) {
printf("*** %s didn't update i\n", argv[0]);
return 1;
}
printf("%s: success\n", argv[0]);
return 0;
}

View File

@@ -0,0 +1,73 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// CONFIG
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <Block.h>
int
main(int argc, char *argv[])
{
__block int var = 0;
void (^b)(void) = ^{ var++; };
//sanity(b);
b();
printf("%s: success!\n", argv[0]);
return 0;
}
#if 1
/* replicated internal data structures: BEWARE, MAY CHANGE!!! */
enum {
BLOCK_REFCOUNT_MASK = (0xffff),
BLOCK_NEEDS_FREE = (1 << 24),
BLOCK_HAS_COPY_DISPOSE = (1 << 25),
BLOCK_NO_COPY = (1 << 26), // interim byref: no copies allowed
BLOCK_IS_GC = (1 << 27),
BLOCK_IS_GLOBAL = (1 << 28),
};
struct byref_id {
struct byref_id *forwarding;
int flags;//refcount;
int size;
void (*byref_keep)(struct byref_id *dst, struct byref_id *src);
void (*byref_destroy)(struct byref_id *);
int var;
};
struct Block_basic2 {
void *isa;
int Block_flags; // int32_t
int Block_size; // XXX should be packed into Block_flags
void (*Block_invoke)(void *);
void (*Block_copy)(void *dst, void *src);
void (*Block_dispose)(void *);
struct byref_id *ref;
};
void sanity(void *arg) {
struct Block_basic2 *bb = (struct Block_basic2 *)arg;
if ( ! (bb->Block_flags & BLOCK_HAS_COPY_DISPOSE)) {
printf("missing copy/dispose helpers for byref data\n");
exit(1);
}
struct byref_id *ref = bb->ref;
if (ref->forwarding != ref) {
printf("forwarding pointer should be %p but is %p\n", ref, ref->forwarding);
exit(1);
}
}
#endif

View File

@@ -0,0 +1,57 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// -*- mode:C; c-basic-offset:4; tab-width:4; intent-tabs-mode:nil; -*-
// CONFIG
#import <stdio.h>
#import <stdlib.h>
#import <string.h>
typedef struct {
unsigned long ps[30];
int qs[30];
} BobTheStruct;
int main (int argc, const char * argv[]) {
__block BobTheStruct fiddly;
BobTheStruct copy;
void (^incrementFiddly)() = ^{
int i;
for(i=0; i<30; i++) {
fiddly.ps[i]++;
fiddly.qs[i]++;
}
};
memset(&fiddly, 0xA5, sizeof(fiddly));
memset(&copy, 0x2A, sizeof(copy));
int i;
for(i=0; i<30; i++) {
fiddly.ps[i] = i * i * i;
fiddly.qs[i] = -i * i * i;
}
copy = fiddly;
incrementFiddly();
if ( &copy == &fiddly ) {
printf("%s: struct wasn't copied.", argv[0]);
exit(1);
}
for(i=0; i<30; i++) {
//printf("[%d]: fiddly.ps: %lu, copy.ps: %lu, fiddly.qs: %d, copy.qs: %d\n", i, fiddly.ps[i], copy.ps[i], fiddly.qs[i], copy.qs[i]);
if ( (fiddly.ps[i] != copy.ps[i] + 1) || (fiddly.qs[i] != copy.qs[i] + 1) ) {
printf("%s: struct contents were not incremented.", argv[0]);
exit(1);
}
}
printf("%s: success\n", argv[0]);
return 0;
}

View File

@@ -0,0 +1,20 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
// c99.m
//
// CONFIG C99 rdar://problem/6399225
#import <stdio.h>
#import <stdlib.h>
int main(int argc, char *argv[]) {
void (^blockA)(void) = ^ { ; };
blockA();
printf("%s: success\n", argv[0]);
exit(0);
}

View File

@@ -0,0 +1,37 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
/*
* cast.c
* testObjects
*
* Created by Blaine Garst on 2/17/09.
*
*/
// PURPOSE should allow casting of a Block reference to an arbitrary pointer and back
// CONFIG open
#include <stdio.h>
int main(int argc, char *argv[]) {
void (^aBlock)(void);
int *ip;
char *cp;
double *dp;
ip = (int *)aBlock;
cp = (char *)aBlock;
dp = (double *)aBlock;
aBlock = (void (^)(void))ip;
aBlock = (void (^)(void))cp;
aBlock = (void (^)(void))dp;
printf("%s: success", argv[0]);
return 0;
}

View File

@@ -0,0 +1,28 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
// constassign.c
// bocktest
//
// Created by Blaine Garst on 3/21/08.
//
// shouldn't be able to assign to a const pointer
// CONFIG error: assignment of read-only
#import <stdio.h>
void foo(void) { printf("I'm in foo\n"); }
void bar(void) { printf("I'm in bar\n"); }
int main(int argc, char *argv[]) {
void (*const fptr)(void) = foo;
void (^const blockA)(void) = ^ { printf("hello\n"); };
blockA = ^ { printf("world\n"); } ;
fptr = bar;
printf("%s: success\n", argv[0]);
return 0;
}

View File

@@ -0,0 +1,29 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// CONFIG open rdar://6439600
#import <stdio.h>
#import <stdlib.h>
#define NUMBER_OF_BLOCKS 100
int main (int argc, const char * argv[]) {
int (^x[NUMBER_OF_BLOCKS])();
int i;
for(i=0; i<NUMBER_OF_BLOCKS; i++) x[i] = ^{ return i; };
for(i=0; i<NUMBER_OF_BLOCKS; i++) {
if (x[i]() != i) {
printf("%s: failure, %d != %d\n", argv[0], x[i](), i);
exit(1);
}
}
printf("%s: success\n", argv[0]);
return 0;
}

View File

@@ -0,0 +1,85 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
#include <stdio.h>
#include <Block.h>
// CONFIG C++ rdar://6243400,rdar://6289367
int constructors = 0;
int destructors = 0;
#define CONST const
class TestObject
{
public:
TestObject(CONST TestObject& inObj);
TestObject();
~TestObject();
TestObject& operator=(CONST TestObject& inObj);
int version() CONST { return _version; }
private:
mutable int _version;
};
TestObject::TestObject(CONST TestObject& inObj)
{
++constructors;
_version = inObj._version;
//printf("%p (%d) -- TestObject(const TestObject&) called\n", this, _version);
}
TestObject::TestObject()
{
_version = ++constructors;
//printf("%p (%d) -- TestObject() called\n", this, _version);
}
TestObject::~TestObject()
{
//printf("%p -- ~TestObject() called\n", this);
++destructors;
}
TestObject& TestObject::operator=(CONST TestObject& inObj)
{
//printf("%p -- operator= called\n", this);
_version = inObj._version;
return *this;
}
void testRoutine() {
TestObject one;
void (^b)(void) = ^{ printf("my const copy of one is %d\n", one.version()); };
}
int main(int argc, char *argv[]) {
testRoutine();
if (constructors == 0) {
printf("No copy constructors!!!\n");
return 1;
}
if (constructors != destructors) {
printf("%d constructors but only %d destructors\n", constructors, destructors);
return 1;
}
printf("%s:success\n", argv[0]);
return 0;
}

View File

@@ -0,0 +1,37 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
/*
* copynull.c
* testObjects
*
* Created by Blaine Garst on 10/15/08.
*
*/
#import <stdio.h>
#import <Block.h>
#import <Block_private.h>
// CONFIG rdar://6295848
int main(int argc, char *argv[]) {
void (^block)(void) = (void (^)(void))0;
void (^blockcopy)(void) = Block_copy(block);
if (blockcopy != (void (^)(void))0) {
printf("whoops, somehow we copied NULL!\n");
return 1;
}
// make sure we can also
Block_release(blockcopy);
// and more secretly
//_Block_destroy(blockcopy);
printf("%s: success\n", argv[0]);
return 0;
}

View File

@@ -0,0 +1,57 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
#include <CoreFoundation/CoreFoundation.h>
#include <dispatch/dispatch.h>
#include <unistd.h>
//#import <Foundation/Foundation.h>
#include <Block.h>
// CONFIG rdar://problem/6371811
const char *whoami = "nobody";
void EnqueueStuff(dispatch_queue_t q)
{
__block CFIndex counter;
// above call has a side effect: it works around:
// <rdar://problem/6225809> __block variables not implicitly imported into intermediate scopes
dispatch_async(q, ^{
counter = 0;
});
dispatch_async(q, ^{
//printf("outer block.\n");
counter++;
dispatch_async(q, ^{
//printf("inner block.\n");
counter--;
if(counter == 0) {
printf("%s: success\n", whoami);
exit(0);
}
});
if(counter == 0) {
printf("already done? inconceivable!\n");
exit(1);
}
});
}
int main (int argc, const char * argv[]) {
dispatch_queue_t q = dispatch_queue_create("queue", NULL);
whoami = argv[0];
EnqueueStuff(q);
dispatch_main();
printf("shouldn't get here\n");
return 1;
}

View File

@@ -0,0 +1,31 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
#include <stdio.h>
#include <Block.h>
// CONFIG
void callsomething(const char *format, int argument) {
}
void
dispatch_call_Block_with_release2(void *block)
{
void (^b)(void) = (void (^)(void))block;
b();
Block_release(b);
}
int main(int argc, char *argv[]) {
void (^b1)(void) = ^{ callsomething("argc is %d\n", argc); };
void (^b2)(void) = ^{ callsomething("hellow world\n", 0); }; // global block now
dispatch_call_Block_with_release2(Block_copy(b1));
dispatch_call_Block_with_release2(Block_copy(b2));
printf("%s: Success\n", argv[0]);
return 0;
}

View File

@@ -0,0 +1,107 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
/*
* fail.c
* testObjects
*
* Created by Blaine Garst on 9/16/08.
*
*/
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
bool readfile(char *buffer, const char *from) {
int fd = open(from, 0);
if (fd < 0) return false;
int count = read(fd, buffer, 512);
if (count < 0) return false;
buffer[count] = 0; // zap newline
return true;
}
// basic idea, take compiler args, run compiler, and verify that expected failure matches any existing one
int main(int argc, char *argv[]) {
if (argc == 1) return 0;
char *copy[argc+1]; // make a copy
// find and strip off -e "errorfile"
char *errorfile = NULL;
int counter = 0, i = 0;
for (i = 1; i < argc; ++i) { // skip 0 arg which is "fail"
if (!strncmp(argv[i], "-e", 2)) {
errorfile = argv[++i];
}
else {
copy[counter++] = argv[i];
}
}
copy[counter] = NULL;
pid_t child = fork();
char buffer[512];
if (child == 0) {
// in child
sprintf(buffer, "/tmp/errorfile_%d", getpid());
close(1);
int fd = creat(buffer, 0777);
if (fd != 1) {
fprintf(stderr, "didn't open custom error file %s as 1, got %d\n", buffer, fd);
exit(1);
}
close(2);
dup(1);
int result = execv(copy[0], copy);
exit(10);
}
if (child < 0) {
printf("fork failed\n");
exit(1);
}
int status = 0;
pid_t deadchild = wait(&status);
if (deadchild != child) {
printf("wait got %d instead of %d\n", deadchild, child);
exit(1);
}
if (WEXITSTATUS(status) == 0) {
printf("compiler exited normally, not good under these circumstances\n");
exit(1);
}
//printf("exit status of child %d was %d\n", child, WEXITSTATUS(status));
sprintf(buffer, "/tmp/errorfile_%d", child);
if (errorfile) {
//printf("ignoring error file: %s\n", errorfile);
char desired[512];
char got[512];
bool gotErrorFile = readfile(desired, errorfile);
bool gotOutput = readfile(got, buffer);
if (!gotErrorFile && gotOutput) {
printf("didn't read errorfile %s, it should have something from\n*****\n%s\n*****\nin it.\n",
errorfile, got);
exit(1);
}
else if (gotErrorFile && gotOutput) {
char *where = strstr(got, desired);
if (!where) {
printf("didn't find contents of %s in %s\n", errorfile, buffer);
exit(1);
}
}
else {
printf("errorfile %s and output %s inconsistent\n", errorfile, buffer);
exit(1);
}
}
unlink(buffer);
printf("success\n");
exit(0);
}

View File

@@ -0,0 +1,21 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
#include <stdio.h>
/* CONFIG rdar://6310599
*/
int main(int argc, char *argv[])
{
__block int flags;
__block void *isa;
^{ flags=1; isa = (void *)isa; };
printf("%s: success\n", argv[0]);
return 0;
}

Some files were not shown because too many files have changed in this diff Show More