diff options
Diffstat (limited to 'test')
447 files changed, 10898 insertions, 1121 deletions
diff --git a/test/Analysis/additive-folding.c b/test/Analysis/additive-folding.c index 15d7588..e4a5651 100644 --- a/test/Analysis/additive-folding.c +++ b/test/Analysis/additive-folding.c @@ -18,7 +18,7 @@ void separateExpressions (int a) { char* buf = malloc(1); if (a != 0 && b == 0) - return; // no-warning + return; // expected-warning{{never executed}} free(buf); } @@ -29,7 +29,7 @@ void oneLongExpression (int a) { char* buf = malloc(1); if (a != 0 && b == 0) - return; // no-warning + return; // expected-warning{{never executed}} free(buf); } @@ -40,11 +40,11 @@ void mixedTypes (int a) { // This is part of PR7406. int b = a + 1LL; if (a != 0 && (b-1) == 0) // not crash - return; // no warning + return; // expected-warning{{never executed}} int c = a + 1U; if (a != 0 && (c-1) == 0) // not crash - return; // no warning + return; // expected-warning{{never executed}} free(buf); } @@ -85,7 +85,7 @@ void mixed_eq_ne (int a) { if (a+1U != 2) return; // no-warning if (a-1U != 0) - return; // no-warning + return; // expected-warning{{never executed}} free(b); } @@ -96,7 +96,7 @@ void mixed_ne_eq (int a) { if (a+1U == 2) return; // no-warning if (a-1U == 0) - return; // no-warning + return; // expected-warning{{never executed}} free(b); } @@ -191,7 +191,7 @@ void tautologyGE (unsigned a) { void tautologyLT (unsigned a) { char* b = malloc(1); if (a < 0) - return; // no-warning + return; // expected-warning{{never executed}} free(b); } diff --git a/test/Analysis/array-struct-region.c b/test/Analysis/array-struct-region.c new file mode 100644 index 0000000..dabd25b --- /dev/null +++ b/test/Analysis/array-struct-region.c @@ -0,0 +1,47 @@ +// RUN: %clang_cc1 -analyze -analyzer-experimental-checks -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-checks -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s + +int string_literal_init() { + char a[] = "abc"; + char b[2] = "abc"; // expected-warning{{too long}} + char c[5] = "abc"; + + if (a[1] != 'b') + return 0; // expected-warning{{never executed}} + if (b[1] != 'b') + return 0; // expected-warning{{never executed}} + if (c[1] != 'b') + return 0; // expected-warning{{never executed}} + + if (a[3] != 0) + return 0; // expected-warning{{never executed}} + if (c[3] != 0) + return 0; // expected-warning{{never executed}} + + if (c[4] != 0) + return 0; // expected-warning{{never executed}} + + return 42; +} + +void nested_compound_literals(int rad) { + int vec[6][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, + {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}}; + int a; + + for (a = 0; a < 6; ++a) { + vec[a][0] *= rad; // no-warning + vec[a][1] *= rad; // no-warning + } +} + +void nested_compound_literals_float(float rad) { + float vec[6][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, + {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}}; + int a; + + for (a = 0; a < 6; ++a) { + vec[a][0] *= rad; // no-warning + vec[a][1] *= rad; // no-warning + } +} diff --git a/test/Analysis/bstring.c b/test/Analysis/bstring.c index f4ddb0a..ffe420f 100644 --- a/test/Analysis/bstring.c +++ b/test/Analysis/bstring.c @@ -48,27 +48,30 @@ void *memcpy(void *restrict s1, const void *restrict s2, size_t n); void memcpy0 () { char src[] = {1, 2, 3, 4}; - char dst[4]; + char dst[4] = {0}; memcpy(dst, src, 4); // no-warning if (memcpy(dst, src, 4) != dst) { - (void)*(char*)0; // no-warning -- should be unreachable + (void)*(char*)0; // no-warning } + + if (dst[0] != 0) + (void)*(char*)0; // expected-warning{{null}} } void memcpy1 () { char src[] = {1, 2, 3, 4}; char dst[10]; - memcpy(dst, src, 5); // expected-warning{{out-of-bound}} + memcpy(dst, src, 5); // expected-warning{{Byte string function accesses out-of-bound array element}} } void memcpy2 () { char src[] = {1, 2, 3, 4}; char dst[1]; - memcpy(dst, src, 4); // expected-warning{{out-of-bound}} + memcpy(dst, src, 4); // expected-warning{{Byte string function overflows destination buffer}} } void memcpy3 () { @@ -82,14 +85,14 @@ void memcpy4 () { char src[] = {1, 2, 3, 4}; char dst[10]; - memcpy(dst+2, src+2, 3); // expected-warning{{out-of-bound}} + memcpy(dst+2, src+2, 3); // expected-warning{{Byte string function accesses out-of-bound array element}} } void memcpy5() { char src[] = {1, 2, 3, 4}; char dst[3]; - memcpy(dst+2, src+2, 2); // expected-warning{{out-of-bound}} + memcpy(dst+2, src+2, 2); // expected-warning{{Byte string function overflows destination buffer}} } void memcpy6() { @@ -150,13 +153,16 @@ void *memmove(void *s1, const void *s2, size_t n); void memmove0 () { char src[] = {1, 2, 3, 4}; - char dst[4]; + char dst[4] = {0}; memmove(dst, src, 4); // no-warning if (memmove(dst, src, 4) != dst) { - (void)*(char*)0; // no-warning -- should be unreachable + (void)*(char*)0; // no-warning } + + if (dst[0] != 0) + (void)*(char*)0; // expected-warning{{null}} } void memmove1 () { @@ -170,7 +176,7 @@ void memmove2 () { char src[] = {1, 2, 3, 4}; char dst[1]; - memmove(dst, src, 4); // expected-warning{{out-of-bound}} + memmove(dst, src, 4); // expected-warning{{overflow}} } //===----------------------------------------------------------------------=== @@ -246,6 +252,12 @@ void memcmp6 (char *a, char *b, size_t n) { (void)*(char*)0; // expected-warning{{null}} } +int memcmp7 (char *a, size_t x, size_t y, size_t n) { + // We used to crash when either of the arguments was unknown. + return memcmp(a, &a[x*y], n) + + memcmp(&a[x*y], a, n); +} + //===----------------------------------------------------------------------=== // bcopy() //===----------------------------------------------------------------------=== @@ -257,9 +269,12 @@ void bcopy(/*const*/ void *s1, void *s2, size_t n); void bcopy0 () { char src[] = {1, 2, 3, 4}; - char dst[4]; + char dst[4] = {0}; bcopy(src, dst, 4); // no-warning + + if (dst[0] != 0) + (void)*(char*)0; // expected-warning{{null}} } void bcopy1 () { @@ -273,5 +288,5 @@ void bcopy2 () { char src[] = {1, 2, 3, 4}; char dst[1]; - bcopy(src, dst, 4); // expected-warning{{out-of-bound}} + bcopy(src, dst, 4); // expected-warning{{overflow}} } diff --git a/test/Analysis/constant-folding.c b/test/Analysis/constant-folding.c index 6ed2b39..9191a9e 100644 --- a/test/Analysis/constant-folding.c +++ b/test/Analysis/constant-folding.c @@ -9,51 +9,51 @@ void testComparisons (int a) { // Sema can already catch the simple comparison a==a, // since that's usually a logic error (and not path-dependent). int b = a; - if (!(b==a)) WARN; - if (!(b>=a)) WARN; - if (!(b<=a)) WARN; - if (b!=a) WARN; - if (b>a) WARN; - if (b<a) WARN; + if (!(b==a)) WARN; // expected-warning{{never executed}} + if (!(b>=a)) WARN; // expected-warning{{never executed}} + if (!(b<=a)) WARN; // expected-warning{{never executed}} + if (b!=a) WARN; // expected-warning{{never executed}} + if (b>a) WARN; // expected-warning{{never executed}} + if (b<a) WARN; // expected-warning{{never executed}} } void testSelfOperations (int a) { - if ((a|a) != a) WARN; - if ((a&a) != a) WARN; - if ((a^a) != 0) WARN; - if ((a-a) != 0) WARN; + if ((a|a) != a) WARN; // expected-warning{{never executed}} + if ((a&a) != a) WARN; // expected-warning{{never executed}} + if ((a^a) != 0) WARN; // expected-warning{{never executed}} + if ((a-a) != 0) WARN; // expected-warning{{never executed}} } void testIdempotent (int a) { - if ((a*1) != a) WARN; - if ((a/1) != a) WARN; - if ((a+0) != a) WARN; - if ((a-0) != a) WARN; - if ((a<<0) != a) WARN; - if ((a>>0) != a) WARN; - if ((a^0) != a) WARN; - if ((a&(~0)) != a) WARN; - if ((a|0) != a) WARN; + if ((a*1) != a) WARN; // expected-warning{{never executed}} + if ((a/1) != a) WARN; // expected-warning{{never executed}} + if ((a+0) != a) WARN; // expected-warning{{never executed}} + if ((a-0) != a) WARN; // expected-warning{{never executed}} + if ((a<<0) != a) WARN; // expected-warning{{never executed}} + if ((a>>0) != a) WARN; // expected-warning{{never executed}} + if ((a^0) != a) WARN; // expected-warning{{never executed}} + if ((a&(~0)) != a) WARN; // expected-warning{{never executed}} + if ((a|0) != a) WARN; // expected-warning{{never executed}} } void testReductionToConstant (int a) { - if ((a*0) != 0) WARN; - if ((a&0) != 0) WARN; - if ((a|(~0)) != (~0)) WARN; + if ((a*0) != 0) WARN; // expected-warning{{never executed}} + if ((a&0) != 0) WARN; // expected-warning{{never executed}} + if ((a|(~0)) != (~0)) WARN; // expected-warning{{never executed}} } void testSymmetricIntSymOperations (int a) { - if ((2+a) != (a+2)) WARN; - if ((2*a) != (a*2)) WARN; - if ((2&a) != (a&2)) WARN; - if ((2^a) != (a^2)) WARN; - if ((2|a) != (a|2)) WARN; + if ((2+a) != (a+2)) WARN; // expected-warning{{never executed}} + if ((2*a) != (a*2)) WARN; // expected-warning{{never executed}} + if ((2&a) != (a&2)) WARN; // expected-warning{{never executed}} + if ((2^a) != (a^2)) WARN; // expected-warning{{never executed}} + if ((2|a) != (a|2)) WARN; // expected-warning{{never executed}} } void testAsymmetricIntSymOperations (int a) { - if (((~0) >> a) != (~0)) WARN; - if ((0 >> a) != 0) WARN; - if ((0 << a) != 0) WARN; + if (((~0) >> a) != (~0)) WARN; // expected-warning{{never executed}} + if ((0 >> a) != 0) WARN; // expected-warning{{never executed}} + if ((0 << a) != 0) WARN; // expected-warning{{never executed}} // Unsigned right shift shifts in zeroes. if ((((unsigned)(~0)) >> ((unsigned) a)) != ((unsigned)(~0))) @@ -62,11 +62,11 @@ void testAsymmetricIntSymOperations (int a) { void testLocations (char *a) { char *b = a; - if (!(b==a)) WARN; - if (!(b>=a)) WARN; - if (!(b<=a)) WARN; - if (b!=a) WARN; - if (b>a) WARN; - if (b<a) WARN; - if (b-a) WARN; + if (!(b==a)) WARN; // expected-warning{{never executed}} + if (!(b>=a)) WARN; // expected-warning{{never executed}} + if (!(b<=a)) WARN; // expected-warning{{never executed}} + if (b!=a) WARN; // expected-warning{{never executed}} + if (b>a) WARN; // expected-warning{{never executed}} + if (b<a) WARN; // expected-warning{{never executed}} + if (b-a) WARN; // expected-warning{{never executed}} } diff --git a/test/Analysis/dead-stores.c b/test/Analysis/dead-stores.c index defd7e0..57d5d11 100644 --- a/test/Analysis/dead-stores.c +++ b/test/Analysis/dead-stores.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-experimental-internal-checks -analyzer-check-dead-stores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s +// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-check-dead-stores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s // RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -analyzer-check-dead-stores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s // RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -analyzer-check-dead-stores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s // RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -analyzer-check-dead-stores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s @@ -150,7 +150,7 @@ void f15(unsigned x, unsigned y) { int f16(int x) { x = x * 2; - x = sizeof(int [x = (x || x + 1) * 2]) // expected-warning{{Although the value stored to 'x' is used}} + x = sizeof(int [x = (x || x + 1) * 2]) // expected-warning{{Although the value stored to 'x' is used}} expected-warning{{The left operand to '*' is always 1}} ? 5 : 8; return x; } @@ -158,7 +158,7 @@ int f16(int x) { // Self-assignments should not be flagged as dead stores. void f17() { int x = 1; - x = x; // no-warning + x = x; } // <rdar://problem/6506065> @@ -458,7 +458,31 @@ void rdar8014335() { // Note that the next value stored to 'i' is never executed // because the next statement to be executed is the 'break' // in the increment code of the first loop. - i = i * 3; // expected-warning{{Value stored to 'i' is never read}} + i = i * 3; // expected-warning{{Value stored to 'i' is never read}} expected-warning{{The left operand to '*' is always 1}} } } +// <rdar://problem/8320674> NullStmts followed by do...while() can lead to disconnected CFG +// +// This previously caused bogus dead-stores warnings because the body of the first do...while was +// disconnected from the entry of the function. +typedef struct { float r; float i; } s_rdar8320674; +typedef struct { s_rdar8320674 x[1]; } s2_rdar8320674; + +void rdar8320674(s_rdar8320674 *z, unsigned y, s2_rdar8320674 *st, int m) +{ + s_rdar8320674 * z2; + s_rdar8320674 * tw1 = st->x; + s_rdar8320674 t; + z2 = z + m; + do{ + ; ; + do{ (t).r = (*z2).r*(*tw1).r - (*z2).i*(*tw1).i; (t).i = (*z2).r*(*tw1).i + (*z2).i*(*tw1).r; }while(0); + tw1 += y; + do { (*z2).r=(*z).r-(t).r; (*z2).i=(*z).i-(t).i; }while(0); + do { (*z).r += (t).r; (*z).i += (t).i; }while(0); + ++z2; + ++z; + }while (--m); +} + diff --git a/test/Analysis/flat-store.c b/test/Analysis/flat-store.c new file mode 100644 index 0000000..bb274b0 --- /dev/null +++ b/test/Analysis/flat-store.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=flat -verify %s +#define FAIL ((void)*(char*)0) +struct simple { int x; }; + +void PR7297 () { + struct simple a; + struct simple *p = &a; + p->x = 5; + if (!p[0].x) FAIL; // no-warning + if (p[0].x) FAIL; // expected-warning {{null}} +} diff --git a/test/Analysis/idempotent-operations.c b/test/Analysis/idempotent-operations.c index 9cef08e..5c9a59d 100644 --- a/test/Analysis/idempotent-operations.c +++ b/test/Analysis/idempotent-operations.c @@ -1,52 +1,189 @@ -// RUN: %clang_cc1 -analyze -analyzer-idempotent-operation -analyzer-store=region -analyzer-constraints=range -fblocks -verify -analyzer-opt-analyze-nested-blocks -analyzer-check-objc-mem -verify %s +// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-check-objc-mem -analyzer-check-idempotent-operations -verify %s // Basic tests extern void test(int i); +extern void test_f(float f); -void basic() { +unsigned basic() { int x = 10, zero = 0, one = 1; // x op x - x = x; // expected-warning {{idempotent operation; both operands are always equal in value}} - test(x - x); // expected-warning {{idempotent operation; both operands are always equal in value}} - x -= x; // expected-warning {{idempotent operation; both operands are always equal in value}} + x = x; // expected-warning {{Assigned value is always the same as the existing value}} + test(x - x); // expected-warning {{Both operands to '-' always have the same value}} + x -= x; // expected-warning {{Both operands to '-=' always have the same value}} x = 10; // no-warning - test(x / x); // expected-warning {{idempotent operation; both operands are always equal in value}} - x /= x; // expected-warning {{idempotent operation; both operands are always equal in value}} + test(x / x); // expected-warning {{Both operands to '/' always have the same value}} + x /= x; // expected-warning {{Both operands to '/=' always have the same value}} x = 10; // no-warning - test(x & x); // expected-warning {{idempotent operation; both operands are always equal in value}} - x &= x; // expected-warning {{idempotent operation; both operands are always equal in value}} - test(x | x); // expected-warning {{idempotent operation; both operands are always equal in value}} - x |= x; // expected-warning {{idempotent operation; both operands are always equal in value}} + test(x & x); // expected-warning {{Both operands to '&' always have the same value}} + x &= x; // expected-warning {{Both operands to '&=' always have the same value}} + test(x | x); // expected-warning {{Both operands to '|' always have the same value}} + x |= x; // expected-warning {{Both operands to '|=' always have the same value}} // x op 1 - test(x * one); // expected-warning {{idempotent operation; the right operand is always 1}} - x *= one; // expected-warning {{idempotent operation; the right operand is always 1}} - test(x / one); // expected-warning {{idempotent operation; the right operand is always 1}} - x /= one; // expected-warning {{idempotent operation; the right operand is always 1}} + test(x * one); // expected-warning {{The right operand to '*' is always 1}} + x *= one; // expected-warning {{The right operand to '*=' is always 1}} + test(x / one); // expected-warning {{The right operand to '/' is always 1}} + x /= one; // expected-warning {{The right operand to '/=' is always 1}} // 1 op x - test(one * x); // expected-warning {{idempotent operation; the left operand is always 1}} + test(one * x); // expected-warning {{The left operand to '*' is always 1}} // x op 0 - test(x + zero); // expected-warning {{idempotent operation; the right operand is always 0}} - test(x - zero); // expected-warning {{idempotent operation; the right operand is always 0}} - test(x * zero); // expected-warning {{idempotent operation; the right operand is always 0}} - test(x & zero); // expected-warning {{idempotent operation; the right operand is always 0}} - test(x | zero); // expected-warning {{idempotent operation; the right operand is always 0}} - test(x ^ zero); // expected-warning {{idempotent operation; the right operand is always 0}} - test(x << zero); // expected-warning {{idempotent operation; the right operand is always 0}} - test(x >> zero); // expected-warning {{idempotent operation; the right operand is always 0}} + test(x + zero); // expected-warning {{The right operand to '+' is always 0}} + test(x - zero); // expected-warning {{The right operand to '-' is always 0}} + test(x * zero); // expected-warning {{The right operand to '*' is always 0}} + test(x & zero); // expected-warning {{The right operand to '&' is always 0}} + test(x | zero); // expected-warning {{The right operand to '|' is always 0}} + test(x ^ zero); // expected-warning {{The right operand to '^' is always 0}} + test(x << zero); // expected-warning {{The right operand to '<<' is always 0}} + test(x >> zero); // expected-warning {{The right operand to '>>' is always 0}} // 0 op x - test(zero + x); // expected-warning {{idempotent operation; the left operand is always 0}} - test(zero - x); // expected-warning {{idempotent operation; the left operand is always 0}} - test(zero / x); // expected-warning {{idempotent operation; the left operand is always 0}} - test(zero * x); // expected-warning {{idempotent operation; the left operand is always 0}} - test(zero & x); // expected-warning {{idempotent operation; the left operand is always 0}} - test(zero | x); // expected-warning {{idempotent operation; the left operand is always 0}} - test(zero ^ x); // expected-warning {{idempotent operation; the left operand is always 0}} - test(zero << x); // expected-warning {{idempotent operation; the left operand is always 0}} - test(zero >> x); // expected-warning {{idempotent operation; the left operand is always 0}} + test(zero + x); // expected-warning {{The left operand to '+' is always 0}} + test(zero - x); // expected-warning {{The left operand to '-' is always 0}} + test(zero / x); // expected-warning {{The left operand to '/' is always 0}} + test(zero * x); // expected-warning {{The left operand to '*' is always 0}} + test(zero & x); // expected-warning {{The left operand to '&' is always 0}} + test(zero | x); // expected-warning {{The left operand to '|' is always 0}} + test(zero ^ x); // expected-warning {{The left operand to '^' is always 0}} + test(zero << x); // expected-warning {{The left operand to '<<' is always 0}} + test(zero >> x); // expected-warning {{The left operand to '>>' is always 0}} + + // Overwrite the values so these aren't marked as Pseudoconstants + x = 1; + zero = 2; + one = 3; + + return x + zero + one; +} + +void floats(float x) { + test_f(x * 1.0); // no-warning + test_f(x * 1.0F); // no-warning +} + +// Ensure that we don't report false poitives in complex loops +void bailout() { + int unused = 0, result = 4; + result = result; // expected-warning {{Assigned value is always the same as the existing value}} + + for (unsigned bg = 0; bg < 1024; bg ++) { + result = bg * result; // no-warning + + for (int i = 0; i < 256; i++) { + unused *= i; // no-warning + } + } +} + +// Relaxed liveness - check that we don't kill liveness at assignments +typedef unsigned uintptr_t; +void kill_at_assign() { + short array[2]; + uintptr_t x = array; // expected-warning{{incompatible pointer to integer conversion}} + short *p = x; // expected-warning{{incompatible integer to pointer conversion}} + + // The following branch should be infeasible. + if (!(p = &array[0])) { // expected-warning{{Assigned value is always the same as the existing value}} + p = 0; + *p = 1; // no-warning + } +} + +// False positive tests + +unsigned false1() { + int a = 10; + return a * (5 - 2 - 3); // no-warning +} + +enum testenum { enum1 = 0, enum2 }; +unsigned false2() { + int a = 1234; + return enum1 + a; // no-warning +} + +// Self assignments of unused variables are common false positives +unsigned false3(int param, int param2) { + param = param; // no-warning + + // if a self assigned variable is used later, then it should be reported still + param2 = param2; // expected-warning{{Assigned value is always the same as the existing value}} + + unsigned nonparam = 5; + + nonparam = nonparam; // expected-warning{{Assigned value is always the same as the existing value}} + + return param2 + nonparam; +} + +// Pseudo-constants (vars only read) and constants should not be reported +unsigned false4() { + // Trivial constant + const int height = 1; + int c = 42; + test(height * c); // no-warning + + // Pseudo-constant (never changes after decl) + int width = height; + + return width * 10; // no-warning +} + +// Block pseudoconstants +void false4a() { + // Pseudo-constant + __block int a = 1; + int b = 10; + __block int c = 0; + b *= a; // no-warning + + ^{ + // Psuedoconstant block var + test(b * c); // no-warning + + // Non-pseudoconstant block var + int d = 0; + test(b * d); // expected-warning{{The right operand to '*' is always 0}} + d = 5; + test(d); + }(); + + test(a + b); +} + +// Static vars are common false positives +int false5() { + static int test = 0; + int a = 56; + a *= test; // no-warning + test++; + return a; +} + +// Non-local storage vars are considered false positives +int globalInt = 1; +int false6() { + int localInt = 23; + + localInt /= globalInt; + + return localInt; +} + +// Check that assignments filter out false positives correctly +int false7() { + int zero = 0; // psuedo-constant + int one = 1; + + int a = 55; + a = a; // expected-warning{{Assigned value is always the same as the existing value}} + a = enum1 * a; // no-warning + + int b = 123; + b = b; // no-warning + + return a; } diff --git a/test/Analysis/idempotent-operations.cpp b/test/Analysis/idempotent-operations.cpp new file mode 100644 index 0000000..c5d1ceb --- /dev/null +++ b/test/Analysis/idempotent-operations.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-check-objc-mem -analyzer-check-idempotent-operations -verify %s + +// C++ specific false positives + +extern void test(int i); +extern void test_ref(int &i); + +// Test references affecting pseudoconstants +void false1() { + int a = 0; + int five = 5; + int &b = a; + test(five * a); // expected-warning {{The right operand to '*' is always 0}} + b = 4; +} diff --git a/test/Analysis/malloc.c b/test/Analysis/malloc.c index b4c1314..e443150 100644 --- a/test/Analysis/malloc.c +++ b/test/Analysis/malloc.c @@ -4,22 +4,136 @@ void *malloc(size_t); void free(void *); void *realloc(void *ptr, size_t size); void *calloc(size_t nmemb, size_t size); +void __attribute((ownership_returns(malloc))) *my_malloc(size_t); +void __attribute((ownership_takes(malloc, 1))) my_free(void *); +void __attribute((ownership_returns(malloc, 1))) *my_malloc2(size_t); +void __attribute((ownership_holds(malloc, 1))) my_hold(void *); + +// Duplicate attributes are silly, but not an error. +// Duplicate attribute has no extra effect. +// If two are of different kinds, that is an error and reported as such. +void __attribute((ownership_holds(malloc, 1))) +__attribute((ownership_holds(malloc, 1))) +__attribute((ownership_holds(malloc, 3))) my_hold2(void *, void *, void *); +void *my_malloc3(size_t); +void *myglobalpointer; +struct stuff { + void *somefield; +}; +struct stuff myglobalstuff; void f1() { int *p = malloc(12); return; // expected-warning{{Allocated memory never released. Potential memory leak.}} } -void f1_b() { - int *p = malloc(12); // expected-warning{{Allocated memory never released. Potential memory leak.}} -} - void f2() { int *p = malloc(12); free(p); free(p); // expected-warning{{Try to free a memory block that has been released}} } +// ownership attributes tests +void naf1() { + int *p = my_malloc3(12); + return; // no-warning +} + +void n2af1() { + int *p = my_malloc2(12); + return; // expected-warning{{Allocated memory never released. Potential memory leak.}} +} + +void af1() { + int *p = my_malloc(12); + return; // expected-warning{{Allocated memory never released. Potential memory leak.}} +} + +void af1_b() { + int *p = my_malloc(12); // expected-warning{{Allocated memory never released. Potential memory leak.}} +} + +void af1_c() { + myglobalpointer = my_malloc(12); // no-warning +} + +void af1_d() { + struct stuff mystuff; + mystuff.somefield = my_malloc(12); // expected-warning{{Allocated memory never released. Potential memory leak.}} +} + +// Test that we can pass out allocated memory via pointer-to-pointer. +void af1_e(void **pp) { + *pp = my_malloc(42); // no-warning +} + +void af1_f(struct stuff *somestuff) { + somestuff->somefield = my_malloc(12); // no-warning +} + +// Allocating memory for a field via multiple indirections to our arguments is OK. +void af1_g(struct stuff **pps) { + *pps = my_malloc(sizeof(struct stuff)); // no-warning + (*pps)->somefield = my_malloc(42); // no-warning +} + +void af2() { + int *p = my_malloc(12); + my_free(p); + free(p); // expected-warning{{Try to free a memory block that has been released}} +} + +void af2b() { + int *p = my_malloc(12); + free(p); + my_free(p); // expected-warning{{Try to free a memory block that has been released}} +} + +void af2c() { + int *p = my_malloc(12); + free(p); + my_hold(p); // expected-warning{{Try to free a memory block that has been released}} +} + +void af2d() { + int *p = my_malloc(12); + free(p); + my_hold2(0, 0, p); // expected-warning{{Try to free a memory block that has been released}} +} + +// No leak if malloc returns null. +void af2e() { + int *p = my_malloc(12); + if (!p) + return; // no-warning + free(p); // no-warning +} + +// This case would inflict a double-free elsewhere. +// However, this case is considered an analyzer bug since it causes false-positives. +void af3() { + int *p = my_malloc(12); + my_hold(p); + free(p); // no-warning +} + +// This case would inflict a double-free elsewhere. +// However, this case is considered an analyzer bug since it causes false-positives. +int * af4() { + int *p = my_malloc(12); + my_free(p); + return p; // no-warning +} + +// This case is (possibly) ok, be conservative +int * af5() { + int *p = my_malloc(12); + my_hold(p); + return p; // no-warning +} + + + // This case tests that storing malloc'ed memory to a static variable which is // then returned is not leaked. In the absence of known contracts for functions // or inter-procedural analysis, this is a conservative answer. @@ -117,7 +231,7 @@ char callocZeroesBad () { char *buf = calloc(2,2); char result = buf[3]; // no-warning if (buf[1] != 0) { - free(buf); + free(buf); // expected-warning{{never executed}} } return result; // expected-warning{{never released}} } diff --git a/test/Analysis/misc-ps-region-store.cpp b/test/Analysis/misc-ps-region-store.cpp index 6794d48..bfa5e5c 100644 --- a/test/Analysis/misc-ps-region-store.cpp +++ b/test/Analysis/misc-ps-region-store.cpp @@ -132,3 +132,30 @@ int TestHandleThis::null_deref_positive() { return 0; } +// PR 7675 - passing literals by-reference +void pr7675(const double &a); +void pr7675(const int &a); +void pr7675(const char &a); +void pr7675_i(const _Complex double &a); + +void pr7675_test() { + pr7675(10.0); + pr7675(10); + pr7675('c'); + pr7675_i(4.0i); + // Add null deref to ensure we are analyzing the code up to this point. + int *p = 0; + *p = 0xDEADBEEF; // expected-warning{{null pointer}} +} + +// <rdar://problem/8375510> - CFGBuilder should handle temporaries. +struct R8375510 { + R8375510(); + ~R8375510(); + R8375510 operator++(int); +}; + +int r8375510(R8375510 x, R8375510 y) { + for (; ; x++) { } +} + diff --git a/test/Analysis/misc-ps-region-store.m b/test/Analysis/misc-ps-region-store.m index 6b4f658..a4e0d0b 100644 --- a/test/Analysis/misc-ps-region-store.m +++ b/test/Analysis/misc-ps-region-store.m @@ -253,7 +253,7 @@ void rdar_7249327(unsigned int A[2*32]) { a = A; b = B; - n = *a++; + n = *a++; // expected-warning{{Assigned value is always the same as the existing value}} if (n) x += *b++; // no-warning } @@ -1041,3 +1041,102 @@ void pr_7450() { pr_7450_aux(p + 8); } +// <rdar://problem/8243408> - Symbolicate struct values returned by value. +struct s_rdar_8243408 { int x; }; +extern struct s_rdar_8243408 rdar_8243408_aux(void); +void rdar_8243408(void) { + struct s_rdar_8243408 a = { 1 }, *b = 0; + while (a.x && !b) + a = rdar_8243408_aux(); + + // Previously there was a false error here with 'b' being null. + (void) (a.x && b->x); // no-warning + + // Introduce a null deref to ensure we are checking this path. + int *p = 0; + *p = 0xDEADBEEF; // expected-warning{{Dereference of null pointer}} +} + +// <rdar://problem/8258814> +int r8258814() +{ + int foo; + int * a = &foo; + a[0] = 10; + // Do not warn that the value of 'foo' is uninitialized. + return foo; // no-warning +} + +// PR 8052 - Don't crash when reasoning about loads from a function address.\n +typedef unsigned int __uint32_t; +typedef unsigned long vm_offset_t; +typedef __uint32_t pd_entry_t; +typedef unsigned char u_char; +typedef unsigned int u_int; +typedef unsigned long u_long; +extern int bootMP_size; +void bootMP(void); +static void +pr8052(u_int boot_addr) +{ + int x; + int size = *(int *) ((u_long) & bootMP_size); + u_char *src = (u_char *) ((u_long) bootMP); + u_char *dst = (u_char *) boot_addr + ((vm_offset_t) ((((((((1 << +12) / (sizeof(pd_entry_t))) - 1) - 1) - (260 - 2))) << 22) | ((0) << 12))); + for (x = 0; + x < size; + ++x) + *dst++ = *src++; +} + +// PR 8015 - don't return undefined values for arrays when using a valid +// symbolic index +int pr8015_A(); +void pr8015_B(const char *); + +void pr8015_C() { + int number = pr8015_A(); + const char *numbers[] = { "zero" }; + if (number == 0) { + pr8015_B(numbers[number]); // no-warning + } +} + +// FIXME: This is a false positive due to not reasoning about symbolic +// array indices correctly. Discussion in PR 8015. +void pr8015_D_FIXME() { + int number = pr8015_A(); + const char *numbers[] = { "zero" }; + if (number == 0) { + if (numbers[number] == numbers[0]) + return; + int *p = 0; + *p = 0xDEADBEEF; // expected-warning{{Dereference of null pointer}} + } +} + +void pr8015_E() { + // Similar to pr8015_C, but number is allowed to be a valid range. + unsigned number = pr8015_A(); + const char *numbers[] = { "zero", "one", "two" }; + if (number < 3) { + pr8015_B(numbers[number]); // no-warning + } +} + +void pr8015_F_FIXME() { + // Similar to pr8015_E, but like pr8015_D we check if the pointer + // is the same as one of the string literals. The null dereference + // here is not feasible in practice, so this is a false positive. + int number = pr8015_A(); + const char *numbers[] = { "zero", "one", "two" }; + if (number < 3) { + const char *p = numbers[number]; + if (p == numbers[0] || p == numbers[1] || p == numbers[2]) + return; + int *q = 0; + *q = 0xDEADBEEF; // expected-warning{{Dereference of null pointer}} + } +} + diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index b1d47e2..4fbaa49 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -86,11 +86,11 @@ unsigned r6268365Aux(); void r6268365() { unsigned x = 0; - x &= r6268365Aux(); + x &= r6268365Aux(); // expected-warning{{The left operand to '&=' is always 0}} unsigned j = 0; if (x == 0) ++j; - if (x == 0) x = x / j; // no-warning + if (x == 0) x = x / j; // expected-warning{{Assigned value is always the same as the existing value}} expected-warning{{The right operand to '/' is always 1}} } void divzeroassume(unsigned x, unsigned j) { @@ -298,6 +298,7 @@ void rdar_6777209(char *p) { typedef void *Opcode; Opcode pr_4033_getOpcode(); void pr_4033(void) { + void *lbl = &&next_opcode; next_opcode: { Opcode op = pr_4033_getOpcode(); @@ -406,14 +407,14 @@ void test_trivial_symbolic_comparison(int *x) { int test_trivial_symbolic_comparison_aux(); int a = test_trivial_symbolic_comparison_aux(); int b = a; - if (a != b) { + if (a != b) { // expected-warning{{Both operands to '!=' always have the same value}} int *p = 0; *p = 0xDEADBEEF; // no-warning } a = a == 1; b = b == 1; - if (a != b) { + if (a != b) { // expected-warning{{Both operands to '!=' always have the same value}} int *p = 0; *p = 0xDEADBEEF; // no-warning } @@ -457,7 +458,7 @@ void rdar_7062158_2() { // ElementRegion is created. unsigned char test_array_index_bitwidth(const unsigned char *p) { unsigned short i = 0; - for (i = 0; i < 2; i++) p = &p[i]; + for (i = 0; i < 2; i++) p = &p[i]; return p[i+1]; } @@ -1020,3 +1021,50 @@ void pr7475_warn() { *someStatic = 0; // expected-warning{{null pointer}} } +// <rdar://problem/8202272> - __imag passed non-complex should not crash +float f0(_Complex float x) { + float l0 = __real x; + return __real l0 + __imag l0; +} + + +//===----------------------------------------------------------------------=== +// Test that we can reduce symbols to constants whether they are on the left +// or right side of an expression. +//===----------------------------------------------------------------------=== + +void reduce_to_constant(int x, int y) { + if (x != 20) + return; + + int a = x + y; + int b = y + x; + + if (y == -20 && a != 0) + (void)*(char*)0; // no-warning + if (y == -20 && b != 0) + (void)*(char*)0; // no-warning +} + +// <rdar://problem/8360854> - Test that code after a switch statement with no +// 'case:' labels is correctly evaluated. +void r8360854(int n) { + switch (n) { + default: ; + } + int *p = 0; + *p = 0xDEADBEEF; // expected-warning{{null pointer}} +} + +// PR 8050 - crash in CastSizeChecker when pointee is an incomplete type +typedef long unsigned int __darwin_size_t; +typedef __darwin_size_t size_t; +void *malloc(size_t); + +struct PR8050; + +void pr8050(struct PR8050 **arg) +{ + *arg = malloc(1); +} + diff --git a/test/Analysis/null-deref-ps.c b/test/Analysis/null-deref-ps.c index 7ca22ad..8daa845 100644 --- a/test/Analysis/null-deref-ps.c +++ b/test/Analysis/null-deref-ps.c @@ -64,13 +64,13 @@ int f4_b() { short array[2]; uintptr_t x = array; // expected-warning{{incompatible pointer to integer conversion}} short *p = x; // expected-warning{{incompatible integer to pointer conversion}} - + // The following branch should be infeasible. - if (!(p = &array[0])) { + if (!(p == &array[0])) { // expected-warning{{Both operands to '==' always have the same value}} p = 0; *p = 1; // no-warning } - + if (p) { *p = 5; // no-warning p = 0; @@ -81,7 +81,6 @@ int f4_b() { return 0; } - int f5() { char *s = "hello world"; @@ -280,7 +279,7 @@ void f12(HF12ITEM i, char *q) { // Test handling of translating between integer "pointers" and back. void f13() { int *x = 0; - if (((((int) x) << 2) + 1) >> 1) *x = 1; // no-warning + if (((((int) x) << 2) + 1) >> 1) *x = 1; } // PR 4759 - Attribute non-null checking by the analyzer was not correctly diff --git a/test/Analysis/outofbound.c b/test/Analysis/outofbound.c index 9b48730..ed51dc6 100644 --- a/test/Analysis/outofbound.c +++ b/test/Analysis/outofbound.c @@ -71,3 +71,27 @@ void sizeof_vla(int a) { y[5] = 5; // expected-warning{{out-of-bound}} } } + +void alloca_region(int a) { + if (a == 5) { + char *x = __builtin_alloca(a); + x[4] = 4; // no-warning + x[5] = 5; // expected-warning{{out-of-bound}} + } +} + +int symbolic_index(int a) { + int x[2] = {1, 2}; + if (a == 2) { + return x[a]; // expected-warning{{out-of-bound}} + } + return 0; +} + +int symbolic_index2(int a) { + int x[2] = {1, 2}; + if (a < 0) { + return x[a]; // expected-warning{{out-of-bound}} + } + return 0; +} diff --git a/test/Analysis/plist-output.m b/test/Analysis/plist-output.m index aa866de..95faa06 100644 --- a/test/Analysis/plist-output.m +++ b/test/Analysis/plist-output.m @@ -205,7 +205,7 @@ void test_null_field(void) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>10</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> diff --git a/test/Analysis/retain-release-region-store.m b/test/Analysis/retain-release-region-store.m index db49b91..7b98554 100644 --- a/test/Analysis/retain-release-region-store.m +++ b/test/Analysis/retain-release-region-store.m @@ -50,6 +50,7 @@ typedef struct _NSZone NSZone; @end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end @interface NSObject <NSObject> {} +- (id)init; + (id)allocWithZone:(NSZone *)zone; + (id)alloc; - (void)dealloc; @@ -223,3 +224,29 @@ void pr6699(int x) { } } +// <rdar://problem/8261992> Idempotent operation checker false positive with ObjC ivars +@interface R8261992 : NSObject { + @package int myIvar; +} +@end + +static void R8261992_ChangeMyIvar(R8261992 *tc) { + tc->myIvar = 5; +} + +void R8261992_test(R8261992 *tc) { + int temp = tc->myIvar; + // The ivar binding for tc->myIvar gets invalidated. + R8261992_ChangeMyIvar(tc); + tc->myIvar = temp; // no-warning + tc = [[R8261992 alloc] init]; + temp = tc->myIvar; // no-warning + // The ivar binding for tc->myIvar gets invalidated. + R8261992_ChangeMyIvar(tc); + tc->myIvar = temp; + [tc release]; // no-warning + // did we analyze this? + int *p = 0x0; + *p = 0xDEADBEEF; // expected-warning{{null}} +} + diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m index c9c7d27..064165a 100644 --- a/test/Analysis/retain-release.m +++ b/test/Analysis/retain-release.m @@ -1358,3 +1358,12 @@ void test_blocks_1_indirect_retain_via_call(void) { } @end +// <rdar://problem/8272168> - Correcly handle Class<...> in Cocoa Conventions +// detector. + +@protocol Prot_R8272168 @end +Class <Prot_R8272168> GetAClassThatImplementsProt_R8272168(); +void r8272168() { + GetAClassThatImplementsProt_R8272168(); +} + diff --git a/test/Analysis/stack-addr-ps.cpp b/test/Analysis/stack-addr-ps.cpp new file mode 100644 index 0000000..593ba1d --- /dev/null +++ b/test/Analysis/stack-addr-ps.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s + +// FIXME: Only the stack-address checking in Sema catches this right now, and +// the stack analyzer doesn't handle the ImplicitCastExpr (lvalue). +const int& g() { + int s; + return s; // expected-warning{{reference to stack memory associated with local variable 's' returned}} +} diff --git a/test/Analysis/stream.c b/test/Analysis/stream.c index 2b6a903..73bbc13 100644 --- a/test/Analysis/stream.c +++ b/test/Analysis/stream.c @@ -6,6 +6,8 @@ typedef struct _IO_FILE FILE; #define SEEK_CUR 1 /* Seek from current position. */ #define SEEK_END 2 /* Seek from end of file. */ extern FILE *fopen(const char *path, const char *mode); +extern FILE *tmpfile(void); +extern int fclose(FILE *fp); extern size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream); extern int fseek (FILE *__stream, long int __off, int __whence); extern long int ftell (FILE *__stream); @@ -15,21 +17,25 @@ void f1(void) { FILE *p = fopen("foo", "r"); char buf[1024]; fread(buf, 1, 1, p); // expected-warning {{Stream pointer might be NULL.}} + fclose(p); } void f2(void) { FILE *p = fopen("foo", "r"); fseek(p, 1, SEEK_SET); // expected-warning {{Stream pointer might be NULL.}} + fclose(p); } void f3(void) { FILE *p = fopen("foo", "r"); ftell(p); // expected-warning {{Stream pointer might be NULL.}} + fclose(p); } void f4(void) { FILE *p = fopen("foo", "r"); rewind(p); // expected-warning {{Stream pointer might be NULL.}} + fclose(p); } void f5(void) { @@ -38,4 +44,36 @@ void f5(void) { return; fseek(p, 1, SEEK_SET); // no-warning fseek(p, 1, 3); // expected-warning {{The whence argument to fseek() should be SEEK_SET, SEEK_END, or SEEK_CUR.}} + fclose(p); +} + +void f6(void) { + FILE *p = fopen("foo", "r"); + fclose(p); + fclose(p); // expected-warning {{Try to close a file Descriptor already closed. Cause undefined behaviour.}} +} + +void f7(void) { + FILE *p = tmpfile(); + ftell(p); // expected-warning {{Stream pointer might be NULL.}} + fclose(p); +} + +void f8(int c) { + FILE *p = fopen("foo.c", "r"); + if(c) + return; // expected-warning {{Opened File never closed. Potential Resource leak.}} + fclose(p); +} + +FILE *f9(void) { + FILE *p = fopen("foo.c", "r"); + if (p) + return p; // no-warning + else + return 0; +} + +void pr7831(FILE *fp) { + fclose(fp); // no-warning } diff --git a/test/Analysis/string.c b/test/Analysis/string.c new file mode 100644 index 0000000..35ed710 --- /dev/null +++ b/test/Analysis/string.c @@ -0,0 +1,240 @@ +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-experimental-checks -verify %s +// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-experimental-checks -verify %s +// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-experimental-checks -verify %s +// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-experimental-checks -verify %s + +//===----------------------------------------------------------------------=== +// Declarations +//===----------------------------------------------------------------------=== + +// Some functions are so similar to each other that they follow the same code +// path, such as memcpy and __memcpy_chk, or memcmp and bcmp. If VARIANT is +// defined, make sure to use the variants instead to make sure they are still +// checked by the analyzer. + +// Some functions are implemented as builtins. These should be #defined as +// BUILTIN(f), which will prepend "__builtin_" if USE_BUILTINS is defined. + +// Functions that have variants and are also availabe as builtins should be +// declared carefully! See memcpy() for an example. + +#ifdef USE_BUILTINS +# define BUILTIN(f) __builtin_ ## f +#else /* USE_BUILTINS */ +# define BUILTIN(f) f +#endif /* USE_BUILTINS */ + +#define NULL 0 +typedef typeof(sizeof(int)) size_t; + +//===----------------------------------------------------------------------=== +// strlen() +//===----------------------------------------------------------------------=== + +#define strlen BUILTIN(strlen) +size_t strlen(const char *s); + +void strlen_constant0() { + if (strlen("123") != 3) + (void)*(char*)0; // no-warning +} + +void strlen_constant1() { + const char *a = "123"; + if (strlen(a) != 3) + (void)*(char*)0; // no-warning +} + +void strlen_constant2(char x) { + char a[] = "123"; + if (strlen(a) != 3) + (void)*(char*)0; // no-warning + a[0] = x; + if (strlen(a) != 3) + (void)*(char*)0; // expected-warning{{null}} +} + +size_t strlen_null() { + return strlen(0); // expected-warning{{Null pointer argument in call to byte string function}} +} + +size_t strlen_fn() { + return strlen((char*)&strlen_fn); // expected-warning{{Argument to byte string function is the address of the function 'strlen_fn', which is not a null-terminated string}} +} + +size_t strlen_nonloc() { +label: + return strlen((char*)&&label); // expected-warning{{Argument to byte string function is the address of the label 'label', which is not a null-terminated string}} +} + +void strlen_subregion() { + struct two_strings { char a[2], b[2] }; + extern void use_two_strings(struct two_strings *); + + struct two_strings z; + use_two_strings(&z); + + size_t a = strlen(z.a); + z.b[0] = 5; + size_t b = strlen(z.a); + if (a == 0 && b != 0) + (void)*(char*)0; // expected-warning{{never executed}} + + use_two_strings(&z); + + size_t c = strlen(z.a); + if (a == 0 && c != 0) + (void)*(char*)0; // expected-warning{{null}} +} + +extern void use_string(char *); +void strlen_argument(char *x) { + size_t a = strlen(x); + size_t b = strlen(x); + if (a == 0 && b != 0) + (void)*(char*)0; // expected-warning{{never executed}} + + use_string(x); + + size_t c = strlen(x); + if (a == 0 && c != 0) + (void)*(char*)0; // expected-warning{{null}} +} + +extern char global_str[]; +void strlen_global() { + size_t a = strlen(global_str); + size_t b = strlen(global_str); + if (a == 0 && b != 0) + (void)*(char*)0; // expected-warning{{never executed}} + + // Call a function with unknown effects, which should invalidate globals. + use_string(0); + + size_t c = strlen(global_str); + if (a == 0 && c != 0) + (void)*(char*)0; // expected-warning{{null}} +} + +void strlen_indirect(char *x) { + size_t a = strlen(x); + char *p = x; + char **p2 = &p; + size_t b = strlen(x); + if (a == 0 && b != 0) + (void)*(char*)0; // expected-warning{{never executed}} + + extern void use_string_ptr(char*const*); + use_string_ptr(p2); + + size_t c = strlen(x); + if (a == 0 && c != 0) + (void)*(char*)0; // expected-warning{{null}} +} + +void strlen_liveness(const char *x) { + if (strlen(x) < 5) + return; + if (strlen(x) < 5) + (void)*(char*)0; // no-warning +} + +//===----------------------------------------------------------------------=== +// strcpy() +//===----------------------------------------------------------------------=== + +#ifdef VARIANT + +#define __strcpy_chk BUILTIN(__strcpy_chk) +char *__strcpy_chk(char *restrict s1, const char *restrict s2, size_t destlen); + +#define strcpy(a,b) __strcpy_chk(a,b,(size_t)-1) + +#else /* VARIANT */ + +#define strcpy BUILTIN(strcpy) +char *strcpy(char *restrict s1, const char *restrict s2); + +#endif /* VARIANT */ + + +void strcpy_null_dst(char *x) { + strcpy(NULL, x); // expected-warning{{Null pointer argument in call to byte string function}} +} + +void strcpy_null_src(char *x) { + strcpy(x, NULL); // expected-warning{{Null pointer argument in call to byte string function}} +} + +void strcpy_fn(char *x) { + strcpy(x, (char*)&strcpy_fn); // expected-warning{{Argument to byte string function is the address of the function 'strcpy_fn', which is not a null-terminated string}} +} + +void strcpy_effects(char *x, char *y) { + char a = x[0]; + + if (strcpy(x, y) != x) + (void)*(char*)0; // no-warning + + if (strlen(x) != strlen(y)) + (void)*(char*)0; // no-warning + + if (a != x[0]) + (void)*(char*)0; // expected-warning{{null}} +} + +void strcpy_overflow(char *y) { + char x[4]; + if (strlen(y) == 4) + strcpy(x, y); // expected-warning{{Byte string function overflows destination buffer}} +} + +void strcpy_no_overflow(char *y) { + char x[4]; + if (strlen(y) == 3) + strcpy(x, y); // no-warning +} + +//===----------------------------------------------------------------------=== +// stpcpy() +//===----------------------------------------------------------------------=== + +#ifdef VARIANT + +#define __stpcpy_chk BUILTIN(__stpcpy_chk) +char *__stpcpy_chk(char *restrict s1, const char *restrict s2, size_t destlen); + +#define stpcpy(a,b) __stpcpy_chk(a,b,(size_t)-1) + +#else /* VARIANT */ + +#define stpcpy BUILTIN(stpcpy) +char *stpcpy(char *restrict s1, const char *restrict s2); + +#endif /* VARIANT */ + + +void stpcpy_effect(char *x, char *y) { + char a = x[0]; + + if (stpcpy(x, y) != &x[strlen(y)]) + (void)*(char*)0; // no-warning + + if (strlen(x) != strlen(y)) + (void)*(char*)0; // no-warning + + if (a != x[0]) + (void)*(char*)0; // expected-warning{{null}} +} + +void stpcpy_overflow(char *y) { + char x[4]; + if (strlen(y) == 4) + stpcpy(x, y); // expected-warning{{Byte string function overflows destination buffer}} +} + +void stpcpy_no_overflow(char *y) { + char x[4]; + if (strlen(y) == 3) + stpcpy(x, y); // no-warning +} diff --git a/test/Analysis/uninit-vals-ps-region.m b/test/Analysis/uninit-vals-ps-region.m index 69c1ecd..751e91b 100644 --- a/test/Analysis/uninit-vals-ps-region.m +++ b/test/Analysis/uninit-vals-ps-region.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=region -analyzer-check-idempotent-operations -verify %s struct s { int data; @@ -42,7 +42,7 @@ void test_uninit_pos_3() { void test_uninit_neg() { struct TestUninit v1 = { 0, 0 }; struct TestUninit v2 = test_uninit_aux(); - test_unit_aux2(v2.x + v1.y); // no-warning + test_unit_aux2(v2.x + v1.y); // expected-warning{{The right operand to '+' is always 0}} } extern void test_uninit_struct_arg_aux(struct TestUninit arg); diff --git a/test/Analysis/unreachable-code-path.c b/test/Analysis/unreachable-code-path.c new file mode 100644 index 0000000..0715327 --- /dev/null +++ b/test/Analysis/unreachable-code-path.c @@ -0,0 +1,104 @@ +// RUN: %clang_cc1 -analyze -analyzer-experimental-checks -analyzer-check-objc-mem -analyzer-check-dead-stores -verify -analyzer-opt-analyze-nested-blocks %s + +extern void foo(int a); + +// The first few tests are non-path specific - we should be able to find them + +void test(unsigned a) { + switch (a) { + a += 5; // expected-warning{{never executed}} + case 2: + a *= 10; + case 3: + a %= 2; + } + foo(a); +} + +void test2(unsigned a) { + help: + if (a > 0) + return; + if (a == 0) + return; + foo(a); // expected-warning{{never executed}} + goto help; +} + +void test3(unsigned a) { + while(1); + if (a > 5) { // expected-warning{{never executed}} + return; + } +} + +// These next tests are path-sensitive + +void test4() { + int a = 5; + + while (a > 1) + a -= 2; + + if (a > 1) { + a = a + 56; // expected-warning{{never executed}} + } + + foo(a); +} + +extern void bar(char c); + +void test5(const char *c) { + foo(c[0]); + + if (!c) { + bar(1); // expected-warning{{never executed}} + } +} + +// These next tests are false positives and should not generate warnings + +void test6(const char *c) { + if (c) return; + if (!c) return; + __builtin_unreachable(); // no-warning +} + +// Compile-time constant false positives +#define CONSTANT 0 +enum test_enum { Off, On }; +void test7() { + if (CONSTANT) + return; // no-warning + + if (sizeof(int)) + return; // no-warning + + if (Off) + return; // no-warning +} + +void test8() { + static unsigned a = 0; + + if (a) + a = 123; // no-warning + + a = 5; +} + +// Check for bugs where multiple statements are reported +void test9(unsigned a) { + switch (a) { + if (a) // expected-warning{{never executed}} + foo(a + 5); // no-warning + else // no-warning + foo(a); // no-warning + case 1: + case 2: + break; + default: + break; + } +} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6bb5b6c..611867f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -54,7 +54,7 @@ if(PYTHONINTERP_FOUND) --param build_config=${CMAKE_CFG_INTDIR} -sv ${CLANG_TEST_EXTRA_ARGS} ${CMAKE_CURRENT_BINARY_DIR}/${testdir} - DEPENDS clang c-index-test + DEPENDS clang c-index-test FileCheck not count COMMENT "Running Clang regression tests in ${testdir}") endforeach() @@ -65,7 +65,7 @@ if(PYTHONINTERP_FOUND) --param build_config=${CMAKE_CFG_INTDIR} -sv ${CLANG_TEST_EXTRA_ARGS} ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS clang c-index-test + DEPENDS clang c-index-test FileCheck not count COMMENT "Running Clang regression tests") add_custom_target(clang-c++tests @@ -75,6 +75,6 @@ if(PYTHONINTERP_FOUND) --param build_config=${CMAKE_CFG_INTDIR} -sv ${CLANG_TEST_EXTRA_ARGS} ${CMAKE_CURRENT_SOURCE_DIR}/../utils/C++Tests - DEPENDS clang c-index-test + DEPENDS clang c-index-test FileCheck not count COMMENT "Running Clang regression tests") endif() diff --git a/test/CXX/class.access/class.protected/p1.cpp b/test/CXX/class.access/class.protected/p1.cpp index 778e16a..8698fb1 100644 --- a/test/CXX/class.access/class.protected/p1.cpp +++ b/test/CXX/class.access/class.protected/p1.cpp @@ -68,7 +68,7 @@ namespace test1 { namespace test2 { class A { - protected: int x; // expected-note 3 {{declared}} + protected: int x; // expected-note 3 {{object type must derive}} static int sx; static void test(A&); }; @@ -103,7 +103,7 @@ namespace test2 { namespace test3 { class B; class A { - protected: int x; // expected-note {{declared}} + protected: int x; // expected-note {{object type must derive}} static int sx; static void test(B&); }; @@ -138,7 +138,7 @@ namespace test3 { namespace test4 { class C; class A { - protected: int x; // expected-note 3 {{declared}} + protected: int x; // expected-note {{declared}} expected-note 2 {{object type must derive}} static int sx; // expected-note 3{{member is declared here}} static void test(C&); }; @@ -215,7 +215,7 @@ namespace test6 { class Static {}; class A { protected: - void foo(int); // expected-note 3 {{declared}} + void foo(int); // expected-note 3 {{object type must derive}} void foo(long); static void foo(Static); @@ -253,7 +253,7 @@ namespace test7 { class Static {}; class A { protected: - void foo(int); // expected-note 3 {{declared}} + void foo(int); // expected-note 3 {{object type must derive}} void foo(long); static void foo(Static); @@ -291,7 +291,7 @@ namespace test8 { class Static {}; class A { protected: - void foo(int); // expected-note 3 {{declared}} + void foo(int); // expected-note 3 {{object type must derive}} void foo(long); static void foo(Static); @@ -329,8 +329,7 @@ namespace test8 { namespace test9 { class A { // expected-note {{member is declared here}} - protected: int foo(); // expected-note 8 {{declared}} \ - // expected-note {{member is declared here}} + protected: int foo(); // expected-note 4 {{declared}} expected-note 2 {{object type must derive}} expected-note {{object type 'test9::A' must derive}} }; class B : public A { // expected-note {{member is declared here}} @@ -338,7 +337,7 @@ namespace test9 { }; class C : protected B { // expected-note {{declared}} \ - // expected-note 6 {{constrained}} + // expected-note 9 {{constrained}} }; class D : public A { @@ -351,7 +350,7 @@ namespace test9 { static void test(B &b) { b.foo(); - b.A::foo(); // expected-error {{'foo' is a protected member}} + b.A::foo(); b.B::foo(); b.C::foo(); // expected-error {{'foo' is a protected member}} } @@ -359,8 +358,7 @@ namespace test9 { static void test(C &c) { c.foo(); // expected-error {{'foo' is a protected member}} \ // expected-error {{cannot cast}} - c.A::foo(); // expected-error {{'foo' is a protected member}} \ - // expected-error {{'A' is a protected member}} \ + c.A::foo(); // expected-error {{'A' is a protected member}} \ // expected-error {{cannot cast}} c.B::foo(); // expected-error {{'B' is a protected member}} \ // expected-error {{cannot cast}} @@ -388,3 +386,50 @@ namespace test10 { template class A<int>; } + +// rdar://problem/8360285: class.protected friendship +namespace test11 { + class A { + protected: + int foo(); + }; + + class B : public A { + friend class C; + }; + + class C { + void test() { + B b; + b.A::foo(); + } + }; +} + +// This friendship is considered because a public member of A would be +// a private member of C. +namespace test12 { + class A { protected: int foo(); }; + class B : public virtual A {}; + class C : private B { friend void test(); }; + class D : private C, public virtual A {}; + + void test() { + D d; + d.A::foo(); + } +} + +// This friendship is not considered because a public member of A is +// inaccessible in C. +namespace test13 { + class A { protected: int foo(); }; // expected-note {{declared protected here}} + class B : private virtual A {}; + class C : private B { friend void test(); }; + class D : public virtual A {}; + + void test() { + D d; + d.A::foo(); // expected-error {{protected member}} + } +} diff --git a/test/CXX/class.access/p4.cpp b/test/CXX/class.access/p4.cpp index 90a1449..115a22a 100644 --- a/test/CXX/class.access/p4.cpp +++ b/test/CXX/class.access/p4.cpp @@ -372,7 +372,7 @@ namespace test15 { int private_foo; // expected-note {{declared private here}} static int private_sfoo; // expected-note {{declared private here}} protected: - int protected_foo; // expected-note 4 {{declared protected here}} + int protected_foo; // expected-note 3 {{declared protected here}} // expected-note {{object type must derive from context type 'test15::B<int>'}} static int protected_sfoo; // expected-note 3 {{declared protected here}} int test1(A<int> &a) { @@ -427,3 +427,26 @@ namespace test16 { void b() { throw A(); } // expected-error{{temporary of type 'test16::A' has private destructor}} \ // expected-error{{exception object of type 'test16::A' has private destructor}} } + +// rdar://problem/8146294 +namespace test17 { + class A { + template <typename T> class Inner { }; // expected-note {{declared private here}} + }; + + A::Inner<int> s; // expected-error {{'Inner' is a private member of 'test17::A'}} +} + +namespace test18 { + template <class T> class A {}; + class B : A<int> { + A<int> member; + }; + + // FIXME: this access to A should be forbidden (because C++ is dumb), + // but LookupResult can't express the necessary information to do + // the check, so we aggressively suppress access control. + class C : B { + A<int> member; + }; +} diff --git a/test/CXX/class.access/p6.cpp b/test/CXX/class.access/p6.cpp index 734a4d8..8795708 100644 --- a/test/CXX/class.access/p6.cpp +++ b/test/CXX/class.access/p6.cpp @@ -119,3 +119,23 @@ namespace test4 { foo(a, 0); } } + +// PR7644 +namespace test5 { + class A { + enum Enum { E0, E1, E2 }; // expected-note 4 {{declared private here}} + template <Enum> void foo(); + template <Enum> class bar; + }; + + template <A::Enum en> void A::foo() {} + template <A::Enum en> class A::bar {}; + + template <A::Enum en> void foo() {} // expected-error {{'Enum' is a private member of 'test5::A'}} + template <A::Enum en> class bar {}; // expected-error {{'Enum' is a private member of 'test5::A'}} + + class B { + template <A::Enum en> void foo() {} // expected-error {{'Enum' is a private member of 'test5::A'}} + template <A::Enum en> class bar {}; // expected-error {{'Enum' is a private member of 'test5::A'}} + }; +} diff --git a/test/CXX/class/class.mem/p1.cpp b/test/CXX/class/class.mem/p1.cpp new file mode 100644 index 0000000..55507d4 --- /dev/null +++ b/test/CXX/class/class.mem/p1.cpp @@ -0,0 +1,64 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +struct S +{ + static int v1; // expected-note{{previous declaration is here}} + int v1; //expected-error{{duplicate member 'v1'}} + int v; //expected-note 2{{previous definition is here}} \ + // expected-note{{previous declaration is here}} + static int v; //expected-error{{redefinition of 'v' as different kind of symbol}} + int v; //expected-error{{duplicate member 'v'}} + static int v; //expected-error{{redefinition of 'v' as different kind of symbol}} + enum EnumT { E = 10 }; + friend struct M; + struct X; //expected-note{{forward declaration of 'S::X'}} + friend struct X; +}; + +S::EnumT Evar = S::E; // ok +S::EnumT Evar2 = EnumT(); //expected-error{{use of undeclared identifier 'EnumT'}} +S::M m; //expected-error{{no type named 'M' in 'S'}} +S::X x; //expected-error{{variable has incomplete type 'S::X'}} + + +struct S2 +{ + static int v2; // expected-note{{previous declaration is here}} + static int v2; //expected-error{{duplicate member 'v2'}} +}; + +struct S3 +{ + static int v3; + struct S4 + { + static int v3; + }; +}; + +struct S4 +{ + static int v4; +}; + +int S4::v4; //expected-note{{previous definition is here}} +int S4::v4; //expected-error{{redefinition of 'v4'}} + +struct S5 +{ + static int v5; //expected-note{{previous definition is here}} + void v5() { } //expected-error{{redefinition of 'v5' as different kind of symbol}} + + void v6() { } //expected-note{{previous definition is here}} + static int v6; //expected-error{{redefinition of 'v6' as different kind of symbol}} + + void v7() { } + void v7(int) { } //expected-note{{previous definition is here}} + static int v7; //expected-error{{redefinition of 'v7' as different kind of symbol}} + + void v8(); + int v8(int); //expected-note{{previous declaration is here}} + int v8; //expected-error{{duplicate member 'v8'}} + + +}; diff --git a/test/CXX/class/class.static/class.static.data/p4.cpp b/test/CXX/class/class.static/class.static.data/p4.cpp new file mode 100644 index 0000000..2b1eca7 --- /dev/null +++ b/test/CXX/class/class.static/class.static.data/p4.cpp @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +struct InClassInitializerOnly { + static const int i = 0; +}; +int const InClassInitializerOnly::i; + +struct OutOfClassInitializerOnly { + static const int i; +}; +int const OutOfClassInitializerOnly::i = 0; + +struct InClassInitializerAndOutOfClassCopyInitializer { + static const int i = 0; // expected-note{{previous definition is here}} +}; +int const InClassInitializerAndOutOfClassCopyInitializer::i = 0; // expected-error{{redefinition of 'i'}} + +struct InClassInitializerAndOutOfClassDirectInitializer { + static const int i = 0; // expected-note{{previous definition is here}} +}; +int const InClassInitializerAndOutOfClassDirectInitializer::i(0); // expected-error{{redefinition of 'i'}} + + + +int main() { } + diff --git a/test/CXX/conv/conv.ptr/p2.cpp b/test/CXX/conv/conv.ptr/p2.cpp new file mode 100644 index 0000000..8808d20 --- /dev/null +++ b/test/CXX/conv/conv.ptr/p2.cpp @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +namespace pr7801 { + extern void* x[]; + void* dummy[] = { &x }; +} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp new file mode 100644 index 0000000..6ffa873 --- /dev/null +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 -pedantic %s + +// Intentionally compiled as C++03 to test the extension warning. + +namespace a {} // original +namespace a {} // ext +inline namespace b {} // inline original expected-warning {{inline namespaces are}} +inline namespace b {} // inline ext expected-warning {{inline namespaces are}} +inline namespace {} // inline unnamed expected-warning {{inline namespaces are}} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp new file mode 100644 index 0000000..198b013 --- /dev/null +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s + +namespace NIL {} // expected-note {{previous definition}} +inline namespace NIL {} // expected-error {{cannot be reopened as inline}} +inline namespace IL {} // expected-note {{previous definition}} +namespace IL {} // expected-error {{cannot be reopened as non-inline}} + +namespace {} // expected-note {{previous definition}} +inline namespace {} // expected-error {{cannot be reopened as inline}} +namespace X { + inline namespace {} // expected-note {{previous definition}} + namespace {} // expected-error {{cannot be reopened as non-inline}} +} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp new file mode 100644 index 0000000..b9ad6e1 --- /dev/null +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp @@ -0,0 +1,97 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s + +// Fun things you can do with inline namespaces: + +inline namespace X { + void f1(); + + inline namespace Y { + void f2(); + + template <typename T> class C {}; + } + + // Specialize and partially specialize somewhere else. + template <> class C<int> {}; + template <typename T> class C<T*> {}; +} + +// Qualified and unqualified lookup as if member of enclosing NS. +void foo1() { + f1(); + ::f1(); + X::f1(); + Y::f1(); // expected-error {{no member named 'f1' in namespace 'X::Y'}} + + f2(); + ::f2(); + X::f2(); + Y::f2(); +} + +template <> class C<float> {}; +template <typename T> class C<T&> {}; + +template class C<double>; + + +// As well as all the fun with ADL. + +namespace ADL { + struct Outer {}; + + inline namespace IL { + struct Inner {}; + + void fo(Outer); + } + + void fi(Inner); + + inline namespace IL2 { + void fi2(Inner); + } +} + +void foo2() { + ADL::Outer o; + ADL::Inner i; + fo(o); + fi(i); + fi2(i); +} + +// Let's not forget overload sets. +struct Distinct {}; +inline namespace Over { + void over(Distinct); +} +void over(int); + +void foo3() { + Distinct d; + ::over(d); +} + +// Don't forget to do correct lookup for redeclarations. +namespace redecl { inline namespace n1 { + + template <class Tp> class allocator; + + template <> + class allocator<void> + { + public: + typedef const void* const_pointer; + }; + + template <class Tp> + class allocator + { + public: + typedef Tp& reference; + + void allocate(allocator<void>::const_pointer = 0); + }; + +} } diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p10.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p10.cpp index 27b41a7..546c4a4 100644 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p10.cpp +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p10.cpp @@ -31,3 +31,4 @@ namespace test1 { using test1::foo; } } + diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p6.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p6.cpp new file mode 100644 index 0000000..4cb91cd --- /dev/null +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p6.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// <rdar://problem/8296180> +typedef int pid_t; +namespace ns { + typedef int pid_t; +} +using namespace ns; +pid_t x; + +struct A { }; +namespace ns { + typedef ::A A; +} +A a; diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p3.cpp index 99a4f7a..d7b9eff 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p3.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p3.cpp @@ -1,11 +1,13 @@ // RUN: %clang_cc1 -verify %s -// XFAIL: * -void f0(void) { - inline void f1(); // expected-error {{'inline' is not allowed on block scope function declaration}} +void f0a(void) { + inline void f1(); // expected-error {{inline declaration of 'f1' not allowed in block scope}} +} + +void f0b(void) { + void f1(); } // FIXME: Add test for "If the inline specifier is used in a friend declaration, // that declaration shall be a definition or the function shall have previously // been declared inline. - diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp index f507eec..491ab17 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp @@ -1,12 +1,11 @@ // RUN: %clang_cc1 -verify %s -struct S; // expected-note {{forward declaration of 'S'}} +struct S; // expected-note 2{{forward declaration of 'S'}} extern S a; extern S f(); // expected-note {{'f' declared here}} -extern void g(S a); // expected-note {{candidate function}} +extern void g(S a); void h() { - // FIXME: This diagnostic could be better. - g(a); // expected-error {{no matching function for call to 'g'}} + g(a); // expected-error {{argument type 'S' is incomplete}} f(); // expected-error {{calling 'f' with incomplete return type 'S'}} } diff --git a/test/CXX/dcl.decl/dcl.init/p5.cpp b/test/CXX/dcl.decl/dcl.init/p5.cpp new file mode 100644 index 0000000..b50e8d7 --- /dev/null +++ b/test/CXX/dcl.decl/dcl.init/p5.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// FIXME: Very incomplete! + +// A program that calls for default-initialization or value-initialization of +// an entity of reference type is illformed. If T is a cv-qualified type, the +// cv-unqualified version of T is used for these definitions of +// zero-initialization, default-initialization, and value-initialization. +// +// FIXME: The diagnostics for these errors are terrible because they fall out +// of the AST representation rather than being explicitly issued during the +// respective initialization forms. +struct S { // expected-error {{implicit default constructor for 'S' must explicitly initialize the reference member}} \ + // expected-note {{candidate constructor (the implicit copy constructor) not viable}} + int& x; // expected-note {{declared here}} +}; +S s; // expected-note {{implicit default constructor for 'S' first required here}} +S f() { + return S(); // expected-error {{no matching constructor for initialization of 'S'}} +} diff --git a/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp b/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp new file mode 100644 index 0000000..170c734 --- /dev/null +++ b/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp @@ -0,0 +1,45 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// rdar://problem/8347416 +namespace test0 { + struct A { + void foo(void (A::*)(int)); // expected-note {{passing argument to parameter here}} + template<typename T> void g(T); + + void test() { + // FIXME: this diagnostic is terrible + foo(&g<int>); // expected-error {{cannot initialize a parameter of type 'void (test0::A::*)(int)' with an rvalue of type '<overloaded function type>'}} + } + }; +} + +// This should succeed. +namespace test1 { + struct A { + static void f(void (A::*)()); + static void f(void (*)(int)); + void g(); + static void g(int); + + void test() { + f(&g); + } + }; +} + +// Also rdar://problem/8347416 +namespace test2 { + struct A { + static int foo(short); + static int foo(float); + int foo(int); + int foo(double); + + void test(); + }; + + void A::test() { + // FIXME: This diagnostic is terrible. + int (A::*ptr)(int) = &(A::foo); // expected-error {{cannot initialize a variable of type 'int (test2::A::*)(int)' with an rvalue of type '<overloaded function type>'}} + } +} diff --git a/test/CXX/special/class.dtor/p9.cpp b/test/CXX/special/class.dtor/p9.cpp new file mode 100644 index 0000000..8b76a15 --- /dev/null +++ b/test/CXX/special/class.dtor/p9.cpp @@ -0,0 +1,85 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +typedef typeof(sizeof(int)) size_t; + +// PR7803 +namespace test0 { + class A { + public: + static void operator delete(void *p) {}; + virtual ~A(); + }; + + class B : protected A { + public: + ~B(); + }; + + class C : protected B { + public: + using B::operator delete; + ~C(); + }; + + // Shouldn't have an error. + C::~C() {} +} + +namespace test1 { + class A { + public: + static void operator delete(void *p) {}; // expected-note {{member 'operator delete' declared here}} + virtual ~A(); + }; + + class B : protected A { + public: + static void operator delete(void *, size_t) {}; // expected-note {{member 'operator delete' declared here}} + ~B(); + }; + + class C : protected B { + public: + using A::operator delete; + using B::operator delete; + + ~C(); + }; + + C::~C() {} // expected-error {{multiple suitable 'operator delete' functions in 'C'}} +} + +// ...at the point of definition of a virtual destructor... +namespace test2 { + struct A { + virtual ~A(); + static void operator delete(void*, const int &); + }; + + struct B { + virtual ~B(); + static void operator delete(void*, const int &); // expected-note {{declared here}} + }; + B::~B() {} // expected-error {{no suitable member 'operator delete' in 'B'}} + + struct CBase { virtual ~CBase(); }; + struct C : CBase { // expected-error {{no suitable member 'operator delete' in 'C'}} + static void operator delete(void*, const int &); // expected-note {{declared here}} + }; + void test() { + C c; // expected-note {{first required here}} + } +} + +// PR7346 +namespace test3 { + struct A { + virtual ~A(); + static void operator delete(void*, const int &); + }; + + struct B : A { + virtual ~B() {} + static void operator delete(void*); + }; +} diff --git a/test/CXX/temp/temp.arg/temp.arg.type/p2-cxx0x.cpp b/test/CXX/temp/temp.arg/temp.arg.type/p2-cxx0x.cpp new file mode 100644 index 0000000..6f6286f --- /dev/null +++ b/test/CXX/temp/temp.arg/temp.arg.type/p2-cxx0x.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++0x -verify %s + +// C++03 imposed restrictions in this paragraph that were lifted with 0x, so we +// just test that the example given now parses cleanly. + +template <class T> class X { }; +template <class T> void f(T t) { } +struct { } unnamed_obj; +void f() { + struct A { }; + enum { e1 }; + typedef struct { } B; + B b; + X<A> x1; + X<A*> x2; + X<B> x3; + f(e1); + f(unnamed_obj); + f(b); +} diff --git a/test/CXX/temp/temp.decls/temp.friend/p4.cpp b/test/CXX/temp/temp.decls/temp.friend/p4.cpp index 226ac0f..e036cef 100644 --- a/test/CXX/temp/temp.decls/temp.friend/p4.cpp +++ b/test/CXX/temp/temp.decls/temp.friend/p4.cpp @@ -8,3 +8,21 @@ struct X1 { X1<int> x1a; X1<float> x1b; // expected-note {{in instantiation of}} + +template<typename T> +struct X2 { + operator int(); + + friend void f(int x) { } // expected-error{{redefinition}} \ + // expected-note{{previous definition}} +}; + +int array0[sizeof(X2<int>)]; +int array1[sizeof(X2<float>)]; // expected-note{{instantiation of}} + +void g() { + X2<int> xi; + f(xi); + X2<float> xf; + f(xf); +} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/sfinae-1.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/sfinae-1.cpp index f6121b3..6481485 100644 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/sfinae-1.cpp +++ b/test/CXX/temp/temp.fct.spec/temp.deduct/sfinae-1.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s +// RUN: %clang_cc1 -verify %s typedef char one_byte; struct two_bytes { char data[2]; }; @@ -15,3 +15,28 @@ struct X { }; int array0[is_class<X>::value? 1 : -1]; int array1[is_class<int>::value? -1 : 1]; int array2[is_class<char[3]>::value? -1 : 1]; + +namespace instantiation_order1 { + template<typename T> + struct it_is_a_trap { + typedef typename T::trap type; + }; + + template<bool, typename T = void> + struct enable_if { + typedef T type; + }; + + template<typename T> + struct enable_if<false, T> { }; + + template<typename T> + typename enable_if<sizeof(T) == 17>::type + f(const T&, typename it_is_a_trap<T>::type* = 0); + + void f(...); + + void test_f() { + f('a'); + } +} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp index 1b240cc..16b5cd2 100644 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp +++ b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp @@ -93,3 +93,21 @@ namespace test1 { invoke(&temp2<int, int>); // expected-error {{no matching function for call to 'invoke'}} } } + +namespace rdar8360106 { + template<typename R, typename T> void f0(R (*)(T), T); + template<typename R, typename T> void f1(R (&)(T) , T); // expected-note{{candidate template ignored: couldn't infer template argument 'R'}} + template<typename R, typename T> void f2(R (* const&)(T), T); // expected-note{{candidate template ignored: couldn't infer template argument 'R'}} + + int g(int); + int g(int, int); + + void h() { + f0(g, 1); + f0(&g, 1); + f1(g, 1); + f1(&g, 1); // expected-error{{no matching function for call to 'f1'}} + f2(g, 1); // expected-error{{no matching function for call to 'f2'}} + f2(&g, 1); + } +} diff --git a/test/CXX/temp/temp.param/p4.cpp b/test/CXX/temp/temp.param/p4.cpp index 5ec402a..809fb20 100644 --- a/test/CXX/temp/temp.param/p4.cpp +++ b/test/CXX/temp/temp.param/p4.cpp @@ -17,4 +17,5 @@ template<typename T, T x> struct A10; template<float f> struct A11; // expected-error{{a non-type template parameter cannot have type 'float'}} -template<void *Ptr> struct A12; // expected-error{{a non-type template parameter cannot have type 'void *'}} +template<void *Ptr> struct A12; +template<int (*IncompleteArrayPtr)[]> struct A13; diff --git a/test/CXX/temp/temp.spec/temp.explicit/p3.cpp b/test/CXX/temp/temp.spec/temp.explicit/p3.cpp index e9758bc..48c42c3 100644 --- a/test/CXX/temp/temp.spec/temp.explicit/p3.cpp +++ b/test/CXX/temp/temp.spec/temp.explicit/p3.cpp @@ -2,8 +2,9 @@ // A declaration of a function template shall be in scope at the point of the // explicit instantiation of the function template. -template<typename T> void f0(T) { } +template<typename T> void f0(T); template void f0(int); // okay +template<typename T> void f0(T) { } // A definition of the class or class template containing a member function // template shall be in scope at the point of the explicit instantiation of @@ -47,3 +48,27 @@ template X2<int>::X2(); // expected-error{{not an instantiation}} template X2<int>::X2(const X2&); // expected-error{{not an instantiation}} template X2<int>::~X2(); // expected-error{{not an instantiation}} template X2<int> &X2<int>::operator=(const X2<int>&); // expected-error{{not an instantiation}} + + +// A definition of a class template is sufficient to explicitly +// instantiate a member of the class template which itself is not yet defined. +namespace PR7979 { + template <typename T> struct S { + void f(); + static void g(); + static int i; + struct S2 { + void h(); + }; + }; + + template void S<int>::f(); + template void S<int>::g(); + template int S<int>::i; + template void S<int>::S2::h(); + + template <typename T> void S<T>::f() {} + template <typename T> void S<T>::g() {} + template <typename T> int S<T>::i; + template <typename T> void S<T>::S2::h() {} +} diff --git a/test/CodeCompletion/enum-switch-case.c b/test/CodeCompletion/enum-switch-case.c index 0820726..d5df371 100644 --- a/test/CodeCompletion/enum-switch-case.c +++ b/test/CodeCompletion/enum-switch-case.c @@ -18,11 +18,28 @@ void test(enum Color color) { case Green: break; - + } + + unsigned c2; + switch (c2) { + case + } + // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:10 %s -o - | FileCheck -check-prefix=CC1 %s // CHECK-CC1: Blue // CHECK-CC1-NEXT: Green // CHECK-CC1-NEXT: Indigo // CHECK-CC1-NEXT: Orange // CHECK-CC1-NEXT: Violet - + + // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:25:10 %s -o - | FileCheck -check-prefix=CC2 %s + // CHECK-CC2: COMPLETION: Blue : [#enum Color#]Blue + // CHECK-CC2-NEXT: COMPLETION: c2 : [#unsigned int#]c2 + // CHECK-CC2-NEXT: COMPLETION: color : [#enum Color#]color + // CHECK-CC2-NEXT: COMPLETION: Green : [#enum Color#]Green + // CHECK-CC2-NEXT: COMPLETION: Indigo : [#enum Color#]Indigo + // CHECK-CC2-NEXT: COMPLETION: Orange : [#enum Color#]Orange + // CHECK-CC2-NEXT: COMPLETION: Red : [#enum Color#]Red + // CHECK-CC2-NEXT: COMPLETION: Pattern : sizeof(<#expression-or-type#>) + // CHECK-CC2-NEXT: COMPLETION: Violet : [#enum Color#]Violet + // CHECK-CC2-NEXT: COMPLETION: Yellow : [#enum Color#]Yellow diff --git a/test/CodeCompletion/functions.cpp b/test/CodeCompletion/functions.cpp index 6838de3..fcab3dc 100644 --- a/test/CodeCompletion/functions.cpp +++ b/test/CodeCompletion/functions.cpp @@ -5,4 +5,4 @@ void test() { :: // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:5:5 %s -o - | FileCheck -check-prefix=CC1 %s // CHECK-CC1: f(<#int i#>{#, <#int j#>{#, <#int k#>#}#}) - // CHECK-CC1: f(<#float x#>, <#float y#><#, ...#>) + // CHECK-CC1: f(<#float x#>, <#float y, ...#>) diff --git a/test/CodeGen/2009-04-23-dbg.c b/test/CodeGen/2009-04-23-dbg.c index 6a8bf01..704aba2 100644 --- a/test/CodeGen/2009-04-23-dbg.c +++ b/test/CodeGen/2009-04-23-dbg.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -g -o %t %s -emit-llvm-bc && llc %t -o %t.s +// RUN: %clang_cc1 -S -g -o %t %s # 1 "a.c" # 1 "a.c" 1 # 1 "<built-in>" 1 diff --git a/test/CodeGen/2009-10-20-GlobalDebug.c b/test/CodeGen/2009-10-20-GlobalDebug.c index 1db37de..3c46bea 100644 --- a/test/CodeGen/2009-10-20-GlobalDebug.c +++ b/test/CodeGen/2009-10-20-GlobalDebug.c @@ -1,7 +1,7 @@ // RUN: %clang -ccc-host-triple i386-apple-darwin10 -S -g -dA %s -o - | FileCheck %s int global; +// CHECK: ascii "localstatic" ## DW_AT_name // CHECK: asciz "global" ## External Name -// CHECK: asciz "localstatic" ## External Name int main() { static int localstatic; return 0; diff --git a/test/CodeGen/2010-08-10-DbgConstant.c b/test/CodeGen/2010-08-10-DbgConstant.c new file mode 100644 index 0000000..5b8f064 --- /dev/null +++ b/test/CodeGen/2010-08-10-DbgConstant.c @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -S -emit-llvm -g %s -o - | grep DW_TAG_variable + +static const unsigned int ro = 201; +void bar(int); +void foo() { bar(ro); } diff --git a/test/CodeGen/_Bool-conversion.c b/test/CodeGen/_Bool-conversion.c new file mode 100644 index 0000000..9e5e894 --- /dev/null +++ b/test/CodeGen/_Bool-conversion.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple i386 -emit-llvm -O2 -o - %s | FileCheck %s + +// CHECK: define i32 @f0() +// CHECK: ret i32 1 +// CHECK: } + +static _Bool f0_0(void *a0) { return (_Bool) a0; } +int f0() { return f0_0((void*) 0x2); } + +_Bool f1(void) { + return (_Bool) ({ void (*x)(); x = 0; }); +} diff --git a/test/CodeGen/address-space-field1.c b/test/CodeGen/address-space-field1.c index a81e08e..e9c1871 100644 --- a/test/CodeGen/address-space-field1.c +++ b/test/CodeGen/address-space-field1.c @@ -1,22 +1,22 @@ -// RUN: %clang_cc1 -emit-llvm < %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin10 < %s -o - | FileCheck %s // CHECK:%struct.S = type { i32, i32 } // CHECK:define void @test_addrspace(%struct.S addrspace(1)* %p1, %struct.S addrspace(2)* %p2) nounwind // CHECK: [[p1addr:%.*]] = alloca %struct.S addrspace(1)* // CHECK: [[p2addr:%.*]] = alloca %struct.S addrspace(2)* // CHECK: store %struct.S addrspace(1)* %p1, %struct.S addrspace(1)** [[p1addr]] // CHECK: store %struct.S addrspace(2)* %p2, %struct.S addrspace(2)** [[p2addr]] -// CHECK: [[t0:%.*]] = load %struct.S addrspace(2)** [[p2addr]] ; <%struct.S addrspace(2)*> [#uses=1] -// CHECK: [[t1:%.*]] = getelementptr inbounds %struct.S addrspace(2)* [[t0]], i32 0, i32 1 ; <i32 addrspace(2)*> [#uses=1] -// CHECK: [[t2:%.*]] = load i32 addrspace(2)* [[t1]] ; <i32> [#uses=1] -// CHECK: [[t3:%.*]] = load %struct.S addrspace(1)** [[p1addr]] ; <%struct.S addrspace(1)*> [#uses=1] -// CHECK: [[t4:%.*]] = getelementptr inbounds %struct.S addrspace(1)* [[t3]], i32 0, i32 0 ; <i32 addrspace(1)*> [#uses=1] -// CHECK: store i32 [[t2]], i32 addrspace(1)* [[t4]] -// CHECK: [[t5:%.*]] = load %struct.S addrspace(2)** [[p2addr]] ; <%struct.S addrspace(2)*> [#uses=1] -// CHECK: [[t6:%.*]] = getelementptr inbounds %struct.S addrspace(2)* [[t5]], i32 0, i32 0 ; <i32 addrspace(2)*> [#uses=1] -// CHECK: [[t7:%.*]] = load i32 addrspace(2)* [[t6]] ; <i32> [#uses=1] -// CHECK: [[t8:%.*]] = load %struct.S addrspace(1)** [[p1addr]] ; <%struct.S addrspace(1)*> [#uses=1] -// CHECK: [[t9:%.*]] = getelementptr inbounds %struct.S addrspace(1)* [[t8]], i32 0, i32 1 ; <i32 addrspace(1)*> [#uses=1] -// CHECK: store i32 [[t7]], i32 addrspace(1)* [[t9]] +// CHECK: [[t0:%.*]] = load %struct.S addrspace(2)** [[p2addr]], align 8 +// CHECK: [[t1:%.*]] = getelementptr inbounds %struct.S addrspace(2)* [[t0]], i32 0, i32 1 +// CHECK: [[t2:%.*]] = load i32 addrspace(2)* [[t1]], align 4 +// CHECK: [[t3:%.*]] = load %struct.S addrspace(1)** [[p1addr]], align 8 +// CHECK: [[t4:%.*]] = getelementptr inbounds %struct.S addrspace(1)* [[t3]], i32 0, i32 0 +// CHECK: store i32 [[t2]], i32 addrspace(1)* [[t4]], align 4 +// CHECK: [[t5:%.*]] = load %struct.S addrspace(2)** [[p2addr]], align 8 +// CHECK: [[t6:%.*]] = getelementptr inbounds %struct.S addrspace(2)* [[t5]], i32 0, i32 0 +// CHECK: [[t7:%.*]] = load i32 addrspace(2)* [[t6]], align 4 +// CHECK: [[t8:%.*]] = load %struct.S addrspace(1)** [[p1addr]], align 8 +// CHECK: [[t9:%.*]] = getelementptr inbounds %struct.S addrspace(1)* [[t8]], i32 0, i32 1 +// CHECK: store i32 [[t7]], i32 addrspace(1)* [[t9]], align 4 // CHECK: ret void // CHECK:} diff --git a/test/CodeGen/address-space-field2.c b/test/CodeGen/address-space-field2.c deleted file mode 100644 index 9c21cab..0000000 --- a/test/CodeGen/address-space-field2.c +++ /dev/null @@ -1,46 +0,0 @@ -// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s -// CHECK: addrspace(1) -// CHECK: addrspace(2) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(2) -// CHECK: addrspace(2) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(2) -// CHECK: addrspace(2) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(2) -// CHECK: addrspace(2) -// CHECK: addrspace(2) -// CHECK: addrspace(2) -// CHECK: addrspace(2) -// CHECK: addrspace(2) -// CHECK: addrspace(2) -// CHECK: addrspace(2) -// CHECK: addrspace(2) - -// Check that we don't lose the address space when accessing an array element -// inside a structure. - -#define __addr1 __attribute__((address_space(1))) -#define __addr2 __attribute__((address_space(2))) - -typedef struct S { - int arr[ 3 ]; -} S; - -void test_addrspace(__addr1 S* p1, __addr2 S*p2, int* val, int n) { - for (int i=0; i < 3; ++i) { - int t = val[i]; - p1->arr[i] = t; - for (int j=0; j < n; ++j) - p2[j].arr[i] = t; - } -} diff --git a/test/CodeGen/address-space-field3.c b/test/CodeGen/address-space-field3.c deleted file mode 100644 index c17085c..0000000 --- a/test/CodeGen/address-space-field3.c +++ /dev/null @@ -1,42 +0,0 @@ -// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s -// CHECK: addrspace(1) -// CHECK: addrspace(2) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(2) -// CHECK: addrspace(2) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(2) -// CHECK: addrspace(2) -// CHECK: addrspace(2) -// CHECK: addrspace(2) -// CHECK: addrspace(2) -// CHECK: addrspace(2) -// CHECK: addrspace(2) -// CHECK: addrspace(2) -// CHECK: addrspace(2) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) - -// Check that we don't lose the address space when accessing an array element -// inside a structure. - -#define __addr1 __attribute__((address_space(1))) -#define __addr2 __attribute__((address_space(2))) - -typedef struct S { - int arr[ 3 ]; -} S; - -void test_addrspace(__addr1 S* p1, __addr2 S*p2, int* val, int n) { - for (int i=0; i < 3; ++i) { - int t = val[i]; - p1->arr[i] = p2->arr[i]; - } -} diff --git a/test/CodeGen/address-space-field4.c b/test/CodeGen/address-space-field4.c deleted file mode 100644 index a896ab6..0000000 --- a/test/CodeGen/address-space-field4.c +++ /dev/null @@ -1,55 +0,0 @@ -// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s -// CHECK: addrspace(2) -// CHECK: addrspace(3) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(3) -// CHECK: addrspace(3) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(1) -// CHECK: addrspace(2) -// CHECK: addrspace(2) - -// Check the load and store are using the correct address space to access -// the variables. - -#define __addr1 __attribute__((address_space(1))) -#define __addr2 __attribute__((address_space(2))) -#define __addr3 __attribute__((address_space(3))) - -typedef struct Pair { - __addr2 int* a; - __addr3 int* b; -} Pair; - -typedef struct S { - Pair arr[ 3 ]; -} S; - -void test_addrspace(__addr1 S* p1, __addr1 S* p2) { - *p1->arr[0].a = *p2->arr[1].b; -} diff --git a/test/CodeGen/asm-errors.c b/test/CodeGen/asm-errors.c index 7323e61..aea5cb2 100644 --- a/test/CodeGen/asm-errors.c +++ b/test/CodeGen/asm-errors.c @@ -1,4 +1,4 @@ -// RUN: not %clang_cc1 -triple i386-apple-darwin10 -emit-obj %s > %t 2>&1 +// RUN: not %clang_cc1 -triple i386-apple-darwin10 -emit-obj %s -o /dev/null > %t 2>&1 // RUN: FileCheck %s < %t int test1(int X) { diff --git a/test/CodeGen/asm-inout.c b/test/CodeGen/asm-inout.c new file mode 100644 index 0000000..f042766 --- /dev/null +++ b/test/CodeGen/asm-inout.c @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s +// PR3800 +int *foo(void); + +// CHECK: @test1 +void test1() { + // CHECK: [[REGCALLRESULT:%[a-zA-Z0-9\.]+]] = call i32* @foo() + // CHECK: call void asm "foobar", "=*m,*m,~{dirflag},~{fpsr},~{flags}"(i32* [[REGCALLRESULT]], i32* [[REGCALLRESULT]]) + asm ("foobar" : "+m"(*foo())); +} + +// CHECK: @test2 +void test2() { + // CHECK: [[REGCALLRESULT:%[a-zA-Z0-9\.]+]] = call i32* @foo() + // CHECK: load i32* [[REGCALLRESULT]] + // CHECK: call i32 asm + // CHECK: store i32 {{%[a-zA-Z0-9\.]+}}, i32* [[REGCALLRESULT]] + asm ("foobar" : "+r"(*foo())); +} diff --git a/test/CodeGen/asm.c b/test/CodeGen/asm.c index 5077028..eb11285 100644 --- a/test/CodeGen/asm.c +++ b/test/CodeGen/asm.c @@ -168,3 +168,25 @@ float t21(long double x) { // CHECK: call x86_fp80 asm sideeffect "frndint" // CHECK-NEXT: fptrunc x86_fp80 {{.*}} to float } + +// <rdar://problem/8348447> - accept 'l' constraint +unsigned char t22(unsigned char a, unsigned char b) { + unsigned int la = a; + unsigned int lb = b; + unsigned int bigres; + unsigned char res; + __asm__ ("0:\n1:\n" : [bigres] "=la"(bigres) : [la] "0"(la), [lb] "c"(lb) : + "edx", "cc"); + res = bigres; + return res; +} + +// <rdar://problem/8348447> - accept 'l' constraint +unsigned char t23(unsigned char a, unsigned char b) { + unsigned int la = a; + unsigned int lb = b; + unsigned char res; + __asm__ ("0:\n1:\n" : [res] "=la"(res) : [la] "0"(la), [lb] "c"(lb) : + "edx", "cc"); + return res; +} diff --git a/test/CodeGen/asm_arm.c b/test/CodeGen/asm_arm.c index aac47d5..633bf55 100644 --- a/test/CodeGen/asm_arm.c +++ b/test/CodeGen/asm_arm.c @@ -30,3 +30,25 @@ void test4(float *a, float *b) { "vst1.32 {q4}, [%0,:128] \n\t" :: "r"(a), "r"(b)); } + +// {sp, lr, pc} are the canonical names for {r13, r14, r15}. +// +// CHECK: @test5 +// CHECK: call void asm sideeffect "", "~{sp},~{lr},~{pc},~{sp},~{lr},~{pc}"() +void test5() { + __asm__("" : : : "r13", "r14", "r15", "sp", "lr", "pc"); +} + +// CHECK: @test6 +// CHECK: call void asm sideeffect "", " +// CHECK: ~{s0},~{s1},~{s2},~{s3},~{s4},~{s5},~{s6},~{s7}, +// CHECK: ~{s8},~{s9},~{s10},~{s11},~{s12},~{s13},~{s14},~{s15}, +// CHECK: ~{s16},~{s17},~{s18},~{s19},~{s20},~{s21},~{s22},~{s23}, +// CHECK: ~{s24},~{s25},~{s26},~{s27},~{s28},~{s29},~{s30},~{s31}"() +void test6() { + __asm__("" : : : + "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", + "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", + "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", + "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31"); +} diff --git a/test/CodeGen/atomic.c b/test/CodeGen/atomic.c index aa5aa15..d0a7e04 100644 --- a/test/CodeGen/atomic.c +++ b/test/CodeGen/atomic.c @@ -1,5 +1,5 @@ // RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin9 > %t1 -// RUN: grep @llvm.memory.barrier %t1 | count 38 +// RUN: grep @llvm.memory.barrier %t1 | count 42 // RUN: grep @llvm.atomic.load.add.i32 %t1 | count 3 // RUN: grep @llvm.atomic.load.sub.i8 %t1 | count 2 // RUN: grep @llvm.atomic.load.min.i32 %t1 @@ -7,7 +7,7 @@ // RUN: grep @llvm.atomic.load.umin.i32 %t1 // RUN: grep @llvm.atomic.load.umax.i32 %t1 // RUN: grep @llvm.atomic.swap.i32 %t1 -// RUN: grep @llvm.atomic.cmp.swap.i32 %t1 | count 4 +// RUN: grep @llvm.atomic.cmp.swap.i32 %t1 | count 5 // RUN: grep @llvm.atomic.load.and.i32 %t1 // RUN: grep @llvm.atomic.load.or.i8 %t1 // RUN: grep @llvm.atomic.load.xor.i8 %t1 @@ -19,6 +19,7 @@ int atomic(void) int old; int val = 1; char valc = 1; + _Bool valb = 0; unsigned int uval = 1; int cmp = 0; @@ -43,10 +44,18 @@ int atomic(void) __sync_val_compare_and_swap((void **)0, (void *)0, (void *)0); - + if ( __sync_val_compare_and_swap(&valb, 0, 1)) { + old = 42; + } + __sync_bool_compare_and_swap((void **)0, (void *)0, (void *)0); __sync_lock_release(&val); __sync_synchronize (); return old; } + +void release_return(int *lock) { + // Ensure this is actually returning void all the way through. + return __sync_lock_release(lock); +} diff --git a/test/CodeGen/available-externally-suppress.c b/test/CodeGen/available-externally-suppress.c index c3b7a21..747d3cd 100644 --- a/test/CodeGen/available-externally-suppress.c +++ b/test/CodeGen/available-externally-suppress.c @@ -10,3 +10,18 @@ inline void f0(int y) { x = y; } void test() { f0(17); } + +inline int __attribute__((always_inline)) f1(int x) { + int blarg = 0; + for (int i = 0; i < x; ++i) + blarg = blarg + x * i; + return blarg; +} + +// CHECK: @test1 +int test1(int x) { + // CHECK: br i1 + // CHECK-NOT: call + // CHECK: ret i32 + return f1(x); +} diff --git a/test/CodeGen/bitfield-2.c b/test/CodeGen/bitfield-2.c index e91859f..8de432f 100644 --- a/test/CodeGen/bitfield-2.c +++ b/test/CodeGen/bitfield-2.c @@ -12,7 +12,7 @@ // CHECK-RECORD: Record: struct s0 // CHECK-RECORD: Layout: <CGRecordLayout // CHECK-RECORD: LLVMType:<{ [3 x i8] }> -// CHECK-RECORD: ContainsPointerToDataMember:0 +// CHECK-RECORD: IsZeroInitializable:1 // CHECK-RECORD: BitFields:[ // CHECK-RECORD: <CGBitFieldInfo Size:24 IsSigned:1 // CHECK-RECORD: NumComponents:2 Components: [ @@ -57,7 +57,7 @@ unsigned long long test_0() { // CHECK-RECORD: Record: struct s1 // CHECK-RECORD: Layout: <CGRecordLayout // CHECK-RECORD: LLVMType:<{ [2 x i8], i8 }> -// CHECK-RECORD: ContainsPointerToDataMember:0 +// CHECK-RECORD: IsZeroInitializable:1 // CHECK-RECORD: BitFields:[ // CHECK-RECORD: <CGBitFieldInfo Size:10 IsSigned:1 // CHECK-RECORD: NumComponents:1 Components: [ @@ -114,7 +114,7 @@ unsigned long long test_1() { // CHECK-RECORD: Record: union u2 // CHECK-RECORD: Layout: <CGRecordLayout // CHECK-RECORD: LLVMType:<{ i8 }> -// CHECK-RECORD: ContainsPointerToDataMember:0 +// CHECK-RECORD: IsZeroInitializable:1 // CHECK-RECORD: BitFields:[ // CHECK-RECORD: <CGBitFieldInfo Size:3 IsSigned:0 // CHECK-RECORD: NumComponents:1 Components: [ @@ -289,7 +289,7 @@ _Bool test_6() { // CHECK-RECORD: Record: struct s7 // CHECK-RECORD: Layout: <CGRecordLayout // CHECK-RECORD: LLVMType:{ i32, i32, i32, i8, [3 x i8], [4 x i8], [12 x i8] } -// CHECK-RECORD: ContainsPointerToDataMember:0 +// CHECK-RECORD: IsZeroInitializable:1 // CHECK-RECORD: BitFields:[ // CHECK-RECORD: <CGBitFieldInfo Size:5 IsSigned:1 // CHECK-RECORD: NumComponents:1 Components: [ diff --git a/test/CodeGen/block-decl-merging.c b/test/CodeGen/block-decl-merging.c new file mode 100644 index 0000000..1e7a9f4 --- /dev/null +++ b/test/CodeGen/block-decl-merging.c @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -triple i386-apple-darwin10 -fblocks -emit-llvm -o - %s | \ +// RUN: FileCheck %s + +// CHECK: @_NSConcreteGlobalBlock = extern_weak global +extern void * _NSConcreteStackBlock[32] __attribute__((weak_import)); +// CHECK: @_NSConcreteStackBlock = extern_weak global +extern void * _NSConcreteGlobalBlock[32] __attribute__((weak_import)); +extern void _Block_object_dispose(const void *, const int) __attribute__((weak_import)); +// CHECK: declare extern_weak void @_Block_object_assign +extern void _Block_object_assign(void *, const void *, const int) __attribute__((weak_import)); +// CHECK: declare extern_weak void @_Block_object_dispose + +void *x = ^(){}; + +void f1(void (^a0)(void)); + +void f0() { + __block int x; + f1(^(void){ x = 1; }); +} diff --git a/test/CodeGen/blockstret.c b/test/CodeGen/blockstret.c index 09292b8..f630f22 100644 --- a/test/CodeGen/blockstret.c +++ b/test/CodeGen/blockstret.c @@ -98,8 +98,8 @@ int main(int argc, char *argv[]) { /* desired global flags: 1879048192 desired stack flags: 1610612736 -should be non-zero: 0 -should be non-zero: 0 +should be non-zero: 1 +should be non-zero: 1 should be non-zero: 1 should be zero: 0 diff --git a/test/CodeGen/builtin-expect.c b/test/CodeGen/builtin-expect.c new file mode 100644 index 0000000..8f02c4d --- /dev/null +++ b/test/CodeGen/builtin-expect.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s + +int x; +int y(void); +void foo(); +void FUNC() { +// CHECK: [[call:%.*]] = call i32 @y + if (__builtin_expect (x, y())) + foo (); +} + diff --git a/test/CodeGen/builtins-arm.c b/test/CodeGen/builtins-arm.c index 546f57a..09df1ef 100644 --- a/test/CodeGen/builtins-arm.c +++ b/test/CodeGen/builtins-arm.c @@ -9,4 +9,4 @@ void f1(char *a, char *b) { __clear_cache(a,b); } -// CHECK: call void @__clear_cache +// CHECK: call {{.*}} @__clear_cache diff --git a/test/CodeGen/builtins-ppc-altivec.c b/test/CodeGen/builtins-ppc-altivec.c index 6f65866..8627499 100644 --- a/test/CodeGen/builtins-ppc-altivec.c +++ b/test/CodeGen/builtins-ppc-altivec.c @@ -1,31 +1,25 @@ // RUN: %clang_cc1 -faltivec -triple powerpc-unknown-unknown -emit-llvm %s -o - | FileCheck %s -// TODO: uncomment -/* vector bool char vbc = { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 }; */ +vector bool char vbc = { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 }; vector signed char vsc = { 1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16 }; vector unsigned char vuc = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; -// TODO: uncomment -/* vector bool short vbs = { 1, 0, 1, 0, 1, 0, 1, 0 }; */ +vector bool short vbs = { 1, 0, 1, 0, 1, 0, 1, 0 }; vector short vs = { -1, 2, -3, 4, -5, 6, -7, 8 }; vector unsigned short vus = { 1, 2, 3, 4, 5, 6, 7, 8 }; -// TODO: uncomment -/* vector bool int vbi = { 1, 0, 1, 0 }; */ +vector pixel vp = { 1, 2, 3, 4, 5, 6, 7, 8 }; +vector bool int vbi = { 1, 0, 1, 0 }; vector int vi = { -1, 2, -3, 4 }; vector unsigned int vui = { 1, 2, 3, 4 }; vector float vf = { -1.5, 2.5, -3.5, 4.5 }; -// TODO: uncomment -/* vector bool char res_vbc; */ +vector bool char res_vbc; vector signed char res_vsc; vector unsigned char res_vuc; -// TODO: uncomment -/* vector bool short res_vbs; */ +vector bool short res_vbs; vector short res_vs; vector unsigned short res_vus; -// TODO: uncomment vector pixel res_vp; -// TODO: uncomment -/* vector bool int res_vbi; */ +vector bool int res_vbi; vector int res_vi; vector unsigned int res_vui; vector float res_vf; @@ -40,8 +34,8 @@ float param_f; int res_i; -int test1() { -// CHECK: define i32 @test1 +// CHECK: define void @test1 +void test1() { /* vec_abs */ vsc = vec_abs(vsc); // CHECK: sub nsw <16 x i8> zeroinitializer @@ -67,18 +61,42 @@ int test1() { /* vec_add */ res_vsc = vec_add(vsc, vsc); // CHECK: add nsw <16 x i8> + res_vsc = vec_add(vbc, vsc); // CHECK: add nsw <16 x i8> + res_vsc = vec_add(vsc, vbc); // CHECK: add nsw <16 x i8> res_vuc = vec_add(vuc, vuc); // CHECK: add <16 x i8> + res_vuc = vec_add(vbc, vuc); // CHECK: add <16 x i8> + res_vuc = vec_add(vuc, vbc); // CHECK: add <16 x i8> res_vs = vec_add(vs, vs); // CHECK: add nsw <8 x i16> + res_vs = vec_add(vbs, vs); // CHECK: add nsw <8 x i16> + res_vs = vec_add(vs, vbs); // CHECK: add nsw <8 x i16> res_vus = vec_add(vus, vus); // CHECK: add <8 x i16> + res_vus = vec_add(vbs, vus); // CHECK: add <8 x i16> + res_vus = vec_add(vus, vbs); // CHECK: add <8 x i16> res_vi = vec_add(vi, vi); // CHECK: add nsw <4 x i32> + res_vi = vec_add(vbi, vi); // CHECK: add nsw <4 x i32> + res_vi = vec_add(vi, vbi); // CHECK: add nsw <4 x i32> res_vui = vec_add(vui, vui); // CHECK: add <4 x i32> + res_vui = vec_add(vbi, vui); // CHECK: add <4 x i32> + res_vui = vec_add(vui, vbi); // CHECK: add <4 x i32> res_vf = vec_add(vf, vf); // CHECK: fadd <4 x float> res_vsc = vec_vaddubm(vsc, vsc); // CHECK: add nsw <16 x i8> + res_vsc = vec_vaddubm(vbc, vsc); // CHECK: add nsw <16 x i8> + res_vsc = vec_vaddubm(vsc, vbc); // CHECK: add nsw <16 x i8> res_vuc = vec_vaddubm(vuc, vuc); // CHECK: add <16 x i8> + res_vuc = vec_vaddubm(vbc, vuc); // CHECK: add <16 x i8> + res_vuc = vec_vaddubm(vuc, vbc); // CHECK: add <16 x i8> res_vs = vec_vadduhm(vs, vs); // CHECK: add nsw <8 x i16> + res_vs = vec_vadduhm(vbs, vs); // CHECK: add nsw <8 x i16> + res_vs = vec_vadduhm(vs, vbs); // CHECK: add nsw <8 x i16> res_vus = vec_vadduhm(vus, vus); // CHECK: add <8 x i16> + res_vus = vec_vadduhm(vbs, vus); // CHECK: add <8 x i16> + res_vus = vec_vadduhm(vus, vbs); // CHECK: add <8 x i16> res_vi = vec_vadduwm(vi, vi); // CHECK: add nsw <4 x i32> + res_vi = vec_vadduwm(vbi, vi); // CHECK: add nsw <4 x i32> + res_vi = vec_vadduwm(vi, vbi); // CHECK: add nsw <4 x i32> res_vui = vec_vadduwm(vui, vui); // CHECK: add <4 x i32> + res_vui = vec_vadduwm(vbi, vui); // CHECK: add <4 x i32> + res_vui = vec_vadduwm(vui, vbi); // CHECK: add <4 x i32> res_vf = vec_vaddfp(vf, vf); // CHECK: fadd <4 x float> /* vec_addc */ @@ -87,80 +105,231 @@ int test1() { /* vec_adds */ res_vsc = vec_adds(vsc, vsc); // CHECK: @llvm.ppc.altivec.vaddsbs + res_vsc = vec_adds(vbc, vsc); // CHECK: @llvm.ppc.altivec.vaddsbs + res_vsc = vec_adds(vsc, vbc); // CHECK: @llvm.ppc.altivec.vaddsbs res_vuc = vec_adds(vuc, vuc); // CHECK: @llvm.ppc.altivec.vaddubs + res_vuc = vec_adds(vbc, vuc); // CHECK: @llvm.ppc.altivec.vaddubs + res_vuc = vec_adds(vuc, vbc); // CHECK: @llvm.ppc.altivec.vaddubs res_vs = vec_adds(vs, vs); // CHECK: @llvm.ppc.altivec.vaddshs + res_vs = vec_adds(vbs, vs); // CHECK: @llvm.ppc.altivec.vaddshs + res_vs = vec_adds(vs, vbs); // CHECK: @llvm.ppc.altivec.vaddshs res_vus = vec_adds(vus, vus); // CHECK: @llvm.ppc.altivec.vadduhs + res_vus = vec_adds(vbs, vus); // CHECK: @llvm.ppc.altivec.vadduhs + res_vus = vec_adds(vus, vbs); // CHECK: @llvm.ppc.altivec.vadduhs res_vi = vec_adds(vi, vi); // CHECK: @llvm.ppc.altivec.vaddsws + res_vi = vec_adds(vbi, vi); // CHECK: @llvm.ppc.altivec.vaddsws + res_vi = vec_adds(vi, vbi); // CHECK: @llvm.ppc.altivec.vaddsws res_vui = vec_adds(vui, vui); // CHECK: @llvm.ppc.altivec.vadduws + res_vui = vec_adds(vbi, vui); // CHECK: @llvm.ppc.altivec.vadduws + res_vui = vec_adds(vui, vbi); // CHECK: @llvm.ppc.altivec.vadduws res_vsc = vec_vaddsbs(vsc, vsc); // CHECK: @llvm.ppc.altivec.vaddsbs + res_vsc = vec_vaddsbs(vbc, vsc); // CHECK: @llvm.ppc.altivec.vaddsbs + res_vsc = vec_vaddsbs(vsc, vbc); // CHECK: @llvm.ppc.altivec.vaddsbs res_vuc = vec_vaddubs(vuc, vuc); // CHECK: @llvm.ppc.altivec.vaddubs + res_vuc = vec_vaddubs(vbc, vuc); // CHECK: @llvm.ppc.altivec.vaddubs + res_vuc = vec_vaddubs(vuc, vbc); // CHECK: @llvm.ppc.altivec.vaddubs res_vs = vec_vaddshs(vs, vs); // CHECK: @llvm.ppc.altivec.vaddshs + res_vs = vec_vaddshs(vbs, vs); // CHECK: @llvm.ppc.altivec.vaddshs + res_vs = vec_vaddshs(vs, vbs); // CHECK: @llvm.ppc.altivec.vaddshs res_vus = vec_vadduhs(vus, vus); // CHECK: @llvm.ppc.altivec.vadduhs + res_vus = vec_vadduhs(vbs, vus); // CHECK: @llvm.ppc.altivec.vadduhs + res_vus = vec_vadduhs(vus, vbs); // CHECK: @llvm.ppc.altivec.vadduhs res_vi = vec_vaddsws(vi, vi); // CHECK: @llvm.ppc.altivec.vaddsws + res_vi = vec_vaddsws(vbi, vi); // CHECK: @llvm.ppc.altivec.vaddsws + res_vi = vec_vaddsws(vi, vbi); // CHECK: @llvm.ppc.altivec.vaddsws res_vui = vec_vadduws(vui, vui); // CHECK: @llvm.ppc.altivec.vadduws + res_vui = vec_vadduws(vbi, vui); // CHECK: @llvm.ppc.altivec.vadduws + res_vui = vec_vadduws(vui, vbi); // CHECK: @llvm.ppc.altivec.vadduws /* vec_and */ res_vsc = vec_and(vsc, vsc); // CHECK: and <16 x i8> + res_vsc = vec_and(vbc, vsc); // CHECK: and <16 x i8> + res_vsc = vec_and(vsc, vbc); // CHECK: and <16 x i8> res_vuc = vec_and(vuc, vuc); // CHECK: and <16 x i8> + res_vuc = vec_and(vbc, vuc); // CHECK: and <16 x i8> + res_vuc = vec_and(vuc, vbc); // CHECK: and <16 x i8> + res_vbc = vec_and(vbc, vbc); // CHECK: and <16 x i8> res_vs = vec_and(vs, vs); // CHECK: and <8 x i16> + res_vs = vec_and(vbs, vs); // CHECK: and <8 x i16> + res_vs = vec_and(vs, vbs); // CHECK: and <8 x i16> res_vus = vec_and(vus, vus); // CHECK: and <8 x i16> + res_vus = vec_and(vbs, vus); // CHECK: and <8 x i16> + res_vus = vec_and(vus, vbs); // CHECK: and <8 x i16> + res_vbs = vec_and(vbs, vbs); // CHECK: and <8 x i16> res_vi = vec_and(vi, vi); // CHECK: and <4 x i32> + res_vi = vec_and(vbi, vi); // CHECK: and <4 x i32> + res_vi = vec_and(vi, vbi); // CHECK: and <4 x i32> res_vui = vec_and(vui, vui); // CHECK: and <4 x i32> + res_vui = vec_and(vbi, vui); // CHECK: and <4 x i32> + res_vui = vec_and(vui, vbi); // CHECK: and <4 x i32> + res_vbi = vec_and(vbi, vbi); // CHECK: and <4 x i32> res_vsc = vec_vand(vsc, vsc); // CHECK: and <16 x i8> + res_vsc = vec_vand(vbc, vsc); // CHECK: and <16 x i8> + res_vsc = vec_vand(vsc, vbc); // CHECK: and <16 x i8> res_vuc = vec_vand(vuc, vuc); // CHECK: and <16 x i8> + res_vuc = vec_vand(vbc, vuc); // CHECK: and <16 x i8> + res_vuc = vec_vand(vuc, vbc); // CHECK: and <16 x i8> + res_vbc = vec_vand(vbc, vbc); // CHECK: and <16 x i8> res_vs = vec_vand(vs, vs); // CHECK: and <8 x i16> + res_vs = vec_vand(vbs, vs); // CHECK: and <8 x i16> + res_vs = vec_vand(vs, vbs); // CHECK: and <8 x i16> res_vus = vec_vand(vus, vus); // CHECK: and <8 x i16> + res_vus = vec_vand(vbs, vus); // CHECK: and <8 x i16> + res_vus = vec_vand(vus, vbs); // CHECK: and <8 x i16> + res_vbs = vec_vand(vbs, vbs); // CHECK: and <8 x i16> res_vi = vec_vand(vi, vi); // CHECK: and <4 x i32> + res_vi = vec_vand(vbi, vi); // CHECK: and <4 x i32> + res_vi = vec_vand(vi, vbi); // CHECK: and <4 x i32> res_vui = vec_vand(vui, vui); // CHECK: and <4 x i32> + res_vui = vec_vand(vbi, vui); // CHECK: and <4 x i32> + res_vui = vec_vand(vui, vbi); // CHECK: and <4 x i32> + res_vbi = vec_vand(vbi, vbi); // CHECK: and <4 x i32> /* vec_andc */ res_vsc = vec_andc(vsc, vsc); // CHECK: xor <16 x i8> // CHECK: and <16 x i8> + res_vsc = vec_andc(vbc, vsc); // CHECK: xor <16 x i8> + // CHECK: and <16 x i8> + + res_vsc = vec_andc(vsc, vbc); // CHECK: xor <16 x i8> + // CHECK: and <16 x i8> + res_vuc = vec_andc(vuc, vuc); // CHECK: xor <16 x i8> // CHECK: and <16 x i8> + res_vuc = vec_andc(vbc, vuc); // CHECK: xor <16 x i8> + // CHECK: and <16 x i8> + + res_vuc = vec_andc(vuc, vbc); // CHECK: xor <16 x i8> + // CHECK: and <16 x i8> + + res_vbc = vec_andc(vbc, vbc); // CHECK: xor <16 x i8> + // CHECK: and <16 x i8> + res_vs = vec_andc(vs, vs); // CHECK: xor <8 x i16> // CHECK: and <8 x i16> + res_vs = vec_andc(vbs, vs); // CHECK: xor <8 x i16> + // CHECK: and <8 x i16> + + res_vs = vec_andc(vs, vbs); // CHECK: xor <8 x i16> + // CHECK: and <8 x i16> + res_vus = vec_andc(vus, vus); // CHECK: xor <8 x i16> // CHECK: and <8 x i16> + res_vus = vec_andc(vbs, vus); // CHECK: xor <8 x i16> + // CHECK: and <8 x i16> + + res_vus = vec_andc(vus, vbs); // CHECK: xor <8 x i16> + // CHECK: and <8 x i16> + + res_vbs = vec_andc(vbs, vbs); // CHECK: xor <8 x i16> + // CHECK: and <8 x i16> + res_vi = vec_andc(vi, vi); // CHECK: xor <4 x i32> // CHECK: and <4 x i32> + res_vi = vec_andc(vbi, vi); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + + res_vi = vec_andc(vi, vbi); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + res_vui = vec_andc(vui, vui); // CHECK: xor <4 x i32> // CHECK: and <4 x i32> + res_vui = vec_andc(vbi, vui); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + + res_vui = vec_andc(vui, vbi); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + res_vf = vec_andc(vf, vf); // CHECK: xor <4 x i32> // CHECK: and <4 x i32> + res_vf = vec_andc(vbi, vf); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + + res_vf = vec_andc(vf, vbi); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + res_vsc = vec_vandc(vsc, vsc); // CHECK: xor <16 x i8> // CHECK: and <16 x i8> + res_vsc = vec_vandc(vbc, vsc); // CHECK: xor <16 x i8> + // CHECK: and <16 x i8> + + res_vsc = vec_vandc(vsc, vbc); // CHECK: xor <16 x i8> + // CHECK: and <16 x i8> + res_vuc = vec_vandc(vuc, vuc); // CHECK: xor <16 x i8> // CHECK: and <16 x i8> + res_vuc = vec_vandc(vbc, vuc); // CHECK: xor <16 x i8> + // CHECK: and <16 x i8> + + res_vuc = vec_vandc(vuc, vbc); // CHECK: xor <16 x i8> + // CHECK: and <16 x i8> + + res_vbc = vec_vandc(vbc, vbc); // CHECK: xor <16 x i8> + // CHECK: and <16 x i8> + res_vs = vec_vandc(vs, vs); // CHECK: xor <8 x i16> // CHECK: and <8 x i16> + res_vs = vec_vandc(vbs, vs); // CHECK: xor <8 x i16> + // CHECK: and <8 x i16> + + res_vs = vec_vandc(vs, vbs); // CHECK: xor <8 x i16> + // CHECK: and <8 x i16> + res_vus = vec_vandc(vus, vus); // CHECK: xor <8 x i16> // CHECK: and <8 x i16> + res_vus = vec_vandc(vbs, vus); // CHECK: xor <8 x i16> + // CHECK: and <8 x i16> + + res_vus = vec_vandc(vus, vbs); // CHECK: xor <8 x i16> + // CHECK: and <8 x i16> + + res_vbs = vec_vandc(vbs, vbs); // CHECK: xor <8 x i16> + // CHECK: and <8 x i16> + res_vi = vec_vandc(vi, vi); // CHECK: xor <4 x i32> // CHECK: and <4 x i32> + res_vi = vec_vandc(vbi, vi); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + + res_vi = vec_vandc(vi, vbi); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + res_vui = vec_vandc(vui, vui); // CHECK: xor <4 x i32> // CHECK: and <4 x i32> + res_vui = vec_vandc(vbi, vui); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + + res_vui = vec_vandc(vui, vbi); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + res_vf = vec_vandc(vf, vf); // CHECK: xor <4 x i32> // CHECK: and <4 x i32> + + res_vf = vec_vandc(vbi, vf); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + + res_vf = vec_vandc(vf, vbi); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + } -// CHECK: i32 @test2 -int test2() { +// CHECK: define void @test2 +void test2() { /* vec_avg */ - res_vsc = vec_avg(vsc, vsc); // CHECK: call {{.*}}@llvm.ppc.altivec.vavgsb + res_vsc = vec_avg(vsc, vsc); // CHECK: @llvm.ppc.altivec.vavgsb res_vuc = vec_avg(vuc, vuc); // CHECK: @llvm.ppc.altivec.vavgub res_vs = vec_avg(vs, vs); // CHECK: @llvm.ppc.altivec.vavgsh res_vus = vec_avg(vus, vus); // CHECK: @llvm.ppc.altivec.vavguh @@ -182,53 +351,52 @@ int test2() { res_vi = vec_vcmpbfp(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpbfp /* vec_cmpeq */ - vsc = vec_cmpeq(vsc, vsc); // CHCK: call {{.*}}@llvm.ppc.altivec.vcmpequb - vuc = vec_cmpeq(vuc, vuc); // CHCK: @llvm.ppc.altivec.vcmpequb - vs = vec_cmpeq(vs, vs); // CHCK: @llvm.ppc.altivec.vcmpequh - vs = vec_cmpeq(vus, vus); // CHCK: @llvm.ppc.altivec.vcmpequh - vi = vec_cmpeq(vi, vi); // CHCK: @llvm.ppc.altivec.vcmpequw - vui = vec_cmpeq(vui, vui); // CHCK: @llvm.ppc.altivec.vcmpequw - vf = vec_cmpeq(vf, vf); // CHCK: @llvm.ppc.altivec.vcmpeqfp + res_vbc = vec_cmpeq(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb + res_vbc = vec_cmpeq(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb + res_vbs = vec_cmpeq(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh + res_vbs = vec_cmpeq(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpequh + res_vbi = vec_cmpeq(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw + res_vbi = vec_cmpeq(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpequw + res_vbi = vec_cmpeq(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp /* vec_cmpge */ - vf = vec_cmpge(vf, vf); // CHCK: @llvm.ppc.altivec.vcmpgefp - vf = vec_vcmpgefp(vf, vf); // CHCK: call {{.*}}@llvm.ppc.altivec.vcmpgefp - + res_vbi = vec_cmpge(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp + res_vbi = vec_vcmpgefp(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp } -// CHECK: define i32 @test5 -int test5() { +// CHECK: define void @test5 +void test5() { /* vec_cmpgt */ - vsc = vec_cmpgt(vsc, vsc); // CHECK: call {{.*}}@llvm.ppc.altivec.vcmpgtsb - vuc = vec_cmpgt(vuc, vuc); // CHECK: call {{.*}}@llvm.ppc.altivec.vcmpgtub - vs = vec_cmpgt(vs, vs); // CHECK: call {{.*}}@llvm.ppc.altivec.vcmpgtsh - vus = vec_cmpgt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh - vi = vec_cmpgt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw - vui = vec_cmpgt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw - vf = vec_cmpgt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp - vsc = vec_vcmpgtsb(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb - vuc = vec_vcmpgtub(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub - vs = vec_vcmpgtsh(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh - vus = vec_vcmpgtuh(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh - vi = vec_vcmpgtsw(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw - vui = vec_vcmpgtuw(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw - vf = vec_vcmpgtfp(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp + res_vbc = vec_cmpgt(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb + res_vbc = vec_cmpgt(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub + res_vbs = vec_cmpgt(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh + res_vbs = vec_cmpgt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh + res_vbi = vec_cmpgt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw + res_vbi = vec_cmpgt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw + res_vbi = vec_cmpgt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp + res_vbc = vec_vcmpgtsb(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb + res_vbc = vec_vcmpgtub(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub + res_vbs = vec_vcmpgtsh(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh + res_vbs = vec_vcmpgtuh(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh + res_vbi = vec_vcmpgtsw(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw + res_vbi = vec_vcmpgtuw(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw + res_vbi = vec_vcmpgtfp(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp /* vec_cmple */ - vf = vec_cmple(vf, vf); // CHECK: call {{.*}}@llvm.ppc.altivec.vcmpgefp + res_vbi = vec_cmple(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp } -// CHECK: define i32 @test6 -int test6() { +// CHECK: define void @test6 +void test6() { /* vec_cmplt */ - vsc =vec_cmplt(vsc, vsc); // CHECK: call {{.*}}@llvm.ppc.altivec.vcmpgtsb - vsc =vec_cmplt(vuc, vuc); // CHECK: call {{.*}}@llvm.ppc.altivec.vcmpgtub - vs = vec_cmplt(vs, vs); // CHECK: call {{.*}}@llvm.ppc.altivec.vcmpgtsh - vs = vec_cmplt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh - vi = vec_cmplt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw - vui = vec_cmplt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw - vf = vec_cmplt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp + res_vbc = vec_cmplt(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb + res_vbc = vec_cmplt(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub + res_vbs = vec_cmplt(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh + res_vbs = vec_cmplt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh + res_vbi = vec_cmplt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw + res_vbi = vec_cmplt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw + res_vbi = vec_cmplt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp /* vec_ctf */ res_vf = vec_ctf(vi, param_i); // CHECK: @llvm.ppc.altivec.vcfsx @@ -275,28 +443,36 @@ int test6() { res_vsc = vec_ld(0, ¶m_sc); // CHECK: @llvm.ppc.altivec.lvx res_vuc = vec_ld(0, &vuc); // CHECK: @llvm.ppc.altivec.lvx res_vuc = vec_ld(0, ¶m_uc); // CHECK: @llvm.ppc.altivec.lvx + res_vbc = vec_ld(0, &vbc); // CHECK: @llvm.ppc.altivec.lvx res_vs = vec_ld(0, &vs); // CHECK: @llvm.ppc.altivec.lvx res_vs = vec_ld(0, ¶m_s); // CHECK: @llvm.ppc.altivec.lvx res_vus = vec_ld(0, &vus); // CHECK: @llvm.ppc.altivec.lvx res_vus = vec_ld(0, ¶m_us); // CHECK: @llvm.ppc.altivec.lvx + res_vbs = vec_ld(0, &vbs); // CHECK: @llvm.ppc.altivec.lvx + res_vp = vec_ld(0, &vp); // CHECK: @llvm.ppc.altivec.lvx res_vi = vec_ld(0, &vi); // CHECK: @llvm.ppc.altivec.lvx res_vi = vec_ld(0, ¶m_i); // CHECK: @llvm.ppc.altivec.lvx res_vui = vec_ld(0, &vui); // CHECK: @llvm.ppc.altivec.lvx res_vui = vec_ld(0, ¶m_ui); // CHECK: @llvm.ppc.altivec.lvx + res_vbi = vec_ld(0, &vbi); // CHECK: @llvm.ppc.altivec.lvx res_vf = vec_ld(0, &vf); // CHECK: @llvm.ppc.altivec.lvx res_vf = vec_ld(0, ¶m_f); // CHECK: @llvm.ppc.altivec.lvx res_vsc = vec_lvx(0, &vsc); // CHECK: @llvm.ppc.altivec.lvx res_vsc = vec_lvx(0, ¶m_sc); // CHECK: @llvm.ppc.altivec.lvx res_vuc = vec_lvx(0, &vuc); // CHECK: @llvm.ppc.altivec.lvx res_vuc = vec_lvx(0, ¶m_uc); // CHECK: @llvm.ppc.altivec.lvx + res_vbc = vec_lvx(0, &vbc); // CHECK: @llvm.ppc.altivec.lvx res_vs = vec_lvx(0, &vs); // CHECK: @llvm.ppc.altivec.lvx res_vs = vec_lvx(0, ¶m_s); // CHECK: @llvm.ppc.altivec.lvx res_vus = vec_lvx(0, &vus); // CHECK: @llvm.ppc.altivec.lvx res_vus = vec_lvx(0, ¶m_us); // CHECK: @llvm.ppc.altivec.lvx + res_vbs = vec_lvx(0, &vbs); // CHECK: @llvm.ppc.altivec.lvx + res_vp = vec_lvx(0, &vp); // CHECK: @llvm.ppc.altivec.lvx res_vi = vec_lvx(0, &vi); // CHECK: @llvm.ppc.altivec.lvx res_vi = vec_lvx(0, ¶m_i); // CHECK: @llvm.ppc.altivec.lvx res_vui = vec_lvx(0, &vui); // CHECK: @llvm.ppc.altivec.lvx res_vui = vec_lvx(0, ¶m_ui); // CHECK: @llvm.ppc.altivec.lvx + res_vbi = vec_lvx(0, &vbi); // CHECK: @llvm.ppc.altivec.lvx res_vf = vec_lvx(0, &vf); // CHECK: @llvm.ppc.altivec.lvx res_vf = vec_lvx(0, ¶m_f); // CHECK: @llvm.ppc.altivec.lvx @@ -321,28 +497,36 @@ int test6() { res_vsc = vec_ldl(0, ¶m_sc); // CHECK: @llvm.ppc.altivec.lvxl res_vuc = vec_ldl(0, &vuc); // CHECK: @llvm.ppc.altivec.lvxl res_vuc = vec_ldl(0, ¶m_uc); // CHECK: @llvm.ppc.altivec.lvxl + res_vbc = vec_ldl(0, &vbc); // CHECK: @llvm.ppc.altivec.lvxl res_vs = vec_ldl(0, &vs); // CHECK: @llvm.ppc.altivec.lvxl res_vs = vec_ldl(0, ¶m_s); // CHECK: @llvm.ppc.altivec.lvxl res_vus = vec_ldl(0, &vus); // CHECK: @llvm.ppc.altivec.lvxl res_vus = vec_ldl(0, ¶m_us); // CHECK: @llvm.ppc.altivec.lvxl + res_vbs = vec_ldl(0, &vbs); // CHECK: @llvm.ppc.altivec.lvxl + res_vp = vec_ldl(0, &vp); // CHECK: @llvm.ppc.altivec.lvxl res_vi = vec_ldl(0, &vi); // CHECK: @llvm.ppc.altivec.lvxl res_vi = vec_ldl(0, ¶m_i); // CHECK: @llvm.ppc.altivec.lvxl res_vui = vec_ldl(0, &vui); // CHECK: @llvm.ppc.altivec.lvxl res_vui = vec_ldl(0, ¶m_ui); // CHECK: @llvm.ppc.altivec.lvxl + res_vbi = vec_ldl(0, &vbi); // CHECK: @llvm.ppc.altivec.lvxl res_vf = vec_ldl(0, &vf); // CHECK: @llvm.ppc.altivec.lvxl res_vf = vec_ldl(0, ¶m_f); // CHECK: @llvm.ppc.altivec.lvxl res_vsc = vec_lvxl(0, &vsc); // CHECK: @llvm.ppc.altivec.lvxl res_vsc = vec_lvxl(0, ¶m_sc); // CHECK: @llvm.ppc.altivec.lvxl res_vuc = vec_lvxl(0, &vuc); // CHECK: @llvm.ppc.altivec.lvxl + res_vbc = vec_lvxl(0, &vbc); // CHECK: @llvm.ppc.altivec.lvxl res_vuc = vec_lvxl(0, ¶m_uc); // CHECK: @llvm.ppc.altivec.lvxl res_vs = vec_lvxl(0, &vs); // CHECK: @llvm.ppc.altivec.lvxl res_vs = vec_lvxl(0, ¶m_s); // CHECK: @llvm.ppc.altivec.lvxl res_vus = vec_lvxl(0, &vus); // CHECK: @llvm.ppc.altivec.lvxl res_vus = vec_lvxl(0, ¶m_us); // CHECK: @llvm.ppc.altivec.lvxl + res_vbs = vec_lvxl(0, &vbs); // CHECK: @llvm.ppc.altivec.lvxl + res_vp = vec_lvxl(0, &vp); // CHECK: @llvm.ppc.altivec.lvxl res_vi = vec_lvxl(0, &vi); // CHECK: @llvm.ppc.altivec.lvxl res_vi = vec_lvxl(0, ¶m_i); // CHECK: @llvm.ppc.altivec.lvxl res_vui = vec_lvxl(0, &vui); // CHECK: @llvm.ppc.altivec.lvxl res_vui = vec_lvxl(0, ¶m_ui); // CHECK: @llvm.ppc.altivec.lvxl + res_vbi = vec_lvxl(0, &vbi); // CHECK: @llvm.ppc.altivec.lvxl res_vf = vec_lvxl(0, &vf); // CHECK: @llvm.ppc.altivec.lvxl res_vf = vec_lvxl(0, ¶m_f); // CHECK: @llvm.ppc.altivec.lvxl @@ -366,50 +550,90 @@ int test6() { /* vec_max */ res_vsc = vec_max(vsc, vsc); // CHECK: @llvm.ppc.altivec.vmaxsb + res_vsc = vec_max(vbc, vsc); // CHECK: @llvm.ppc.altivec.vmaxsb + res_vsc = vec_max(vsc, vbc); // CHECK: @llvm.ppc.altivec.vmaxsb res_vuc = vec_max(vuc, vuc); // CHECK: @llvm.ppc.altivec.vmaxub + res_vuc = vec_max(vbc, vuc); // CHECK: @llvm.ppc.altivec.vmaxub + res_vuc = vec_max(vuc, vbc); // CHECK: @llvm.ppc.altivec.vmaxub res_vs = vec_max(vs, vs); // CHECK: @llvm.ppc.altivec.vmaxsh + res_vs = vec_max(vbs, vs); // CHECK: @llvm.ppc.altivec.vmaxsh + res_vs = vec_max(vs, vbs); // CHECK: @llvm.ppc.altivec.vmaxsh res_vus = vec_max(vus, vus); // CHECK: @llvm.ppc.altivec.vmaxuh + res_vus = vec_max(vbs, vus); // CHECK: @llvm.ppc.altivec.vmaxuh + res_vus = vec_max(vus, vbs); // CHECK: @llvm.ppc.altivec.vmaxuh res_vi = vec_max(vi, vi); // CHECK: @llvm.ppc.altivec.vmaxsw + res_vi = vec_max(vbi, vi); // CHECK: @llvm.ppc.altivec.vmaxsw + res_vi = vec_max(vi, vbi); // CHECK: @llvm.ppc.altivec.vmaxsw res_vui = vec_max(vui, vui); // CHECK: @llvm.ppc.altivec.vmaxuw + res_vui = vec_max(vbi, vui); // CHECK: @llvm.ppc.altivec.vmaxuw + res_vui = vec_max(vui, vbi); // CHECK: @llvm.ppc.altivec.vmaxuw res_vf = vec_max(vf, vf); // CHECK: @llvm.ppc.altivec.vmaxfp res_vsc = vec_vmaxsb(vsc, vsc); // CHECK: @llvm.ppc.altivec.vmaxsb + res_vsc = vec_vmaxsb(vbc, vsc); // CHECK: @llvm.ppc.altivec.vmaxsb + res_vsc = vec_vmaxsb(vsc, vbc); // CHECK: @llvm.ppc.altivec.vmaxsb res_vuc = vec_vmaxub(vuc, vuc); // CHECK: @llvm.ppc.altivec.vmaxub + res_vuc = vec_vmaxub(vbc, vuc); // CHECK: @llvm.ppc.altivec.vmaxub + res_vuc = vec_vmaxub(vuc, vbc); // CHECK: @llvm.ppc.altivec.vmaxub res_vs = vec_vmaxsh(vs, vs); // CHECK: @llvm.ppc.altivec.vmaxsh + res_vs = vec_vmaxsh(vbs, vs); // CHECK: @llvm.ppc.altivec.vmaxsh + res_vs = vec_vmaxsh(vs, vbs); // CHECK: @llvm.ppc.altivec.vmaxsh res_vus = vec_vmaxuh(vus, vus); // CHECK: @llvm.ppc.altivec.vmaxuh + res_vus = vec_vmaxuh(vbs, vus); // CHECK: @llvm.ppc.altivec.vmaxuh + res_vus = vec_vmaxuh(vus, vbs); // CHECK: @llvm.ppc.altivec.vmaxuh res_vi = vec_vmaxsw(vi, vi); // CHECK: @llvm.ppc.altivec.vmaxsw + res_vi = vec_vmaxsw(vbi, vi); // CHECK: @llvm.ppc.altivec.vmaxsw + res_vi = vec_vmaxsw(vi, vbi); // CHECK: @llvm.ppc.altivec.vmaxsw res_vui = vec_vmaxuw(vui, vui); // CHECK: @llvm.ppc.altivec.vmaxuw + res_vui = vec_vmaxuw(vbi, vui); // CHECK: @llvm.ppc.altivec.vmaxuw + res_vui = vec_vmaxuw(vui, vbi); // CHECK: @llvm.ppc.altivec.vmaxuw res_vf = vec_vmaxfp(vf, vf); // CHECK: @llvm.ppc.altivec.vmaxfp /* vec_mergeh */ res_vsc = vec_mergeh(vsc, vsc); // CHECK: @llvm.ppc.altivec.vperm res_vuc = vec_mergeh(vuc, vuc); // CHECK: @llvm.ppc.altivec.vperm + res_vbc = vec_mergeh(vbc, vbc); // CHECK: @llvm.ppc.altivec.vperm res_vs = vec_mergeh(vs, vs); // CHECK: @llvm.ppc.altivec.vperm + res_vp = vec_mergeh(vp, vp); // CHECK: @llvm.ppc.altivec.vperm res_vus = vec_mergeh(vus, vus); // CHECK: @llvm.ppc.altivec.vperm + res_vbs = vec_mergeh(vbs, vbs); // CHECK: @llvm.ppc.altivec.vperm res_vi = vec_mergeh(vi, vi); // CHECK: @llvm.ppc.altivec.vperm res_vui = vec_mergeh(vui, vui); // CHECK: @llvm.ppc.altivec.vperm + res_vbi = vec_mergeh(vbi, vbi); // CHECK: @llvm.ppc.altivec.vperm res_vf = vec_mergeh(vf, vf); // CHECK: @llvm.ppc.altivec.vperm res_vsc = vec_vmrghb(vsc, vsc); // CHECK: @llvm.ppc.altivec.vperm res_vuc = vec_vmrghb(vuc, vuc); // CHECK: @llvm.ppc.altivec.vperm + res_vbc = vec_vmrghb(vbc, vbc); // CHECK: @llvm.ppc.altivec.vperm res_vs = vec_vmrghh(vs, vs); // CHECK: @llvm.ppc.altivec.vperm + res_vp = vec_vmrghh(vp, vp); // CHECK: @llvm.ppc.altivec.vperm res_vus = vec_vmrghh(vus, vus); // CHECK: @llvm.ppc.altivec.vperm + res_vbs = vec_vmrghh(vbs, vbs); // CHECK: @llvm.ppc.altivec.vperm res_vi = vec_vmrghw(vi, vi); // CHECK: @llvm.ppc.altivec.vperm res_vui = vec_vmrghw(vui, vui); // CHECK: @llvm.ppc.altivec.vperm + res_vbi = vec_vmrghw(vbi, vbi); // CHECK: @llvm.ppc.altivec.vperm res_vf = vec_vmrghw(vf, vf); // CHECK: @llvm.ppc.altivec.vperm /* vec_mergel */ res_vsc = vec_mergel(vsc, vsc); // CHECK: @llvm.ppc.altivec.vperm res_vuc = vec_mergel(vuc, vuc); // CHECK: @llvm.ppc.altivec.vperm + res_vbc = vec_mergel(vbc, vbc); // CHECK: @llvm.ppc.altivec.vperm res_vs = vec_mergel(vs, vs); // CHECK: @llvm.ppc.altivec.vperm + res_vp = vec_mergeh(vp, vp); // CHECK: @llvm.ppc.altivec.vperm res_vus = vec_mergel(vus, vus); // CHECK: @llvm.ppc.altivec.vperm + res_vbs = vec_mergel(vbs, vbs); // CHECK: @llvm.ppc.altivec.vperm res_vi = vec_mergel(vi, vi); // CHECK: @llvm.ppc.altivec.vperm res_vui = vec_mergel(vui, vui); // CHECK: @llvm.ppc.altivec.vperm + res_vbi = vec_mergel(vbi, vbi); // CHECK: @llvm.ppc.altivec.vperm res_vf = vec_mergel(vf, vf); // CHECK: @llvm.ppc.altivec.vperm res_vsc = vec_vmrglb(vsc, vsc); // CHECK: @llvm.ppc.altivec.vperm res_vuc = vec_vmrglb(vuc, vuc); // CHECK: @llvm.ppc.altivec.vperm + res_vbc = vec_vmrglb(vbc, vbc); // CHECK: @llvm.ppc.altivec.vperm res_vs = vec_vmrglh(vs, vs); // CHECK: @llvm.ppc.altivec.vperm + res_vp = vec_vmrglh(vp, vp); // CHECK: @llvm.ppc.altivec.vperm res_vus = vec_vmrglh(vus, vus); // CHECK: @llvm.ppc.altivec.vperm + res_vbs = vec_vmrglh(vbs, vbs); // CHECK: @llvm.ppc.altivec.vperm res_vi = vec_vmrglw(vi, vi); // CHECK: @llvm.ppc.altivec.vperm res_vui = vec_vmrglw(vui, vui); // CHECK: @llvm.ppc.altivec.vperm + res_vbi = vec_vmrglw(vbi, vbi); // CHECK: @llvm.ppc.altivec.vperm res_vf = vec_vmrglw(vf, vf); // CHECK: @llvm.ppc.altivec.vperm /* vec_mfvscr */ @@ -417,18 +641,42 @@ int test6() { /* vec_min */ res_vsc = vec_min(vsc, vsc); // CHECK: @llvm.ppc.altivec.vminsb + res_vsc = vec_min(vbc, vsc); // CHECK: @llvm.ppc.altivec.vminsb + res_vsc = vec_min(vsc, vbc); // CHECK: @llvm.ppc.altivec.vminsb res_vuc = vec_min(vuc, vuc); // CHECK: @llvm.ppc.altivec.vminub + res_vuc = vec_min(vbc, vuc); // CHECK: @llvm.ppc.altivec.vminub + res_vuc = vec_min(vuc, vbc); // CHECK: @llvm.ppc.altivec.vminub res_vs = vec_min(vs, vs); // CHECK: @llvm.ppc.altivec.vminsh + res_vs = vec_min(vbs, vs); // CHECK: @llvm.ppc.altivec.vminsh + res_vs = vec_min(vs, vbs); // CHECK: @llvm.ppc.altivec.vminsh res_vus = vec_min(vus, vus); // CHECK: @llvm.ppc.altivec.vminuh + res_vus = vec_min(vbs, vus); // CHECK: @llvm.ppc.altivec.vminuh + res_vus = vec_min(vus, vbs); // CHECK: @llvm.ppc.altivec.vminuh res_vi = vec_min(vi, vi); // CHECK: @llvm.ppc.altivec.vminsw + res_vi = vec_min(vbi, vi); // CHECK: @llvm.ppc.altivec.vminsw + res_vi = vec_min(vi, vbi); // CHECK: @llvm.ppc.altivec.vminsw res_vui = vec_min(vui, vui); // CHECK: @llvm.ppc.altivec.vminuw + res_vui = vec_min(vbi, vui); // CHECK: @llvm.ppc.altivec.vminuw + res_vui = vec_min(vui, vbi); // CHECK: @llvm.ppc.altivec.vminuw res_vf = vec_min(vf, vf); // CHECK: @llvm.ppc.altivec.vminfp res_vsc = vec_vminsb(vsc, vsc); // CHECK: @llvm.ppc.altivec.vminsb + res_vsc = vec_vminsb(vbc, vsc); // CHECK: @llvm.ppc.altivec.vminsb + res_vsc = vec_vminsb(vsc, vbc); // CHECK: @llvm.ppc.altivec.vminsb res_vuc = vec_vminub(vuc, vuc); // CHECK: @llvm.ppc.altivec.vminub + res_vuc = vec_vminub(vbc, vuc); // CHECK: @llvm.ppc.altivec.vminub + res_vuc = vec_vminub(vuc, vbc); // CHECK: @llvm.ppc.altivec.vminub res_vs = vec_vminsh(vs, vs); // CHECK: @llvm.ppc.altivec.vminsh + res_vs = vec_vminsh(vbs, vs); // CHECK: @llvm.ppc.altivec.vminsh + res_vs = vec_vminsh(vs, vbs); // CHECK: @llvm.ppc.altivec.vminsh res_vus = vec_vminuh(vus, vus); // CHECK: @llvm.ppc.altivec.vminuh + res_vus = vec_vminuh(vbs, vus); // CHECK: @llvm.ppc.altivec.vminuh + res_vus = vec_vminuh(vus, vbs); // CHECK: @llvm.ppc.altivec.vminuh res_vi = vec_vminsw(vi, vi); // CHECK: @llvm.ppc.altivec.vminsw + res_vi = vec_vminsw(vbi, vi); // CHECK: @llvm.ppc.altivec.vminsw + res_vi = vec_vminsw(vi, vbi); // CHECK: @llvm.ppc.altivec.vminsw res_vui = vec_vminuw(vui, vui); // CHECK: @llvm.ppc.altivec.vminuw + res_vui = vec_vminuw(vbi, vui); // CHECK: @llvm.ppc.altivec.vminuw + res_vui = vec_vminuw(vui, vbi); // CHECK: @llvm.ppc.altivec.vminuw res_vf = vec_vminfp(vf, vf); // CHECK: @llvm.ppc.altivec.vminfp /* vec_mladd */ @@ -466,6 +714,15 @@ int test6() { /* vec_mtvscr */ vec_mtvscr(vsc); // CHECK: @llvm.ppc.altivec.mtvscr + vec_mtvscr(vuc); // CHECK: @llvm.ppc.altivec.mtvscr + vec_mtvscr(vbc); // CHECK: @llvm.ppc.altivec.mtvscr + vec_mtvscr(vs); // CHECK: @llvm.ppc.altivec.mtvscr + vec_mtvscr(vus); // CHECK: @llvm.ppc.altivec.mtvscr + vec_mtvscr(vbs); // CHECK: @llvm.ppc.altivec.mtvscr + vec_mtvscr(vp); // CHECK: @llvm.ppc.altivec.mtvscr + vec_mtvscr(vi); // CHECK: @llvm.ppc.altivec.mtvscr + vec_mtvscr(vui); // CHECK: @llvm.ppc.altivec.mtvscr + vec_mtvscr(vbi); // CHECK: @llvm.ppc.altivec.mtvscr /* vec_mule */ res_vs = vec_mule(vsc, vsc); // CHECK: @llvm.ppc.altivec.vmulesb @@ -498,18 +755,27 @@ int test6() { res_vuc = vec_nor(vuc, vuc); // CHECK: or <16 x i8> // CHECK: xor <16 x i8> + res_vuc = vec_nor(vbc, vbc); // CHECK: or <16 x i8> + // CHECK: xor <16 x i8> + res_vs = vec_nor(vs, vs); // CHECK: or <8 x i16> // CHECK: xor <8 x i16> res_vus = vec_nor(vus, vus); // CHECK: or <8 x i16> // CHECK: xor <8 x i16> + res_vus = vec_nor(vbs, vbs); // CHECK: or <8 x i16> + // CHECK: xor <8 x i16> + res_vi = vec_nor(vi, vi); // CHECK: or <4 x i32> // CHECK: xor <4 x i32> res_vui = vec_nor(vui, vui); // CHECK: or <4 x i32> // CHECK: xor <4 x i32> + res_vui = vec_nor(vbi, vbi); // CHECK: or <4 x i32> + // CHECK: xor <4 x i32> + res_vf = vec_nor(vf, vf); // CHECK: or <4 x i32> // CHECK: xor <4 x i32> @@ -519,46 +785,93 @@ int test6() { res_vuc = vec_vnor(vuc, vuc); // CHECK: or <16 x i8> // CHECK: xor <16 x i8> + res_vuc = vec_vnor(vbc, vbc); // CHECK: or <16 x i8> + // CHECK: xor <16 x i8> + res_vs = vec_vnor(vs, vs); // CHECK: or <8 x i16> // CHECK: xor <8 x i16> res_vus = vec_vnor(vus, vus); // CHECK: or <8 x i16> // CHECK: xor <8 x i16> + res_vus = vec_vnor(vbs, vbs); // CHECK: or <8 x i16> + // CHECK: xor <8 x i16> + res_vi = vec_vnor(vi, vi); // CHECK: or <4 x i32> // CHECK: xor <4 x i32> res_vui = vec_vnor(vui, vui); // CHECK: or <4 x i32> // CHECK: xor <4 x i32> + res_vui = vec_vnor(vbi, vbi); // CHECK: or <4 x i32> + // CHECK: xor <4 x i32> + res_vf = vec_vnor(vf, vf); // CHECK: or <4 x i32> // CHECK: xor <4 x i32> /* vec_or */ res_vsc = vec_or(vsc, vsc); // CHECK: or <16 x i8> + res_vsc = vec_or(vbc, vsc); // CHECK: or <16 x i8> + res_vsc = vec_or(vsc, vbc); // CHECK: or <16 x i8> res_vuc = vec_or(vuc, vuc); // CHECK: or <16 x i8> + res_vuc = vec_or(vbc, vuc); // CHECK: or <16 x i8> + res_vuc = vec_or(vuc, vbc); // CHECK: or <16 x i8> + res_vbc = vec_or(vbc, vbc); // CHECK: or <16 x i8> res_vs = vec_or(vs, vs); // CHECK: or <8 x i16> + res_vs = vec_or(vbs, vs); // CHECK: or <8 x i16> + res_vs = vec_or(vs, vbs); // CHECK: or <8 x i16> res_vus = vec_or(vus, vus); // CHECK: or <8 x i16> + res_vus = vec_or(vbs, vus); // CHECK: or <8 x i16> + res_vus = vec_or(vus, vbs); // CHECK: or <8 x i16> + res_vbs = vec_or(vbs, vbs); // CHECK: or <8 x i16> res_vi = vec_or(vi, vi); // CHECK: or <4 x i32> + res_vi = vec_or(vbi, vi); // CHECK: or <4 x i32> + res_vi = vec_or(vi, vbi); // CHECK: or <4 x i32> res_vui = vec_or(vui, vui); // CHECK: or <4 x i32> + res_vui = vec_or(vbi, vui); // CHECK: or <4 x i32> + res_vui = vec_or(vui, vbi); // CHECK: or <4 x i32> + res_vbi = vec_or(vbi, vbi); // CHECK: or <4 x i32> res_vf = vec_or(vf, vf); // CHECK: or <4 x i32> + res_vf = vec_or(vbi, vf); // CHECK: or <4 x i32> + res_vf = vec_or(vf, vbi); // CHECK: or <4 x i32> res_vsc = vec_vor(vsc, vsc); // CHECK: or <16 x i8> + res_vsc = vec_vor(vbc, vsc); // CHECK: or <16 x i8> + res_vsc = vec_vor(vsc, vbc); // CHECK: or <16 x i8> res_vuc = vec_vor(vuc, vuc); // CHECK: or <16 x i8> + res_vuc = vec_vor(vbc, vuc); // CHECK: or <16 x i8> + res_vuc = vec_vor(vuc, vbc); // CHECK: or <16 x i8> + res_vbc = vec_vor(vbc, vbc); // CHECK: or <16 x i8> res_vs = vec_vor(vs, vs); // CHECK: or <8 x i16> + res_vs = vec_vor(vbs, vs); // CHECK: or <8 x i16> + res_vs = vec_vor(vs, vbs); // CHECK: or <8 x i16> res_vus = vec_vor(vus, vus); // CHECK: or <8 x i16> + res_vus = vec_vor(vbs, vus); // CHECK: or <8 x i16> + res_vus = vec_vor(vus, vbs); // CHECK: or <8 x i16> + res_vbs = vec_vor(vbs, vbs); // CHECK: or <8 x i16> res_vi = vec_vor(vi, vi); // CHECK: or <4 x i32> + res_vi = vec_vor(vbi, vi); // CHECK: or <4 x i32> + res_vi = vec_vor(vi, vbi); // CHECK: or <4 x i32> res_vui = vec_vor(vui, vui); // CHECK: or <4 x i32> + res_vui = vec_vor(vbi, vui); // CHECK: or <4 x i32> + res_vui = vec_vor(vui, vbi); // CHECK: or <4 x i32> + res_vbi = vec_vor(vbi, vbi); // CHECK: or <4 x i32> res_vf = vec_vor(vf, vf); // CHECK: or <4 x i32> + res_vf = vec_vor(vbi, vf); // CHECK: or <4 x i32> + res_vf = vec_vor(vf, vbi); // CHECK: or <4 x i32> /* vec_pack */ res_vsc = vec_pack(vs, vs); // CHECK: @llvm.ppc.altivec.vperm res_vuc = vec_pack(vus, vus); // CHECK: @llvm.ppc.altivec.vperm + res_vbc = vec_pack(vbs, vbs); // CHECK: @llvm.ppc.altivec.vperm res_vs = vec_pack(vi, vi); // CHECK: @llvm.ppc.altivec.vperm res_vus = vec_pack(vui, vui); // CHECK: @llvm.ppc.altivec.vperm + res_vbs = vec_pack(vbi, vbi); // CHECK: @llvm.ppc.altivec.vperm res_vsc = vec_vpkuhum(vs, vs); // CHECK: @llvm.ppc.altivec.vperm res_vuc = vec_vpkuhum(vus, vus); // CHECK: @llvm.ppc.altivec.vperm + res_vbc = vec_vpkuhum(vbs, vbs); // CHECK: @llvm.ppc.altivec.vperm res_vs = vec_vpkuwum(vi, vi); // CHECK: @llvm.ppc.altivec.vperm res_vus = vec_vpkuwum(vui, vui); // CHECK: @llvm.ppc.altivec.vperm + res_vbs = vec_vpkuwum(vbi, vbi); // CHECK: @llvm.ppc.altivec.vperm /* vec_packpx */ res_vp = vec_packpx(vui, vui); // CHECK: @llvm.ppc.altivec.vpkpx @@ -587,17 +900,25 @@ int test6() { /* vec_perm */ res_vsc = vec_perm(vsc, vsc, vuc); // CHECK: @llvm.ppc.altivec.vperm res_vuc = vec_perm(vuc, vuc, vuc); // CHECK: @llvm.ppc.altivec.vperm + res_vbc = vec_perm(vbc, vbc, vuc); // CHECK: @llvm.ppc.altivec.vperm res_vs = vec_perm(vs, vs, vuc); // CHECK: @llvm.ppc.altivec.vperm res_vus = vec_perm(vus, vus, vuc); // CHECK: @llvm.ppc.altivec.vperm + res_vbs = vec_perm(vbs, vbs, vuc); // CHECK: @llvm.ppc.altivec.vperm + res_vp = vec_perm(vp, vp, vuc); // CHECK: @llvm.ppc.altivec.vperm res_vi = vec_perm(vi, vi, vuc); // CHECK: @llvm.ppc.altivec.vperm res_vui = vec_perm(vui, vui, vuc); // CHECK: @llvm.ppc.altivec.vperm + res_vbi = vec_perm(vbi, vbi, vuc); // CHECK: @llvm.ppc.altivec.vperm res_vf = vec_perm(vf, vf, vuc); // CHECK: @llvm.ppc.altivec.vperm res_vsc = vec_vperm(vsc, vsc, vuc); // CHECK: @llvm.ppc.altivec.vperm res_vuc = vec_vperm(vuc, vuc, vuc); // CHECK: @llvm.ppc.altivec.vperm + res_vbc = vec_vperm(vbc, vbc, vuc); // CHECK: @llvm.ppc.altivec.vperm res_vs = vec_vperm(vs, vs, vuc); // CHECK: @llvm.ppc.altivec.vperm res_vus = vec_vperm(vus, vus, vuc); // CHECK: @llvm.ppc.altivec.vperm + res_vbs = vec_vperm(vbs, vbs, vuc); // CHECK: @llvm.ppc.altivec.vperm + res_vp = vec_vperm(vp, vp, vuc); // CHECK: @llvm.ppc.altivec.vperm res_vi = vec_vperm(vi, vi, vuc); // CHECK: @llvm.ppc.altivec.vperm res_vui = vec_vperm(vui, vui, vuc); // CHECK: @llvm.ppc.altivec.vperm + res_vbi = vec_vperm(vbi, vbi, vuc); // CHECK: @llvm.ppc.altivec.vperm res_vf = vec_vperm(vf, vf, vuc); // CHECK: @llvm.ppc.altivec.vperm /* vec_re */ @@ -632,77 +953,200 @@ int test6() { // CHECK: and <16 x i8> // CHECK: or <16 x i8> + res_vsc = vec_sel(vsc, vsc, vbc); // CHECK: xor <16 x i8> + // CHECK: and <16 x i8> + // CHECK: and <16 x i8> + // CHECK: or <16 x i8> + res_vuc = vec_sel(vuc, vuc, vuc); // CHECK: xor <16 x i8> // CHECK: and <16 x i8> // CHECK: and <16 x i8> // CHECK: or <16 x i8> + res_vuc = vec_sel(vuc, vuc, vbc); // CHECK: xor <16 x i8> + // CHECK: and <16 x i8> + // CHECK: and <16 x i8> + // CHECK: or <16 x i8> + + res_vbc = vec_sel(vbc, vbc, vuc); // CHECK: xor <16 x i8> + // CHECK: and <16 x i8> + // CHECK: and <16 x i8> + // CHECK: or <16 x i8> + + res_vbc = vec_sel(vbc, vbc, vbc); // CHECK: xor <16 x i8> + // CHECK: and <16 x i8> + // CHECK: and <16 x i8> + // CHECK: or <16 x i8> + res_vs = vec_sel(vs, vs, vus); // CHECK: xor <8 x i16> // CHECK: and <8 x i16> // CHECK: and <8 x i16> // CHECK: or <8 x i16> + res_vs = vec_sel(vs, vs, vbs); // CHECK: xor <8 x i16> + // CHECK: and <8 x i16> + // CHECK: and <8 x i16> + // CHECK: or <8 x i16> res_vus = vec_sel(vus, vus, vus); // CHECK: xor <8 x i16> // CHECK: and <8 x i16> // CHECK: and <8 x i16> // CHECK: or <8 x i16> + res_vus = vec_sel(vus, vus, vbs); // CHECK: xor <8 x i16> + // CHECK: and <8 x i16> + // CHECK: and <8 x i16> + // CHECK: or <8 x i16> + + res_vbs = vec_sel(vbs, vbs, vus); // CHECK: xor <8 x i16> + // CHECK: and <8 x i16> + // CHECK: and <8 x i16> + // CHECK: or <8 x i16> + + res_vbs = vec_sel(vbs, vbs, vbs); // CHECK: xor <8 x i16> + // CHECK: and <8 x i16> + // CHECK: and <8 x i16> + // CHECK: or <8 x i16> + res_vi = vec_sel(vi, vi, vui); // CHECK: xor <4 x i32> // CHECK: and <4 x i32> // CHECK: and <4 x i32> // CHECK: or <4 x i32> + res_vi = vec_sel(vi, vi, vbi); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + // CHECK: and <4 x i32> + // CHECK: or <4 x i32> res_vui = vec_sel(vui, vui, vui); // CHECK: xor <4 x i32> // CHECK: and <4 x i32> // CHECK: and <4 x i32> // CHECK: or <4 x i32> + res_vui = vec_sel(vui, vui, vbi); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + // CHECK: and <4 x i32> + // CHECK: or <4 x i32> + + res_vbi = vec_sel(vbi, vbi, vui); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + // CHECK: and <4 x i32> + // CHECK: or <4 x i32> + + res_vbi = vec_sel(vbi, vbi, vbi); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + // CHECK: and <4 x i32> + // CHECK: or <4 x i32> res_vf = vec_sel(vf, vf, vui); // CHECK: xor <4 x i32> // CHECK: and <4 x i32> // CHECK: and <4 x i32> // CHECK: or <4 x i32> + res_vf = vec_sel(vf, vf, vbi); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + // CHECK: and <4 x i32> + // CHECK: or <4 x i32> + res_vsc = vec_vsel(vsc, vsc, vuc); // CHECK: xor <16 x i8> // CHECK: and <16 x i8> // CHECK: and <16 x i8> // CHECK: or <16 x i8> + res_vsc = vec_vsel(vsc, vsc, vbc); // CHECK: xor <16 x i8> + // CHECK: and <16 x i8> + // CHECK: and <16 x i8> + // CHECK: or <16 x i8> + res_vuc = vec_vsel(vuc, vuc, vuc); // CHECK: xor <16 x i8> // CHECK: and <16 x i8> // CHECK: and <16 x i8> // CHECK: or <16 x i8> + res_vuc = vec_vsel(vuc, vuc, vbc); // CHECK: xor <16 x i8> + // CHECK: and <16 x i8> + // CHECK: and <16 x i8> + // CHECK: or <16 x i8> + + res_vbc = vec_vsel(vbc, vbc, vuc); // CHECK: xor <16 x i8> + // CHECK: and <16 x i8> + // CHECK: and <16 x i8> + // CHECK: or <16 x i8> + + res_vbc = vec_vsel(vbc, vbc, vbc); // CHECK: xor <16 x i8> + // CHECK: and <16 x i8> + // CHECK: and <16 x i8> + // CHECK: or <16 x i8> + res_vs = vec_vsel(vs, vs, vus); // CHECK: xor <8 x i16> // CHECK: and <8 x i16> // CHECK: and <8 x i16> // CHECK: or <8 x i16> + res_vs = vec_vsel(vs, vs, vbs); // CHECK: xor <8 x i16> + // CHECK: and <8 x i16> + // CHECK: and <8 x i16> + // CHECK: or <8 x i16> res_vus = vec_vsel(vus, vus, vus); // CHECK: xor <8 x i16> // CHECK: and <8 x i16> // CHECK: and <8 x i16> // CHECK: or <8 x i16> + res_vus = vec_vsel(vus, vus, vbs); // CHECK: xor <8 x i16> + // CHECK: and <8 x i16> + // CHECK: and <8 x i16> + // CHECK: or <8 x i16> + + res_vbs = vec_vsel(vbs, vbs, vus); // CHECK: xor <8 x i16> + // CHECK: and <8 x i16> + // CHECK: and <8 x i16> + // CHECK: or <8 x i16> + + res_vbs = vec_vsel(vbs, vbs, vbs); // CHECK: xor <8 x i16> + // CHECK: and <8 x i16> + // CHECK: and <8 x i16> + // CHECK: or <8 x i16> + res_vi = vec_vsel(vi, vi, vui); // CHECK: xor <4 x i32> // CHECK: and <4 x i32> // CHECK: and <4 x i32> // CHECK: or <4 x i32> + res_vi = vec_vsel(vi, vi, vbi); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + // CHECK: and <4 x i32> + // CHECK: or <4 x i32> res_vui = vec_vsel(vui, vui, vui); // CHECK: xor <4 x i32> // CHECK: and <4 x i32> // CHECK: and <4 x i32> // CHECK: or <4 x i32> + res_vui = vec_vsel(vui, vui, vbi); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + // CHECK: and <4 x i32> + // CHECK: or <4 x i32> + + res_vbi = vec_vsel(vbi, vbi, vui); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + // CHECK: and <4 x i32> + // CHECK: or <4 x i32> + + res_vbi = vec_vsel(vbi, vbi, vbi); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + // CHECK: and <4 x i32> + // CHECK: or <4 x i32> res_vf = vec_vsel(vf, vf, vui); // CHECK: xor <4 x i32> // CHECK: and <4 x i32> // CHECK: and <4 x i32> // CHECK: or <4 x i32> + res_vf = vec_vsel(vf, vf, vbi); // CHECK: xor <4 x i32> + // CHECK: and <4 x i32> + // CHECK: and <4 x i32> + // CHECK: or <4 x i32> /* vec_sl */ res_vsc = vec_sl(vsc, vuc); // CHECK: shl <16 x i8> @@ -723,6 +1167,7 @@ int test6() { res_vuc = vec_sld(vuc, vuc, 0); // CHECK: @llvm.ppc.altivec.vperm res_vs = vec_sld(vs, vs, 0); // CHECK: @llvm.ppc.altivec.vperm res_vus = vec_sld(vus, vus, 0); // CHECK: @llvm.ppc.altivec.vperm + res_vp = vec_sld(vp, vp, 0); // CHECK: @llvm.ppc.altivec.vperm res_vi = vec_sld(vi, vi, 0); // CHECK: @llvm.ppc.altivec.vperm res_vui = vec_sld(vui, vui, 0); // CHECK: @llvm.ppc.altivec.vperm res_vf = vec_sld(vf, vf, 0); // CHECK: @llvm.ppc.altivec.vperm @@ -730,6 +1175,7 @@ int test6() { res_vuc = vec_vsldoi(vuc, vuc, 0); // CHECK: @llvm.ppc.altivec.vperm res_vs = vec_vsldoi(vs, vs, 0); // CHECK: @llvm.ppc.altivec.vperm res_vus = vec_vsldoi(vus, vus, 0); // CHECK: @llvm.ppc.altivec.vperm + res_vp = vec_vsldoi(vp, vp, 0); // CHECK: @llvm.ppc.altivec.vperm res_vi = vec_vsldoi(vi, vi, 0); // CHECK: @llvm.ppc.altivec.vperm res_vui = vec_vsldoi(vui, vui, 0); // CHECK: @llvm.ppc.altivec.vperm res_vf = vec_vsldoi(vf, vf, 0); // CHECK: @llvm.ppc.altivec.vperm @@ -741,36 +1187,60 @@ int test6() { res_vuc = vec_sll(vuc, vuc); // CHECK: @llvm.ppc.altivec.vsl res_vuc = vec_sll(vuc, vus); // CHECK: @llvm.ppc.altivec.vsl res_vuc = vec_sll(vuc, vui); // CHECK: @llvm.ppc.altivec.vsl + res_vbc = vec_sll(vbc, vuc); // CHECK: @llvm.ppc.altivec.vsl + res_vbc = vec_sll(vbc, vus); // CHECK: @llvm.ppc.altivec.vsl + res_vbc = vec_sll(vbc, vui); // CHECK: @llvm.ppc.altivec.vsl res_vs = vec_sll(vs, vuc); // CHECK: @llvm.ppc.altivec.vsl res_vs = vec_sll(vs, vus); // CHECK: @llvm.ppc.altivec.vsl res_vs = vec_sll(vs, vui); // CHECK: @llvm.ppc.altivec.vsl res_vus = vec_sll(vus, vuc); // CHECK: @llvm.ppc.altivec.vsl res_vus = vec_sll(vus, vus); // CHECK: @llvm.ppc.altivec.vsl res_vus = vec_sll(vus, vui); // CHECK: @llvm.ppc.altivec.vsl + res_vbs = vec_sll(vbs, vuc); // CHECK: @llvm.ppc.altivec.vsl + res_vbs = vec_sll(vbs, vus); // CHECK: @llvm.ppc.altivec.vsl + res_vbs = vec_sll(vbs, vui); // CHECK: @llvm.ppc.altivec.vsl + res_vp = vec_sll(vp, vuc); // CHECK: @llvm.ppc.altivec.vsl + res_vp = vec_sll(vp, vus); // CHECK: @llvm.ppc.altivec.vsl + res_vp = vec_sll(vp, vui); // CHECK: @llvm.ppc.altivec.vsl res_vi = vec_sll(vi, vuc); // CHECK: @llvm.ppc.altivec.vsl res_vi = vec_sll(vi, vus); // CHECK: @llvm.ppc.altivec.vsl res_vi = vec_sll(vi, vui); // CHECK: @llvm.ppc.altivec.vsl res_vui = vec_sll(vui, vuc); // CHECK: @llvm.ppc.altivec.vsl res_vui = vec_sll(vui, vus); // CHECK: @llvm.ppc.altivec.vsl res_vui = vec_sll(vui, vui); // CHECK: @llvm.ppc.altivec.vsl + res_vbi = vec_sll(vbi, vuc); // CHECK: @llvm.ppc.altivec.vsl + res_vbi = vec_sll(vbi, vus); // CHECK: @llvm.ppc.altivec.vsl + res_vbi = vec_sll(vbi, vui); // CHECK: @llvm.ppc.altivec.vsl res_vsc = vec_vsl(vsc, vuc); // CHECK: @llvm.ppc.altivec.vsl res_vsc = vec_vsl(vsc, vus); // CHECK: @llvm.ppc.altivec.vsl res_vsc = vec_vsl(vsc, vui); // CHECK: @llvm.ppc.altivec.vsl res_vuc = vec_vsl(vuc, vuc); // CHECK: @llvm.ppc.altivec.vsl res_vuc = vec_vsl(vuc, vus); // CHECK: @llvm.ppc.altivec.vsl res_vuc = vec_vsl(vuc, vui); // CHECK: @llvm.ppc.altivec.vsl + res_vbc = vec_vsl(vbc, vuc); // CHECK: @llvm.ppc.altivec.vsl + res_vbc = vec_vsl(vbc, vus); // CHECK: @llvm.ppc.altivec.vsl + res_vbc = vec_vsl(vbc, vui); // CHECK: @llvm.ppc.altivec.vsl res_vs = vec_vsl(vs, vuc); // CHECK: @llvm.ppc.altivec.vsl res_vs = vec_vsl(vs, vus); // CHECK: @llvm.ppc.altivec.vsl res_vs = vec_vsl(vs, vui); // CHECK: @llvm.ppc.altivec.vsl res_vus = vec_vsl(vus, vuc); // CHECK: @llvm.ppc.altivec.vsl res_vus = vec_vsl(vus, vus); // CHECK: @llvm.ppc.altivec.vsl res_vus = vec_vsl(vus, vui); // CHECK: @llvm.ppc.altivec.vsl + res_vbs = vec_vsl(vbs, vuc); // CHECK: @llvm.ppc.altivec.vsl + res_vbs = vec_vsl(vbs, vus); // CHECK: @llvm.ppc.altivec.vsl + res_vbs = vec_vsl(vbs, vui); // CHECK: @llvm.ppc.altivec.vsl + res_vp = vec_vsl(vp, vuc); // CHECK: @llvm.ppc.altivec.vsl + res_vp = vec_vsl(vp, vus); // CHECK: @llvm.ppc.altivec.vsl + res_vp = vec_vsl(vp, vui); // CHECK: @llvm.ppc.altivec.vsl res_vi = vec_vsl(vi, vuc); // CHECK: @llvm.ppc.altivec.vsl res_vi = vec_vsl(vi, vus); // CHECK: @llvm.ppc.altivec.vsl res_vi = vec_vsl(vi, vui); // CHECK: @llvm.ppc.altivec.vsl res_vui = vec_vsl(vui, vuc); // CHECK: @llvm.ppc.altivec.vsl res_vui = vec_vsl(vui, vus); // CHECK: @llvm.ppc.altivec.vsl res_vui = vec_vsl(vui, vui); // CHECK: @llvm.ppc.altivec.vsl + res_vbi = vec_vsl(vbi, vuc); // CHECK: @llvm.ppc.altivec.vsl + res_vbi = vec_vsl(vbi, vus); // CHECK: @llvm.ppc.altivec.vsl + res_vbi = vec_vsl(vbi, vui); // CHECK: @llvm.ppc.altivec.vsl /* vec_slo */ res_vsc = vec_slo(vsc, vsc); // CHECK: @llvm.ppc.altivec.vslo @@ -781,6 +1251,8 @@ int test6() { res_vs = vec_slo(vs, vuc); // CHECK: @llvm.ppc.altivec.vslo res_vus = vec_slo(vus, vsc); // CHECK: @llvm.ppc.altivec.vslo res_vus = vec_slo(vus, vuc); // CHECK: @llvm.ppc.altivec.vslo + res_vp = vec_slo(vp, vsc); // CHECK: @llvm.ppc.altivec.vslo + res_vp = vec_slo(vp, vuc); // CHECK: @llvm.ppc.altivec.vslo res_vi = vec_slo(vi, vsc); // CHECK: @llvm.ppc.altivec.vslo res_vi = vec_slo(vi, vuc); // CHECK: @llvm.ppc.altivec.vslo res_vui = vec_slo(vui, vsc); // CHECK: @llvm.ppc.altivec.vslo @@ -795,6 +1267,8 @@ int test6() { res_vs = vec_vslo(vs, vuc); // CHECK: @llvm.ppc.altivec.vslo res_vus = vec_vslo(vus, vsc); // CHECK: @llvm.ppc.altivec.vslo res_vus = vec_vslo(vus, vuc); // CHECK: @llvm.ppc.altivec.vslo + res_vp = vec_vslo(vp, vsc); // CHECK: @llvm.ppc.altivec.vslo + res_vp = vec_vslo(vp, vuc); // CHECK: @llvm.ppc.altivec.vslo res_vi = vec_vslo(vi, vsc); // CHECK: @llvm.ppc.altivec.vslo res_vi = vec_vslo(vi, vuc); // CHECK: @llvm.ppc.altivec.vslo res_vui = vec_vslo(vui, vsc); // CHECK: @llvm.ppc.altivec.vslo @@ -805,17 +1279,25 @@ int test6() { /* vec_splat */ res_vsc = vec_splat(vsc, 0); // CHECK: @llvm.ppc.altivec.vperm res_vuc = vec_splat(vuc, 0); // CHECK: @llvm.ppc.altivec.vperm + res_vbc = vec_splat(vbc, 0); // CHECK: @llvm.ppc.altivec.vperm res_vs = vec_splat(vs, 0); // CHECK: @llvm.ppc.altivec.vperm res_vus = vec_splat(vus, 0); // CHECK: @llvm.ppc.altivec.vperm + res_vbs = vec_splat(vbs, 0); // CHECK: @llvm.ppc.altivec.vperm + res_vp = vec_splat(vp, 0); // CHECK: @llvm.ppc.altivec.vperm res_vi = vec_splat(vi, 0); // CHECK: @llvm.ppc.altivec.vperm res_vui = vec_splat(vui, 0); // CHECK: @llvm.ppc.altivec.vperm + res_vbi = vec_splat(vbi, 0); // CHECK: @llvm.ppc.altivec.vperm res_vf = vec_splat(vf, 0); // CHECK: @llvm.ppc.altivec.vperm res_vsc = vec_vspltb(vsc, 0); // CHECK: @llvm.ppc.altivec.vperm res_vuc = vec_vspltb(vuc, 0); // CHECK: @llvm.ppc.altivec.vperm + res_vbc = vec_vspltb(vbc, 0); // CHECK: @llvm.ppc.altivec.vperm res_vs = vec_vsplth(vs, 0); // CHECK: @llvm.ppc.altivec.vperm res_vus = vec_vsplth(vus, 0); // CHECK: @llvm.ppc.altivec.vperm + res_vbs = vec_vsplth(vbs, 0); // CHECK: @llvm.ppc.altivec.vperm + res_vp = vec_vsplth(vp, 0); // CHECK: @llvm.ppc.altivec.vperm res_vi = vec_vspltw(vi, 0); // CHECK: @llvm.ppc.altivec.vperm res_vui = vec_vspltw(vui, 0); // CHECK: @llvm.ppc.altivec.vperm + res_vbi = vec_vspltw(vbi, 0); // CHECK: @llvm.ppc.altivec.vperm res_vf = vec_vspltw(vf, 0); // CHECK: @llvm.ppc.altivec.vperm /* vec_splat_s8 */ @@ -874,36 +1356,60 @@ int test6() { res_vuc = vec_srl(vuc, vuc); // CHECK: @llvm.ppc.altivec.vsr res_vuc = vec_srl(vuc, vus); // CHECK: @llvm.ppc.altivec.vsr res_vuc = vec_srl(vuc, vui); // CHECK: @llvm.ppc.altivec.vsr + res_vbc = vec_srl(vbc, vuc); // CHECK: @llvm.ppc.altivec.vsr + res_vbc = vec_srl(vbc, vus); // CHECK: @llvm.ppc.altivec.vsr + res_vbc = vec_srl(vbc, vui); // CHECK: @llvm.ppc.altivec.vsr res_vs = vec_srl(vs, vuc); // CHECK: @llvm.ppc.altivec.vsr res_vs = vec_srl(vs, vus); // CHECK: @llvm.ppc.altivec.vsr res_vs = vec_srl(vs, vui); // CHECK: @llvm.ppc.altivec.vsr res_vus = vec_srl(vus, vuc); // CHECK: @llvm.ppc.altivec.vsr res_vus = vec_srl(vus, vus); // CHECK: @llvm.ppc.altivec.vsr res_vus = vec_srl(vus, vui); // CHECK: @llvm.ppc.altivec.vsr + res_vbs = vec_srl(vbs, vuc); // CHECK: @llvm.ppc.altivec.vsr + res_vbs = vec_srl(vbs, vus); // CHECK: @llvm.ppc.altivec.vsr + res_vbs = vec_srl(vbs, vui); // CHECK: @llvm.ppc.altivec.vsr + res_vp = vec_srl(vp, vuc); // CHECK: @llvm.ppc.altivec.vsr + res_vp = vec_srl(vp, vus); // CHECK: @llvm.ppc.altivec.vsr + res_vp = vec_srl(vp, vui); // CHECK: @llvm.ppc.altivec.vsr res_vi = vec_srl(vi, vuc); // CHECK: @llvm.ppc.altivec.vsr res_vi = vec_srl(vi, vus); // CHECK: @llvm.ppc.altivec.vsr res_vi = vec_srl(vi, vui); // CHECK: @llvm.ppc.altivec.vsr res_vui = vec_srl(vui, vuc); // CHECK: @llvm.ppc.altivec.vsr res_vui = vec_srl(vui, vus); // CHECK: @llvm.ppc.altivec.vsr res_vui = vec_srl(vui, vui); // CHECK: @llvm.ppc.altivec.vsr + res_vbi = vec_srl(vbi, vuc); // CHECK: @llvm.ppc.altivec.vsr + res_vbi = vec_srl(vbi, vus); // CHECK: @llvm.ppc.altivec.vsr + res_vbi = vec_srl(vbi, vui); // CHECK: @llvm.ppc.altivec.vsr res_vsc = vec_vsr(vsc, vuc); // CHECK: @llvm.ppc.altivec.vsr res_vsc = vec_vsr(vsc, vus); // CHECK: @llvm.ppc.altivec.vsr res_vsc = vec_vsr(vsc, vui); // CHECK: @llvm.ppc.altivec.vsr res_vuc = vec_vsr(vuc, vuc); // CHECK: @llvm.ppc.altivec.vsr res_vuc = vec_vsr(vuc, vus); // CHECK: @llvm.ppc.altivec.vsr res_vuc = vec_vsr(vuc, vui); // CHECK: @llvm.ppc.altivec.vsr + res_vbc = vec_vsr(vbc, vuc); // CHECK: @llvm.ppc.altivec.vsr + res_vbc = vec_vsr(vbc, vus); // CHECK: @llvm.ppc.altivec.vsr + res_vbc = vec_vsr(vbc, vui); // CHECK: @llvm.ppc.altivec.vsr res_vs = vec_vsr(vs, vuc); // CHECK: @llvm.ppc.altivec.vsr res_vs = vec_vsr(vs, vus); // CHECK: @llvm.ppc.altivec.vsr res_vs = vec_vsr(vs, vui); // CHECK: @llvm.ppc.altivec.vsr res_vus = vec_vsr(vus, vuc); // CHECK: @llvm.ppc.altivec.vsr res_vus = vec_vsr(vus, vus); // CHECK: @llvm.ppc.altivec.vsr res_vus = vec_vsr(vus, vui); // CHECK: @llvm.ppc.altivec.vsr + res_vbs = vec_vsr(vbs, vuc); // CHECK: @llvm.ppc.altivec.vsr + res_vbs = vec_vsr(vbs, vus); // CHECK: @llvm.ppc.altivec.vsr + res_vbs = vec_vsr(vbs, vui); // CHECK: @llvm.ppc.altivec.vsr + res_vp = vec_vsr(vp, vuc); // CHECK: @llvm.ppc.altivec.vsr + res_vp = vec_vsr(vp, vus); // CHECK: @llvm.ppc.altivec.vsr + res_vp = vec_vsr(vp, vui); // CHECK: @llvm.ppc.altivec.vsr res_vi = vec_vsr(vi, vuc); // CHECK: @llvm.ppc.altivec.vsr res_vi = vec_vsr(vi, vus); // CHECK: @llvm.ppc.altivec.vsr res_vi = vec_vsr(vi, vui); // CHECK: @llvm.ppc.altivec.vsr res_vui = vec_vsr(vui, vuc); // CHECK: @llvm.ppc.altivec.vsr res_vui = vec_vsr(vui, vus); // CHECK: @llvm.ppc.altivec.vsr res_vui = vec_vsr(vui, vui); // CHECK: @llvm.ppc.altivec.vsr + res_vbi = vec_vsr(vbi, vuc); // CHECK: @llvm.ppc.altivec.vsr + res_vbi = vec_vsr(vbi, vus); // CHECK: @llvm.ppc.altivec.vsr + res_vbi = vec_vsr(vbi, vui); // CHECK: @llvm.ppc.altivec.vsr /* vec_sro */ res_vsc = vec_sro(vsc, vsc); // CHECK: @llvm.ppc.altivec.vsro @@ -914,6 +1420,8 @@ int test6() { res_vs = vec_sro(vs, vuc); // CHECK: @llvm.ppc.altivec.vsro res_vus = vec_sro(vus, vsc); // CHECK: @llvm.ppc.altivec.vsro res_vus = vec_sro(vus, vuc); // CHECK: @llvm.ppc.altivec.vsro + res_vp = vec_sro(vp, vsc); // CHECK: @llvm.ppc.altivec.vsro + res_vp = vec_sro(vp, vuc); // CHECK: @llvm.ppc.altivec.vsro res_vi = vec_sro(vi, vsc); // CHECK: @llvm.ppc.altivec.vsro res_vi = vec_sro(vi, vuc); // CHECK: @llvm.ppc.altivec.vsro res_vui = vec_sro(vui, vsc); // CHECK: @llvm.ppc.altivec.vsro @@ -928,6 +1436,8 @@ int test6() { res_vs = vec_vsro(vs, vuc); // CHECK: @llvm.ppc.altivec.vsro res_vus = vec_vsro(vus, vsc); // CHECK: @llvm.ppc.altivec.vsro res_vus = vec_vsro(vus, vuc); // CHECK: @llvm.ppc.altivec.vsro + res_vp = vec_vsro(vp, vsc); // CHECK: @llvm.ppc.altivec.vsro + res_vp = vec_vsro(vp, vuc); // CHECK: @llvm.ppc.altivec.vsro res_vi = vec_vsro(vi, vsc); // CHECK: @llvm.ppc.altivec.vsro res_vi = vec_vsro(vi, vuc); // CHECK: @llvm.ppc.altivec.vsro res_vui = vec_vsro(vui, vsc); // CHECK: @llvm.ppc.altivec.vsro @@ -940,45 +1450,85 @@ int test6() { vec_st(vsc, 0, ¶m_sc); // CHECK: @llvm.ppc.altivec.stvx vec_st(vuc, 0, &vuc); // CHECK: @llvm.ppc.altivec.stvx vec_st(vuc, 0, ¶m_uc); // CHECK: @llvm.ppc.altivec.stvx + vec_st(vbc, 0, ¶m_uc); // CHECK: @llvm.ppc.altivec.stvx + vec_st(vbc, 0, ¶m_uc); // CHECK: @llvm.ppc.altivec.stvx + vec_st(vbc, 0, &vbc); // CHECK: @llvm.ppc.altivec.stvx vec_st(vs, 0, &vs); // CHECK: @llvm.ppc.altivec.stvx vec_st(vs, 0, ¶m_s); // CHECK: @llvm.ppc.altivec.stvx vec_st(vus, 0, &vus); // CHECK: @llvm.ppc.altivec.stvx vec_st(vus, 0, ¶m_us); // CHECK: @llvm.ppc.altivec.stvx + vec_st(vbs, 0, ¶m_s); // CHECK: @llvm.ppc.altivec.stvx + vec_st(vbs, 0, ¶m_us); // CHECK: @llvm.ppc.altivec.stvx + vec_st(vbs, 0, &vbs); // CHECK: @llvm.ppc.altivec.stvx + vec_st(vp, 0, ¶m_s); // CHECK: @llvm.ppc.altivec.stvx + vec_st(vp, 0, ¶m_us); // CHECK: @llvm.ppc.altivec.stvx + vec_st(vp, 0, &vp); // CHECK: @llvm.ppc.altivec.stvx vec_st(vi, 0, &vi); // CHECK: @llvm.ppc.altivec.stvx vec_st(vi, 0, ¶m_i); // CHECK: @llvm.ppc.altivec.stvx vec_st(vui, 0, &vui); // CHECK: @llvm.ppc.altivec.stvx vec_st(vui, 0, ¶m_ui); // CHECK: @llvm.ppc.altivec.stvx + vec_st(vbi, 0, ¶m_i); // CHECK: @llvm.ppc.altivec.stvx + vec_st(vbi, 0, ¶m_ui); // CHECK: @llvm.ppc.altivec.stvx + vec_st(vbi, 0, &vbi); // CHECK: @llvm.ppc.altivec.stvx vec_st(vf, 0, &vf); // CHECK: @llvm.ppc.altivec.stvx vec_st(vf, 0, ¶m_f); // CHECK: @llvm.ppc.altivec.stvx vec_stvx(vsc, 0, &vsc); // CHECK: @llvm.ppc.altivec.stvx vec_stvx(vsc, 0, ¶m_sc); // CHECK: @llvm.ppc.altivec.stvx vec_stvx(vuc, 0, &vuc); // CHECK: @llvm.ppc.altivec.stvx vec_stvx(vuc, 0, ¶m_uc); // CHECK: @llvm.ppc.altivec.stvx + vec_stvx(vbc, 0, ¶m_uc); // CHECK: @llvm.ppc.altivec.stvx + vec_stvx(vbc, 0, ¶m_uc); // CHECK: @llvm.ppc.altivec.stvx + vec_stvx(vbc, 0, &vbc); // CHECK: @llvm.ppc.altivec.stvx vec_stvx(vs, 0, &vs); // CHECK: @llvm.ppc.altivec.stvx vec_stvx(vs, 0, ¶m_s); // CHECK: @llvm.ppc.altivec.stvx vec_stvx(vus, 0, &vus); // CHECK: @llvm.ppc.altivec.stvx vec_stvx(vus, 0, ¶m_us); // CHECK: @llvm.ppc.altivec.stvx + vec_stvx(vbs, 0, ¶m_s); // CHECK: @llvm.ppc.altivec.stvx + vec_stvx(vbs, 0, ¶m_us); // CHECK: @llvm.ppc.altivec.stvx + vec_stvx(vbs, 0, &vbs); // CHECK: @llvm.ppc.altivec.stvx + vec_stvx(vp, 0, ¶m_s); // CHECK: @llvm.ppc.altivec.stvx + vec_stvx(vp, 0, ¶m_us); // CHECK: @llvm.ppc.altivec.stvx + vec_stvx(vp, 0, &vp); // CHECK: @llvm.ppc.altivec.stvx vec_stvx(vi, 0, &vi); // CHECK: @llvm.ppc.altivec.stvx vec_stvx(vi, 0, ¶m_i); // CHECK: @llvm.ppc.altivec.stvx vec_stvx(vui, 0, &vui); // CHECK: @llvm.ppc.altivec.stvx vec_stvx(vui, 0, ¶m_ui); // CHECK: @llvm.ppc.altivec.stvx + vec_stvx(vbi, 0, ¶m_i); // CHECK: @llvm.ppc.altivec.stvx + vec_stvx(vbi, 0, ¶m_ui); // CHECK: @llvm.ppc.altivec.stvx + vec_stvx(vbi, 0, &vbi); // CHECK: @llvm.ppc.altivec.stvx vec_stvx(vf, 0, &vf); // CHECK: @llvm.ppc.altivec.stvx vec_stvx(vf, 0, ¶m_f); // CHECK: @llvm.ppc.altivec.stvx /* vec_ste */ vec_ste(vsc, 0, ¶m_sc); // CHECK: @llvm.ppc.altivec.stvebx vec_ste(vuc, 0, ¶m_uc); // CHECK: @llvm.ppc.altivec.stvebx + vec_ste(vbc, 0, ¶m_sc); // CHECK: @llvm.ppc.altivec.stvebx + vec_ste(vbc, 0, ¶m_uc); // CHECK: @llvm.ppc.altivec.stvebx vec_ste(vs, 0, ¶m_s); // CHECK: @llvm.ppc.altivec.stvehx vec_ste(vus, 0, ¶m_us); // CHECK: @llvm.ppc.altivec.stvehx + vec_ste(vbs, 0, ¶m_s); // CHECK: @llvm.ppc.altivec.stvehx + vec_ste(vbs, 0, ¶m_us); // CHECK: @llvm.ppc.altivec.stvehx + vec_ste(vp, 0, ¶m_s); // CHECK: @llvm.ppc.altivec.stvehx + vec_ste(vp, 0, ¶m_us); // CHECK: @llvm.ppc.altivec.stvehx vec_ste(vi, 0, ¶m_i); // CHECK: @llvm.ppc.altivec.stvewx vec_ste(vui, 0, ¶m_ui); // CHECK: @llvm.ppc.altivec.stvewx + vec_ste(vbi, 0, ¶m_i); // CHECK: @llvm.ppc.altivec.stvewx + vec_ste(vbi, 0, ¶m_ui); // CHECK: @llvm.ppc.altivec.stvewx vec_ste(vf, 0, ¶m_f); // CHECK: @llvm.ppc.altivec.stvewx vec_stvebx(vsc, 0, ¶m_sc); // CHECK: @llvm.ppc.altivec.stvebx vec_stvebx(vuc, 0, ¶m_uc); // CHECK: @llvm.ppc.altivec.stvebx + vec_stvebx(vbc, 0, ¶m_sc); // CHECK: @llvm.ppc.altivec.stvebx + vec_stvebx(vbc, 0, ¶m_uc); // CHECK: @llvm.ppc.altivec.stvebx vec_stvehx(vs, 0, ¶m_s); // CHECK: @llvm.ppc.altivec.stvehx vec_stvehx(vus, 0, ¶m_us); // CHECK: @llvm.ppc.altivec.stvehx + vec_stvehx(vbs, 0, ¶m_s); // CHECK: @llvm.ppc.altivec.stvehx + vec_stvehx(vbs, 0, ¶m_us); // CHECK: @llvm.ppc.altivec.stvehx + vec_stvehx(vp, 0, ¶m_s); // CHECK: @llvm.ppc.altivec.stvehx + vec_stvehx(vp, 0, ¶m_us); // CHECK: @llvm.ppc.altivec.stvehx vec_stvewx(vi, 0, ¶m_i); // CHECK: @llvm.ppc.altivec.stvewx vec_stvewx(vui, 0, ¶m_ui); // CHECK: @llvm.ppc.altivec.stvewx + vec_stvewx(vbi, 0, ¶m_i); // CHECK: @llvm.ppc.altivec.stvewx + vec_stvewx(vbi, 0, ¶m_ui); // CHECK: @llvm.ppc.altivec.stvewx vec_stvewx(vf, 0, ¶m_f); // CHECK: @llvm.ppc.altivec.stvewx /* vec_stl */ @@ -986,45 +1536,93 @@ int test6() { vec_stl(vsc, 0, ¶m_sc); // CHECK: @llvm.ppc.altivec.stvxl vec_stl(vuc, 0, &vuc); // CHECK: @llvm.ppc.altivec.stvxl vec_stl(vuc, 0, ¶m_uc); // CHECK: @llvm.ppc.altivec.stvxl + vec_stl(vbc, 0, ¶m_sc); // CHECK: @llvm.ppc.altivec.stvxl + vec_stl(vbc, 0, ¶m_uc); // CHECK: @llvm.ppc.altivec.stvxl + vec_stl(vbc, 0, &vbc); // CHECK: @llvm.ppc.altivec.stvxl vec_stl(vs, 0, &vs); // CHECK: @llvm.ppc.altivec.stvxl vec_stl(vs, 0, ¶m_s); // CHECK: @llvm.ppc.altivec.stvxl vec_stl(vus, 0, &vus); // CHECK: @llvm.ppc.altivec.stvxl vec_stl(vus, 0, ¶m_us); // CHECK: @llvm.ppc.altivec.stvxl + vec_stl(vbs, 0, ¶m_s); // CHECK: @llvm.ppc.altivec.stvxl + vec_stl(vbs, 0, ¶m_us); // CHECK: @llvm.ppc.altivec.stvxl + vec_stl(vbs, 0, &vbs); // CHECK: @llvm.ppc.altivec.stvxl + vec_stl(vp, 0, ¶m_s); // CHECK: @llvm.ppc.altivec.stvxl + vec_stl(vp, 0, ¶m_us); // CHECK: @llvm.ppc.altivec.stvxl + vec_stl(vp, 0, &vp); // CHECK: @llvm.ppc.altivec.stvxl vec_stl(vi, 0, &vi); // CHECK: @llvm.ppc.altivec.stvxl vec_stl(vi, 0, ¶m_i); // CHECK: @llvm.ppc.altivec.stvxl vec_stl(vui, 0, &vui); // CHECK: @llvm.ppc.altivec.stvxl vec_stl(vui, 0, ¶m_ui); // CHECK: @llvm.ppc.altivec.stvxl + vec_stl(vbi, 0, ¶m_i); // CHECK: @llvm.ppc.altivec.stvxl + vec_stl(vbi, 0, ¶m_ui); // CHECK: @llvm.ppc.altivec.stvxl + vec_stl(vbi, 0, &vbi); // CHECK: @llvm.ppc.altivec.stvxl vec_stl(vf, 0, &vf); // CHECK: @llvm.ppc.altivec.stvxl vec_stl(vf, 0, ¶m_f); // CHECK: @llvm.ppc.altivec.stvxl vec_stvxl(vsc, 0, &vsc); // CHECK: @llvm.ppc.altivec.stvxl vec_stvxl(vsc, 0, ¶m_sc); // CHECK: @llvm.ppc.altivec.stvxl vec_stvxl(vuc, 0, &vuc); // CHECK: @llvm.ppc.altivec.stvxl vec_stvxl(vuc, 0, ¶m_uc); // CHECK: @llvm.ppc.altivec.stvxl + vec_stvxl(vbc, 0, ¶m_sc); // CHECK: @llvm.ppc.altivec.stvxl + vec_stvxl(vbc, 0, ¶m_uc); // CHECK: @llvm.ppc.altivec.stvxl + vec_stvxl(vbc, 0, &vbc); // CHECK: @llvm.ppc.altivec.stvxl vec_stvxl(vs, 0, &vs); // CHECK: @llvm.ppc.altivec.stvxl vec_stvxl(vs, 0, ¶m_s); // CHECK: @llvm.ppc.altivec.stvxl vec_stvxl(vus, 0, &vus); // CHECK: @llvm.ppc.altivec.stvxl vec_stvxl(vus, 0, ¶m_us); // CHECK: @llvm.ppc.altivec.stvxl + vec_stvxl(vbs, 0, ¶m_s); // CHECK: @llvm.ppc.altivec.stvxl + vec_stvxl(vbs, 0, ¶m_us); // CHECK: @llvm.ppc.altivec.stvxl + vec_stvxl(vbs, 0, &vbs); // CHECK: @llvm.ppc.altivec.stvxl + vec_stvxl(vp, 0, ¶m_s); // CHECK: @llvm.ppc.altivec.stvxl + vec_stvxl(vp, 0, ¶m_us); // CHECK: @llvm.ppc.altivec.stvxl + vec_stvxl(vp, 0, &vp); // CHECK: @llvm.ppc.altivec.stvxl vec_stvxl(vi, 0, &vi); // CHECK: @llvm.ppc.altivec.stvxl vec_stvxl(vi, 0, ¶m_i); // CHECK: @llvm.ppc.altivec.stvxl vec_stvxl(vui, 0, &vui); // CHECK: @llvm.ppc.altivec.stvxl vec_stvxl(vui, 0, ¶m_ui); // CHECK: @llvm.ppc.altivec.stvxl + vec_stvxl(vbi, 0, ¶m_i); // CHECK: @llvm.ppc.altivec.stvxl + vec_stvxl(vbi, 0, ¶m_ui); // CHECK: @llvm.ppc.altivec.stvxl + vec_stvxl(vbi, 0, &vbi); // CHECK: @llvm.ppc.altivec.stvxl vec_stvxl(vf, 0, &vf); // CHECK: @llvm.ppc.altivec.stvxl vec_stvxl(vf, 0, ¶m_f); // CHECK: @llvm.ppc.altivec.stvxl /* vec_sub */ res_vsc = vec_sub(vsc, vsc); // CHECK: sub nsw <16 x i8> + res_vsc = vec_sub(vbc, vsc); // CHECK: sub nsw <16 x i8> + res_vsc = vec_sub(vsc, vbc); // CHECK: sub nsw <16 x i8> res_vuc = vec_sub(vuc, vuc); // CHECK: sub <16 x i8> + res_vuc = vec_sub(vbc, vuc); // CHECK: sub <16 x i8> + res_vuc = vec_sub(vuc, vbc); // CHECK: sub <16 x i8> res_vs = vec_sub(vs, vs); // CHECK: sub nsw <8 x i16> + res_vs = vec_sub(vbs, vs); // CHECK: sub nsw <8 x i16> + res_vs = vec_sub(vs, vbs); // CHECK: sub nsw <8 x i16> res_vus = vec_sub(vus, vus); // CHECK: sub <8 x i16> + res_vus = vec_sub(vbs, vus); // CHECK: sub <8 x i16> + res_vus = vec_sub(vus, vbs); // CHECK: sub <8 x i16> res_vi = vec_sub(vi, vi); // CHECK: sub nsw <4 x i32> + res_vi = vec_sub(vbi, vi); // CHECK: sub nsw <4 x i32> + res_vi = vec_sub(vi, vbi); // CHECK: sub nsw <4 x i32> res_vui = vec_sub(vui, vui); // CHECK: sub <4 x i32> + res_vui = vec_sub(vbi, vui); // CHECK: sub <4 x i32> + res_vui = vec_sub(vui, vbi); // CHECK: sub <4 x i32> res_vf = vec_sub(vf, vf); // CHECK: fsub <4 x float> res_vsc = vec_vsububm(vsc, vsc); // CHECK: sub nsw <16 x i8> + res_vsc = vec_vsububm(vbc, vsc); // CHECK: sub nsw <16 x i8> + res_vsc = vec_vsububm(vsc, vbc); // CHECK: sub nsw <16 x i8> res_vuc = vec_vsububm(vuc, vuc); // CHECK: sub <16 x i8> + res_vuc = vec_vsububm(vbc, vuc); // CHECK: sub <16 x i8> + res_vuc = vec_vsububm(vuc, vbc); // CHECK: sub <16 x i8> res_vs = vec_vsubuhm(vs, vs); // CHECK: sub nsw <8 x i16> + res_vs = vec_vsubuhm(vbs, vus); // CHECK: sub <8 x i16> + res_vs = vec_vsubuhm(vus, vbs); // CHECK: sub <8 x i16> res_vus = vec_vsubuhm(vus, vus); // CHECK: sub <8 x i16> + res_vus = vec_vsubuhm(vbs, vus); // CHECK: sub <8 x i16> + res_vus = vec_vsubuhm(vus, vbs); // CHECK: sub <8 x i16> res_vi = vec_vsubuwm(vi, vi); // CHECK: sub nsw <4 x i32> + res_vi = vec_vsubuwm(vbi, vi); // CHECK: sub nsw <4 x i32> + res_vi = vec_vsubuwm(vi, vbi); // CHECK: sub nsw <4 x i32> res_vui = vec_vsubuwm(vui, vui); // CHECK: sub <4 x i32> + res_vui = vec_vsubuwm(vbi, vui); // CHECK: sub <4 x i32> + res_vui = vec_vsubuwm(vui, vbi); // CHECK: sub <4 x i32> res_vf = vec_vsubfp(vf, vf); // CHECK: fsub <4 x float> /* vec_subc */ @@ -1033,17 +1631,41 @@ int test6() { /* vec_subs */ res_vsc = vec_subs(vsc, vsc); // CHECK: @llvm.ppc.altivec.vsubsbs + res_vsc = vec_subs(vbc, vsc); // CHECK: @llvm.ppc.altivec.vsubsbs + res_vsc = vec_subs(vsc, vbc); // CHECK: @llvm.ppc.altivec.vsubsbs res_vuc = vec_subs(vuc, vuc); // CHECK: @llvm.ppc.altivec.vsububs + res_vuc = vec_subs(vbc, vuc); // CHECK: @llvm.ppc.altivec.vsububs + res_vuc = vec_subs(vuc, vbc); // CHECK: @llvm.ppc.altivec.vsububs res_vs = vec_subs(vs, vs); // CHECK: @llvm.ppc.altivec.vsubshs + res_vs = vec_subs(vbs, vs); // CHECK: @llvm.ppc.altivec.vsubshs + res_vs = vec_subs(vs, vbs); // CHECK: @llvm.ppc.altivec.vsubshs res_vus = vec_subs(vus, vus); // CHECK: @llvm.ppc.altivec.vsubuhs + res_vus = vec_subs(vbs, vus); // CHECK: @llvm.ppc.altivec.vsubuhs + res_vus = vec_subs(vus, vbs); // CHECK: @llvm.ppc.altivec.vsubuhs res_vi = vec_subs(vi, vi); // CHECK: @llvm.ppc.altivec.vsubsws + res_vi = vec_subs(vbi, vi); // CHECK: @llvm.ppc.altivec.vsubsws + res_vi = vec_subs(vi, vbi); // CHECK: @llvm.ppc.altivec.vsubsws res_vui = vec_subs(vui, vui); // CHECK: @llvm.ppc.altivec.vsubuws + res_vui = vec_subs(vbi, vui); // CHECK: @llvm.ppc.altivec.vsubuws + res_vui = vec_subs(vui, vbi); // CHECK: @llvm.ppc.altivec.vsubuws res_vsc = vec_vsubsbs(vsc, vsc); // CHECK: @llvm.ppc.altivec.vsubsbs + res_vsc = vec_vsubsbs(vbc, vsc); // CHECK: @llvm.ppc.altivec.vsubsbs + res_vsc = vec_vsubsbs(vsc, vbc); // CHECK: @llvm.ppc.altivec.vsubsbs res_vuc = vec_vsububs(vuc, vuc); // CHECK: @llvm.ppc.altivec.vsububs + res_vuc = vec_vsububs(vbc, vuc); // CHECK: @llvm.ppc.altivec.vsububs + res_vuc = vec_vsububs(vuc, vbc); // CHECK: @llvm.ppc.altivec.vsububs res_vs = vec_vsubshs(vs, vs); // CHECK: @llvm.ppc.altivec.vsubshs + res_vs = vec_vsubshs(vbs, vs); // CHECK: @llvm.ppc.altivec.vsubshs + res_vs = vec_vsubshs(vs, vbs); // CHECK: @llvm.ppc.altivec.vsubshs res_vus = vec_vsubuhs(vus, vus); // CHECK: @llvm.ppc.altivec.vsubuhs + res_vus = vec_vsubuhs(vbs, vus); // CHECK: @llvm.ppc.altivec.vsubuhs + res_vus = vec_vsubuhs(vus, vbs); // CHECK: @llvm.ppc.altivec.vsubuhs res_vi = vec_vsubsws(vi, vi); // CHECK: @llvm.ppc.altivec.vsubsws + res_vi = vec_vsubsws(vbi, vi); // CHECK: @llvm.ppc.altivec.vsubsws + res_vi = vec_vsubsws(vi, vbi); // CHECK: @llvm.ppc.altivec.vsubsws res_vui = vec_vsubuws(vui, vui); // CHECK: @llvm.ppc.altivec.vsubuws + res_vui = vec_vsubuws(vbi, vui); // CHECK: @llvm.ppc.altivec.vsubuws + res_vui = vec_vsubuws(vui, vbi); // CHECK: @llvm.ppc.altivec.vsubuws /* vec_sum4s */ res_vi = vec_sum4s(vsc, vi); // CHECK: @llvm.ppc.altivec.vsum4sbs @@ -1066,60 +1688,152 @@ int test6() { res_vf = vec_vrfiz(vf); // CHECK: @llvm.ppc.altivec.vrfiz /* vec_unpackh */ - res_vs = vec_unpackh(vsc); // CHECK: @llvm.ppc.altivec.vupkhsb - res_vi = vec_unpackh(vs); // CHECK: @llvm.ppc.altivec.vupkhsh - res_vs = vec_vupkhsb(vsc); // CHECK: @llvm.ppc.altivec.vupkhsb - res_vi = vec_vupkhsh(vs); // CHECK: @llvm.ppc.altivec.vupkhsh + res_vs = vec_unpackh(vsc); // CHECK: @llvm.ppc.altivec.vupkhsb + res_vbs = vec_unpackh(vbc); // CHECK: @llvm.ppc.altivec.vupkhsb + res_vi = vec_unpackh(vs); // CHECK: @llvm.ppc.altivec.vupkhsh + res_vbi = vec_unpackh(vbs); // CHECK: @llvm.ppc.altivec.vupkhsh + res_vui = vec_unpackh(vp); // CHECK: @llvm.ppc.altivec.vupkhsh + res_vs = vec_vupkhsb(vsc); // CHECK: @llvm.ppc.altivec.vupkhsb + res_vbs = vec_vupkhsb(vbc); // CHECK: @llvm.ppc.altivec.vupkhsb + res_vi = vec_vupkhsh(vs); // CHECK: @llvm.ppc.altivec.vupkhsh + res_vbi = vec_vupkhsh(vbs); // CHECK: @llvm.ppc.altivec.vupkhsh + res_vui = vec_vupkhsh(vp); // CHECK: @llvm.ppc.altivec.vupkhsh /* vec_unpackl */ - res_vs = vec_unpackl(vsc); // CHECK: @llvm.ppc.altivec.vupklsb - res_vi = vec_vupklsh(vs); // CHECK: @llvm.ppc.altivec.vupklsh - res_vs = vec_vupklsb(vsc); // CHECK: @llvm.ppc.altivec.vupklsb - res_vi = vec_vupklsh(vs); // CHECK: @llvm.ppc.altivec.vupklsh + res_vs = vec_unpackl(vsc); // CHECK: @llvm.ppc.altivec.vupklsb + res_vbs = vec_unpackl(vbc); // CHECK: @llvm.ppc.altivec.vupklsb + res_vi = vec_unpackl(vs); // CHECK: @llvm.ppc.altivec.vupklsh + res_vbi = vec_unpackl(vbs); // CHECK: @llvm.ppc.altivec.vupklsh + res_vui = vec_unpackl(vp); // CHECK: @llvm.ppc.altivec.vupklsh + res_vs = vec_vupklsb(vsc); // CHECK: @llvm.ppc.altivec.vupklsb + res_vbs = vec_vupklsb(vbc); // CHECK: @llvm.ppc.altivec.vupklsb + res_vi = vec_vupklsh(vs); // CHECK: @llvm.ppc.altivec.vupklsh + res_vbi = vec_vupklsh(vbs); // CHECK: @llvm.ppc.altivec.vupklsh + res_vui = vec_vupklsh(vp); // CHECK: @llvm.ppc.altivec.vupklsh /* vec_xor */ res_vsc = vec_xor(vsc, vsc); // CHECK: xor <16 x i8> + res_vsc = vec_xor(vbc, vsc); // CHECK: xor <16 x i8> + res_vsc = vec_xor(vsc, vbc); // CHECK: xor <16 x i8> res_vuc = vec_xor(vuc, vuc); // CHECK: xor <16 x i8> + res_vuc = vec_xor(vbc, vuc); // CHECK: xor <16 x i8> + res_vuc = vec_xor(vuc, vbc); // CHECK: xor <16 x i8> + res_vbc = vec_xor(vbc, vbc); // CHECK: xor <16 x i8> res_vs = vec_xor(vs, vs); // CHECK: xor <8 x i16> + res_vs = vec_xor(vbs, vs); // CHECK: xor <8 x i16> + res_vs = vec_xor(vs, vbs); // CHECK: xor <8 x i16> res_vus = vec_xor(vus, vus); // CHECK: xor <8 x i16> + res_vus = vec_xor(vbs, vus); // CHECK: xor <8 x i16> + res_vus = vec_xor(vus, vbs); // CHECK: xor <8 x i16> + res_vbs = vec_xor(vbs, vbs); // CHECK: xor <8 x i16> res_vi = vec_xor(vi, vi); // CHECK: xor <4 x i32> + res_vi = vec_xor(vbi, vi); // CHECK: xor <4 x i32> + res_vi = vec_xor(vi, vbi); // CHECK: xor <4 x i32> res_vui = vec_xor(vui, vui); // CHECK: xor <4 x i32> + res_vui = vec_xor(vbi, vui); // CHECK: xor <4 x i32> + res_vui = vec_xor(vui, vbi); // CHECK: xor <4 x i32> + res_vbi = vec_xor(vbi, vbi); // CHECK: xor <4 x i32> res_vf = vec_xor(vf, vf); // CHECK: xor <4 x i32> + res_vf = vec_xor(vbi, vf); // CHECK: xor <4 x i32> + res_vf = vec_xor(vf, vbi); // CHECK: xor <4 x i32> res_vsc = vec_vxor(vsc, vsc); // CHECK: xor <16 x i8> + res_vsc = vec_vxor(vbc, vsc); // CHECK: xor <16 x i8> + res_vsc = vec_vxor(vsc, vbc); // CHECK: xor <16 x i8> res_vuc = vec_vxor(vuc, vuc); // CHECK: xor <16 x i8> + res_vuc = vec_vxor(vbc, vuc); // CHECK: xor <16 x i8> + res_vuc = vec_vxor(vuc, vbc); // CHECK: xor <16 x i8> + res_vbc = vec_vxor(vbc, vbc); // CHECK: xor <16 x i8> res_vs = vec_vxor(vs, vs); // CHECK: xor <8 x i16> + res_vs = vec_vxor(vbs, vs); // CHECK: xor <8 x i16> + res_vs = vec_vxor(vs, vbs); // CHECK: xor <8 x i16> res_vus = vec_vxor(vus, vus); // CHECK: xor <8 x i16> + res_vus = vec_vxor(vbs, vus); // CHECK: xor <8 x i16> + res_vus = vec_vxor(vus, vbs); // CHECK: xor <8 x i16> + res_vbs = vec_vxor(vbs, vbs); // CHECK: xor <8 x i16> res_vi = vec_vxor(vi, vi); // CHECK: xor <4 x i32> + res_vi = vec_vxor(vbi, vi); // CHECK: xor <4 x i32> + res_vi = vec_vxor(vi, vbi); // CHECK: xor <4 x i32> res_vui = vec_vxor(vui, vui); // CHECK: xor <4 x i32> + res_vui = vec_vxor(vbi, vui); // CHECK: xor <4 x i32> + res_vui = vec_vxor(vui, vbi); // CHECK: xor <4 x i32> + res_vbi = vec_vxor(vbi, vbi); // CHECK: xor <4 x i32> res_vf = vec_vxor(vf, vf); // CHECK: xor <4 x i32> + res_vf = vec_vxor(vbi, vf); // CHECK: xor <4 x i32> + res_vf = vec_vxor(vf, vbi); // CHECK: xor <4 x i32> /* ------------------------------ predicates -------------------------------------- */ /* vec_all_eq */ res_i = vec_all_eq(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_all_eq(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p res_i = vec_all_eq(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_all_eq(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_all_eq(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_all_eq(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_all_eq(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p res_i = vec_all_eq(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_all_eq(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p res_i = vec_all_eq(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_all_eq(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_all_eq(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_all_eq(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_all_eq(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_all_eq(vp, vp); // CHECK: @llvm.ppc.altivec.vcmpequh.p res_i = vec_all_eq(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_all_eq(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p res_i = vec_all_eq(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_all_eq(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_all_eq(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_all_eq(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_all_eq(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p res_i = vec_all_eq(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p /* vec_all_ge */ res_i = vec_all_ge(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_all_ge(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p res_i = vec_all_ge(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_ge(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_ge(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_ge(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_ge(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p res_i = vec_all_ge(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_all_ge(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p res_i = vec_all_ge(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_ge(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_ge(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_ge(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_ge(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p res_i = vec_all_ge(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_all_ge(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p res_i = vec_all_ge(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_ge(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_ge(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_ge(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_ge(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p res_i = vec_all_ge(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp.p /* vec_all_gt */ res_i = vec_all_gt(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_all_gt(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p res_i = vec_all_gt(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_gt(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_gt(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_gt(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_gt(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p res_i = vec_all_gt(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_all_gt(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p res_i = vec_all_gt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_gt(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_gt(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_gt(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_gt(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p res_i = vec_all_gt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_all_gt(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p res_i = vec_all_gt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_gt(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_gt(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_gt(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_gt(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p res_i = vec_all_gt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p /* vec_all_in */ @@ -1127,23 +1841,78 @@ int test6() { /* vec_all_le */ res_i = vec_all_le(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_all_le(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p res_i = vec_all_le(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_le(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_le(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_le(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_le(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p res_i = vec_all_le(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_all_le(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p res_i = vec_all_le(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_le(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_le(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_le(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_le(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p res_i = vec_all_le(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_all_le(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p res_i = vec_all_le(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_le(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_le(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_le(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_le(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p res_i = vec_all_le(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp.p + /* vec_all_lt */ + res_i = vec_all_lt(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_all_lt(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_all_lt(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_lt(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_lt(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_lt(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_lt(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_lt(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_all_lt(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_all_lt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_lt(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_lt(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_lt(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_lt(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_lt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_all_lt(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_all_lt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_lt(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_lt(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_lt(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_lt(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_lt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + /* vec_all_nan */ res_i = vec_all_nan(vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p /* vec_all_ne */ res_i = vec_all_ne(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_all_ne(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p res_i = vec_all_ne(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_all_ne(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_all_ne(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_all_ne(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_all_ne(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p res_i = vec_all_ne(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_all_ne(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p res_i = vec_all_ne(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_all_ne(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_all_ne(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_all_ne(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_all_ne(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_all_ne(vp, vp); // CHECK: @llvm.ppc.altivec.vcmpequh.p res_i = vec_all_ne(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_all_ne(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p res_i = vec_all_ne(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_all_ne(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_all_ne(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_all_ne(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_all_ne(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p res_i = vec_all_ne(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p /* vec_all_nge */ @@ -1163,47 +1932,123 @@ int test6() { /* vec_any_eq */ res_i = vec_any_eq(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_any_eq(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p res_i = vec_any_eq(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_any_eq(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_any_eq(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_any_eq(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_any_eq(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p res_i = vec_any_eq(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_any_eq(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p res_i = vec_any_eq(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_any_eq(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_any_eq(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_any_eq(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_any_eq(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_any_eq(vp, vp); // CHECK: @llvm.ppc.altivec.vcmpequh.p res_i = vec_any_eq(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_any_eq(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p res_i = vec_any_eq(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_any_eq(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_any_eq(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_any_eq(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_any_eq(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p res_i = vec_any_eq(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p /* vec_any_ge */ res_i = vec_any_ge(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_any_ge(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p res_i = vec_any_ge(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_ge(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_ge(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_ge(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_ge(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p res_i = vec_any_ge(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_any_ge(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p res_i = vec_any_ge(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_ge(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_ge(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_ge(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_ge(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p res_i = vec_any_ge(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_any_ge(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p res_i = vec_any_ge(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_ge(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_ge(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_ge(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_ge(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p res_i = vec_any_ge(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp.p /* vec_any_gt */ res_i = vec_any_gt(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_any_gt(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p res_i = vec_any_gt(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_gt(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_gt(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_gt(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_gt(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p res_i = vec_any_gt(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_any_gt(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p res_i = vec_any_gt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_gt(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_gt(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_gt(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_gt(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p res_i = vec_any_gt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_any_gt(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p res_i = vec_any_gt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_gt(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_gt(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_gt(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_gt(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p res_i = vec_any_gt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p /* vec_any_le */ res_i = vec_any_le(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_any_le(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p res_i = vec_any_le(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_le(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_le(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_le(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_le(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p res_i = vec_any_le(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_any_le(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p res_i = vec_any_le(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_le(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_le(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_le(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_le(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p res_i = vec_any_le(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_any_le(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p res_i = vec_any_le(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_le(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_le(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_le(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_le(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p res_i = vec_any_le(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp.p /* vec_any_lt */ res_i = vec_any_lt(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_any_lt(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p res_i = vec_any_lt(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_lt(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_lt(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_lt(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_lt(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p res_i = vec_any_lt(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_any_lt(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p res_i = vec_any_lt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_lt(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_lt(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_lt(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_lt(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p res_i = vec_any_lt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_any_lt(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p res_i = vec_any_lt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_lt(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_lt(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_lt(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_lt(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p res_i = vec_any_lt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p /* vec_any_nan */ @@ -1211,11 +2056,27 @@ int test6() { /* vec_any_ne */ res_i = vec_any_ne(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_any_ne(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p res_i = vec_any_ne(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_any_ne(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_any_ne(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_any_ne(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_any_ne(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p res_i = vec_any_ne(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_any_ne(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p res_i = vec_any_ne(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_any_ne(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_any_ne(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_any_ne(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_any_ne(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_any_ne(vp, vp); // CHECK: @llvm.ppc.altivec.vcmpequh.p res_i = vec_any_ne(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_any_ne(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p res_i = vec_any_ne(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_any_ne(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_any_ne(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_any_ne(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_any_ne(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p res_i = vec_any_ne(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p /* vec_any_nge */ @@ -1235,6 +2096,4 @@ int test6() { /* vec_any_out */ res_i = vec_any_out(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpbfp.p - - return 0; } diff --git a/test/CodeGen/builtins-x86.c b/test/CodeGen/builtins-x86.c index b587814..1b4e68b 100644 --- a/test/CodeGen/builtins-x86.c +++ b/test/CodeGen/builtins-x86.c @@ -24,6 +24,14 @@ typedef signed long long V2LLi __attribute__((vector_size(16))); typedef float V4f __attribute__((vector_size(16))); typedef double V2d __attribute__((vector_size(16))); +// 256-bit +typedef char V32c __attribute__((vector_size(32))); +typedef signed int V8i __attribute__((vector_size(32))); +typedef signed long long V4LLi __attribute__((vector_size(32))); + +typedef double V4d __attribute__((vector_size(32))); +typedef float V8f __attribute__((vector_size(32))); + void f0() { signed char tmp_c; // unsigned char tmp_Uc; @@ -76,6 +84,22 @@ void f0() { V2LLi tmp_V2LLi; V4f tmp_V4f; V2d tmp_V2d; + V2d* tmp_V2dp; + V4f* tmp_V4fp; + const V2d* tmp_V2dCp; + const V4f* tmp_V4fCp; + + // 256-bit + V32c tmp_V32c; + V4d tmp_V4d; + V8f tmp_V8f; + V4LLi tmp_V4LLi; + V8i tmp_V8i; + V4LLi* tmp_V4LLip; + V4d* tmp_V4dp; + V8f* tmp_V8fp; + const V4d* tmp_V4dCp; + const V8f* tmp_V8fCp; tmp_i = __builtin_ia32_comieq(tmp_V4f, tmp_V4f); tmp_i = __builtin_ia32_comilt(tmp_V4f, tmp_V4f); @@ -365,6 +389,95 @@ void f0() { tmp_V2d = __builtin_ia32_roundpd(tmp_V2d, imm_i_0_16); tmp_V4f = __builtin_ia32_insertps128(tmp_V4f, tmp_V4f, tmp_i); #endif -} - + tmp_V4d = __builtin_ia32_addsubpd256(tmp_V4d, tmp_V4d); + tmp_V8f = __builtin_ia32_addsubps256(tmp_V8f, tmp_V8f); + tmp_V4d = __builtin_ia32_haddpd256(tmp_V4d, tmp_V4d); + tmp_V8f = __builtin_ia32_hsubps256(tmp_V8f, tmp_V8f); + tmp_V4d = __builtin_ia32_hsubpd256(tmp_V4d, tmp_V4d); + tmp_V8f = __builtin_ia32_haddps256(tmp_V8f, tmp_V8f); + tmp_V4d = __builtin_ia32_maxpd256(tmp_V4d, tmp_V4d); + tmp_V8f = __builtin_ia32_maxps256(tmp_V8f, tmp_V8f); + tmp_V4d = __builtin_ia32_minpd256(tmp_V4d, tmp_V4d); + tmp_V8f = __builtin_ia32_minps256(tmp_V8f, tmp_V8f); + tmp_V2d = __builtin_ia32_vpermilvarpd(tmp_V2d, tmp_V2LLi); + tmp_V4f = __builtin_ia32_vpermilvarps(tmp_V4f, tmp_V4i); + tmp_V4d = __builtin_ia32_vpermilvarpd256(tmp_V4d, tmp_V4LLi); + tmp_V8f = __builtin_ia32_vpermilvarps256(tmp_V8f, tmp_V8i); + tmp_V4d = __builtin_ia32_blendpd256(tmp_V4d, tmp_V4d, 0x7); + tmp_V8f = __builtin_ia32_blendps256(tmp_V8f, tmp_V8f, 0x7); + tmp_V4d = __builtin_ia32_blendvpd256(tmp_V4d, tmp_V4d, tmp_V4d); + tmp_V8f = __builtin_ia32_blendvps256(tmp_V8f, tmp_V8f, tmp_V8f); + tmp_V8f = __builtin_ia32_dpps256(tmp_V8f, tmp_V8f, 0x7); + tmp_V4d = __builtin_ia32_cmppd256(tmp_V4d, tmp_V4d, 0); + tmp_V8f = __builtin_ia32_cmpps256(tmp_V8f, tmp_V8f, 0); + tmp_V2d = __builtin_ia32_vextractf128_pd256(tmp_V4d, 0x7); + tmp_V4f = __builtin_ia32_vextractf128_ps256(tmp_V8f, 0x7); + tmp_V4i = __builtin_ia32_vextractf128_si256(tmp_V8i, 0x7); + tmp_V4d = __builtin_ia32_cvtdq2pd256(tmp_V4i); + tmp_V8f = __builtin_ia32_cvtdq2ps256(tmp_V8i); + tmp_V4f = __builtin_ia32_cvtpd2ps256(tmp_V4d); + tmp_V8i = __builtin_ia32_cvtps2dq256(tmp_V8f); + tmp_V4d = __builtin_ia32_cvtps2pd256(tmp_V4f); + tmp_V4i = __builtin_ia32_cvttpd2dq256(tmp_V4d); + tmp_V4i = __builtin_ia32_cvtpd2dq256(tmp_V4d); + tmp_V8i = __builtin_ia32_cvttps2dq256(tmp_V8f); + tmp_V4d = __builtin_ia32_vperm2f128_pd256(tmp_V4d, tmp_V4d, 0x7); + tmp_V8f = __builtin_ia32_vperm2f128_ps256(tmp_V8f, tmp_V8f, 0x7); + tmp_V8i = __builtin_ia32_vperm2f128_si256(tmp_V8i, tmp_V8i, 0x7); + tmp_V2d = __builtin_ia32_vpermilpd(tmp_V2d, 0x7); + tmp_V4f = __builtin_ia32_vpermilps(tmp_V4f, 0x7); + tmp_V4d = __builtin_ia32_vpermilpd256(tmp_V4d, 0x7); + tmp_V8f = __builtin_ia32_vpermilps256(tmp_V8f, 0x7); + tmp_V4d = __builtin_ia32_vinsertf128_pd256(tmp_V4d, tmp_V2d, 0x7); + tmp_V8f = __builtin_ia32_vinsertf128_ps256(tmp_V8f, tmp_V4f, 0x7); + tmp_V8i = __builtin_ia32_vinsertf128_si256(tmp_V8i, tmp_V4i, 0x7); + tmp_V4d = __builtin_ia32_sqrtpd256(tmp_V4d); + tmp_V8f = __builtin_ia32_sqrtps256(tmp_V8f); + tmp_V8f = __builtin_ia32_rsqrtps256(tmp_V8f); + tmp_V8f = __builtin_ia32_rcpps256(tmp_V8f); + tmp_V4d = __builtin_ia32_roundpd256(tmp_V4d, tmp_i); + tmp_V8f = __builtin_ia32_roundps256(tmp_V8f, tmp_i); + tmp_i = __builtin_ia32_vtestzpd(tmp_V2d, tmp_V2d); + tmp_i = __builtin_ia32_vtestcpd(tmp_V2d, tmp_V2d); + tmp_i = __builtin_ia32_vtestnzcpd(tmp_V2d, tmp_V2d); + tmp_i = __builtin_ia32_vtestzps(tmp_V4f, tmp_V4f); + tmp_i = __builtin_ia32_vtestcps(tmp_V4f, tmp_V4f); + tmp_i = __builtin_ia32_vtestnzcps(tmp_V4f, tmp_V4f); + tmp_i = __builtin_ia32_vtestzpd256(tmp_V4d, tmp_V4d); + tmp_i = __builtin_ia32_vtestcpd256(tmp_V4d, tmp_V4d); + tmp_i = __builtin_ia32_vtestnzcpd256(tmp_V4d, tmp_V4d); + tmp_i = __builtin_ia32_vtestzps256(tmp_V8f, tmp_V8f); + tmp_i = __builtin_ia32_vtestcps256(tmp_V8f, tmp_V8f); + tmp_i = __builtin_ia32_vtestnzcps256(tmp_V8f, tmp_V8f); + tmp_i = __builtin_ia32_ptestz256(tmp_V4LLi, tmp_V4LLi); + tmp_i = __builtin_ia32_ptestc256(tmp_V4LLi, tmp_V4LLi); + tmp_i = __builtin_ia32_ptestnzc256(tmp_V4LLi, tmp_V4LLi); + tmp_i = __builtin_ia32_movmskpd256(tmp_V4d); + tmp_i = __builtin_ia32_movmskps256(tmp_V8f); + __builtin_ia32_vzeroall(); + __builtin_ia32_vzeroupper(); + tmp_V4f = __builtin_ia32_vbroadcastss(tmp_fCp); + tmp_V4d = __builtin_ia32_vbroadcastsd256(tmp_dCp); + tmp_V8f = __builtin_ia32_vbroadcastss256(tmp_fCp); + tmp_V4d = __builtin_ia32_vbroadcastf128_pd256(tmp_V2dCp); + tmp_V8f = __builtin_ia32_vbroadcastf128_ps256(tmp_V4fCp); + tmp_V4d = __builtin_ia32_loadupd256(tmp_dCp); + tmp_V8f = __builtin_ia32_loadups256(tmp_fCp); + __builtin_ia32_storeupd256(tmp_dp, tmp_V4d); + __builtin_ia32_storeups256(tmp_fp, tmp_V8f); + tmp_V32c = __builtin_ia32_loaddqu256(tmp_cCp); + __builtin_ia32_storedqu256(tmp_cp, tmp_V32c); + tmp_V32c = __builtin_ia32_lddqu256(tmp_cCp); + __builtin_ia32_movntdq256(tmp_V4LLip, tmp_V4LLi); + __builtin_ia32_movntpd256(tmp_dp, tmp_V4d); + __builtin_ia32_movntps256(tmp_fp, tmp_V8f); + tmp_V2d = __builtin_ia32_maskloadpd(tmp_V2dCp, tmp_V2d); + tmp_V4f = __builtin_ia32_maskloadps(tmp_V4fCp, tmp_V4f); + tmp_V4d = __builtin_ia32_maskloadpd256(tmp_V4dCp, tmp_V4d); + tmp_V8f = __builtin_ia32_maskloadps256(tmp_V8fCp, tmp_V8f); + __builtin_ia32_maskstorepd(tmp_V2dp, tmp_V2d, tmp_V2d); + __builtin_ia32_maskstoreps(tmp_V4fp, tmp_V4f, tmp_V4f); + __builtin_ia32_maskstorepd256(tmp_V4dp, tmp_V4d, tmp_V4d); + __builtin_ia32_maskstoreps256(tmp_V8fp, tmp_V8f, tmp_V8f); +} diff --git a/test/CodeGen/const-arithmetic.c b/test/CodeGen/const-arithmetic.c index 92c02f0..a28f73f 100644 --- a/test/CodeGen/const-arithmetic.c +++ b/test/CodeGen/const-arithmetic.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s -// CHECK: @g1 = global [2 x i8*] [i8* getelementptr (i8* getelementptr inbounds ([0 x %struct.anon]* @g0, i32 0, i32 0, i32 0), i64 -2), i8* getelementptr (i8* getelementptr inbounds ([0 x %struct.anon]* @g0, i32 0, i32 0, i32 0), i64 -46)], align 16 ; <[2 x i8*]*> [#uses=0] -// CHECK: @g2 = global [2 x i8*] [i8* getelementptr (i8* getelementptr inbounds ([0 x %struct.anon]* @g0, i32 0, i32 0, i32 0), i64 -2), i8* getelementptr (i8* getelementptr inbounds ([0 x %struct.anon]* @g0, i32 0, i32 0, i32 0), i64 -46)], align 16 ; <[2 x i8*]*> [#uses=0] +// CHECK: @g1 = global [2 x i8*] [i8* getelementptr (i8* getelementptr inbounds ([0 x %struct.anon]* @g0, i32 0, i32 0, i32 0), i64 -2), i8* getelementptr (i8* getelementptr inbounds ([0 x %struct.anon]* @g0, i32 0, i32 0, i32 0), i64 -46)], align 16 +// CHECK: @g2 = global [2 x i8*] [i8* getelementptr (i8* getelementptr inbounds ([0 x %struct.anon]* @g0, i32 0, i32 0, i32 0), i64 -2), i8* getelementptr (i8* getelementptr inbounds ([0 x %struct.anon]* @g0, i32 0, i32 0, i32 0), i64 -46)], align 16 extern struct { unsigned char a, b; } g0[]; void *g1[] = {g0 + -1, g0 + -23 }; diff --git a/test/CodeGen/const-init.c b/test/CodeGen/const-init.c index c7a53be..ac26b65 100644 --- a/test/CodeGen/const-init.c +++ b/test/CodeGen/const-init.c @@ -117,9 +117,14 @@ struct g22 {int x;} __attribute((packed)); struct g23 {char a; short b; char c; struct g22 d;}; struct g23 g24 = {1,2,3,4}; -// CHECK: @__func__.g25 = private constant [4 x i8] c"g25\00" // CHECK: @g25.g26 = internal global i8* getelementptr inbounds ([4 x i8]* @__func__.g25, i32 0, i32 0) +// CHECK: @__func__.g25 = private constant [4 x i8] c"g25\00" int g25() { static const char *g26 = __func__; return *g26; } + +// CHECK: @g27.x = internal global i8* bitcast (i8** @g27.x to i8*), align 4 +void g27() { // PR8073 + static void *x = &x; +} diff --git a/test/CodeGen/debug-info-enum.c b/test/CodeGen/debug-info-enum.c new file mode 100644 index 0000000..b4a1ce0 --- /dev/null +++ b/test/CodeGen/debug-info-enum.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -emit-llvm -g %s -o %t +// RUN: grep DW_TAG_enumeration_type %t +// Radar 8195980 + +enum vtag { + VT_ONE +}; + +int foo(int i) { + return i == VT_ONE; +} diff --git a/test/CodeGen/debug-info-scope.c b/test/CodeGen/debug-info-scope.c new file mode 100644 index 0000000..6051e6e --- /dev/null +++ b/test/CodeGen/debug-info-scope.c @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -g -emit-llvm < %s | FileCheck %s +// Two variables with same name in separate scope. +// Radar 8330217. +int main() { + int j = 0; + int k = 0; +// CHECK: DW_TAG_auto_variable +// CHECK-NEXT: DW_TAG_lexical_block + for (int i = 0; i < 10; i++) + j++; + for (int i = 0; i < 10; i++) + k++; + return 0; +} diff --git a/test/CodeGen/designated-initializers.c b/test/CodeGen/designated-initializers.c index 49f57ad..312d785 100644 --- a/test/CodeGen/designated-initializers.c +++ b/test/CodeGen/designated-initializers.c @@ -8,10 +8,10 @@ struct foo { // CHECK: @u = global %union.anon zeroinitializer union { int i; float f; } u = { }; -// CHECK: @u2 = global %0 { i32 0, [4 x i8] undef } +// CHECK: @u2 = global %1 { i32 0, [4 x i8] undef } union { int i; double f; } u2 = { }; -// CHECK: @u3 = global %1 zeroinitializer +// CHECK: @u3 = global %2 zeroinitializer union { double f; int i; } u3 = { }; // CHECK: @b = global [2 x i32] [i32 0, i32 22] @@ -19,7 +19,7 @@ int b[2] = { [1] = 22 }; -int main(int argc, char **argv) +void test1(int argc, char **argv) { // CHECK: internal global %struct.foo { i8* null, i32 1024 } static struct foo foo = { @@ -33,5 +33,24 @@ int main(int argc, char **argv) // CHECK-NOT: call void @llvm.memset union { int i; float f; } u3; - // CHECK: ret i32 + // CHECK: ret void +} + + +// PR7151 +struct S { + int nkeys; + int *keys; + union { + void *data; + }; +}; + +void test2() { + struct S *btkr; + + *btkr = (struct S) { + .keys = 0, + { .data = 0 }, + }; } diff --git a/test/CodeGen/enum2.c b/test/CodeGen/enum2.c new file mode 100644 index 0000000..3203627 --- /dev/null +++ b/test/CodeGen/enum2.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -triple i386-unknown-unknown %s -g -emit-llvm -o /dev/null +int v; +enum e { MAX }; + +void foo (void) +{ + v = MAX; +} diff --git a/test/CodeGen/exprs.c b/test/CodeGen/exprs.c index 7cc1134..c9978b8 100644 --- a/test/CodeGen/exprs.c +++ b/test/CodeGen/exprs.c @@ -145,3 +145,10 @@ double f13(double X) { // CHECK: fsub double -0.0 return -X; } + +// Check operations on incomplete types. +struct s14; +void f14(struct s13 *a) { + (void) &*a; +} + diff --git a/test/CodeGen/fold-const-declref.c b/test/CodeGen/fold-const-declref.c new file mode 100644 index 0000000..5a7ba8e --- /dev/null +++ b/test/CodeGen/fold-const-declref.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -verify -emit-llvm-only + +// PR7242: Check that this doesn't crash. +int main(void) +{ + int __negative = 1; + const int __max = __negative && 0 ; + __max / 0; +} diff --git a/test/CodeGen/func-in-block.c b/test/CodeGen/func-in-block.c index 27e0c09..7e65ff9 100644 --- a/test/CodeGen/func-in-block.c +++ b/test/CodeGen/func-in-block.c @@ -15,4 +15,5 @@ int main() return 0; // not reached } +// CHECK: @__func__.__main_block_invoke_0 = private constant [22 x i8] c"__main_block_invoke_0\00" // CHECK: call void @PRINTF({{.*}}@__func__.__main_block_invoke_ diff --git a/test/CodeGen/lineno-dbginfo.c b/test/CodeGen/lineno-dbginfo.c index c5c350f..176d415 100644 --- a/test/CodeGen/lineno-dbginfo.c +++ b/test/CodeGen/lineno-dbginfo.c @@ -1,6 +1,5 @@ // RUN: echo "#include <stdio.h>" > %t.h -// RUN: %clang -S -save-temps -g -include %t.h %s -emit-llvm -o %t.ll +// RUN: %clang -S -g -include %t.h %s -emit-llvm -o %t.ll // RUN: grep "i32 5" %t.ll -// RUN: rm -f lineno-dbginfo.i // outer is at line number 5. int outer = 42; diff --git a/test/CodeGen/packed-structure.c b/test/CodeGen/packed-structure.c new file mode 100644 index 0000000..2934d01 --- /dev/null +++ b/test/CodeGen/packed-structure.c @@ -0,0 +1,89 @@ +// RUN: %clang_cc1 -triple x86_64 -emit-llvm -o - %s | opt -S -strip -o %t +// RUX: llvm-gcc -flto -S -O3 -o %t %s +// RUN: FileCheck --check-prefix=CHECK-GLOBAL < %t %s +// RUN: FileCheck --check-prefix=CHECK-FUNCTIONS < %t %s + +struct s0 { + int x; + int y __attribute__((packed)); +}; + +// CHECK-GLOBAL: @s0_align_x = global i32 4 + +// FIXME: This should be 1 to match gcc. PR7951. +// CHECK-GLOBAL: @s0_align_y = global i32 4 + +// CHECK-GLOBAL: @s0_align = global i32 4 +int s0_align_x = __alignof(((struct s0*)0)->x); +int s0_align_y = __alignof(((struct s0*)0)->y); +int s0_align = __alignof(struct s0); + +// CHECK-FUNCTIONS: define i32 @s0_load_x +// CHECK-FUNCTIONS: [[s0_load_x:%.*]] = load i32* {{.*}}, align 4 +// CHECK-FUNCTIONS: ret i32 [[s0_load_x]] +int s0_load_x(struct s0 *a) { return a->x; } +// FIXME: This seems like it should be align 1. This is actually something which +// has changed in llvm-gcc recently, previously both x and y would be loaded +// with align 1 (in 2363.1 at least). +// +// CHECK-FUNCTIONS: define i32 @s0_load_y +// CHECK-FUNCTIONS: [[s0_load_y:%.*]] = load i32* {{.*}}, align 4 +// CHECK-FUNCTIONS: ret i32 [[s0_load_y]] +int s0_load_y(struct s0 *a) { return a->y; } +// CHECK-FUNCTIONS: define void @s0_copy +// CHECK-FUNCTIONS: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 8, i32 4, i1 false) +void s0_copy(struct s0 *a, struct s0 *b) { *b = *a; } + +// + +struct s1 { + int x; + int y; +} __attribute__((packed)); + +// CHECK-GLOBAL: @s1_align_x = global i32 1 +// CHECK-GLOBAL: @s1_align_y = global i32 1 +// CHECK-GLOBAL: @s1_align = global i32 1 +int s1_align_x = __alignof(((struct s1*)0)->x); +int s1_align_y = __alignof(((struct s1*)0)->y); +int s1_align = __alignof(struct s1); + +// CHECK-FUNCTIONS: define i32 @s1_load_x +// CHECK-FUNCTIONS: [[s1_load_x:%.*]] = load i32* {{.*}}, align 1 +// CHECK-FUNCTIONS: ret i32 [[s1_load_x]] +int s1_load_x(struct s1 *a) { return a->x; } +// CHECK-FUNCTIONS: define i32 @s1_load_y +// CHECK-FUNCTIONS: [[s1_load_y:%.*]] = load i32* {{.*}}, align 1 +// CHECK-FUNCTIONS: ret i32 [[s1_load_y]] +int s1_load_y(struct s1 *a) { return a->y; } +// CHECK-FUNCTIONS: define void @s1_copy +// CHECK-FUNCTIONS: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 8, i32 1, i1 false) +void s1_copy(struct s1 *a, struct s1 *b) { *b = *a; } + +// + +#pragma pack(push,2) +struct s2 { + int x; + int y; +}; +#pragma pack(pop) + +// CHECK-GLOBAL: @s2_align_x = global i32 2 +// CHECK-GLOBAL: @s2_align_y = global i32 2 +// CHECK-GLOBAL: @s2_align = global i32 2 +int s2_align_x = __alignof(((struct s2*)0)->x); +int s2_align_y = __alignof(((struct s2*)0)->y); +int s2_align = __alignof(struct s2); + +// CHECK-FUNCTIONS: define i32 @s2_load_x +// CHECK-FUNCTIONS: [[s2_load_y:%.*]] = load i32* {{.*}}, align 2 +// CHECK-FUNCTIONS: ret i32 [[s2_load_y]] +int s2_load_x(struct s2 *a) { return a->x; } +// CHECK-FUNCTIONS: define i32 @s2_load_y +// CHECK-FUNCTIONS: [[s2_load_y:%.*]] = load i32* {{.*}}, align 2 +// CHECK-FUNCTIONS: ret i32 [[s2_load_y]] +int s2_load_y(struct s2 *a) { return a->y; } +// CHECK-FUNCTIONS: define void @s2_copy +// CHECK-FUNCTIONS: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 8, i32 2, i1 false) +void s2_copy(struct s2 *a, struct s2 *b) { *b = *a; } diff --git a/test/CodeGen/palignr.c b/test/CodeGen/palignr.c index 6297b2e..e9c1dbd 100644 --- a/test/CodeGen/palignr.c +++ b/test/CodeGen/palignr.c @@ -27,4 +27,4 @@ int2 align6(int2 a, int2 b) { return _mm_alignr_pi8(a, b, 9); } int2 align7(int2 a, int2 b) { return _mm_alignr_pi8(a, b, 16); } // CHECK: palignr -int2 align8(int2 a, int2 b) { return _mm_alignr_pi8(a, b, 7); }
\ No newline at end of file +int2 align8(int2 a, int2 b) { return _mm_alignr_pi8(a, b, 7); } diff --git a/test/CodeGen/pragma-visibility.c b/test/CodeGen/pragma-visibility.c new file mode 100644 index 0000000..16460a2 --- /dev/null +++ b/test/CodeGen/pragma-visibility.c @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s + +#pragma GCC visibility push(hidden) +int x = 2; +// CHECK: @x = hidden global + +extern int y; +#pragma GCC visibility pop +int y = 4; +// CHECK: @y = hidden global + +#pragma GCC visibility push(hidden) +extern __attribute((visibility("default"))) int z; +int z = 0; +// CHECK: @z = global +#pragma GCC visibility pop + +#pragma GCC visibility push(hidden) +void f() {} +// CHECK: define hidden void @f + +__attribute((visibility("default"))) void g(); +void g() {} +// CHECK: define void @g diff --git a/test/CodeGen/statements.c b/test/CodeGen/statements.c index 7ed82ad..0ea0597 100644 --- a/test/CodeGen/statements.c +++ b/test/CodeGen/statements.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Wreturn-type < %s -emit-llvm +// RUN: %clang_cc1 -Wreturn-type %s -emit-llvm -o /dev/null void test1(int x) { switch (x) { @@ -31,5 +31,10 @@ static long y = &&baz; } // PR3869 -int test5(long long b) { goto *b; } +int test5(long long b) { + static void *lbls[] = { &&lbl }; + goto *b; + lbl: + return 0; +} diff --git a/test/CodeGen/struct-passing.c b/test/CodeGen/struct-passing.c index 409d14e..cbc14d5 100644 --- a/test/CodeGen/struct-passing.c +++ b/test/CodeGen/struct-passing.c @@ -1,10 +1,10 @@ // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o %t %s -// RUN: grep 'declare i32 @f0() readnone$' %t -// RUN: grep 'declare i32 @f1() readonly$' %t -// RUN: grep 'declare void @f2(.* sret)$' %t -// RUN: grep 'declare void @f3(.* sret)$' %t -// RUN: grep 'declare void @f4(.* byval)$' %t -// RUN: grep 'declare void @f5(.* byval)$' %t +// RUN: grep 'declare i32 @f0() readnone' %t +// RUN: grep 'declare i32 @f1() readonly' %t +// RUN: grep 'declare void @f2(.* sret)' %t +// RUN: grep 'declare void @f3(.* sret)' %t +// RUN: grep 'declare void @f4(.* byval)' %t +// RUN: grep 'declare void @f5(.* byval)' %t // PR3835 typedef int T0; diff --git a/test/CodeGen/thread-specifier.c b/test/CodeGen/thread-specifier.c index b1e1ed8..a16103f 100644 --- a/test/CodeGen/thread-specifier.c +++ b/test/CodeGen/thread-specifier.c @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple i686-pc-linux-gnu -emit-llvm -o - %s | grep thread_local | count 4 +// RUN: %clang_cc1 -triple i686-pc-linux-gnu -emit-llvm -o - %s | not grep common __thread int a; extern __thread int b; diff --git a/test/CodeGen/trapv.c b/test/CodeGen/trapv.c index d10d617..7f192c6 100644 --- a/test/CodeGen/trapv.c +++ b/test/CodeGen/trapv.c @@ -1,10 +1,51 @@ -// RUN: %clang_cc1 -ftrapv %s -emit-llvm -o %t -// RUN: grep "__overflow_handler" %t | count 2 +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -ftrapv %s -emit-llvm -o - | FileCheck %s + +// CHECK: [[I32O:%.*]] = type { i32, i1 } unsigned int ui, uj, uk; int i, j, k; -void foo() { +// CHECK: define void @test0() +void test0() { + // -ftrapv doesn't affect unsigned arithmetic. + // CHECK: [[T1:%.*]] = load i32* @uj + // CHECK-NEXT: [[T2:%.*]] = load i32* @uk + // CHECK-NEXT: [[T3:%.*]] = add i32 [[T1]], [[T2]] + // CHECK-NEXT: store i32 [[T3]], i32* @ui ui = uj + uk; + + // CHECK: [[T1:%.*]] = load i32* @j + // CHECK-NEXT: [[T2:%.*]] = load i32* @k + // CHECK-NEXT: [[T3:%.*]] = call [[I32O]] @llvm.sadd.with.overflow.i32(i32 [[T1]], i32 [[T2]]) + // CHECK-NEXT: [[T4:%.*]] = extractvalue [[I32O]] [[T3]], 0 + // CHECK-NEXT: [[T5:%.*]] = extractvalue [[I32O]] [[T3]], 1 + // CHECK-NEXT: br i1 [[T5]] + // CHECK: call void @llvm.trap() i = j + k; } + +// CHECK: define void @test1() +void test1() { + extern void opaque(int); + opaque(i++); + + // CHECK: [[T1:%.*]] = load i32* @i + // CHECK-NEXT: [[T2:%.*]] = call [[I32O]] @llvm.sadd.with.overflow.i32(i32 [[T1]], i32 1) + // CHECK-NEXT: [[T3:%.*]] = extractvalue [[I32O]] [[T2]], 0 + // CHECK-NEXT: [[T4:%.*]] = extractvalue [[I32O]] [[T2]], 1 + // CHECK-NEXT: br i1 [[T4]] + // CHECK: call void @llvm.trap() +} + +// CHECK: define void @test2() +void test2() { + extern void opaque(int); + opaque(++i); + + // CHECK: [[T1:%.*]] = load i32* @i + // CHECK-NEXT: [[T2:%.*]] = call [[I32O]] @llvm.sadd.with.overflow.i32(i32 [[T1]], i32 1) + // CHECK-NEXT: [[T3:%.*]] = extractvalue [[I32O]] [[T2]], 0 + // CHECK-NEXT: [[T4:%.*]] = extractvalue [[I32O]] [[T2]], 1 + // CHECK-NEXT: br i1 [[T4]] + // CHECK: call void @llvm.trap() +} diff --git a/test/CodeGen/unwind-attr.c b/test/CodeGen/unwind-attr.c index ee3199d..c588ca8 100644 --- a/test/CodeGen/unwind-attr.c +++ b/test/CodeGen/unwind-attr.c @@ -1,6 +1,24 @@ -// RUN: %clang_cc1 -fexceptions -emit-llvm -o - %s | grep "@foo()" | not grep nounwind -// RUN: %clang_cc1 -emit-llvm -o - %s | grep "@foo()" | grep nounwind +// RUN: %clang_cc1 -fexceptions -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefix NOEXC %s -int foo(void) { +int opaque(); + +// CHECK: define [[INT:i.*]] @test0() { +// CHECK-NOEXC: define [[INT:i.*]] @test0() nounwind { +int test0(void) { + return opaque(); +} + +// <rdar://problem/8087431>: locally infer nounwind at -O0 +// CHECK: define [[INT:i.*]] @test1() nounwind { +// CHECK-NOEXC: define [[INT:i.*]] @test1() nounwind { +int test1(void) { + return 0; +} + +// <rdar://problem/8283071>: not for weak functions +// CHECK: define weak [[INT:i.*]] @test2() { +// CHECK-NOEXC: define weak [[INT:i.*]] @test2() nounwind { +__attribute__((weak)) int test2(void) { return 0; } diff --git a/test/CodeGen/vector.c b/test/CodeGen/vector.c index c16d65b..3fa5f14 100644 --- a/test/CodeGen/vector.c +++ b/test/CodeGen/vector.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -target-cpu pentium4 -g -emit-llvm %s -o - +// RUN: %clang_cc1 -triple i386-apple-darwin9 -O1 -target-cpu pentium4 -target-feature +sse4.1 -g -emit-llvm %s -o - | FileCheck %s typedef short __v4hi __attribute__ ((__vector_size__ (8))); void test1() { @@ -20,6 +20,8 @@ void test3 ( vec4* a, char b, float c ) { +// Don't include mm_malloc.h, it's system specific. +#define __MM_MALLOC_H #include <mmintrin.h> @@ -40,3 +42,16 @@ int test4(int argc, char *argv[]) { return result; } + +#include <smmintrin.h> + +unsigned long test_epi8(__m128i x) { return _mm_extract_epi8(x, 4); } +// CHECK: @test_epi8 +// CHECK: extractelement <16 x i8> {{.*}}, i32 4 +// CHECK: zext i8 {{.*}} to i32 + +unsigned long test_epi16(__m128i x) { return _mm_extract_epi16(x, 3); } + +// CHECK: @test_epi16 +// CHECK: extractelement <8 x i16> {{.*}}, i32 3 +// CHECK: zext i16 {{.*}} to i32 diff --git a/test/CodeGen/x86_32-arguments.c b/test/CodeGen/x86_32-arguments.c index 01c3e23..75dfb82 100644 --- a/test/CodeGen/x86_32-arguments.c +++ b/test/CodeGen/x86_32-arguments.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fblocks -triple i386-apple-darwin9 -emit-llvm -o %t %s +// RUN: %clang_cc1 -w -fblocks -triple i386-apple-darwin9 -emit-llvm -o %t %s // RUN: FileCheck < %t %s // CHECK: define signext i8 @f0() @@ -214,3 +214,17 @@ struct __attribute__((aligned(32))) s53 { int y; }; void f53(struct s53 x) {} + +typedef unsigned short v2i16 __attribute__((__vector_size__(4))); + +// CHECK: define i32 @f54(i32 %arg.coerce) +// rdar://8359483 +v2i16 f54(v2i16 arg) { return arg+arg; } + + +typedef int v4i32 __attribute__((__vector_size__(16))); + +// CHECK: define <2 x i64> @f55(<4 x i32> %arg) +// PR8029 +v4i32 f55(v4i32 arg) { return arg+arg; } + diff --git a/test/CodeGen/x86_64-arguments.c b/test/CodeGen/x86_64-arguments.c index cc318dc..51a234d 100644 --- a/test/CodeGen/x86_64-arguments.c +++ b/test/CodeGen/x86_64-arguments.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o %t %s -// RUN: FileCheck < %t %s +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s| FileCheck %s +#include <stdarg.h> // CHECK: %0 = type { i64, double } @@ -63,8 +63,8 @@ void f10(struct s10 a0) {} // CHECK: define void @f11(%struct.s19* sret %agg.result) union { long double a; float b; } f11() { while (1) {} } -// CHECK: define i64 @f12_0() -// CHECK: define void @f12_1(i64 %a0.coerce) +// CHECK: define i32 @f12_0() +// CHECK: define void @f12_1(i32 %a0.coerce) struct s12 { int a __attribute__((aligned(16))); }; struct s12 f12_0(void) { while (1) {} } void f12_1(struct s12 a0) {} @@ -131,3 +131,117 @@ void f22(L x, L y) { } // CHECK: %y = alloca{{.*}}, align 16 + +// PR7714 +struct f23S { + short f0; + unsigned f1; + int f2; +}; + + +void f23(int A, struct f23S B) { + // CHECK: define void @f23(i32 %A, i64 %B.coerce0, i32 %B.coerce1) +} + +struct f24s { long a; int b; }; + +struct f23S f24(struct f23S *X, struct f24s *P2) { + return *X; + + // CHECK: define %struct.f24s @f24(%struct.f23S* %X, %struct.f24s* %P2) +} + +// rdar://8248065 +typedef float v4f32 __attribute__((__vector_size__(16))); +v4f32 f25(v4f32 X) { + // CHECK: define <4 x float> @f25(<4 x float> %X) + // CHECK-NOT: alloca + // CHECK: alloca <4 x float> + // CHECK-NOT: alloca + // CHECK: store <4 x float> %X, <4 x float>* + // CHECK-NOT: store + // CHECK: ret <4 x float> + return X+X; +} + +struct foo26 { + int *X; + float *Y; +}; + +struct foo26 f26(struct foo26 *P) { + // CHECK: define %struct.foo26 @f26(%struct.foo26* %P) + return *P; +} + + +struct v4f32wrapper { + v4f32 v; +}; + +struct v4f32wrapper f27(struct v4f32wrapper X) { + // CHECK: define <4 x float> @f27(<4 x float> %X.coerce) + return X; +} + +// rdar://5711709 +struct f28c { + double x; + int y; +}; +void f28(struct f28c C) { + // CHECK: define void @f28(double %C.coerce0, i32 %C.coerce1) +} + +struct f29a { + struct c { + double x; + int y; + } x[1]; +}; + +void f29a(struct f29a A) { + // CHECK: define void @f29a(double %A.coerce0, i32 %A.coerce1) +} + +// rdar://8249586 +struct S0 { char f0[8]; char f2; char f3; char f4; }; +void f30(struct S0 p_4) { + // CHECK: define void @f30(i64 %p_4.coerce0, i24 %p_4.coerce1) +} + +// Pass the third element as a float when followed by tail padding. +// rdar://8251384 +struct f31foo { float a, b, c; }; +float f31(struct f31foo X) { + // CHECK: define float @f31(<2 x float> %X.coerce0, float %X.coerce1) + return X.c; +} + +_Complex float f32(_Complex float A, _Complex float B) { + // rdar://6379669 + // CHECK: define <2 x float> @f32(<2 x float> %A.coerce, <2 x float> %B.coerce) + return A+B; +} + + +// rdar://8357396 +struct f33s { long x; float c,d; }; + +void f33(va_list X) { + va_arg(X, struct f33s); +} + +typedef unsigned long long v1i64 __attribute__((__vector_size__(8))); + +// rdar://8359248 +// CHECK: define i64 @f34(i64 %arg.coerce) +v1i64 f34(v1i64 arg) { return arg; } + + +// rdar://8358475 +// CHECK: define i64 @f35(i64 %arg.coerce) +typedef unsigned long v1i64_2 __attribute__((__vector_size__(8))); +v1i64_2 f35(v1i64_2 arg) { return arg+arg; } + diff --git a/test/CodeGenCXX/anonymous-namespaces.cpp b/test/CodeGenCXX/anonymous-namespaces.cpp index fb3470c..3ec7032 100644 --- a/test/CodeGenCXX/anonymous-namespaces.cpp +++ b/test/CodeGenCXX/anonymous-namespaces.cpp @@ -1,12 +1,14 @@ -// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm %s -o - > %t +// RUN: FileCheck %s -check-prefix=1 < %t +// RUN: FileCheck %s -check-prefix=2 < %t int f(); namespace { - // CHECK: @_ZN12_GLOBAL__N_11bE = internal global i32 0 - // CHECK: @_ZN12_GLOBAL__N_1L1cE = internal global i32 0 - // CHECK: @_ZN12_GLOBAL__N_11D1dE = internal global i32 0 - // CHECK: @_ZN12_GLOBAL__N_11aE = internal global i32 0 + // CHECK-1: @_ZN12_GLOBAL__N_11bE = internal global i32 0 + // CHECK-1: @_ZN12_GLOBAL__N_1L1cE = internal global i32 0 + // CHECK-1: @_ZN12_GLOBAL__N_11D1dE = internal global i32 0 + // CHECK-1: @_ZN12_GLOBAL__N_11aE = internal global i32 0 int a = 0; int b = f(); @@ -20,18 +22,18 @@ namespace { int D::d = f(); // Check for generation of a VTT with internal linkage - // CHECK: @_ZTSN12_GLOBAL__N_11X1EE = internal constant + // CHECK-1: @_ZTSN12_GLOBAL__N_11X1EE = internal constant struct X { struct EBase { }; struct E : public virtual EBase { virtual ~E() {} }; }; - // CHECK: define internal i32 @_ZN12_GLOBAL__N_13fooEv() + // CHECK-1: define internal i32 @_ZN12_GLOBAL__N_13fooEv() int foo() { return 32; } - // CHECK: define internal i32 @_ZN12_GLOBAL__N_11A3fooEv() + // CHECK-1: define internal i32 @_ZN12_GLOBAL__N_11A3fooEv() namespace A { int foo() { return 45; @@ -44,3 +46,23 @@ int concrete() { } void test_XE() { throw X::E(); } + +// Miscompile on llvmc plugins. +namespace test2 { + struct A { + template <class T> struct B { + static void foo() {} + }; + }; + namespace { + struct C; + } + + // CHECK-2: define void @_ZN5test24testEv() + // CHECK-2: call void @_ZN5test21A1BINS_12_GLOBAL__N_11CEE3fooEv() + void test() { + A::B<C>::foo(); + } + + // CHECK-2: define internal void @_ZN5test21A1BINS_12_GLOBAL__N_11CEE3fooEv() +} diff --git a/test/CodeGenCXX/anonymous-union-member-initializer.cpp b/test/CodeGenCXX/anonymous-union-member-initializer.cpp index a4da2c0..9ba3805 100644 --- a/test/CodeGenCXX/anonymous-union-member-initializer.cpp +++ b/test/CodeGenCXX/anonymous-union-member-initializer.cpp @@ -78,3 +78,15 @@ namespace test3 { // CHECK-NEXT: [[CVALUE:%.*]] = getelementptr inbounds {{.*}} [[STRUCT]], i32 0, i32 0 // CHECK-NEXT: store i8* null, void i8** [[CVALUE]] } + +struct S { + // CHECK: store i32 42 + // CHECK: store i32 55 + S() : x(42), y(55) {} + union { + struct { + int x; + union { int y; }; + }; + }; +} s; diff --git a/test/CodeGenCXX/arm.cpp b/test/CodeGenCXX/arm.cpp index 1d4085c..44c0aff 100644 --- a/test/CodeGenCXX/arm.cpp +++ b/test/CodeGenCXX/arm.cpp @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 %s -triple=thumbv7-apple-darwin3.0.0-iphoneos -fno-use-cxa-atexit -target-abi apcs-gnu -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple=thumbv7-apple-darwin3.0.0-iphoneos -fno-use-cxa-atexit -target-abi apcs-gnu -emit-llvm -o - -fexceptions | FileCheck %s + +typedef typeof(sizeof(int)) size_t; class foo { public: @@ -13,7 +15,275 @@ public: // The global dtor needs the right calling conv with -fno-use-cxa-atexit // rdar://7817590 +// Checked at end of file. bar baz; +// Destructors and constructors must return this. +namespace test1 { + void foo(); + + struct A { + A(int i) { foo(); } + ~A() { foo(); } + void bar() { foo(); } + }; + + // CHECK: define void @_ZN5test14testEv() + void test() { + // CHECK: [[AV:%.*]] = alloca [[A:%.*]], align 1 + // CHECK: call [[A]]* @_ZN5test11AC1Ei([[A]]* [[AV]], i32 10) + // CHECK: invoke void @_ZN5test11A3barEv([[A]]* [[AV]]) + // CHECK: call [[A]]* @_ZN5test11AD1Ev([[A]]* [[AV]]) + // CHECK: ret void + A a = 10; + a.bar(); + } + + // CHECK: define linkonce_odr [[A]]* @_ZN5test11AC1Ei([[A]]* + // CHECK: [[RET:%.*]] = alloca [[A]]*, align 4 + // CHECK: [[THIS:%.*]] = alloca [[A]]*, align 4 + // CHECK: store [[A]]* {{.*}}, [[A]]** [[THIS]] + // CHECK: [[THIS1:%.*]] = load [[A]]** [[THIS]] + // CHECK: store [[A]]* [[THIS1]], [[A]]** [[RET]] + // CHECK: call [[A]]* @_ZN5test11AC2Ei( + // CHECK: [[THIS2:%.*]] = load [[A]]** [[RET]] + // CHECK: ret [[A]]* [[THIS2]] + + // CHECK: define linkonce_odr [[A]]* @_ZN5test11AD1Ev([[A]]* + // CHECK: [[RET:%.*]] = alloca [[A]]*, align 4 + // CHECK: [[THIS:%.*]] = alloca [[A]]*, align 4 + // CHECK: store [[A]]* {{.*}}, [[A]]** [[THIS]] + // CHECK: [[THIS1:%.*]] = load [[A]]** [[THIS]] + // CHECK: store [[A]]* [[THIS1]], [[A]]** [[RET]] + // CHECK: call [[A]]* @_ZN5test11AD2Ev( + // CHECK: [[THIS2:%.*]] = load [[A]]** [[RET]] + // CHECK: ret [[A]]* [[THIS2]] +} + +// Awkward virtual cases. +namespace test2 { + void foo(); + + struct A { + int x; + + A(int); + virtual ~A() { foo(); } + }; + + struct B { + int y; + int z; + + B(int); + virtual ~B() { foo(); } + }; + + struct C : A, virtual B { + int q; + + C(int i) : A(i), B(i) { foo(); } + ~C() { foo(); } + }; + + void test() { + C c = 10; + } + + // Tests at eof +} + +namespace test3 { + struct A { + int x; + ~A(); + }; + + void a() { + // CHECK: define void @_ZN5test31aEv() + // CHECK: call noalias i8* @_Znam(i32 48) + // CHECK: store i32 4 + // CHECK: store i32 10 + A *x = new A[10]; + } + + void b(int n) { + // CHECK: define void @_ZN5test31bEi( + // CHECK: [[N:%.*]] = load i32* + // CHECK: @llvm.umul.with.overflow.i32(i32 [[N]], i32 4) + // CHECK: @llvm.uadd.with.overflow.i32(i32 {{.*}}, i32 8) + // CHECK: [[SZ:%.*]] = select + // CHECK: call noalias i8* @_Znam(i32 [[SZ]]) + // CHECK: store i32 4 + // CHECK: store i32 [[N]] + A *x = new A[n]; + } + + void c() { + // CHECK: define void @_ZN5test31cEv() + // CHECK: call noalias i8* @_Znam(i32 808) + // CHECK: store i32 4 + // CHECK: store i32 200 + A (*x)[20] = new A[10][20]; + } + + void d(int n) { + // CHECK: define void @_ZN5test31dEi( + // CHECK: [[N:%.*]] = load i32* + // CHECK: [[NE:%.*]] = mul i32 [[N]], 20 + // CHECK: @llvm.umul.with.overflow.i32(i32 [[N]], i32 80) + // CHECK: @llvm.uadd.with.overflow.i32(i32 {{.*}}, i32 8) + // CHECK: [[SZ:%.*]] = select + // CHECK: call noalias i8* @_Znam(i32 [[SZ]]) + // CHECK: store i32 4 + // CHECK: store i32 [[NE]] + A (*x)[20] = new A[n][20]; + } + + void e(A *x) { + // CHECK: define void @_ZN5test31eEPNS_1AE( + // CHECK: icmp eq {{.*}}, null + // CHECK: getelementptr {{.*}}, i64 -8 + // CHECK: getelementptr {{.*}}, i64 4 + // CHECK: bitcast {{.*}} to i32* + // CHECK: load + // CHECK: invoke {{.*}} @_ZN5test31AD1Ev + // CHECK: call void @_ZdaPv + delete [] x; + } + + void f(A (*x)[20]) { + // CHECK: define void @_ZN5test31fEPA20_NS_1AE( + // CHECK: icmp eq {{.*}}, null + // CHECK: getelementptr {{.*}}, i64 -8 + // CHECK: getelementptr {{.*}}, i64 4 + // CHECK: bitcast {{.*}} to i32* + // CHECK: load + // CHECK: invoke {{.*}} @_ZN5test31AD1Ev + // CHECK: call void @_ZdaPv + delete [] x; + } +} + +namespace test4 { + struct A { + int x; + void operator delete[](void *, size_t sz); + }; + + void a() { + // CHECK: define void @_ZN5test41aEv() + // CHECK: call noalias i8* @_Znam(i32 48) + // CHECK: store i32 4 + // CHECK: store i32 10 + A *x = new A[10]; + } + + void b(int n) { + // CHECK: define void @_ZN5test41bEi( + // CHECK: [[N:%.*]] = load i32* + // CHECK: @llvm.umul.with.overflow.i32(i32 [[N]], i32 4) + // CHECK: @llvm.uadd.with.overflow.i32(i32 {{.*}}, i32 8) + // CHECK: [[SZ:%.*]] = select + // CHECK: call noalias i8* @_Znam(i32 [[SZ]]) + // CHECK: store i32 4 + // CHECK: store i32 [[N]] + A *x = new A[n]; + } + + void c() { + // CHECK: define void @_ZN5test41cEv() + // CHECK: call noalias i8* @_Znam(i32 808) + // CHECK: store i32 4 + // CHECK: store i32 200 + A (*x)[20] = new A[10][20]; + } + + void d(int n) { + // CHECK: define void @_ZN5test41dEi( + // CHECK: [[N:%.*]] = load i32* + // CHECK: [[NE:%.*]] = mul i32 [[N]], 20 + // CHECK: @llvm.umul.with.overflow.i32(i32 [[N]], i32 80) + // CHECK: @llvm.uadd.with.overflow.i32(i32 {{.*}}, i32 8) + // CHECK: [[SZ:%.*]] = select + // CHECK: call noalias i8* @_Znam(i32 [[SZ]]) + // CHECK: store i32 4 + // CHECK: store i32 [[NE]] + A (*x)[20] = new A[n][20]; + } + + void e(A *x) { + // CHECK: define void @_ZN5test41eEPNS_1AE( + // CHECK: [[ALLOC:%.*]] = getelementptr inbounds {{.*}}, i64 -8 + // CHECK: getelementptr inbounds {{.*}}, i64 4 + // CHECK: bitcast + // CHECK: [[T0:%.*]] = load i32* + // CHECK: [[T1:%.*]] = mul i32 4, [[T0]] + // CHECK: [[T2:%.*]] = add i32 [[T1]], 8 + // CHECK: call void @_ZN5test41AdaEPvm(i8* [[ALLOC]], i32 [[T2]]) + delete [] x; + } + + void f(A (*x)[20]) { + // CHECK: define void @_ZN5test41fEPA20_NS_1AE( + // CHECK: [[ALLOC:%.*]] = getelementptr inbounds {{.*}}, i64 -8 + // CHECK: getelementptr inbounds {{.*}}, i64 4 + // CHECK: bitcast + // CHECK: [[T0:%.*]] = load i32* + // CHECK: [[T1:%.*]] = mul i32 4, [[T0]] + // CHECK: [[T2:%.*]] = add i32 [[T1]], 8 + // CHECK: call void @_ZN5test41AdaEPvm(i8* [[ALLOC]], i32 [[T2]]) + delete [] x; + } +} + +// <rdar://problem/8386802>: don't crash +namespace test5 { + struct A { + ~A(); + }; + + // CHECK: define void @_ZN5test54testEPNS_1AE + void test(A *a) { + // CHECK: [[PTR:%.*]] = alloca [[A:%.*]]*, align 4 + // CHECK-NEXT: store [[A]]* {{.*}}, [[A]]** [[PTR]], align 4 + // CHECK-NEXT: [[TMP:%.*]] = load [[A]]** [[PTR]], align 4 + // CHECK-NEXT: call [[A]]* @_ZN5test51AD1Ev([[A]]* [[TMP]]) + // CHECK-NEXT: ret void + a->~A(); + } +} + +namespace test6 { + struct A { + virtual ~A(); + }; + + // CHECK: define void @_ZN5test64testEPNS_1AE + void test(A *a) { + // CHECK: [[AVAR:%.*]] = alloca [[A:%.*]]*, align 4 + // CHECK-NEXT: store [[A]]* {{.*}}, [[A]]** [[AVAR]], align 4 + // CHECK-NEXT: [[V:%.*]] = load [[A]]** [[AVAR]], align 4 + // CHECK-NEXT: [[ISNULL:%.*]] = icmp eq [[A]]* [[V]], null + // CHECK-NEXT: br i1 [[ISNULL]] + // CHECK: [[T0:%.*]] = bitcast [[A]]* [[V]] to [[A]]* ([[A]]*)*** + // CHECK-NEXT: [[T1:%.*]] = load [[A]]* ([[A]]*)*** [[T0]] + // CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds [[A]]* ([[A]]*)** [[T1]], i64 1 + // CHECK-NEXT: [[T3:%.*]] = load [[A]]* ([[A]]*)** [[T2]] + // CHECK-NEXT: call [[A]]* [[T3]]([[A]]* [[V]]) + // CHECK-NEXT: br label + // CHECK: ret void + delete a; + } +} + + // CHECK: define linkonce_odr [[C:%.*]]* @_ZTv0_n12_N5test21CD1Ev( + // CHECK: call [[C]]* @_ZN5test21CD1Ev( + // CHECK: ret [[C]]* undef + + // CHECK: define linkonce_odr void @_ZTv0_n12_N5test21CD0Ev( + // CHECK: call void @_ZN5test21CD0Ev( + // CHECK: ret void + // CHECK: @_GLOBAL__D_a() -// CHECK: call void @_ZN3barD1Ev(%class.bar* @baz) +// CHECK: call %class.bar* @_ZN3barD1Ev(%class.bar* @baz) diff --git a/test/CodeGenCXX/condition.cpp b/test/CodeGenCXX/condition.cpp index 652e7c8..cc2eaf5 100644 --- a/test/CodeGenCXX/condition.cpp +++ b/test/CodeGenCXX/condition.cpp @@ -105,12 +105,12 @@ void while_destruct(int z) { // CHECK-NEXT: br i1 [[COND]] // Loop-exit staging block. - // CHECK: store i32 1, i32* [[CLEANUPDEST]] + // CHECK: store i32 3, i32* [[CLEANUPDEST]] // CHECK-NEXT: br // While body. // CHECK: store i32 21, i32* [[Z]] - // CHECK: store i32 2, i32* [[CLEANUPDEST]] + // CHECK: store i32 0, i32* [[CLEANUPDEST]] // CHECK-NEXT: br z = 21; @@ -138,7 +138,7 @@ void while_destruct(int z) { // CHECK: define void @_Z12for_destructi( void for_destruct(int z) { // CHECK: [[Z:%.*]] = alloca i32 - // CHECK: [[XDEST:%.*]] = alloca i32 + // CHECK: [[CLEANUPDEST:%.*]] = alloca i32 // CHECK: [[I:%.*]] = alloca i32 // CHECK: call void @_ZN1YC1Ev // CHECK-NEXT: br @@ -152,7 +152,7 @@ void for_destruct(int z) { // -> %for.body, %for.cond.cleanup // %for.cond.cleanup: Exit cleanup staging. - // CHECK: store i32 1, i32* [[XDEST]] + // CHECK: store i32 2, i32* [[CLEANUPDEST]] // CHECK-NEXT: br // -> %cleanup @@ -166,21 +166,21 @@ void for_destruct(int z) { // CHECK: [[TMP:%.*]] = load i32* [[Z]] // CHECK-NEXT: [[INC:%.*]] = add nsw i32 [[TMP]], 1 // CHECK-NEXT: store i32 [[INC]], i32* [[Z]] - // CHECK-NEXT: store i32 2, i32* [[XDEST]] + // CHECK-NEXT: store i32 0, i32* [[CLEANUPDEST]] // CHECK-NEXT: br // -> %cleanup // %cleanup: Destroys X. // CHECK: call void @_ZN1XD1Ev - // CHECK-NEXT: [[YDESTTMP:%.*]] = load i32* [[XDEST]] + // CHECK-NEXT: [[YDESTTMP:%.*]] = load i32* [[CLEANUPDEST]] // CHECK-NEXT: switch i32 [[YDESTTMP]] - // 1 -> %cleanup4, 2 -> %cleanup.cont + // 0 -> %cleanup.cont, default -> %cleanup1 // %cleanup.cont: (eliminable) // CHECK: br // -> %for.cond - // %cleanup4: Destroys Y. + // %cleanup1: Destroys Y. // CHECK: call void @_ZN1YD1Ev( // CHECK-NEXT: br // -> %for.end diff --git a/test/CodeGenCXX/copy-constructor-elim-2.cpp b/test/CodeGenCXX/copy-constructor-elim-2.cpp index 3a06c10..73e9b94 100644 --- a/test/CodeGenCXX/copy-constructor-elim-2.cpp +++ b/test/CodeGenCXX/copy-constructor-elim-2.cpp @@ -5,3 +5,29 @@ A f() { return A(0); } // CHECK: define void @_Z1fv // CHECK: call void @_ZN1AC1Ei // CHECK-NEXT: ret void + +// Verify that we do not elide copies when constructing a base class. +namespace no_elide_base { + struct Base { + Base(const Base&); + ~Base(); + }; + + struct Other { + operator Base() const; + }; + + struct Derived : public virtual Base { + Derived(const Other &O); + }; + + // CHECK: define void @_ZN13no_elide_base7DerivedC1ERKNS_5OtherE + Derived::Derived(const Other &O) + // CHECK: call void @_ZNK13no_elide_base5OthercvNS_4BaseEEv + // CHECK: call void @_ZN13no_elide_base4BaseC2ERKS0_ + // CHECK: call void @_ZN13no_elide_base4BaseD1Ev + : Base(O) + { + // CHECK: ret void + } +} diff --git a/test/CodeGenCXX/debug-info-byval.cpp b/test/CodeGenCXX/debug-info-byval.cpp new file mode 100644 index 0000000..c99518e --- /dev/null +++ b/test/CodeGenCXX/debug-info-byval.cpp @@ -0,0 +1,31 @@ +// RUN: %clang -g -S %s -o - | FileCheck %s +// Test to check presense of debug info for byval parameter. +// Radar 8350436. +class DAG { +public: + int i; + int j; +}; + +class EVT { +public: + int a; + int b; + int c; +}; + +class VAL { +public: + int x; + int y; +}; +void foo(EVT e); +EVT bar(); + +void get(int *i, unsigned dl, VAL v, VAL *p, unsigned n, EVT missing_arg) { +//CHECK: .ascii "missing_arg" + EVT e = bar(); + if (dl == n) + foo(missing_arg); +} + diff --git a/test/CodeGenCXX/debug-info-class.cpp b/test/CodeGenCXX/debug-info-class.cpp new file mode 100644 index 0000000..151c5f9 --- /dev/null +++ b/test/CodeGenCXX/debug-info-class.cpp @@ -0,0 +1,12 @@ +// RUN: %clang -emit-llvm -g -S %s -o - | grep HdrSize +struct A { + int one; + static const int HdrSize = 52; + int two; + A() { + int x = 1; + } +}; +int main() { + A a; +} diff --git a/test/CodeGenCXX/debug-info-ctor.cpp b/test/CodeGenCXX/debug-info-ctor.cpp new file mode 100644 index 0000000..c31eebe --- /dev/null +++ b/test/CodeGenCXX/debug-info-ctor.cpp @@ -0,0 +1,14 @@ +// RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s + +struct X { + X(int v); + + int value; +}; + +X::X(int v) { + // CHECK_TEMPORARILY_DISABLED: call void @_ZN1XC2Ei(%struct.X* %this1, i32 %tmp), !dbg + // TEMPORARY CHECK: X + value = v; +} + diff --git a/test/CodeGenCXX/debug-info-enum.cpp b/test/CodeGenCXX/debug-info-enum.cpp new file mode 100644 index 0000000..c08fc35 --- /dev/null +++ b/test/CodeGenCXX/debug-info-enum.cpp @@ -0,0 +1,8 @@ +// RUN: %clang -fverbose-asm -S -g %s -o - | grep DW_TAG_enumeration_type + +int v; +enum index { MAX }; +void foo(void) +{ + v = MAX; +} diff --git a/test/CodeGenCXX/debug-info-friend.cpp b/test/CodeGenCXX/debug-info-friend.cpp new file mode 100644 index 0000000..c50f281 --- /dev/null +++ b/test/CodeGenCXX/debug-info-friend.cpp @@ -0,0 +1,11 @@ +// RUN: %clang -fverbose-asm -S -g %s -o - | grep DW_TAG_friend + +class MyFriend; + +class SomeClass +{ + friend class MyFriend; +}; + +SomeClass sc; + diff --git a/test/CodeGenCXX/debug-info-template.cpp b/test/CodeGenCXX/debug-info-template.cpp new file mode 100644 index 0000000..233090c --- /dev/null +++ b/test/CodeGenCXX/debug-info-template.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -emit-llvm-only -g -S %s -o - | grep "TC<int>" +template<typename T> +class TC { +public: + TC(const TC &) {} + TC() {} +}; + +TC<int> tci; diff --git a/test/CodeGenCXX/debug-info.cpp b/test/CodeGenCXX/debug-info.cpp index 6bb9533..71c8603 100644 --- a/test/CodeGenCXX/debug-info.cpp +++ b/test/CodeGenCXX/debug-info.cpp @@ -50,3 +50,8 @@ namespace VirtualBase { B b; } } + +void foo() { + const wchar_t c = L'x'; + wchar_t d = c; +} diff --git a/test/CodeGenCXX/delete.cpp b/test/CodeGenCXX/delete.cpp index 87f8698..1f52a78 100644 --- a/test/CodeGenCXX/delete.cpp +++ b/test/CodeGenCXX/delete.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -emit-llvm -o - | FileCheck %s void t1(int *a) { delete a; @@ -57,3 +57,51 @@ namespace test0 { // CHECK: define linkonce_odr void @_ZN5test01AD1Ev // CHECK: define linkonce_odr void @_ZN5test01AdlEPv } + +namespace test1 { + struct A { + int x; + ~A(); + }; + + // CHECK: define void @_ZN5test14testEPA10_A20_NS_1AE( + void test(A (*arr)[10][20]) { + delete [] arr; + // CHECK: icmp eq [10 x [20 x [[S:%.*]]]]* [[PTR:%.*]], null + // CHECK-NEXT: br i1 + + // CHECK: [[ARR:%.*]] = getelementptr inbounds [10 x [20 x [[S]]]]* [[PTR]], i32 0, i32 0, i32 0 + // CHECK-NEXT: bitcast {{.*}} to i8* + // CHECK-NEXT: [[ALLOC:%.*]] = getelementptr inbounds {{.*}}, i64 -8 + // CHECK-NEXT: bitcast i8* [[ALLOC]] to i64* + // CHECK-NEXT: load + // CHECK-NEXT: store i64 {{.*}}, i64* [[IDX:%.*]] + + // CHECK: load i64* [[IDX]] + // CHECK-NEXT: icmp ne {{.*}}, 0 + // CHECK-NEXT: br i1 + + // CHECK: load i64* [[IDX]] + // CHECK-NEXT: [[I:%.*]] = sub i64 {{.*}}, 1 + // CHECK-NEXT: getelementptr inbounds [[S]]* [[ARR]], i64 [[I]] + // CHECK-NEXT: call void @_ZN5test11AD1Ev( + // CHECK-NEXT: br label + + // CHECK: load i64* [[IDX]] + // CHECK-NEXT: sub + // CHECK-NEXT: store {{.*}}, i64* [[IDX]] + // CHECK-NEXT: br label + + // CHECK: call void @_ZdaPv(i8* [[ALLOC]]) + } +} + +namespace test2 { + // CHECK: define void @_ZN5test21fEPb + void f(bool *b) { + // CHECK: call void @_ZdlPv(i8* + delete b; + // CHECK: call void @_ZdaPv(i8* + delete [] b; + } +} diff --git a/test/CodeGenCXX/dependent-type-member-pointer.cpp b/test/CodeGenCXX/dependent-type-member-pointer.cpp new file mode 100644 index 0000000..41bb5e2 --- /dev/null +++ b/test/CodeGenCXX/dependent-type-member-pointer.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -emit-llvm-only -verify %s +// PR7736 + +template <class scriptmemberptr> int InitMember(scriptmemberptr); + +template <class> +struct contentmap +{ + static void InitDataMap() + { InitMember(&contentmap::SizeHolder); } + int SizeHolder; +}; + +void ReadFrom( ) +{ + contentmap<int>::InitDataMap(); +} + diff --git a/test/CodeGenCXX/destructors.cpp b/test/CodeGenCXX/destructors.cpp index 8efaf01..2eba30f 100644 --- a/test/CodeGenCXX/destructors.cpp +++ b/test/CodeGenCXX/destructors.cpp @@ -260,12 +260,53 @@ namespace test5 { } } -// Checks from test3: +namespace test6 { + void opaque(); - // CHECK: define internal void @_ZN5test312_GLOBAL__N_11CD2Ev( - // CHECK: call void @_ZN5test31BD2Ev( - // CHECK: call void @_ZN5test31AD2Ev( - // CHECK: ret void + struct A { ~A(); }; + template <unsigned> struct B { B(); ~B(); int _; }; + struct C : B<0>, B<1>, virtual B<2>, virtual B<3> { + A x, y, z; + + C(); + ~C(); + }; + + C::C() { opaque(); } + // CHECK: define void @_ZN5test61CC1Ev + // CHECK: call void @_ZN5test61BILj2EEC2Ev + // CHECK: invoke void @_ZN5test61BILj3EEC2Ev + // CHECK: invoke void @_ZN5test61BILj0EEC2Ev + // CHECK: invoke void @_ZN5test61BILj1EEC2Ev + // CHECK: invoke void @_ZN5test66opaqueEv + // CHECK: ret void + // FIXME: way too much EH cleanup code follows + + C::~C() { opaque(); } + // CHECK: define void @_ZN5test61CD1Ev + // CHECK: invoke void @_ZN5test61CD2Ev + // CHECK: invoke void @_ZN5test61BILj3EED2Ev + // CHECK: call void @_ZN5test61BILj2EED2Ev + // CHECK: ret void + // CHECK: invoke void @_ZN5test61BILj3EED2Ev + // CHECK: invoke void @_ZN5test61BILj2EED2Ev + + // CHECK: define void @_ZN5test61CD2Ev + // CHECK: invoke void @_ZN5test66opaqueEv + // CHECK: invoke void @_ZN5test61AD1Ev + // CHECK: invoke void @_ZN5test61AD1Ev + // CHECK: invoke void @_ZN5test61AD1Ev + // CHECK: invoke void @_ZN5test61BILj1EED2Ev + // CHECK: call void @_ZN5test61BILj0EED2Ev + // CHECK: ret void + // CHECK: invoke void @_ZN5test61AD1Ev + // CHECK: invoke void @_ZN5test61AD1Ev + // CHECK: invoke void @_ZN5test61AD1Ev + // CHECK: invoke void @_ZN5test61BILj1EED2Ev + // CHECK: invoke void @_ZN5test61BILj0EED2Ev +} + +// Checks from test3: // CHECK: define internal void @_ZN5test312_GLOBAL__N_11DD0Ev( // CHECK: invoke void @_ZN5test312_GLOBAL__N_11DD1Ev( @@ -289,6 +330,11 @@ namespace test5 { // CHECK: call void @_ZN5test312_GLOBAL__N_11DD0Ev( // CHECK: ret void + // CHECK: define internal void @_ZN5test312_GLOBAL__N_11CD2Ev( + // CHECK: invoke void @_ZN5test31BD2Ev( + // CHECK: call void @_ZN5test31AD2Ev( + // CHECK: ret void + // CHECK: declare void @_ZN5test31BD2Ev( // CHECK: declare void @_ZN5test31AD2Ev( diff --git a/test/CodeGenCXX/dyncast.cpp b/test/CodeGenCXX/dyncast.cpp index 906d44b..723e12b 100644 --- a/test/CodeGenCXX/dyncast.cpp +++ b/test/CodeGenCXX/dyncast.cpp @@ -86,15 +86,12 @@ void test1() { // CHECK-LL-NEXT: [[tmp:%.*]] = load %class.test1_A** [[bp]] // CHECK-LL-NEXT: [[v4:%.*]] = icmp ne %class.test1_A* [[tmp]], null // CHECK-LL-NEXT: br i1 [[v4]], label %[[v5:.*]], label %[[v9:.*]] -// CHECK-LL: ; <label>:[[v5]] -// CHECK-LL-NEXT: [[v6:%.*]] = bitcast %class.test1_A* [[tmp]] to i8* -// CHECK-LL-NEXT: [[v7:%.*]] = call i8* @__dynamic_cast(i8* [[v6]], i8* bitcast (%0* @_ZTI7test1_B to i8*), i8* bitcast (%1* @_ZTI7test1_D to i8*), i64 -1) ; <i8*> [#uses=1] +// CHECK-LL: [[v6:%.*]] = bitcast %class.test1_A* [[tmp]] to i8* +// CHECK-LL-NEXT: [[v7:%.*]] = call i8* @__dynamic_cast(i8* [[v6]], i8* bitcast (%0* @_ZTI7test1_B to i8*), i8* bitcast (%1* @_ZTI7test1_D to i8*), i64 -1) // CHECK-LL-NEXT: [[v8:%.*]] = bitcast i8* [[v7]] to %class.test1_D* // CHECK-LL-NEXT: br label %[[v10:.*]] -// CHECK-LL: ; <label>:[[v9]] -// CHECK-LL-NEXT: br label %[[v10]] -// CHECK-LL: ; <label>:[[v10]] -// CHECK-LL-NEXT: [[v11:%.*]] = phi %class.test1_D* [ [[v8]], %[[v5]] ], [ null, %[[v9]] ] +// CHECK-LL: br label %[[v10]] +// CHECK-LL: [[v11:%.*]] = phi %class.test1_D* [ [[v8]], %[[v5]] ], [ null, %[[v9]] ] // CHECK-LL-NEXT: store %class.test1_D* [[v11]], %class.test1_D** [[dp]] // CHECK-LL-NEXT: [[tmp4:%.*]] = load %class.test1_D** [[dp]] // CHECK-LL-NEXT: [[cmp:%.*]] = icmp eq %class.test1_D* [[tmp4]], null @@ -109,15 +106,12 @@ void test1() { // CHECK-LL-NEXT: [[tmp6:%.*]] = load %class.test1_A** [[bp]] // CHECK-LL-NEXT: [[v12:%.*]] = icmp ne %class.test1_A* [[tmp6]], null // CHECK-LL-NEXT: br i1 [[v12]], label %[[v13:.*]], label %[[v17:.*]] -// CHECK-LL: ; <label>:[[v13]] -// CHECK-LL-NEXT: [[v14:%.*]] = bitcast %class.test1_A* [[tmp6]] to i8* +// CHECK-LL: [[v14:%.*]] = bitcast %class.test1_A* [[tmp6]] to i8* // CHECK-LL-NEXT: [[v15:%.*]] = call i8* @__dynamic_cast(i8* [[v14]], i8* bitcast ({{.*}} @_ZTI7test1_B to i8*), i8* bitcast ({{.*}} @_ZTI7test1_A to i8*), i64 -1) // CHECK-LL-NEXT: [[v16:%.*]] = bitcast i8* [[v15]] to %class.test1_A* // CHECK-LL-NEXT: br label %[[v18:.*]] -// CHECK-LL: ; <label>:[[v17]] -// CHECK-LL-NEXT: br label %[[v18]] -// CHECK-LL: ; <label>:[[v18]] -// CHECK-LL-NEXT: [[v19:%.*]] = phi %class.test1_A* [ [[v16]], %[[v13]] ], [ null, %[[v17]] ] +// CHECK-LL: br label %[[v18]] +// CHECK-LL: [[v19:%.*]] = phi %class.test1_A* [ [[v16]], %[[v13]] ], [ null, %[[v17]] ] // CHECK-LL-NEXT: store %class.test1_A* [[v19]], %class.test1_A** [[ap]] // CHECK-LL-NEXT: [[tmp7:%.*]] = load %class.test1_A** [[ap]] // CHECK-LL-NEXT: [[cmp8:%.*]] = icmp eq %class.test1_A* [[tmp7]], null @@ -132,15 +126,12 @@ void test1() { // CHECK-LL-NEXT: [[tmp14:%.*]] = load %class.test1_A** [[ap]] // CHECK-LL-NEXT: [[v20:%.*]] = icmp ne %class.test1_A* [[tmp14]], null // CHECK-LL-NEXT: br i1 [[v20]], label %[[v21:.*]], label %[[v25:.*]] -// CHECK-LL: ; <label>:[[v21]] -// CHECK-LL-NEXT: [[v22:%.*]] = bitcast %class.test1_A* [[tmp14]] to i8* +// CHECK-LL: [[v22:%.*]] = bitcast %class.test1_A* [[tmp14]] to i8* // CHECK-LL-NEXT: [[v23:%.*]] = call i8* @__dynamic_cast({{.*}} [[v22]], i8* bitcast ({{.*}} @_ZTI7test1_A to i8*), i8* bitcast ({{.*}} @_ZTI7test1_B to i8*), i64 -1) // CHECK-LL-NEXT: [[v24:%.*]] = bitcast i8* [[v23]] to %class.test1_A* // CHECK-LL-NEXT: br label %[[v26:.*]] -// CHECK-LL: ; <label>:[[v25]] -// CHECK-LL-NEXT: br label %[[v26]] -// CHECK-LL: ; <label>:[[v26]] -// CHECK-LL-NEXT: [[v27:%.*]] = phi %class.test1_A* [ [[v24]], %[[v21]] ], [ null, %[[v25]] ] +// CHECK-LL: br label %[[v26]] +// CHECK-LL: [[v27:%.*]] = phi %class.test1_A* [ [[v24]], %[[v21]] ], [ null, %[[v25]] ] // CHECK-LL-NEXT: store %class.test1_A* [[v27]], %class.test1_A** [[bp]] // CHECK-LL-NEXT: [[tmp15:%.*]] = load %class.test1_A** [[bp]] // CHECK-LL-NEXT: [[cmp16:%.*]] = icmp eq %class.test1_A* [[tmp15]], null @@ -203,15 +194,12 @@ void test1() { // CHECK-LL-NEXT: [[tmp54:%.*]] = load %class.test1_A** [[ap37]] // CHECK-LL-NEXT: [[v34:%.*]] = icmp ne %class.test1_A* [[tmp54]], null // CHECK-LL-NEXT: br i1 [[v34]], label %[[v35:.*]], label %[[v39:.*]] -// CHECK-LL: ; <label>:[[v35]] -// CHECK-LL-NEXT: [[v36:%.*]] = bitcast %class.test1_A* [[tmp54]] to i8* +// CHECK-LL: [[v36:%.*]] = bitcast %class.test1_A* [[tmp54]] to i8* // CHECK-LL-NEXT: [[v37:%.*]] = call i8* @__dynamic_cast(i8* [[v36]], i8* bitcast ({{.*}} @_ZTI7test1_A to i8*), i8* bitcast ({{.*}} @_ZTI7test1_D to i8*), i64 -1) // CHECK-LL-NEXT: [[v38:%.*]] = bitcast i8* [[v37]] to %class.test1_D* // CHECK-LL-NEXT: br label %[[v40:.*]] -// CHECK-LL: ; <label>:[[v39]] -// CHECK-LL-NEXT: br label %[[v40]] -// CHECK-LL: ; <label>:[[v40]] -// CHECK-LL-NEXT: [[v41:%.*]] = phi %class.test1_D* [ [[v38]], %[[v35]] ], [ null, %[[v39]] ] +// CHECK-LL: br label %[[v40]] +// CHECK-LL: [[v41:%.*]] = phi %class.test1_D* [ [[v38]], %[[v35]] ], [ null, %[[v39]] ] // CHECK-LL-NEXT: store %class.test1_D* [[v41]], %class.test1_D** [[dp53]] // CHECK-LL-NEXT: [[tmp55:%.*]] = load %class.test1_D** [[dp53]] // CHECK-LL-NEXT: [[cmp56:%.*]] = icmp eq %class.test1_D* [[tmp55]], null @@ -226,15 +214,12 @@ void test1() { // CHECK-LL-NEXT: [[tmp63:%.*]] = load %class.test1_A** [[ap37]] // CHECK-LL-NEXT: [[v42:%.*]] = icmp ne %class.test1_A* [[tmp63]], null // CHECK-LL-NEXT: br i1 [[v42]], label %[[v43:.*]], label %[[v47:.*]] -// CHECK-LL: ; <label>:[[v43]] -// CHECK-LL-NEXT: [[v44:%.*]] = bitcast %class.test1_A* [[tmp63]] to i8* +// CHECK-LL: [[v44:%.*]] = bitcast %class.test1_A* [[tmp63]] to i8* // CHECK-LL-NEXT: [[v45:%.*]] = call i8* @__dynamic_cast(i8* [[v44]], i8* bitcast ({{.*}} @_ZTI7test1_A to i8*), i8* bitcast ({{.*}} @_ZTI7test1_E to i8*), i64 -1) // CHECK-LL-NEXT: [[v46:%.*]] = bitcast i8* [[v45]] to %class.test1_E* // CHECK-LL-NEXT: br label %[[v48:.*]] -// CHECK-LL: ; <label>:[[v47]] -// CHECK-LL-NEXT: br label %[[v48]] -// CHECK-LL: ; <label>:[[v48]] -// CHECK-LL-NEXT: [[v49:%.*]] = phi %class.test1_E* [ [[v46]], %[[v43]] ], [ null, %[[v47]] ] +// CHECK-LL: br label %[[v48]] +// CHECK-LL: [[v49:%.*]] = phi %class.test1_E* [ [[v46]], %[[v43]] ], [ null, %[[v47]] ] // CHECK-LL-NEXT: store %class.test1_E* [[v49]], %class.test1_E** [[ep1]] // CHECK-LL-NEXT: [[tmp64:%.*]] = load %class.test1_E** [[ep1]] // CHECK-LL-NEXT: [[cmp65:%.*]] = icmp ne %class.test1_E* [[tmp64]], null @@ -269,14 +254,11 @@ void test1() { // CHECK-LL-NEXT: br label %[[ifend85]] // CHECK-LL: [[ifend85]] // CHECK-LL-NEXT: br i1 false, label %[[v50:.*]], label %[[v53:.*]] -// CHECK-LL: ; <label>:[[v50]] -// CHECK-LL-NEXT: [[v51:%.*]] = call i8* @__dynamic_cast(i8* null, i8* bitcast ({{.*}}* @_ZTI7test1_A to i8*), i8* bitcast ({{.*}} @_ZTI7test1_D to i8*), i64 -1) +// CHECK-LL: [[v51:%.*]] = call i8* @__dynamic_cast(i8* null, i8* bitcast ({{.*}}* @_ZTI7test1_A to i8*), i8* bitcast ({{.*}} @_ZTI7test1_D to i8*), i64 -1) // CHECK-LL-NEXT: [[v52:%.*]] = bitcast i8* [[v51]] to %class.test1_D* // CHECK-LL-NEXT: br label %[[v54:.*]] -// CHECK-LL: ; <label>:[[v53]] -// CHECK-LL-NEXT: br label %[[v54]] -// CHECK-LL: ; <label>:[[v54]] -// CHECK-LL-NEXT: [[v55:%.*]] = phi %class.test1_D* [ [[v52]], %[[v50]] ], [ null, %[[v53]] ] +// CHECK-LL: br label %[[v54]] +// CHECK-LL: [[v55:%.*]] = phi %class.test1_D* [ [[v52]], %[[v50]] ], [ null, %[[v53]] ] // CHECK-LL-NEXT: store %class.test1_D* [[v55]], %class.test1_D** [[dp]] // CHECK-LL-NEXT: [[tmp86:%.*]] = load %class.test1_D** [[dp]] // CHECK-LL-NEXT: [[cmp87:%.*]] = icmp eq %class.test1_D* [[tmp86]], null @@ -327,7 +309,7 @@ void test1() { // CHECK-LL: [[ifend113]] // CHECK-LL-NEXT: store %class.test1_E* bitcast (%class.test1_F* @test1_f to %class.test1_E*), %class.test1_E** [[ep]] // CHECK-LL-NEXT: [[tmp118:%.*]] = load %class.test1_E** [[ep]] -// CHECK-LL-NEXT: [[cmp122:%.*]] = icmp eq %class.test1_E* [[tmp118]], bitcast (%class.test1_F* @test1_f to %class.test1_E*) ; <i1> [#uses=1] +// CHECK-LL-NEXT: [[cmp122:%.*]] = icmp eq %class.test1_E* [[tmp118]], bitcast (%class.test1_F* @test1_f to %class.test1_E*) // CHECK-LL-NEXT: br i1 [[cmp122]], label %[[ifthen123:.*]], label %[[ifelse125:.*]] // CHECK-LL: [[ifthen123]] @@ -340,18 +322,15 @@ void test1() { // CHECK-LL-NEXT: [[tmp129:%.*]] = load %class.test1_A** [[ap]] // CHECK-LL-NEXT: [[v64:%.*]] = icmp ne %class.test1_A* [[tmp129]], null // CHECK-LL-NEXT: br i1 [[v64]], label %[[v65:.*]], label %[[v70:.*]] -// CHECK-LL: ; <label>:[[v65]] -// CHECK-LL-NEXT: [[v66:%.*]] = bitcast %class.test1_A* [[tmp129]] to i64** +// CHECK-LL: [[v66:%.*]] = bitcast %class.test1_A* [[tmp129]] to i64** // CHECK-LL-NEXT: [[vtable130:%.*]] = load i64** [[v66]] // CHECK-LL-NEXT: [[v67:%.*]] = getelementptr inbounds i64* [[vtable130]], i64 -2 // CHECK-LL-NEXT: [[offsettotop:%.*]] = load i64* [[v67]] // CHECK-LL-NEXT: [[v68:%.*]] = bitcast %class.test1_A* [[tmp129]] to i8* // CHECK-LL-NEXT: [[v69:%.*]] = getelementptr inbounds i8* [[v68]], i64 [[offsettotop]] // CHECK-LL-NEXT: br label %[[v71:.*]] -// CHECK-LL: ; <label>:[[v70]] -// CHECK-LL-NEXT: br label %[[v71]] -// CHECK-LL: ; <label>:[[v71]] -// CHECK-LL-NEXT: [[v72:%.*]] = phi i8* [ [[v69]], %[[v65]] ], [ null, %[[v70]] ] +// CHECK-LL: br label %[[v71]] +// CHECK-LL: [[v72:%.*]] = phi i8* [ [[v69]], %[[v65]] ], [ null, %[[v70]] ] // CHECK-LL-NEXT: store i8* [[v72]], i8** [[vp]] // CHECK-LL-NEXT: [[tmp131:%.*]] = load i8** [[vp]] // CHECK-LL-NEXT: [[cmp132:%.*]] = icmp eq i8* [[tmp131]], getelementptr inbounds (%class.test1_D* @test1_d, i32 0, i32 0, i32 0) @@ -366,18 +345,15 @@ void test1() { // CHECK-LL-NEXT: [[tmp139:%.*]] = load %class.test1_A** [[ap]] // CHECK-LL-NEXT: [[v73:%.*]] = icmp ne %class.test1_A* [[tmp139]], null // CHECK-LL-NEXT: br i1 [[v73]], label %[[v74:.*]], label %[[v79:.*]] -// CHECK-LL: ; <label>:[[v74]] -// CHECK-LL-NEXT: [[v75:%.*]] = bitcast %class.test1_A* [[tmp139]] to i64** +// CHECK-LL: [[v75:%.*]] = bitcast %class.test1_A* [[tmp139]] to i64** // CHECK-LL-NEXT: [[vtable140:%.*]] = load i64** [[v75]] // CHECK-LL-NEXT: [[v76:%.*]] = getelementptr inbounds i64* [[vtable140]], i64 -2 // CHECK-LL-NEXT: [[offsettotop141:%.*]] = load i64* [[v76]] // CHECK-LL-NEXT: [[v77:%.*]] = bitcast %class.test1_A* [[tmp139]] to i8* // CHECK-LL-NEXT: [[v78:%.*]] = getelementptr inbounds i8* [[v77]], i64 [[offsettotop141]] // CHECK-LL-NEXT: br label %[[v80:.*]] -// CHECK-LL: ; <label>:[[v79]] -// CHECK-LL-NEXT: br label %[[v80]] -// CHECK-LL: ; <label>:[[v80]] -// CHECK-LL-NEXT: [[v81:%.*]] = phi i8* [ [[v78]], %[[v74]] ], [ null, %[[v79]] ] +// CHECK-LL: br label %[[v80]] +// CHECK-LL: [[v81:%.*]] = phi i8* [ [[v78]], %[[v74]] ], [ null, %[[v79]] ] // CHECK-LL-NEXT: store i8* [[v81]], i8** [[cvp]] // CHECK-LL-NEXT: [[tmp142:%.*]] = load i8** [[cvp]] // CHECK-LL-NEXT: [[cmp143:%.*]] = icmp eq i8* [[tmp142]], getelementptr inbounds (%class.test1_D* @test1_d, i32 0, i32 0, i32 0) diff --git a/test/CodeGenCXX/eh.cpp b/test/CodeGenCXX/eh.cpp index 6d79c3e..0960ec3 100644 --- a/test/CodeGenCXX/eh.cpp +++ b/test/CodeGenCXX/eh.cpp @@ -39,6 +39,7 @@ void test2() { // CHECK: [[FREEVAR:%.*]] = alloca i1 // CHECK-NEXT: [[EXNOBJVAR:%.*]] = alloca i8* // CHECK-NEXT: [[EXNSLOTVAR:%.*]] = alloca i8* +// CHECK-NEXT: [[CLEANUPDESTVAR:%.*]] = alloca i32 // CHECK-NEXT: store i1 false, i1* [[FREEVAR]] // CHECK-NEXT: [[EXNOBJ:%.*]] = call i8* @__cxa_allocate_exception(i64 16) // CHECK-NEXT: store i8* [[EXNOBJ]], i8** [[EXNOBJVAR]] @@ -124,6 +125,7 @@ namespace test7 { // CHECK-NEXT: [[EXNALLOCVAR:%.*]] = alloca i8* // CHECK-NEXT: [[CAUGHTEXNVAR:%.*]] = alloca i8* // CHECK-NEXT: [[INTCATCHVAR:%.*]] = alloca i32 +// CHECK-NEXT: [[EHCLEANUPDESTVAR:%.*]] = alloca i32 // CHECK-NEXT: store i1 false, i1* [[FREEEXNOBJ]] try { try { @@ -153,6 +155,7 @@ namespace test7 { // CHECK: [[CAUGHTEXN:%.*]] = call i8* @llvm.eh.exception() // CHECK-NEXT: store i8* [[CAUGHTEXN]], i8** [[CAUGHTEXNVAR]] // CHECK-NEXT: call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* [[CAUGHTEXN]], i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* null) +// CHECK-NEXT: store i32 1, i32* [[EHCLEANUPDESTVAR]] // CHECK-NEXT: call void @__cxa_end_catch() // CHECK-NEXT: br label // CHECK: load i8** [[CAUGHTEXNVAR]] @@ -249,3 +252,165 @@ namespace test10 { // CHECK: call void @_ZN6test101AD1Ev( } } + +// __cxa_begin_catch returns pointers by value, even when catching by reference +// <rdar://problem/8212123> +namespace test11 { + void opaque(); + + // CHECK: define void @_ZN6test113fooEv() + void foo() { + try { + // CHECK: invoke void @_ZN6test116opaqueEv() + opaque(); + } catch (int**&p) { + // CHECK: [[EXN:%.*]] = load i8** + // CHECK-NEXT: call i8* @__cxa_begin_catch(i8* [[EXN]]) nounwind + // CHECK-NEXT: [[ADJ1:%.*]] = getelementptr i8* [[EXN]], i32 32 + // CHECK-NEXT: [[ADJ2:%.*]] = bitcast i8* [[ADJ1]] to i32*** + // CHECK-NEXT: store i32*** [[ADJ2]], i32**** [[P:%.*]] + // CHECK-NEXT: call void @__cxa_end_catch() nounwind + } + } + + struct A {}; + + // CHECK: define void @_ZN6test113barEv() + void bar() { + try { + // CHECK: [[EXNSLOT:%.*]] = alloca i8* + // CHECK-NEXT: [[P:%.*]] = alloca [[A:%.*]]**, + // CHECK-NEXT: [[TMP:%.*]] = alloca [[A]]* + // CHECK-NEXT: invoke void @_ZN6test116opaqueEv() + opaque(); + } catch (A*&p) { + // CHECK: [[EXN:%.*]] = load i8** [[EXNSLOT]] + // CHECK-NEXT: [[ADJ1:%.*]] = call i8* @__cxa_begin_catch(i8* [[EXN]]) nounwind + // CHECK-NEXT: [[ADJ2:%.*]] = bitcast i8* [[ADJ1]] to [[A]]* + // CHECK-NEXT: store [[A]]* [[ADJ2]], [[A]]** [[TMP]] + // CHECK-NEXT: store [[A]]** [[TMP]], [[A]]*** [[P]] + // CHECK-NEXT: call void @__cxa_end_catch() nounwind + } + } +} + +// PR7686 +namespace test12 { + struct A { ~A(); }; + bool opaque(const A&); + + // CHECK: define void @_ZN6test124testEv() + void test() { + // CHECK: [[X:%.*]] = alloca [[A:%.*]], + // CHECK: [[EHCLEANUPDEST:%.*]] = alloca i32 + // CHECK: [[Y:%.*]] = alloca [[A]] + // CHECK: [[Z:%.*]] = alloca [[A]] + // CHECK: [[CLEANUPDEST:%.*]] = alloca i32 + + A x; + // CHECK: invoke zeroext i1 @_ZN6test126opaqueERKNS_1AE( + if (opaque(x)) { + A y; + A z; + + // CHECK: invoke void @_ZN6test121AD1Ev([[A]]* [[Z]]) + // CHECK: invoke void @_ZN6test121AD1Ev([[A]]* [[Y]]) + + // It'd be great if something eliminated this switch. + // CHECK: load i32* [[CLEANUPDEST]] + // CHECK-NEXT: switch i32 + goto success; + } + + success: + bool _ = true; + + // CHECK: call void @_ZN6test121AD1Ev([[A]]* [[X]]) + // CHECK-NEXT: ret void + } +} + +// Reduced from some TableGen code that was causing a self-host crash. +namespace test13 { + struct A { ~A(); }; + + void test0(int x) { + try { + switch (x) { + case 0: + break; + case 1:{ + A a; + break; + } + default: + return; + } + return; + } catch (int x) { + } + return; + } + + void test1(int x) { + A y; + try { + switch (x) { + default: break; + } + } catch (int x) {} + } +} + +// rdar://problem/8231514 +namespace test14 { + struct A { ~A(); }; + struct B { ~B(); }; + + B b(); + void opaque(); + + void foo() { + A a; + try { + B str = b(); + opaque(); + } catch (int x) { + } + } +} + +// rdar://problem/8231514 +// JumpDests shouldn't get confused by scopes that aren't normal cleanups. +namespace test15 { + struct A { ~A(); }; + + bool opaque(int); + + // CHECK: define void @_ZN6test153fooEv() + void foo() { + A a; + + try { + // CHECK: [[X:%.*]] = alloca i32 + // CHECK: store i32 10, i32* [[X]] + // CHECK-NEXT: br label + // -> while.cond + int x = 10; + + while (true) { + // CHECK: load i32* [[X]] + // CHECK-NEXT: [[COND:%.*]] = invoke zeroext i1 @_ZN6test156opaqueEi + // CHECK: br i1 [[COND]] + if (opaque(x)) + // CHECK: br label + break; + + // CHECK: br label + } + // CHECK: br label + } catch (int x) { } + + // CHECK: call void @_ZN6test151AD1Ev + } +} diff --git a/test/CodeGenCXX/exceptions-no-rtti.cpp b/test/CodeGenCXX/exceptions-no-rtti.cpp index c26abb2..66b4c4a 100644 --- a/test/CodeGenCXX/exceptions-no-rtti.cpp +++ b/test/CodeGenCXX/exceptions-no-rtti.cpp @@ -18,9 +18,12 @@ namespace test0 { } namespace test1 { - // These classes have key functions defined out-of-line. - // Under normal circumstances, we wouldn't generate RTTI for them; - // under -fno-rtti, we generate RTTI only when required by EH. + // These classes have key functions defined out-of-line. Under + // normal circumstances, we wouldn't generate RTTI for them; under + // -fno-rtti, we generate RTTI only when required by EH. But + // everything gets hidden visibility because we assume that all + // users are also compiled under -fno-rtti and therefore will be + // emitting RTTI regardless of key function. class A { virtual void foo(); }; class B { virtual void foo(); }; class C { virtual void foo(); }; diff --git a/test/CodeGenCXX/explicit-instantiation.cpp b/test/CodeGenCXX/explicit-instantiation.cpp index 24d1a67..b829585 100644 --- a/test/CodeGenCXX/explicit-instantiation.cpp +++ b/test/CodeGenCXX/explicit-instantiation.cpp @@ -1,5 +1,8 @@ // RUN: %clang_cc1 -emit-llvm -triple i686-pc-linux-gnu -o - %s | FileCheck %s +// This check logically is attached to 'template int S<int>::i;' below. +// CHECK: @_ZN1SIiE1iE = weak global i32 + template<typename T, typename U, typename Result> struct plus { Result operator()(const T& t, const U& u) const; @@ -12,3 +15,31 @@ Result plus<T, U, Result>::operator()(const T& t, const U& u) const { // CHECK: define weak_odr i32 @_ZNK4plusIillEclERKiRKl template struct plus<int, long, long>; + +// Check that we emit definitions from explicit instantiations even when they +// occur prior to the definition itself. +template <typename T> struct S { + void f(); + static void g(); + static int i; + struct S2 { + void h(); + }; +}; + +// CHECK: define weak_odr void @_ZN1SIiE1fEv +template void S<int>::f(); + +// CHECK: define weak_odr void @_ZN1SIiE1gEv +template void S<int>::g(); + +// See the check line at the top of the file. +template int S<int>::i; + +// CHECK: define weak_odr void @_ZN1SIiE2S21hEv +template void S<int>::S2::h(); + +template <typename T> void S<T>::f() {} +template <typename T> void S<T>::g() {} +template <typename T> int S<T>::i; +template <typename T> void S<T>::S2::h() {} diff --git a/test/CodeGenCXX/expr.cpp b/test/CodeGenCXX/expr.cpp index d92cfb4..33e8e63 100644 --- a/test/CodeGenCXX/expr.cpp +++ b/test/CodeGenCXX/expr.cpp @@ -14,3 +14,24 @@ void test1() { // PR5514 int a; void test2() { ++a+=10; } + +// PR7892 +int test3(const char*); +int test3g = test3(__PRETTY_FUNCTION__); + + +// PR7889 +struct test4A { + int j : 2; +}; +int test4() { + test4A a; + (a.j = 2) = 3; +} + +// Incomplete type in conditional operator. +// Check operations on incomplete types. +struct s5; +struct s5 &f5_0(bool cond, struct s5 &a, struct s5 &b) { + return cond ? a : b; +} diff --git a/test/CodeGenCXX/global-init.cpp b/test/CodeGenCXX/global-init.cpp index 8ee087e..6ff9598 100644 --- a/test/CodeGenCXX/global-init.cpp +++ b/test/CodeGenCXX/global-init.cpp @@ -14,6 +14,9 @@ struct D { ~D(); }; // CHECK: @c = global %struct.C zeroinitializer, align 8 +// It's okay if we ever implement the IR-generation optimization to remove this. +// CHECK: @_ZN5test3L3varE = internal constant i8* getelementptr inbounds ([7 x i8]* + // CHECK: call void @_ZN1AC1Ev(%struct.A* @a) // CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.A*)* @_ZN1AD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.A* @a, i32 0, i32 0), i8* bitcast (i8** @__dso_handle to i8*)) A a; @@ -29,7 +32,52 @@ C c; // CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.A*)* @_ZN1DD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.A* @d, i32 0, i32 0), i8* bitcast (i8** @__dso_handle to i8*)) D d; +// <rdar://problem/7458115> +namespace test1 { + int f(); + const int x = f(); // This has side-effects and gets emitted immediately. + const int y = x - 1; // This gets deferred. + const int z = ~y; // This also gets deferred, but gets "undeferred" before y. + int test() { return z; } +// CHECK: define i32 @_ZN5test14testEv() + + // All of these initializers end up delayed, so we check them later. +} + +// <rdar://problem/8246444> +namespace test2 { + struct allocator { allocator(); ~allocator(); }; + struct A { A(const allocator &a = allocator()); ~A(); }; + + A a; +// CHECK: call void @_ZN5test29allocatorC1Ev( +// CHECK: invoke void @_ZN5test21AC1ERKNS_9allocatorE( +// CHECK: call void @_ZN5test29allocatorD1Ev( +// CHECK: call i32 @__cxa_atexit({{.*}} @_ZN5test21AD1Ev {{.*}} @_ZN5test21aE +} + +namespace test3 { + // Tested at the beginning of the file. + const char * const var = "string"; + extern const char * const var; + + const char *test() { return var; } +} + +// CHECK: define internal void [[TEST1_Z_INIT:@.*]]() +// CHECK: load i32* @_ZN5test1L1yE +// CHECK-NEXT: xor +// CHECK-NEXT: store i32 {{.*}}, i32* @_ZN5test1L1zE +// CHECK: define internal void [[TEST1_Y_INIT:@.*]]() +// CHECK: load i32* @_ZN5test1L1xE +// CHECK-NEXT: sub +// CHECK-NEXT: store i32 {{.*}}, i32* @_ZN5test1L1yE + +// At the end of the file, we check that y is initialized before z. + // CHECK: define internal void @_GLOBAL__I_a() section "__TEXT,__StaticInit,regular,pure_instructions" { +// CHECK: call void [[TEST1_Y_INIT]] +// CHECK: call void [[TEST1_Z_INIT]] // rdar://problem/8090834: this should be nounwind // CHECK-NOEXC: define internal void @_GLOBAL__I_a() nounwind section "__TEXT,__StaticInit,regular,pure_instructions" { diff --git a/test/CodeGenCXX/key-function-vtable.cpp b/test/CodeGenCXX/key-function-vtable.cpp index 1cfeb0c..15c058d 100644 --- a/test/CodeGenCXX/key-function-vtable.cpp +++ b/test/CodeGenCXX/key-function-vtable.cpp @@ -12,11 +12,11 @@ testb *testbvar = new testb; struct testc { virtual void a(); }; inline void testc::a() {} -// Key functions with inline specifier (PR5705) +// Functions with inline specifier are not key functions (PR5705) struct testd { inline virtual void a(); }; void testd::a() {} -// Key functions with inline specifier (PR5705) +// Functions with inline specifier are not key functions (PR5705) struct teste { inline virtual void a(); }; teste *testevar = new teste; diff --git a/test/CodeGenCXX/mangle-exprs.cpp b/test/CodeGenCXX/mangle-exprs.cpp index d68425f..73221718 100644 --- a/test/CodeGenCXX/mangle-exprs.cpp +++ b/test/CodeGenCXX/mangle-exprs.cpp @@ -39,6 +39,6 @@ namespace Casts { // CHECK: define weak_odr void @_ZN5Casts7static_ILj4EEEvPN9enable_ifIXleT_cvjLi4EEvE4typeE template void static_<4>(void*); - // CHECK: define weak_odr i8 @_ZN5Casts1fILi6EEENS_1TIXT_EEEv + // CHECK: define weak_odr void @_ZN5Casts1fILi6EEENS_1TIXT_EEEv template T<6> f<6>(); } diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp index 814a759..55357c7 100644 --- a/test/CodeGenCXX/mangle.cpp +++ b/test/CodeGenCXX/mangle.cpp @@ -507,3 +507,120 @@ namespace test13 { // CHECK: define weak_odr void @_ZN6test133fooINS_1BEEEvRKNS_1AIT_EE( template void foo(const A<B> &a); } + +namespace test14 { + extern "C" { + struct S { + static int a(), x; + }; + // CHECK: define i32 @_ZN6test141S1aEv + // CHECK: load i32* @_ZN6test141S1xE + int S::a() { return S::x; } + } +} + +// rdar://problem/8204122 +namespace test15 { + enum E { e = 3 }; + template <int I> struct S {}; + + template <int I> void f(S<I + e>) {} + + // CHECK: define weak_odr void @_ZN6test151fILi7EEEvNS_1SIXplT_LNS_1EE3EEEE( + template void f<7>(S<7 + e>); +} + +// rdar://problem/8125400. Don't crash. +namespace test16 { + static union {}; + static union { union {}; }; + static union { struct {}; }; + static union { union { union {}; }; }; + static union { union { struct {}; }; }; + static union { struct { union {}; }; }; + static union { struct { struct {}; }; }; +} + +// rdar://problem/8302148 +namespace test17 { + template <int N> struct A {}; + + struct B { + static int foo(void); + }; + + template <class T> A<sizeof(T::foo())> func(void); + + // CHECK: define void @_ZN6test174testEv() + // CHECK: call {{.*}} @_ZN6test174funcINS_1BEEENS_1AIXszclsrT_3fooEEEEv() + void test() { + func<B>(); + } +} + +// PR7891 +namespace test18 { + struct A { + int operator+(); + int operator-(); + int operator*(); + int operator&(); + }; + template <int (A::*)()> struct S {}; + + template <typename T> void f(S<&T::operator+>) {} + template void f<A>(S<&A::operator+>); + + template <typename T> void f(S<&T::operator- >) {} + template void f<A>(S<&A::operator- >); + + template <typename T> void f(S<&T::operator*>) {} + template void f<A>(S<&A::operator*>); + + template <typename T> void f(S<&T::operator&>) {} + template void f<A>(S<&A::operator&>); + + // CHECK: define weak_odr void @_ZN6test181fINS_1AEEEvNS_1SIXadsrT_plEEE + // CHECK: define weak_odr void @_ZN6test181fINS_1AEEEvNS_1SIXadsrT_miEEE + // CHECK: define weak_odr void @_ZN6test181fINS_1AEEEvNS_1SIXadsrT_mlEEE + // CHECK: define weak_odr void @_ZN6test181fINS_1AEEEvNS_1SIXadsrT_anEEE +} + +// rdar://problem/8332117 +namespace test19 { + struct A { + template <typename T> int f(); + int operator+(); + operator int(); + template <typename T> int operator-(); + }; + + template <int (A::*)()> struct S {}; + + template <typename T> void g (S<&T::template f<int> >) {} + template <typename T> void g (S<&T::operator+ >) {} + template <typename T> void g (S<&T::operator int>) {} + template <typename T> void g (S<&T::template operator- <double> >) {} + + // CHECK: define weak_odr void @_ZN6test191gINS_1AEEEvNS_1SIXadsrT_1fIiEEEE( + template void g<A>(S<&A::f<int> >); + // CHECK: define weak_odr void @_ZN6test191gINS_1AEEEvNS_1SIXadsrT_plEEE( + template void g<A>(S<&A::operator+>); + // CHECK: define weak_odr void @_ZN6test191gINS_1AEEEvNS_1SIXadsrT_cviEEE( + template void g<A>(S<&A::operator int>); + // CHECK: define weak_odr void @_ZN6test191gINS_1AEEEvNS_1SIXadsrT_miIdEEEE( + template void g<A>(S<&A::operator-<double> >); +} + +namespace test20 { + template <class T> T *f(const T&); + template <class T> T *f(T*); + + // CHECK: define weak_odr void @_ZN6test205test0IiEEvDTcl1fIPT_ELi0EEE( + template <class T> void test0(decltype(f<T*>(0))) {} + template void test0<int>(decltype(f<int*>(0))); + + // CHECK: define weak_odr void @_ZN6test205test1IiEEvDTcl1fIEcvT__EEE( + template <class T> void test1(decltype(f<>(T()))) {} + template void test1<int>(decltype(f<>(int()))); +} diff --git a/test/CodeGenCXX/member-function-pointers.cpp b/test/CodeGenCXX/member-function-pointers.cpp index e4beee1..78a571e 100644 --- a/test/CodeGenCXX/member-function-pointers.cpp +++ b/test/CodeGenCXX/member-function-pointers.cpp @@ -1,5 +1,6 @@ // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin9 | FileCheck %s // RUN: %clang_cc1 %s -emit-llvm -o - -triple=i386-apple-darwin9 | FileCheck -check-prefix LP32 %s +// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv7-unknown-unknown | FileCheck -check-prefix ARM %s struct A { int a; void f(); virtual void vf1(); virtual void vf2(); }; struct B { int b; virtual void g(); }; @@ -28,50 +29,38 @@ void (C::*pc2)() = &C::f; void (A::*pc3)() = &A::vf1; void f() { - // CHECK: store i64 0, i64* getelementptr inbounds (%0* @pa, i32 0, i32 0) - // CHECK: store i64 0, i64* getelementptr inbounds (%0* @pa, i32 0, i32 1) + // CHECK: store %0 zeroinitializer, %0* @pa pa = 0; - // CHECK: volatile store i64 0, i64* getelementptr inbounds (%0* @vpa, i32 0, i32 0) - // CHECK: volatile store i64 0, i64* getelementptr inbounds (%0* @vpa, i32 0, i32 1) + // Is this okay? What are LLVM's volatile semantics for structs? + // CHECK: volatile store %0 zeroinitializer, %0* @vpa vpa = 0; - // CHECK: store i64 {{.*}}, i64* getelementptr inbounds (%0* @pc, i32 0, i32 0) - // CHECK: [[ADJ:%[a-zA-Z0-9\.]+]] = add i64 {{.*}}, 16 - // CHECK: store i64 [[ADJ]], i64* getelementptr inbounds (%0* @pc, i32 0, i32 1) + // CHECK: [[TMP:%.*]] = load %0* @pa, align 8 + // CHECK: [[TMPADJ:%.*]] = extractvalue %0 [[TMP]], 1 + // CHECK: [[ADJ:%.*]] = add nsw i64 [[TMPADJ]], 16 + // CHECK: [[RES:%.*]] = insertvalue %0 [[TMP]], i64 [[ADJ]], 1 + // CHECK: store %0 [[RES]], %0* @pc, align 8 pc = pa; - // CHECK: store i64 {{.*}}, i64* getelementptr inbounds (%0* @pa, i32 0, i32 0) - // CHECK: [[ADJ:%[a-zA-Z0-9\.]+]] = sub i64 {{.*}}, 16 - // CHECK: store i64 [[ADJ]], i64* getelementptr inbounds (%0* @pa, i32 0, i32 1) + // CHECK: [[TMP:%.*]] = load %0* @pc, align 8 + // CHECK: [[TMPADJ:%.*]] = extractvalue %0 [[TMP]], 1 + // CHECK: [[ADJ:%.*]] = sub nsw i64 [[TMPADJ]], 16 + // CHECK: [[RES:%.*]] = insertvalue %0 [[TMP]], i64 [[ADJ]], 1 + // CHECK: store %0 [[RES]], %0* @pa, align 8 pa = static_cast<void (A::*)()>(pc); } void f2() { - // CHECK: [[pa2ptr:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa2, i32 0, i32 0 - // CHECK: store i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64* [[pa2ptr]] - // CHECK: [[pa2adj:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa2, i32 0, i32 1 - // CHECK: store i64 0, i64* [[pa2adj]] + // CHECK: store %0 { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 0 } void (A::*pa2)() = &A::f; - // CHECK: [[pa3ptr:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa3, i32 0, i32 0 - // CHECK: store i64 1, i64* [[pa3ptr]] - // CHECK: [[pa3adj:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa3, i32 0, i32 1 - // CHECK: store i64 0, i64* [[pa3adj]] - // CHECK-LP32: [[pa3ptr:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa3, i32 0, i32 0 - // CHECK-LP32: store i32 1, i32* [[pa3ptr]] - // CHECK-LP32: [[pa3adj:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa3, i32 0, i32 1 - // CHECK-LP32: store i32 0, i32* [[pa3adj]] + // CHECK: store %0 { i64 1, i64 0 } + // CHECK-LP32: store %0 { i32 1, i32 0 } void (A::*pa3)() = &A::vf1; - // CHECK: [[pa4ptr:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa4, i32 0, i32 0 - // CHECK: store i64 9, i64* [[pa4ptr]] - // CHECK: [[pa4adj:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa4, i32 0, i32 1 - // CHECK: store i64 0, i64* [[pa4adj]] - // CHECK-LP32: [[pa4ptr:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa4, i32 0, i32 0 - // CHECK-LP32: store i32 5, i32* [[pa4ptr]] - // CHECK-LP32: [[pa4adj:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa4, i32 0, i32 1 - // CHECK-LP32: store i32 0, i32* [[pa4adj]] + // CHECK: store %0 { i64 9, i64 0 } + // CHECK-LP32: store %0 { i32 5, i32 0 } void (A::*pa4)() = &A::vf2; } @@ -190,3 +179,33 @@ namespace PR7027 { struct X { void test( ); }; void testX() { &X::test; } } + +namespace test7 { + struct A { void foo(); virtual void vfoo(); }; + struct B { void foo(); virtual void vfoo(); }; + struct C : A, B { void foo(); virtual void vfoo(); }; + + // CHECK-ARM: @_ZN5test74ptr0E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71A3fooEv to i32), i32 0 } + // CHECK-ARM: @_ZN5test74ptr1E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71B3fooEv to i32), i32 8 } + // CHECK-ARM: @_ZN5test74ptr2E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71C3fooEv to i32), i32 0 } + // CHECK-ARM: @_ZN5test74ptr3E = global {{.*}} { i32 0, i32 1 } + // CHECK-ARM: @_ZN5test74ptr4E = global {{.*}} { i32 0, i32 9 } + // CHECK-ARM: @_ZN5test74ptr5E = global {{.*}} { i32 0, i32 1 } + void (C::*ptr0)() = &A::foo; + void (C::*ptr1)() = &B::foo; + void (C::*ptr2)() = &C::foo; + void (C::*ptr3)() = &A::vfoo; + void (C::*ptr4)() = &B::vfoo; + void (C::*ptr5)() = &C::vfoo; +} + +namespace test8 { + struct X { }; + typedef int (X::*pmf)(int); + + // CHECK: {{define.*_ZN5test81fEv}} + pmf f() { + // CHECK: {{ret.*zeroinitializer}} + return pmf(); + } +} diff --git a/test/CodeGenCXX/member-functions.cpp b/test/CodeGenCXX/member-functions.cpp index b363552..a60d24a 100644 --- a/test/CodeGenCXX/member-functions.cpp +++ b/test/CodeGenCXX/member-functions.cpp @@ -58,6 +58,6 @@ struct T { void test3() { T t1, t2; - // RUN: grep "call i8 @_ZN1TplERKS_" %t + // RUN: grep "call void @_ZN1TplERKS_" %t T result = t1 + t2; } diff --git a/test/CodeGenCXX/member-qual-debug-info.cpp b/test/CodeGenCXX/member-qual-debug-info.cpp deleted file mode 100644 index c6e0991..0000000 --- a/test/CodeGenCXX/member-qual-debug-info.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: %clang_cc1 -g -S -masm-verbose -x c++ -o %t %s -// RUN: grep DW_TAG_volatile_type %t | count 3 -// RUN: grep DW_TAG_const_type %t | count 3 -// one for decl, one for def, one for abbrev - -namespace A { - class B { - public: - void dump() const volatile; - }; -} - -int main () { - using namespace A; - B b; - return 0; -} - -void A::B::dump() const volatile{ -} diff --git a/test/CodeGenCXX/new.cpp b/test/CodeGenCXX/new.cpp index 885158f..10a6f7f 100644 --- a/test/CodeGenCXX/new.cpp +++ b/test/CodeGenCXX/new.cpp @@ -73,6 +73,10 @@ void t8(int n) { new U[n]; } +// noalias +// CHECK: declare noalias i8* @_Znam +void *operator new[](size_t); + void t9() { bool b; @@ -90,19 +94,72 @@ A* t10() { return new(1, 2, 3.45, 100) A; } +// CHECK: define void @_Z3t11i struct B { int a; }; -void t11() { +struct Bmemptr { int Bmemptr::* memptr; int a; }; + +void t11(int n) { // CHECK: call noalias i8* @_Znwm // CHECK: call void @llvm.memset.p0i8.i64( B* b = new B(); + + // CHECK: call noalias i8* @_Znam + // CHECK: {{call void.*llvm.memset.p0i8.i64.*i8 0, i64 %}} + B *b2 = new B[n](); + + // CHECK: call noalias i8* @_Znam + // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64 + // CHECK: br + Bmemptr *b_memptr = new Bmemptr[n](); + + // CHECK: ret void } struct Empty { }; // We don't need to initialize an empty class. +// CHECK: define void @_Z3t12v void t12() { - // CHECK: define void @_Z3t12v - // CHECK-NOT: br label - // CHECK: ret void + // CHECK: call noalias i8* @_Znam + // CHECK-NOT: br (void)new Empty[10]; + + // CHECK: call noalias i8* @_Znam + // CHECK-NOT: br + (void)new Empty[10](); + + // CHECK: ret void +} + +// Zero-initialization +// CHECK: define void @_Z3t13i +void t13(int n) { + // CHECK: call noalias i8* @_Znwm + // CHECK: store i32 0, i32* + (void)new int(); + + // CHECK: call noalias i8* @_Znam + // CHECK: {{call void.*llvm.memset.p0i8.i64.*i8 0, i64 %}} + (void)new int[n](); + + // CHECK-NEXT: ret void +} + +struct Alloc{ + int x; + void* operator new[](size_t size); + void operator delete[](void* p); + ~Alloc(); +}; + +void f() { + // CHECK: call i8* @_ZN5AllocnaEm(i64 808) + // CHECK: store i64 200 + // CHECK: call void @_ZN5AllocD1Ev( + // CHECK: call void @_ZN5AllocdaEPv(i8* + delete[] new Alloc[10][20]; + // CHECK: call noalias i8* @_Znwm + // CHECK: call void @_ZdlPv(i8* + delete new bool; + // CHECK: ret void } diff --git a/test/CodeGenCXX/nonconst-init.cpp b/test/CodeGenCXX/nonconst-init.cpp new file mode 100644 index 0000000..21129b9 --- /dev/null +++ b/test/CodeGenCXX/nonconst-init.cpp @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s + +int a(); +// CHECK: call i32 @_Z1av() +struct x {int x, y : 10;} x = {1, a()}; diff --git a/test/CodeGenCXX/operator-new.cpp b/test/CodeGenCXX/operator-new.cpp index f718fae..db56cda 100644 --- a/test/CodeGenCXX/operator-new.cpp +++ b/test/CodeGenCXX/operator-new.cpp @@ -11,7 +11,19 @@ public: }; void f1() { - // CHECK-SANE: declare noalias i8* @_Znwj( - // CHECK-SANENOT: declare i8* @_Znwj( + // SANE: declare noalias i8* @_Znwj( + // SANENOT: declare i8* @_Znwj( new teste(); } + + +// rdar://5739832 - operator new should check for overflow in multiply. +void *f2(long N) { + return new int[N]; + +// SANE: [[UWO:%.*]] = call {{.*}} @llvm.umul.with.overflow +// SANE-NEXT: [[OVER:%.*]] = extractvalue {{.*}} [[UWO]], 1 +// SANE-NEXT: [[SUM:%.*]] = extractvalue {{.*}} [[UWO]], 0 +// SANE-NEXT: [[RESULT:%.*]] = select i1 [[OVER]], i32 -1, i32 [[SUM]] +// SANE-NEXT: call noalias i8* @_Znaj(i32 [[RESULT]]) +} diff --git a/test/CodeGenCXX/pointers-to-data-members.cpp b/test/CodeGenCXX/pointers-to-data-members.cpp index 70308c6..38c7d28 100644 --- a/test/CodeGenCXX/pointers-to-data-members.cpp +++ b/test/CodeGenCXX/pointers-to-data-members.cpp @@ -65,15 +65,21 @@ int A::*pa; int C::*pc; void f() { - // CHECK: store i64 -1, i64* @_ZN5Casts2paE + // CHECK: store i64 -1, i64* @_ZN5Casts2paE pa = 0; - // CHECK: [[ADJ:%[a-zA-Z0-9\.]+]] = add nsw i64 {{.*}}, 4 - // CHECK: store i64 [[ADJ]], i64* @_ZN5Casts2pcE + // CHECK-NEXT: [[TMP:%.*]] = load i64* @_ZN5Casts2paE, align 8 + // CHECK-NEXT: [[ADJ:%.*]] = add nsw i64 [[TMP]], 4 + // CHECK-NEXT: [[ISNULL:%.*]] = icmp eq i64 [[TMP]], -1 + // CHECK-NEXT: [[RES:%.*]] = select i1 [[ISNULL]], i64 [[TMP]], i64 [[ADJ]] + // CHECK-NEXT: store i64 [[RES]], i64* @_ZN5Casts2pcE pc = pa; - // CHECK: [[ADJ:%[a-zA-Z0-9\.]+]] = sub nsw i64 {{.*}}, 4 - // CHECK: store i64 [[ADJ]], i64* @_ZN5Casts2paE + // CHECK-NEXT: [[TMP:%.*]] = load i64* @_ZN5Casts2pcE, align 8 + // CHECK-NEXT: [[ADJ:%.*]] = sub nsw i64 [[TMP]], 4 + // CHECK-NEXT: [[ISNULL:%.*]] = icmp eq i64 [[TMP]], -1 + // CHECK-NEXT: [[RES:%.*]] = select i1 [[ISNULL]], i64 [[TMP]], i64 [[ADJ]] + // CHECK-NEXT: store i64 [[RES]], i64* @_ZN5Casts2paE pa = static_cast<int A::*>(pc); } @@ -183,3 +189,17 @@ struct A { A a; } + +namespace BoolPtrToMember { + struct X { + bool member; + }; + + // CHECK: define i8* @_ZN15BoolPtrToMember1fERNS_1XEMS0_b + bool &f(X &x, bool X::*member) { + // CHECK: {{bitcast.* to i8\*}} + // CHECK-NEXT: getelementptr inbounds i8* + // CHECK-NEXT: ret i8* + return x.*member; + } +} diff --git a/test/CodeGenCXX/pragma-visibility.cpp b/test/CodeGenCXX/pragma-visibility.cpp new file mode 100644 index 0000000..05de786 --- /dev/null +++ b/test/CodeGenCXX/pragma-visibility.cpp @@ -0,0 +1,72 @@ +// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s + +#pragma GCC visibility push(hidden) +struct x { + static int y; +}; +#pragma GCC visibility pop +int x::y = 10; +// CHECK: @_ZN1x1yE = hidden global + +#pragma GCC visibility push(hidden) +struct __attribute((visibility("default"))) x2 { + static int y; +}; +int x2::y = 10; +// CHECK: @_ZN2x21yE = global +#pragma GCC visibility pop + +#pragma GCC visibility push(hidden) +struct x3 { + static int y; +} __attribute((visibility("default"))); +int x3::y = 10; +// CHECK: @_ZN2x31yE = global +#pragma GCC visibility pop + +#pragma GCC visibility push(hidden) +template<class T> struct x4 { + static int y; +}; +#pragma GCC visibility pop +template<> int x4<int>::y = 10; +// CHECK: @_ZN2x4IiE1yE = hidden global i32 + +#pragma GCC visibility push(hidden) +template<int x> int f() { return x; } +extern "C" int g() { return f<3>(); } +#pragma GCC visibility pop +// CHECK: define hidden i32 @g() +// CHECK: define linkonce_odr hidden i32 @_Z1fILi3EEiv() + +#pragma GCC visibility push(hidden) +template<class T> struct x5 { + void y(); +}; +#pragma GCC visibility pop +template<> void x5<int>::y() {} +// CHECK: define hidden void @_ZN2x5IiE1yEv + +#pragma GCC visibility push(hidden) +namespace n __attribute((visibility("default"))) { + void f() {} + // CHECK: define void @_ZN1n1fEv +} +#pragma GCC visibility pop + +namespace n __attribute((visibility("default"))) { + extern int foofoo; // FIXME: Shouldn't be necessary, but otherwise the pragma + // gets to Sema before the namespace! +#pragma GCC visibility push(hidden) + void g() {} + // CHECK: define hidden void @_ZN1n1gEv +#pragma GCC visibility pop +} + +namespace n __attribute((visibility("hidden"))) { + extern int foofoo; // FIXME: Shouldn't be necessary, but otherwise the pragma + // gets to Sema before the namespace! + #pragma GCC visibility pop + void h() {} + // CHECK: define void @_ZN1n1hEv +} diff --git a/test/CodeGenCXX/reference-cast.cpp b/test/CodeGenCXX/reference-cast.cpp new file mode 100644 index 0000000..585d1db --- /dev/null +++ b/test/CodeGenCXX/reference-cast.cpp @@ -0,0 +1,170 @@ +// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin10 -o - %s | FileCheck %s + +// PR6024 +extern int i; + +// CHECK: define i32* @_Z16lvalue_noop_castv() nounwind +const int &lvalue_noop_cast() { + if (i == 0) + // CHECK: store i32 17, i32* + return (const int&)17; + else if (i == 1) + // CHECK: store i32 17, i32* + return static_cast<const int&>(17); + // CHECK: store i32 17, i32* + return 17; +} + +// CHECK: define i16* @_Z20lvalue_integral_castv() +const short &lvalue_integral_cast() { + if (i == 0) + // CHECK: store i16 17, i16* + return (const short&)17; + else if (i == 1) + // CHECK: store i16 17, i16* + return static_cast<const short&>(17); + // CHECK: store i16 17, i16* + return 17; +} + +// CHECK: define i16* @_Z29lvalue_floating_integral_castv() +const short &lvalue_floating_integral_cast() { + if (i == 0) + // CHECK: store i16 17, i16* + return (const short&)17.5; + else if (i == 1) + // CHECK: store i16 17, i16* + return static_cast<const short&>(17.5); + // CHECK: store i16 17, i16* + return 17.5; +} + +// CHECK: define float* @_Z29lvalue_integral_floating_castv() +const float &lvalue_integral_floating_cast() { + if (i == 0) + // CHECK: store float 1.700000e+{{0*}}1, float* + return (const float&)17; + else if (i == 1) + // CHECK: store float 1.700000e+{{0*}}1, float* + return static_cast<const float&>(17); + // CHECK: store float 1.700000e+{{0*}}1, float* + return 17; +} + +// CHECK: define float* @_Z20lvalue_floating_castv() +const float &lvalue_floating_cast() { + if (i == 0) + // CHECK: store float 1.700000e+{{0*}}1, float* + return (const float&)17.0; + else if (i == 1) + // CHECK: store float 1.700000e+{{0*}}1, float* + return static_cast<const float&>(17.0); + // CHECK: store float 1.700000e+{{0*}}1, float* + return 17.0; +} + +int get_int(); + +// CHECK: define i8* @_Z24lvalue_integer_bool_castv() +const bool &lvalue_integer_bool_cast() { + if (i == 0) + // CHECK: call i32 @_Z7get_intv() + // CHECK: store i8 + return (const bool&)get_int(); + else if (i == 1) + // CHECK: call i32 @_Z7get_intv() + // CHECK: store i8 + return static_cast<const bool&>(get_int()); + // CHECK: call i32 @_Z7get_intv() + // CHECK: store i8 + return get_int(); +} + +float get_float(); + +// CHECK: define i8* @_Z25lvalue_floating_bool_castv() +const bool &lvalue_floating_bool_cast() { + if (i == 0) + // CHECK: call float @_Z9get_floatv() + // CHECK: fcmp une float + // CHECK: store i8 + return (const bool&)get_float(); + else if (i == 1) + // CHECK: call float @_Z9get_floatv() + // CHECK: fcmp une float + // CHECK: store i8 + return static_cast<const bool&>(get_float()); + // CHECK: call float @_Z9get_floatv() + // CHECK: fcmp une float + // CHECK: store i8 + return get_float(); +} + +struct X { }; +typedef int X::*pm; +typedef int (X::*pmf)(int); + +pm get_pointer_to_member_data(); +pmf get_pointer_to_member_function(); + +// CHECK: define i8* @_Z26lvalue_ptrmem_to_bool_castv() +const bool &lvalue_ptrmem_to_bool_cast() { + if (i == 0) + // CHECK: call i64 @_Z26get_pointer_to_member_datav() + // CHECK: store i8 + // CHECK: store i8* + return (const bool&)get_pointer_to_member_data(); + else if (i == 1) + // CHECK: call i64 @_Z26get_pointer_to_member_datav() + // CHECK: store i8 + // CHECK: store i8* + return static_cast<const bool&>(get_pointer_to_member_data()); + // CHECK: call i64 @_Z26get_pointer_to_member_datav() + // CHECK: store i8 + // CHECK: store i8* + return get_pointer_to_member_data(); +} + +// CHECK: define i8* @_Z27lvalue_ptrmem_to_bool_cast2v +const bool &lvalue_ptrmem_to_bool_cast2() { + if (i == 0) + // CHECK: {{call.*_Z30get_pointer_to_member_functionv}} + // CHECK: store i8 + // CHECK: store i8* + return (const bool&)get_pointer_to_member_function(); + else if (i == 1) + // CHECK: {{call.*_Z30get_pointer_to_member_functionv}} + // CHECK: store i8 + // CHECK: store i8* + return static_cast<const bool&>(get_pointer_to_member_function()); + // CHECK: {{call.*_Z30get_pointer_to_member_functionv}} + // CHECK: store i8 + // CHECK: store i8* + return get_pointer_to_member_function(); +} + +_Complex double get_complex_double(); + +// CHECK: {{define.*_Z2f1v}} +const _Complex float &f1() { + if (i == 0) + // CHECK: {{call.*_Z18get_complex_doublev}} + // CHECK: fptrunc + // CHECK: fptrunc + // CHECK: store float + // CHECK: store float + return (const _Complex float&)get_complex_double(); + else if (i == 1) + // CHECK: {{call.*_Z18get_complex_doublev}} + // CHECK: fptrunc + // CHECK: fptrunc + // CHECK: store float + // CHECK: store float + return static_cast<const _Complex float&>(get_complex_double()); + // CHECK: {{call.*_Z18get_complex_doublev}} + // CHECK: fptrunc + // CHECK: fptrunc + // CHECK: store float + // CHECK: store float + return get_complex_double(); +} diff --git a/test/CodeGenCXX/rtti-fundamental.cpp b/test/CodeGenCXX/rtti-fundamental.cpp index 6826321..7f80d99 100644 --- a/test/CodeGenCXX/rtti-fundamental.cpp +++ b/test/CodeGenCXX/rtti-fundamental.cpp @@ -14,60 +14,60 @@ namespace __cxxabiv1 { __fundamental_type_info::~__fundamental_type_info() { } } -// CHECK: @_ZTIv = weak_odr constant -// CHECK: @_ZTIPv = weak_odr constant -// CHECK: @_ZTIPKv = weak_odr constant -// CHECK: @_ZTIDi = weak_odr constant -// CHECK: @_ZTIPDi = weak_odr constant -// CHECK: @_ZTIPKDi = weak_odr constant -// CHECK: @_ZTIDs = weak_odr constant -// CHECK: @_ZTIPDs = weak_odr constant -// CHECK: @_ZTIPKDs = weak_odr constant -// CHECK: @_ZTIy = weak_odr constant -// CHECK: @_ZTIPy = weak_odr constant -// CHECK: @_ZTIPKy = weak_odr constant -// CHECK: @_ZTIx = weak_odr constant -// CHECK: @_ZTIPx = weak_odr constant -// CHECK: @_ZTIPKx = weak_odr constant -// CHECK: @_ZTIw = weak_odr constant -// CHECK: @_ZTIPw = weak_odr constant -// CHECK: @_ZTIPKw = weak_odr constant -// CHECK: @_ZTIt = weak_odr constant -// CHECK: @_ZTIPt = weak_odr constant -// CHECK: @_ZTIPKt = weak_odr constant -// CHECK: @_ZTIs = weak_odr constant -// CHECK: @_ZTIPs = weak_odr constant -// CHECK: @_ZTIPKs = weak_odr constant -// CHECK: @_ZTIm = weak_odr constant -// CHECK: @_ZTIPm = weak_odr constant -// CHECK: @_ZTIPKm = weak_odr constant -// CHECK: @_ZTIl = weak_odr constant -// CHECK: @_ZTIPl = weak_odr constant -// CHECK: @_ZTIPKl = weak_odr constant -// CHECK: @_ZTIj = weak_odr constant -// CHECK: @_ZTIPj = weak_odr constant -// CHECK: @_ZTIPKj = weak_odr constant -// CHECK: @_ZTIi = weak_odr constant -// CHECK: @_ZTIPi = weak_odr constant -// CHECK: @_ZTIPKi = weak_odr constant -// CHECK: @_ZTIh = weak_odr constant -// CHECK: @_ZTIPh = weak_odr constant -// CHECK: @_ZTIPKh = weak_odr constant -// CHECK: @_ZTIf = weak_odr constant -// CHECK: @_ZTIPf = weak_odr constant -// CHECK: @_ZTIPKf = weak_odr constant -// CHECK: @_ZTIe = weak_odr constant -// CHECK: @_ZTIPe = weak_odr constant -// CHECK: @_ZTIPKe = weak_odr constant -// CHECK: @_ZTId = weak_odr constant -// CHECK: @_ZTIPd = weak_odr constant -// CHECK: @_ZTIPKd = weak_odr constant -// CHECK: @_ZTIc = weak_odr constant -// CHECK: @_ZTIPc = weak_odr constant -// CHECK: @_ZTIPKc = weak_odr constant -// CHECK: @_ZTIb = weak_odr constant -// CHECK: @_ZTIPb = weak_odr constant -// CHECK: @_ZTIPKb = weak_odr constant -// CHECK: @_ZTIa = weak_odr constant -// CHECK: @_ZTIPa = weak_odr constant -// CHECK: @_ZTIPKa = weak_odr constant +// CHECK: @_ZTIv = constant +// CHECK: @_ZTIPv = constant +// CHECK: @_ZTIPKv = constant +// CHECK: @_ZTIDi = constant +// CHECK: @_ZTIPDi = constant +// CHECK: @_ZTIPKDi = constant +// CHECK: @_ZTIDs = constant +// CHECK: @_ZTIPDs = constant +// CHECK: @_ZTIPKDs = constant +// CHECK: @_ZTIy = constant +// CHECK: @_ZTIPy = constant +// CHECK: @_ZTIPKy = constant +// CHECK: @_ZTIx = constant +// CHECK: @_ZTIPx = constant +// CHECK: @_ZTIPKx = constant +// CHECK: @_ZTIw = constant +// CHECK: @_ZTIPw = constant +// CHECK: @_ZTIPKw = constant +// CHECK: @_ZTIt = constant +// CHECK: @_ZTIPt = constant +// CHECK: @_ZTIPKt = constant +// CHECK: @_ZTIs = constant +// CHECK: @_ZTIPs = constant +// CHECK: @_ZTIPKs = constant +// CHECK: @_ZTIm = constant +// CHECK: @_ZTIPm = constant +// CHECK: @_ZTIPKm = constant +// CHECK: @_ZTIl = constant +// CHECK: @_ZTIPl = constant +// CHECK: @_ZTIPKl = constant +// CHECK: @_ZTIj = constant +// CHECK: @_ZTIPj = constant +// CHECK: @_ZTIPKj = constant +// CHECK: @_ZTIi = constant +// CHECK: @_ZTIPi = constant +// CHECK: @_ZTIPKi = constant +// CHECK: @_ZTIh = constant +// CHECK: @_ZTIPh = constant +// CHECK: @_ZTIPKh = constant +// CHECK: @_ZTIf = constant +// CHECK: @_ZTIPf = constant +// CHECK: @_ZTIPKf = constant +// CHECK: @_ZTIe = constant +// CHECK: @_ZTIPe = constant +// CHECK: @_ZTIPKe = constant +// CHECK: @_ZTId = constant +// CHECK: @_ZTIPd = constant +// CHECK: @_ZTIPKd = constant +// CHECK: @_ZTIc = constant +// CHECK: @_ZTIPc = constant +// CHECK: @_ZTIPKc = constant +// CHECK: @_ZTIb = constant +// CHECK: @_ZTIPb = constant +// CHECK: @_ZTIPKb = constant +// CHECK: @_ZTIa = constant +// CHECK: @_ZTIPa = constant +// CHECK: @_ZTIPKa = constant diff --git a/test/CodeGenCXX/rtti-linkage.cpp b/test/CodeGenCXX/rtti-linkage.cpp index f8c1167..efa336d 100644 --- a/test/CodeGenCXX/rtti-linkage.cpp +++ b/test/CodeGenCXX/rtti-linkage.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -o - | sort | FileCheck %s +// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -fhidden-weak-vtables -emit-llvm -o - | sort | FileCheck %s // FIXME: Fails on Win32, dunno why. // XFAIL: win32 @@ -11,13 +11,16 @@ -// CHECK: _ZTI1A = weak_odr constant +// CHECK: _ZTI1A = weak_odr hidden constant // CHECK: _ZTI1B = constant // CHECK: _ZTI1C = internal constant -// CHECK: _ZTIA10_i = weak_odr constant +// CHECK: _ZTI1TILj0EE = weak_odr constant +// CHECK: _ZTI1TILj1EE = weak_odr constant +// CHECK: _ZTI1TILj2EE = external constant +// CHECK: _ZTIA10_i = weak_odr hidden constant // CHECK: _ZTIFN12_GLOBAL__N_11DEvE = internal constant // CHECK: _ZTIFvN12_GLOBAL__N_11DEE = internal constant -// CHECK: _ZTIFvvE = weak_odr +// CHECK: _ZTIFvvE = weak_odr hidden constant // CHECK: _ZTIM1A1C = internal constant // CHECK: _ZTIM1AP1C = internal constant // CHECK: _ZTIM1CPS_ = internal constant @@ -26,7 +29,7 @@ // CHECK: _ZTIN12_GLOBAL__N_11DE = internal constant // CHECK: _ZTIN12_GLOBAL__N_11EE = internal constant // CHECK: _ZTIP1C = internal constant -// CHECK: _ZTIPFvvE = weak_odr constant +// CHECK: _ZTIPFvvE = weak_odr hidden constant // CHECK: _ZTIPM1Ci = internal constant // CHECK: _ZTIPN12_GLOBAL__N_11DE = internal constant // CHECK: _ZTIPP1C = internal constant @@ -118,3 +121,14 @@ namespace Arrays { return typeid(A::a); } } + +template <unsigned N> class T { + virtual void anchor() {} +}; +template class T<1>; +template <> class T<2> { virtual void anchor(); }; +void t3() { + (void) typeid(T<0>); + (void) typeid(T<1>); + (void) typeid(T<2>); +} diff --git a/test/CodeGenCXX/static-init-2.cpp b/test/CodeGenCXX/static-init-2.cpp index 7eb4a7d..65ab3bb 100644 --- a/test/CodeGenCXX/static-init-2.cpp +++ b/test/CodeGenCXX/static-init-2.cpp @@ -3,4 +3,4 @@ // Make sure we don't crash generating y; its value is constant, but the // initializer has side effects, so EmitConstantExpr should fail. int x(); -int y = x() && 0; // expected-warning {{use of logical && with constant operand}} +int y = x() && 0; diff --git a/test/CodeGenCXX/template-anonymous-types.cpp b/test/CodeGenCXX/template-anonymous-types.cpp new file mode 100644 index 0000000..5e7a71f --- /dev/null +++ b/test/CodeGenCXX/template-anonymous-types.cpp @@ -0,0 +1,37 @@ +// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -o - | FileCheck %s + +struct S { + enum { FOO = 42 }; + enum { BAR = 42 }; +}; + +template <typename T> struct X { + T value; + X(T t) : value(t) {} + int f() { return value; } +}; + +template <typename T> int f(T t) { + X<T> x(t); + return x.f(); +} + +void test() { + // Look for two instantiations, entirely internal to this TU, one for FOO's + // type and one for BAR's. + // CHECK: define internal i32 @"_Z1fIN1S3$_0EEiT_"(i32 %t) + (void)f(S::FOO); + // CHECK: define internal i32 @"_Z1fIN1S3$_1EEiT_"(i32 %t) + (void)f(S::BAR); + + // Now check for the class template instantiations. Annoyingly, they are in + // reverse order. + // + // BAR's instantiation of X: + // CHECK: define internal i32 @"_ZN1XIN1S3$_1EE1fEv"(%struct.X* %this) + // CHECK: define internal void @"_ZN1XIN1S3$_1EEC2ES1_"(%struct.X* %this, i32 %t) + // + // FOO's instantiation of X: + // CHECK: define internal i32 @"_ZN1XIN1S3$_0EE1fEv"(%struct.X* %this) + // CHECK: define internal void @"_ZN1XIN1S3$_0EEC2ES1_"(%struct.X* %this, i32 %t) +} diff --git a/test/CodeGenCXX/threadsafe-statics-exceptions.cpp b/test/CodeGenCXX/threadsafe-statics-exceptions.cpp index 17c1030..c91590f 100644 --- a/test/CodeGenCXX/threadsafe-statics-exceptions.cpp +++ b/test/CodeGenCXX/threadsafe-statics-exceptions.cpp @@ -17,7 +17,7 @@ void f() { static X x; // CHECK: call i8* @__cxa_allocate_exception - // CHECK: invoke void @__cxa_throw + // CHECK: call void @__cxa_throw throw Y(); // Finally, the landing pad. diff --git a/test/CodeGenCXX/thunks.cpp b/test/CodeGenCXX/thunks.cpp index 1de5761..ba60385 100644 --- a/test/CodeGenCXX/thunks.cpp +++ b/test/CodeGenCXX/thunks.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fhidden-weak-vtables -emit-llvm -o - | FileCheck -check-prefix=HIDDEN %s namespace Test1 { @@ -246,6 +247,19 @@ namespace Test9 { } } +namespace Test10 { + struct A { virtual void foo(); }; + struct B { virtual void foo(); }; + struct C : A, B { void foo() {} }; + + // CHECK-HIDDEN: define linkonce_odr void @_ZN6Test101C3fooEv + // CHECK-HIDDEN: define linkonce_odr hidden void @_ZThn8_N6Test101C3fooEv + + void test() { + C c; + } +} + /**** The following has to go at the end of the file ****/ // This is from Test5: diff --git a/test/CodeGenCXX/uncode-string.cpp b/test/CodeGenCXX/uncode-string.cpp new file mode 100644 index 0000000..e543149 --- /dev/null +++ b/test/CodeGenCXX/uncode-string.cpp @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s +// rdar://8360841 + +wchar_t s[] = L"\u2722"; + +// CHECK: @s = global [8 x i8] c"\22'\00\00\00\00\00\00" diff --git a/test/CodeGenCXX/value-init.cpp b/test/CodeGenCXX/value-init.cpp index 35be159..c4eb1c8 100644 --- a/test/CodeGenCXX/value-init.cpp +++ b/test/CodeGenCXX/value-init.cpp @@ -49,3 +49,92 @@ void test_enum_holder_and_int() { enum_holder_and_int(); // CHECK-NEXT: ret void } + +// PR7834: don't crash. +namespace test1 { + struct A { + int A::*f; + A(); + A(const A&); + A &operator=(const A &); + }; + + struct B { + A base; + }; + + void foo() { + B(); + } +} + +namespace ptrmem { + struct S { + int mem1; + int S::*mem2; + }; + + // CHECK: define i32 @_ZN6ptrmem4testEPNS_1SE + int test(S *s) { + // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64 + // CHECK: getelementptr + // CHECK: ret + return s->*S().mem2; + } +} + +namespace zeroinit { + struct S { int i; }; + + // CHECK: define i32 @_ZN8zeroinit4testEv() + int test() { + // CHECK: call void @llvm.memset.p0i8.i64 + // CHECK: getelementptr + // CHECK: ret i32 + return S().i; + } + + struct X0 { + X0() { } + int x; + }; + + struct X1 : X0 { + int x1; + void f(); + }; + + // CHECK: define void @_ZN8zeroinit9testX0_X1Ev + void testX0_X1() { + // CHECK: call void @llvm.memset.p0i8.i64 + // CHECK-NEXT: call void @_ZN8zeroinit2X1C1Ev + // CHECK-NEXT: call void @_ZN8zeroinit2X11fEv + X1().f(); + } + + template<typename> + struct X2 : X0 { + int x2; + void f(); + }; + + template<typename> + struct X3 : X2<int> { + X3() : X2<int>() { } + }; + + + // CHECK: define void @_ZN8zeroinit9testX0_X3Ev + void testX0_X3() { + // CHECK-NOT: call void @llvm.memset + // CHECK: call void @_ZN8zeroinit2X3IiEC1Ev + // CHECK: call void @_ZN8zeroinit2X2IiE1fEv + // CHECK-NEXT: ret void + X3<int>().f(); + } + + // CHECK: define linkonce_odr void @_ZN8zeroinit2X3IiEC2Ev + // CHECK: call void @llvm.memset.p0i8.i64 + // CHECK-NEXT: call void @_ZN8zeroinit2X2IiEC2Ev + // CHECK-NEXT: ret void +} diff --git a/test/CodeGenCXX/virt-template-vtable.cpp b/test/CodeGenCXX/virt-template-vtable.cpp index b968f38..d60cfb9 100644 --- a/test/CodeGenCXX/virt-template-vtable.cpp +++ b/test/CodeGenCXX/virt-template-vtable.cpp @@ -10,4 +10,13 @@ class B : A<int> { }; B::B() {} +template class A<long>; + +extern template class A<short>; +template class A<short>; + + +// CHECK: @_ZTV1B = weak_odr constant +// CHECK: @_ZTV1AIlE = weak_odr constant +// CHECK: @_ZTV1AIsE = weak_odr constant // CHECK: @_ZTV1AIiE = weak_odr constant diff --git a/test/CodeGenCXX/volatile.cpp b/test/CodeGenCXX/volatile.cpp new file mode 100644 index 0000000..58f433f --- /dev/null +++ b/test/CodeGenCXX/volatile.cpp @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s + +// Check that IR gen doesn't try to do an lvalue-to-rvalue conversion +// on a volatile reference result. rdar://problem/8338198 +namespace test0 { + struct A { + A(const A& t); + A& operator=(const A& t); + volatile A& operator=(const volatile A& t) volatile; + }; + + volatile A *array; + + // CHECK: define void @_ZN5test04testENS_1AE( + void test(A t) { + // CHECK: [[ARR:%.*]] = load [[A:%.*]]** @_ZN5test05arrayE, align 8 + // CHECK-NEXT: [[IDX:%.*]] = getelementptr inbounds [[A]]* [[ARR]], i64 0 + // CHECK-NEXT: [[TMP:%.*]] = call [[A]]* @_ZNV5test01AaSERVKS0_([[A]]* [[IDX]], [[A]]* [[T:%.*]]) + // CHECK-NEXT: ret void + array[0] = t; + } +} + +namespace test1 { + volatile int *x; + + // CHECK: define void @_ZN5test14testEv() + void test() { + // CHECK: [[TMP:%.*]] = load i32** @_ZN5test11xE, align 8 + // *** FIXME: no! bad! should not be loaded! *** + // CHECK-NEXT: [[TMP1:%.*]] = volatile load i32* [[TMP]] + // CHECK-NEXT: ret void + *x; + } +} diff --git a/test/CodeGenCXX/vtable-linkage.cpp b/test/CodeGenCXX/vtable-linkage.cpp index b3b6870..cf988d1 100644 --- a/test/CodeGenCXX/vtable-linkage.cpp +++ b/test/CodeGenCXX/vtable-linkage.cpp @@ -1,16 +1,21 @@ // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o %t +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fhidden-weak-vtables -emit-llvm -o %t.hidden // RUN: FileCheck --check-prefix=CHECK-1 %s < %t // RUN: FileCheck --check-prefix=CHECK-2 %s < %t +// RUN: FileCheck --check-prefix=CHECK-2-HIDDEN %s < %t.hidden // RUN: FileCheck --check-prefix=CHECK-3 %s < %t // RUN: FileCheck --check-prefix=CHECK-4 %s < %t // RUN: FileCheck --check-prefix=CHECK-5 %s < %t +// RUN: FileCheck --check-prefix=CHECK-5-HIDDEN %s < %t.hidden // RUN: FileCheck --check-prefix=CHECK-6 %s < %t +// RUN: FileCheck --check-prefix=CHECK-6-HIDDEN %s < %t.hidden // RUN: FileCheck --check-prefix=CHECK-7 %s < %t // RUN: FileCheck --check-prefix=CHECK-8 %s < %t // RUN: FileCheck --check-prefix=CHECK-9 %s < %t // RUN: FileCheck --check-prefix=CHECK-10 %s < %t // RUN: FileCheck --check-prefix=CHECK-11 %s < %t // RUN: FileCheck --check-prefix=CHECK-12 %s < %t +// RUN: FileCheck --check-prefix=CHECK-13 %s < %t namespace { struct A { @@ -83,22 +88,27 @@ struct F<char> { template struct F<short>; extern template struct F<int>; -void use_F(F<char> &fc) { +void use_F() { + F<char> fc; + fc.foo(); F<int> fi; fi.foo(); F<long> fl; (void)fl; - fc.foo(); } // B has a key function that is not defined in this translation unit so its vtable // has external linkage. // CHECK-1: @_ZTV1B = external constant -// C has no key function, so its vtable should have weak_odr linkage. +// C has no key function, so its vtable should have weak_odr linkage +// and hidden visibility (rdar://problem/7523229). // CHECK-2: @_ZTV1C = weak_odr constant // CHECK-2: @_ZTS1C = weak_odr constant // CHECK-2: @_ZTI1C = weak_odr constant +// CHECK-2-HIDDEN: @_ZTV1C = weak_odr hidden constant +// CHECK-2-HIDDEN: @_ZTS1C = weak_odr constant +// CHECK-2-HIDDEN: @_ZTI1C = weak_odr hidden constant // D has a key function that is defined in this translation unit so its vtable is // defined in the translation unit. @@ -119,12 +129,18 @@ void use_F(F<char> &fc) { // CHECK-5: @_ZTV1EIsE = weak_odr constant // CHECK-5: @_ZTS1EIsE = weak_odr constant // CHECK-5: @_ZTI1EIsE = weak_odr constant +// CHECK-5-HIDDEN: @_ZTV1EIsE = weak_odr constant +// CHECK-5-HIDDEN: @_ZTS1EIsE = weak_odr constant +// CHECK-5-HIDDEN: @_ZTI1EIsE = weak_odr constant // F<short> is an explicit template instantiation without a key // function, so its vtable should have weak_odr linkage // CHECK-6: @_ZTV1FIsE = weak_odr constant // CHECK-6: @_ZTS1FIsE = weak_odr constant // CHECK-6: @_ZTI1FIsE = weak_odr constant +// CHECK-6-HIDDEN: @_ZTV1FIsE = weak_odr constant +// CHECK-6-HIDDEN: @_ZTS1FIsE = weak_odr constant +// CHECK-6-HIDDEN: @_ZTI1FIsE = weak_odr constant // E<long> is an implicit template instantiation with a key function // defined in this translation unit, so its vtable should have @@ -160,6 +176,12 @@ void use_F(F<char> &fc) { // CHECK-12: @_ZTSN12_GLOBAL__N_11AE = internal constant // CHECK-12: @_ZTIN12_GLOBAL__N_11AE = internal constant +// F<char> is an explicit specialization without a key function, so +// its vtable should have weak_odr linkage. +// CHECK-13: @_ZTV1FIcE = weak_odr constant +// CHECK-13: @_ZTS1FIcE = weak_odr constant +// CHECK-13: @_ZTI1FIcE = weak_odr constant + // RUN: FileCheck --check-prefix=CHECK-G %s < %t // // CHECK-G: @_ZTV1GIiE = weak_odr constant diff --git a/test/CodeGenCXX/vtt-layout.cpp b/test/CodeGenCXX/vtt-layout.cpp index d7d4227..814adf0 100644 --- a/test/CodeGenCXX/vtt-layout.cpp +++ b/test/CodeGenCXX/vtt-layout.cpp @@ -59,6 +59,6 @@ namespace Test4 { } // CHECK: @_ZTTN5Test11BE = constant [1 x i8*] [i8* bitcast (i8** getelementptr inbounds ([4 x i8*]* @_ZTVN5Test11BE, i64 0, i64 3) to i8*)] -// CHECK: @_ZTTN5Test41DE = weak_odr constant [19 x i8*] [i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE0_NS_2C1E, i64 0, i64 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE0_NS_2C1E, i64 0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE0_NS_2C1E, i64 0, i64 10) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 12) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 15) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 18) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 17) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 20) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 13) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 13) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 1, i64 0) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test41DE40_NS_2V1E, i64 0, i64 3) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test41DE40_NS_2V1E, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE72_NS_2V2E, i64 0, i64 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE72_NS_2V2E, i64 0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE72_NS_2V2E, i64 0, i64 10) to i8*)] ; <[19 x i8*]*> [#uses=4] -// CHECK: @_ZTTN5Test31DE = weak_odr constant [13 x i8*] [i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 5) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test31DE0_NS_2C1E, i64 0, i64 3) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test31DE0_NS_2C1E, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 10) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 13) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 15) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 11) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 11) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTVN5Test31DE, i64 1, i64 0) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test31DE64_NS_2V2E, i64 0, i64 3) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test31DE64_NS_2V2E, i64 0, i64 6) to i8*)] ; <[13 x i8*]*> [#uses=3] -// CHECK: @_ZTTN5Test21CE = weak_odr constant [2 x i8*] [i8* bitcast (i8** getelementptr inbounds ([5 x i8*]* @_ZTVN5Test21CE, i64 0, i64 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([5 x i8*]* @_ZTVN5Test21CE, i64 0, i64 4) to i8*)] ; <[2 x i8*]*> [#uses=0] +// CHECK: @_ZTTN5Test41DE = weak_odr constant [19 x i8*] [i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE0_NS_2C1E, i64 0, i64 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE0_NS_2C1E, i64 0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE0_NS_2C1E, i64 0, i64 10) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 12) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 15) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 18) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 17) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 20) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 13) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 13) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 1, i64 0) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test41DE40_NS_2V1E, i64 0, i64 3) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test41DE40_NS_2V1E, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE72_NS_2V2E, i64 0, i64 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE72_NS_2V2E, i64 0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE72_NS_2V2E, i64 0, i64 10) to i8*)] +// CHECK: @_ZTTN5Test31DE = weak_odr constant [13 x i8*] [i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 5) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test31DE0_NS_2C1E, i64 0, i64 3) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test31DE0_NS_2C1E, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 10) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 13) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 15) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 11) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 11) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTVN5Test31DE, i64 1, i64 0) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test31DE64_NS_2V2E, i64 0, i64 3) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test31DE64_NS_2V2E, i64 0, i64 6) to i8*)] +// CHECK: @_ZTTN5Test21CE = weak_odr constant [2 x i8*] [i8* bitcast (i8** getelementptr inbounds ([5 x i8*]* @_ZTVN5Test21CE, i64 0, i64 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([5 x i8*]* @_ZTVN5Test21CE, i64 0, i64 4) to i8*)] diff --git a/test/CodeGenCXX/x86_32-arguments.cpp b/test/CodeGenCXX/x86_32-arguments.cpp index 023b729..e94e2ca 100644 --- a/test/CodeGenCXX/x86_32-arguments.cpp +++ b/test/CodeGenCXX/x86_32-arguments.cpp @@ -89,7 +89,7 @@ struct s5 { s5(); int &x; }; s5 f5() { return s5(); } // CHECK: define i32 @_Z4f6_0M2s6i(i32 %a) -// CHECK: define i64 @_Z4f6_1M2s6FivE(%{{.*}} byval %a) +// CHECK: define i64 @_Z4f6_1M2s6FivE(%{{.*}} byval) // FIXME: It would be nice to avoid byval on the previous case. struct s6 {}; typedef int s6::* s6_mdp; diff --git a/test/CodeGenCXX/x86_64-arguments.cpp b/test/CodeGenCXX/x86_64-arguments.cpp index df0c78a..e731698 100644 --- a/test/CodeGenCXX/x86_64-arguments.cpp +++ b/test/CodeGenCXX/x86_64-arguments.cpp @@ -19,11 +19,12 @@ struct f2_s1 : public f2_s0 { char d;}; void f2(f2_s1 a0) { } // PR5831 +// CHECK: define void @_Z2f34s3_1(i64 %x.coerce) struct s3_0 {}; struct s3_1 { struct s3_0 a; long b; }; void f3(struct s3_1 x) {} -// CHECK: define i64 @_Z4f4_0M2s4i(i64 %a.coerce) +// CHECK: define i64 @_Z4f4_0M2s4i(i64 %a) // CHECK: define {{.*}} @_Z4f4_1M2s4FivE(i64 %a.coerce0, i64 %a.coerce1) struct s4 {}; typedef int s4::* s4_mdp; @@ -44,4 +45,73 @@ void foo() { // CHECK: call void @_ZN6PR752310AddKeywordENS_9StringRefEi(i8* {{.*}}, i32 4) AddKeyword(StringRef(), 4); } -}
\ No newline at end of file +} + +namespace PR7742 { // Also rdar://8250764 + struct s2 { + float a[2]; + }; + + struct c2 : public s2 {}; + + // CHECK: define double @_ZN6PR77423fooEPNS_2c2E(%"struct.PR7742::c2"* %P) + c2 foo(c2 *P) { + } + +} + +namespace PR5179 { + struct B {}; + + struct B1 : B { + int* pa; + }; + + struct B2 : B { + B1 b1; + }; + + // CHECK: define i8* @_ZN6PR51793barENS_2B2E(i32* %b2.coerce) + const void *bar(B2 b2) { + return b2.b1.pa; + } +} + +namespace test5 { + struct Xbase { }; + struct Empty { }; + struct Y; + struct X : public Xbase { + Empty empty; + Y f(); + }; + struct Y : public X { + Empty empty; + }; + X getX(); + int takeY(const Y&, int y); + void g() { + // rdar://8340348 - The temporary for the X object needs to have a defined + // address when passed into X::f as 'this'. + takeY(getX().f(), 42); + } + // CHECK: void @_ZN5test51gEv() + // CHECK: alloca %"struct.test5::Y" + // CHECK: alloca %"struct.test5::X" + // CHECK: alloca %"struct.test5::Y" +} + + +// rdar://8360877 +namespace test6 { + struct outer { + int x; + struct epsilon_matcher {} e; + int f; + }; + + int test(outer x) { + return x.x + x.f; + } + // CHECK: define i32 @_ZN5test64testENS_5outerE(i64 %x.coerce0, i32 %x.coerce1) +} diff --git a/test/CodeGenObjC/bitfield-access.m b/test/CodeGenObjC/bitfield-access.m new file mode 100644 index 0000000..16b0001 --- /dev/null +++ b/test/CodeGenObjC/bitfield-access.m @@ -0,0 +1,43 @@ +// RUN: %clang_cc1 -triple i386-apple-darwin10 -emit-llvm -o %t %s +// RUN: FileCheck -check-prefix=CHECK-I386 < %t %s +// RUN: %clang_cc1 -triple armv6-apple-darwin10 -target-abi apcs-gnu -emit-llvm -o %t %s +// RUN: FileCheck -check-prefix=CHECK-ARM < %t %s + +@interface I0 { +@public + unsigned x:15; + unsigned y: 1; +} +@end + +// Check that we don't try to use an i32 load here, which would reach beyond the +// end of the structure. +// +// CHECK-I386: define i32 @f0( +// CHECK-I386: [[t0_0:%.*]] = load i16* {{.*}}, align 1 +// CHECK-I386: lshr i16 [[t0_0]], 7 +// CHECK-I386: } +int f0(I0 *a) { + return a->y; +} + +// Check that we can handled straddled loads. +// +// CHECK-ARM: define i32 @f1( +// CHECK-ARM: [[t1_ptr:%.*]] = getelementptr +// CHECK-ARM: [[t1_base:%.*]] = bitcast i8* [[t1_ptr]] to i32* +// CHECK-ARM: [[t1_0:%.*]] = load i32* [[t1_base]], align 1 +// CHECK-ARM: lshr i32 [[t1_0]], 1 +// CHECK-ARM: [[t1_base_2_cast:%.*]] = bitcast i32* %{{.*}} to i8* +// CHECK-ARM: [[t1_base_2:%.*]] = getelementptr i8* [[t1_base_2_cast]] +// CHECK-ARM: [[t1_1:%.*]] = load i8* [[t1_base_2]], align 1 +// CHECK-ARM: and i8 [[t1_1:%.*]], 1 +// CHECK-ARM: } +@interface I1 { +@public + unsigned x: 1; + unsigned y:32; +} +@end + +int f1(I1 *a) { return a->y; } diff --git a/test/CodeGenObjC/block-var-layout.m b/test/CodeGenObjC/block-var-layout.m new file mode 100644 index 0000000..bf9ba8d --- /dev/null +++ b/test/CodeGenObjC/block-var-layout.m @@ -0,0 +1,123 @@ +// RUN: %clang_cc1 -fblocks -fobjc-gc -triple x86_64-apple-darwin -O0 -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: %clang_cc1 -x objective-c++ -fblocks -fobjc-gc -triple x86_64-apple-darwin -O0 -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s + +struct S { + int i1; + id o1; + struct V { + int i2; + id o2; + } v1; + int i3; + id o3; +}; + +__weak id wid; +void x(id y) {} +void y(int a) {} + +void f() { + __block int byref_int = 0; + char ch = 'a'; + char ch1 = 'b'; + char ch2 = 'c'; + short sh = 2; + const id bar = (id)0; + id baz = 0; + __strong void *strong_void_sta; + __block id byref_bab = (id)0; + __block void *bl_var1; + int i; double dob; + + void (^b)() = ^{ + byref_int = sh + ch+ch1+ch2 ; + x(bar); + x(baz); + x((id)strong_void_sta); + x(byref_bab); + }; + b(); + +// Test 2 + void (^c)() = ^{ + byref_int = sh + ch+ch1+ch2 ; + x(bar); + x(baz); + x((id)strong_void_sta); + x(wid); + bl_var1 = 0; + x(byref_bab); + }; + c(); + +// Test 3 +void (^d)() = ^{ + byref_int = sh + ch+ch1+ch2 ; + x(bar); + x(baz); + x(wid); + bl_var1 = 0; + y(i + dob); + x(byref_bab); + }; + d(); + +// Test4 + struct S s2; + void (^e)() = ^{ + x(s2.o1); + }; + e(); +} + +// Test 5 (unions/structs and their nesting): +void Test5() { +struct S5 { + int i1; + id o1; + struct V { + int i2; + id o2; + } v1; + int i3; + union UI { + void * i1; + id o1; + int i3; + id o3; + }ui; +}; + +union U { + void * i1; + id o1; + int i3; + id o3; +}ui; + +struct S5 s2; +union U u2; +void (^c)() = ^{ + x(s2.ui.o1); + x(u2.o1); +}; +c(); + +} + +// CHECK-LP64: L_OBJC_CLASS_NAME_: +// CHECK-LP64-NEXT: .asciz "A\024" + +// CHECK-LP64: L_OBJC_CLASS_NAME_1: +// CHECK-LP64-NEXT: .asciz "A\025" + +// CHECK-LP64: L_OBJC_CLASS_NAME_6: +// CHECK-LP64-NEXT: .asciz "A\023!" + +// CHECK-LP64: L_OBJC_CLASS_NAME_11: +// CHECK-LP64-NEXT: .asciz "Q\021\021" + +// CHECK-LP64: L_OBJC_CLASS_NAME_14: +// CHECK-LP64-NEXT: .asciz "Q\021\022p" diff --git a/test/CodeGenObjC/debug-info-linkagename.m b/test/CodeGenObjC/debug-info-linkagename.m index 2b10e2b..b606e5d 100644 --- a/test/CodeGenObjC/debug-info-linkagename.m +++ b/test/CodeGenObjC/debug-info-linkagename.m @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -g -S -o %t %s -// RUN: not grep 001 %t +// RUN: not grep "001-[F bar" %t +// Linkage name should not use 001 prefix in debug info. @interface F -(int) bar; diff --git a/test/CodeGenObjC/exceptions.m b/test/CodeGenObjC/exceptions.m index 5be6959..b431e37 100644 --- a/test/CodeGenObjC/exceptions.m +++ b/test/CodeGenObjC/exceptions.m @@ -25,15 +25,111 @@ void f1() { // CHECK-NEXT: icmp // CHECK-NEXT: br i1 @try { - // CHECK: call void @foo() + // CHECK: call void asm sideeffect "", "*m" + // CHECK-NEXT: call void @foo() foo(); - // CHECK: call void @objc_exception_try_exit + // CHECK-NEXT: call void @objc_exception_try_exit // CHECK-NEXT: ret void - // CHECK: call i8* @objc_exception_extract + // CHECK: call void asm sideeffect "", "=*m" // CHECK-NEXT: ret void } @finally { break; } } } + +// Test that modifications to local variables are respected under +// optimization. rdar://problem/8160285 + +// CHECK: define i32 @f2() +int f2() { + extern void foo(void); + + // CHECK: [[X:%.*]] = alloca i32 + // CHECK: store i32 5, i32* [[X]] + int x = 0; + x += 5; + + // CHECK: [[SETJMP:%.*]] = call i32 @_setjmp + // CHECK-NEXT: [[CAUGHT:%.*]] = icmp eq i32 [[SETJMP]], 0 + // CHECK-NEXT: br i1 [[CAUGHT]] + @try { + // If the optimizers ever figure out how to make this store 6, + // that's okay. + // CHECK: [[T1:%.*]] = load i32* [[X]] + // CHECK-NEXT: [[T2:%.*]] = add nsw i32 [[T1]], 1 + // CHECK-NEXT: store i32 [[T2]], i32* [[X]] + x++; + // CHECK-NEXT: call void asm sideeffect "", "*m,*m"(i32* [[X]] + // CHECK-NEXT: call void @foo() + // CHECK-NEXT: call void @objc_exception_try_exit + // CHECK-NEXT: [[T:%.*]] = load i32* [[X]] + // CHECK-NEXT: ret i32 [[T]] + foo(); + } @catch (id) { + // Landing pad. Note that we elide the re-enter. + // CHECK: call void asm sideeffect "", "=*m,=*m"(i32* [[X]] + // CHECK-NEXT: call i8* @objc_exception_extract + // CHECK-NEXT: [[T1:%.*]] = load i32* [[X]] + // CHECK-NEXT: [[T2:%.*]] = add nsw i32 [[T1]], -1 + + // This store is dead. + // CHECK-NEXT: store i32 [[T2]], i32* [[X]] + + // CHECK-NEXT: ret i32 [[T2]] + x--; + } + return x; +} + +// Test that the cleanup destination is saved when entering a finally +// block. rdar://problem/8293901 +// CHECK: define void @f3() +void f3() { + extern void f3_helper(int, int*); + + // CHECK: [[X:%.*]] = alloca i32 + // CHECK: store i32 0, i32* [[X]] + int x = 0; + + // CHECK: call void @objc_exception_try_enter( + // CHECK: call i32 @_setjmp + // CHECK-NEXT: icmp eq + // CHECK-NEXT: br i1 + + @try { + // CHECK: call void @f3_helper(i32 0, i32* [[X]]) + // CHECK: call void @objc_exception_try_exit( + f3_helper(0, &x); + } @finally { + // CHECK: [[DEST1:%.*]] = phi i32 [ 0, {{%.*}} ], [ 3, {{%.*}} ] + // CHECK: call void @objc_exception_try_enter + // CHECK: call i32 @_setjmp + @try { + // CHECK: call void @f3_helper(i32 1, i32* [[X]]) + // CHECK: call void @objc_exception_try_exit( + f3_helper(1, &x); + } @finally { + // CHECK: [[DEST2:%.*]] = phi i32 [ 0, {{%.*}} ], [ 5, {{%.*}} ] + // CHECK: call void @f3_helper(i32 2, i32* [[X]]) + f3_helper(2, &x); + + // This loop is large enough to dissuade the optimizer from just + // duplicating the finally block. + while (x) f3_helper(3, &x); + + // This is a switch or maybe some chained branches, but relying + // on a specific result from the optimizer is really unstable. + // CHECK: [[DEST2]] + } + + // This is a switch or maybe some chained branches, but relying + // on a specific result from the optimizer is really unstable. + // CHECK: [[DEST1]] + } + + // CHECK: call void @f3_helper(i32 4, i32* [[X]]) + // CHECK-NEXT: ret void + f3_helper(4, &x); +} diff --git a/test/CodeGenObjC/for-in.m b/test/CodeGenObjC/for-in.m index 354ff32..7e6098a 100644 --- a/test/CodeGenObjC/for-in.m +++ b/test/CodeGenObjC/for-in.m @@ -23,7 +23,7 @@ void t0() { p("array.length: %d\n", [array count]); unsigned index = 0; - for (NSString *i in array) { + for (NSString *i in array) { // expected-warning {{collection expression type 'NSArray *' may not respond}} p("element %d: %s\n", index++, [i cString]); } } @@ -33,7 +33,7 @@ void t1() { p("array.length: %d\n", [array count]); unsigned index = 0; - for (NSString *i in array) { + for (NSString *i in array) { // expected-warning {{collection expression type 'NSArray *' may not respond}} index++; if (index == 10) continue; diff --git a/test/CodeGenObjC/fpret.m b/test/CodeGenObjC/fpret.m new file mode 100644 index 0000000..4884888 --- /dev/null +++ b/test/CodeGenObjC/fpret.m @@ -0,0 +1,38 @@ +// RUN: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm -o - %s | \ +// RUN: FileCheck --check-prefix=CHECK-X86_32 %s +// +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | \ +// RUN: FileCheck --check-prefix=CHECK-X86_64 %s +// +// RUN: %clang_cc1 -triple armv7-apple-darwin10 -emit-llvm -target-abi apcs-gnu -o - %s | \ +// RUN: FileCheck --check-prefix=CHECK-ARMV7 %s + +@interface A +-(float) floatValue; +-(double) doubleValue; +-(long double) longDoubleValue; +@end + + +// CHECK-X86_32: define void @t0() +// CHECK-X86_32: call float bitcast {{.*}} @objc_msgSend_fpret to +// CHECK-X86_32: call double {{.*}} @objc_msgSend_fpret( +// CHECK-X86_32: call x86_fp80 bitcast {{.*}} @objc_msgSend_fpret to +// CHECK-X86_32: } +// +// CHECK-X86_64: define void @t0() +// CHECK-X86_64: call float bitcast {{.*}} @objc_msgSend to +// CHECK-X86_64: call double bitcast {{.*}} @objc_msgSend to +// CHECK-X86_64: call x86_fp80 bitcast {{.*}} @objc_msgSend_fpret to +// CHECK-X86_64: } +// +// CHECK-ARMV7: define void @t0() +// CHECK-ARMV7: call float bitcast {{.*}} @objc_msgSend to +// CHECK-ARMV7: call double bitcast {{.*}} @objc_msgSend to +// CHECK-ARMV7: call double bitcast {{.*}} @objc_msgSend to +// CHECK-ARMV7: } +void t0() { + [(A*)0 floatValue]; + [(A*)0 doubleValue]; + [(A*)0 longDoubleValue]; +} diff --git a/test/CodeGenObjC/gnu-exceptions.m b/test/CodeGenObjC/gnu-exceptions.m new file mode 100644 index 0000000..6790a29 --- /dev/null +++ b/test/CodeGenObjC/gnu-exceptions.m @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -fexceptions -fgnu-runtime -o - %s | FileCheck %s + +void opaque(void); +void log(int i); + +@class C; + +// CHECK: define void @test0() { +void test0() { + @try { + // CHECK: invoke void @opaque() + opaque(); + + // CHECK: call void @log(i32 1) + + } @catch (C *c) { + // CHECK: call i8* @llvm.eh.exception() + // CHECK: call i32 (i8*, i8*, ...)* @llvm.eh.selector({{.*}} @__gnu_objc_personality_v0 + // CHECK: br i1 + + // CHECK: call void @log(i32 0) + + // CHECK: call void @objc_exception_throw + + log(0); + } + + log(1); +} diff --git a/test/CodeGenObjC/ivar-layout-nonfragile-abi2.m b/test/CodeGenObjC/ivar-layout-nonfragile-abi2.m new file mode 100644 index 0000000..b474caa --- /dev/null +++ b/test/CodeGenObjC/ivar-layout-nonfragile-abi2.m @@ -0,0 +1,51 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi2 -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi2 -emit-llvm -o %t %s +// rdar: // 7824380 + +@interface Super { + int ivar_super_a : 5; +} +@end + +@interface A : Super { +@public + int ivar_a : 5; +} +@end + +int f0(A *a) { + return a->ivar_a; +} + +@interface A () { +@public + int ivar_ext_a : 5; + int ivar_ext_b : 5; +}@end + +int f1(A *a) { + return a->ivar_ext_a + a->ivar_a; +} + +@interface A () { +@public + int ivar_ext2_a : 5; + int ivar_ext2_b : 5; +}@end + +int f2(A* a) { + return a->ivar_ext2_a + a->ivar_ext_a + a->ivar_a; +} + +@implementation A { +@public + int ivar_b : 5; + int ivar_c : 5; + int ivar_d : 5; +} +@end + +int f3(A *a) { + return a->ivar_d + a->ivar_ext2_a + a->ivar_ext_a + a->ivar_a; +} + diff --git a/test/CodeGenObjC/property-dbg.m b/test/CodeGenObjC/property-dbg.m index 5bbb046..42ab611 100644 --- a/test/CodeGenObjC/property-dbg.m +++ b/test/CodeGenObjC/property-dbg.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -S -g -masm-verbose -x objective-c < %s | grep setI | grep DW_AT_name +// RUN: %clang_cc1 -S -g -masm-verbose -x objective-c < %s | grep DW_AT_name @interface Foo { int i; } diff --git a/test/CodeGenObjC/return-objc-object.mm b/test/CodeGenObjC/return-objc-object.mm new file mode 100644 index 0000000..95cce23 --- /dev/null +++ b/test/CodeGenObjC/return-objc-object.mm @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -triple x86_64 -emit-llvm -o - %s | FileCheck %s + +@protocol P1 @end +@interface NSOperationQueue +{ + char ch[64]; + double d; +} +@end + +NSOperationQueue &f(); +NSOperationQueue<P1> &f1(); + +void call_once() { + f(); + f1(); +} +// CHECK: call %0* @_Z1fv() +// CHECK: call %0* @_Z2f1v() diff --git a/test/CodeGenObjC/super-dotsyntax-struct-property.m b/test/CodeGenObjC/super-dotsyntax-struct-property.m new file mode 100644 index 0000000..aac4c1d --- /dev/null +++ b/test/CodeGenObjC/super-dotsyntax-struct-property.m @@ -0,0 +1,47 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -emit-llvm %s -o - | FileCheck %s +// rdar: // 8203426 + + +typedef double CGFloat; +struct CGPoint { + CGFloat x; + CGFloat y; +}; +typedef struct CGPoint CGPoint; + + + +struct CGSize { + CGFloat width; + CGFloat height; +}; +typedef struct CGSize CGSize; + + +struct CGRect { + CGPoint origin; + CGSize size; +}; +typedef struct CGRect CGRect; + +@interface UIView { +} +@property CGRect frame; +@end + +@interface crashclass : UIView { + +} + +@end + +@implementation crashclass +- (void)setFrame:(CGRect)frame +{ + super.frame = frame; + [super setFrame:frame]; +} + +@end +// CHECK-NOT: declare void @objc_msgSendSuper2_stret +// CHECK: declare i8* @objc_msgSendSuper2 diff --git a/test/CodeGenObjC/synchronized.m b/test/CodeGenObjC/synchronized.m index 1af8234..2a80906 100644 --- a/test/CodeGenObjC/synchronized.m +++ b/test/CodeGenObjC/synchronized.m @@ -1,6 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -triple=i686-apple-darwin9 -o %t %s -O2 -// RUN: grep 'ret i32' %t | count 1 -// RUN: grep 'ret i32 1' %t | count 1 +// RUN: %clang_cc1 -emit-llvm -triple=i686-apple-darwin9 -o - %s -O2 | FileCheck %s @interface MyClass { @@ -10,31 +8,71 @@ @implementation MyClass +// CHECK: define internal void @"\01-[MyClass method]" - (void)method { - @synchronized(self) - { - } + // CHECK: call void @objc_sync_enter + // CHECK: call void @objc_exception_try_enter + // CHECK: call i32 @_setjmp + @synchronized(self) { + } } @end +// CHECK: define void @foo( void foo(id a) { + // CHECK: [[A:%.*]] = alloca i8* + // CHECK: [[SYNC:%.*]] = alloca i8* + + // CHECK: store i8* [[AVAL:%.*]], i8** [[A]] + // CHECK-NEXT: call void @objc_sync_enter(i8* [[AVAL]]) + // CHECK-NEXT: store i8* [[AVAL]], i8** [[SYNC]] + // CHECK-NEXT: call void @objc_exception_try_enter + // CHECK: call i32 @_setjmp @synchronized(a) { + // This is unreachable, but the optimizers can't know that. + // CHECK: call void asm sideeffect "", "=*m,=*m,=*m"(i8** [[A]], i8** [[SYNC]] + // CHECK: call void @objc_sync_exit + // CHECK: call i8* @objc_exception_extract + // CHECK: call void @objc_exception_throw + // CHECK: unreachable + + // CHECK: call void @objc_exception_try_exit + // CHECK: [[T:%.*]] = load i8** [[SYNC]] + // CHECK-NEXT: call void @objc_sync_exit + // CHECK: ret void return; } + } +// CHECK: define i32 @f0( int f0(id a) { + // TODO: we can optimize the ret to a constant if we can figure out + // either that x isn't stored to within the synchronized block or + // that the synchronized block can't longjmp. + + // CHECK: [[X:%.*]] = alloca i32 + // CHECK: store i32 1, i32* [[X]] int x = 0; @synchronized((x++, a)) { } - return x; // ret i32 1 + + // CHECK: [[T:%.*]] = load i32* [[X]] + // CHECK: ret i32 [[T]] + return x; } +// CHECK: define void @f1( void f1(id a) { - // The trick here is that the return shouldn't go through clean up, - // but there isn't a simple way to check this property. + // Check that the return doesn't go through the cleanup. + extern void opaque(void); + opaque(); + + // CHECK: call void @opaque() + // CHECK-NEXT: ret void + @synchronized(({ return; }), a) { return; } diff --git a/test/CodeGenObjC/unwind-fn.m b/test/CodeGenObjC/unwind-fn.m index 48217f0..5bfc7dc 100644 --- a/test/CodeGenObjC/unwind-fn.m +++ b/test/CodeGenObjC/unwind-fn.m @@ -2,7 +2,7 @@ // RUN: %clang_cc1 -fsjlj-exceptions -fobjc-nonfragile-abi -fexceptions -emit-llvm -o - %s | FileCheck --check-prefix=SJLJ_EH %s // DEFAULT_EH: declare void @_Unwind_Resume_or_Rethrow(i8*) -// SJLJ_EH: declare void @_Unwind_SjLj_Resume(i8*) +// SJLJ_EH: declare void @_Unwind_SjLj_Resume_or_Rethrow(i8*) void f1(), f2(); void f0() { diff --git a/test/CodeGenObjC/x86_64-struct-return-gc.m b/test/CodeGenObjC/x86_64-struct-return-gc.m index c62a33f..8022d59 100644 --- a/test/CodeGenObjC/x86_64-struct-return-gc.m +++ b/test/CodeGenObjC/x86_64-struct-return-gc.m @@ -9,7 +9,7 @@ struct Coerce coerce_func(void); void Coerce_test(void) { struct Coerce c; - // CHECK: call i64 @coerce_func + // CHECK: call i8* @coerce_func // CHECK: call i8* @objc_memmove_collectable( c = coerce_func(); } diff --git a/test/CodeGenObjCXX/exceptions.mm b/test/CodeGenObjCXX/exceptions.mm new file mode 100644 index 0000000..00de88c --- /dev/null +++ b/test/CodeGenObjCXX/exceptions.mm @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-nonfragile-abi -fexceptions -o - %s | FileCheck %s + +@interface OCType @end +void opaque(); + +namespace test0 { + + // CHECK: define void @_ZN5test03fooEv + void foo() { + try { + // CHECK: invoke void @_Z6opaquev + opaque(); + } catch (OCType *T) { + // CHECK: call i32 (i8*, i8*, ...)* @llvm.eh.selector({{.*}} @__objc_personality_v0 {{.*}} @"OBJC_EHTYPE_$_OCType" + } + } +} diff --git a/test/CodeGenObjCXX/property-objects.mm b/test/CodeGenObjCXX/property-objects.mm index 662dacc..724cf68 100644 --- a/test/CodeGenObjCXX/property-objects.mm +++ b/test/CodeGenObjCXX/property-objects.mm @@ -25,6 +25,8 @@ struct CGRect { - (void)setFrame:(CGRect)frameRect; - (CGRect)frame; - (void) initWithOwner; +- (struct CGRect)extent; +- (void)dealloc; @end @implementation I @@ -40,6 +42,12 @@ struct CGRect { labelLayerFrame = self.bounds; _labelLayer.frame = labelLayerFrame; } +// rdar://8366604 +- (void)dealloc + { + CGRect cgrect = self.extent; + } +- (struct CGRect)extent {return bounds;} @end int main() { diff --git a/test/CodeGenObjCXX/references.mm b/test/CodeGenObjCXX/references.mm index c2232e2..8875fd6 100644 --- a/test/CodeGenObjCXX/references.mm +++ b/test/CodeGenObjCXX/references.mm @@ -19,7 +19,27 @@ struct A { ~A(); }; // CHECK: define void @_Z1fP1B // CHECK: objc_msgSend to +// CHECK-NOT: call void @_ZN1AD1Ev // CHECK: ret void void f(B* b) { (void)[b getA]; } + +// PR7741 +@protocol P1 @end +@protocol P2 @end +@protocol P3 @end +@interface foo<P1> {} @end +@interface bar : foo <P1, P2> {} @end +typedef bar baz; +void f5(foo&); +void f5b(foo<P1>&); +void f5c(foo<P2>&); +void f5d(foo<P3>&); +void f6(baz* x) { + f5(*x); + f5b(*x); + f5c(*x); + f5d(*x); + (void)((foo&)*x); +} diff --git a/test/CodeGenObjCXX/rtti.mm b/test/CodeGenObjCXX/rtti.mm new file mode 100644 index 0000000..27d24cb --- /dev/null +++ b/test/CodeGenObjCXX/rtti.mm @@ -0,0 +1,52 @@ +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s + +// PR7864. This all follows GCC's lead. + +namespace std { class type_info; } + +// CHECK: @_ZTI1A = weak_odr constant {{.*}}@_ZTVN10__cxxabiv117__class_type_infoE{{.*}}@_ZTS1A +@interface A +@end + +// CHECK: @_ZTI1B = weak_odr constant {{.*}}@_ZTVN10__cxxabiv120__si_class_type_infoE{{.*}}@_ZTS1B{{.*}}@_ZTI1A +@interface B : A +@end + +// CHECK: @_ZTIP1B = weak_odr constant {{.*}}@_ZTVN10__cxxabiv119__pointer_type_infoE{{.*}}@_ZTSP1B{{.*}}), i32 0, {{.*}}@_ZTI1B +// CHECK: @_ZTI11objc_object = weak_odr constant {{.*}}@_ZTVN10__cxxabiv117__class_type_infoE{{.*}}@_ZTS11objc_object +// CHECK: @_ZTIP11objc_object = weak_odr constant {{.*}}@_ZTVN10__cxxabiv119__pointer_type_infoE{{.*}}@_ZTSP11objc_object{{.*}}@_ZTI11objc_object +// CHECK: @_ZTI10objc_class = weak_odr constant {{.*}}@_ZTVN10__cxxabiv117__class_type_infoE{{.*}}@_ZTS10objc_class +// CHECK: @_ZTIP10objc_class = weak_odr constant {{.*}}@_ZTVN10__cxxabiv119__pointer_type_infoE{{.*}}@_ZTSP10objc_class{{.*}}@_ZTI10objc_class + +@protocol P; + +int main() { + // CHECK: store {{.*}} @_ZTIP1B + // CHECK: store {{.*}} @_ZTI1B + const std::type_info &t1 = typeid(B*); + const std::type_info &t2 = typeid(B); + + // CHECK: store {{.*}} @_ZTIP11objc_object + // CHECK: store {{.*}} @_ZTI11objc_object + id i = 0; + const std::type_info &t3 = typeid(i); + const std::type_info &t4 = typeid(*i); + + // CHECK: store {{.*}} @_ZTIP10objc_class + // CHECK: store {{.*}} @_ZTI10objc_class + Class c = 0; + const std::type_info &t5 = typeid(c); + const std::type_info &t6 = typeid(*c); + + // CHECK: store {{.*}} @_ZTIP11objc_object + // CHECK: store {{.*}} @_ZTI11objc_object + id<P> i2 = 0; + const std::type_info &t7 = typeid(i2); + const std::type_info &t8 = typeid(*i2); + + // CHECK: store {{.*}} @_ZTIP10objc_class + // CHECK: store {{.*}} @_ZTI10objc_class + Class<P> c2 = 0; + const std::type_info &t9 = typeid(c2); + const std::type_info &t10 = typeid(*c2); +} diff --git a/test/Coverage/parse-callbacks.c b/test/Coverage/parse-callbacks.c deleted file mode 100644 index 02f3a83..0000000 --- a/test/Coverage/parse-callbacks.c +++ /dev/null @@ -1,4 +0,0 @@ -// RUN: %clang_cc1 -parse-noop %s -// RUN: %clang_cc1 -parse-print-callbacks %s - -#include "c-language-features.inc" diff --git a/test/Coverage/parse-callbacks.m b/test/Coverage/parse-callbacks.m deleted file mode 100644 index f023d3d..0000000 --- a/test/Coverage/parse-callbacks.m +++ /dev/null @@ -1,4 +0,0 @@ -// RUN: %clang_cc1 -parse-noop %s -// RUN: %clang_cc1 -parse-print-callbacks %s - -#include "objc-language-features.inc" diff --git a/test/Driver/at_file.c b/test/Driver/at_file.c new file mode 100644 index 0000000..4ad2a5f --- /dev/null +++ b/test/Driver/at_file.c @@ -0,0 +1,30 @@ +// RUN: %clang -E %s @%s.args -o %t.log +// RUN: FileCheck --input-file=%t.log %s + +// CHECK: bar1 +// CHECK-NEXT: bar2 zed2 +// CHECK-NEXT: bar3 zed3 +// CHECK-NEXT: bar4 zed4 +// CHECK-NEXT: bar5 zed5 +// CHECK-NEXT: 'bar6 zed6' +// CHECK-NEXT: "bar7 zed7" +// CHECK-NEXT: foo8bar8zed8 +// CHECK-NEXT: foo9'bar9'zed9 +// CHECK-NEXT: foo10"bar10"zed10 +// CHECK: bar +// CHECK: zed12 + +foo1 +foo2 +foo3 +foo4 +foo5 +foo6 +foo7 +foo8 +foo9 +foo10 +#ifdef foo11 +bar +#endif +foo12 diff --git a/test/Driver/at_file.c.args b/test/Driver/at_file.c.args new file mode 100644 index 0000000..9a2b4ee --- /dev/null +++ b/test/Driver/at_file.c.args @@ -0,0 +1,11 @@ +-Dfoo1=bar1 -Dfoo2="bar2 zed2" +-Dfoo3='bar3 zed3' +"-Dfoo4=bar4 zed4" +'-Dfoo5=bar5 zed5' +-Dfoo6="'bar6 zed6'" +-Dfoo7='"bar7 zed7"' +-Dfoo8=foo8"bar8"zed8 +-Dfoo9=foo9\'bar9\'zed9 +-Dfoo10=foo10\"bar10\"zed10 +-D foo11 +-Dfoo12=zed12\ diff --git a/test/Driver/bindings.c b/test/Driver/bindings.c index e7ec0c5..b825420 100644 --- a/test/Driver/bindings.c +++ b/test/Driver/bindings.c @@ -15,12 +15,6 @@ // RUN: grep '"gcc::Assemble", inputs: \[".*\.s"\], output: ".*\.o"' %t // RUN: grep '"gcc::Link", inputs: \[".*\.o"\], output: "a.out"' %t -// RUN: %clang -ccc-host-triple i386-unknown-unknown -ccc-print-bindings -ccc-no-clang -no-integrated-cpp -pipe %s 2> %t -// RUN: grep '"gcc::Preprocess", inputs: \[".*bindings.c"\], output: (pipe)' %t -// RUN: grep '"gcc::Compile", inputs: \[(pipe)\], output: (pipe)' %t -// RUN: grep '"gcc::Assemble", inputs: \[(pipe)\], output: ".*\.o"' %t -// RUN: grep '"gcc::Link", inputs: \[".*\.o"\], output: "a.out"' %t - // RUN: %clang -ccc-host-triple i386-unknown-unknown -ccc-print-bindings -ccc-no-clang -x c-header %s 2> %t // RUN: grep '"gcc::Precompile", inputs: \[".*bindings.c"\], output: ".*bindings.c.gch' %t diff --git a/test/Driver/cxx-pth.cpp b/test/Driver/cxx-pth.cpp deleted file mode 100644 index 97afb5e..0000000 --- a/test/Driver/cxx-pth.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// Test forced PTH for CXX support. - -// RUN: %clangxx -x c++-header %s -### 2> %t.log -// RUN: FileCheck -check-prefix EMIT -input-file %t.log %s - -// EMIT: "{{.*}}/clang{{.*}}" {{.*}} "-emit-pth" "{{.*}}.cpp.gch" "-x" "c++-header" "{{.*}}.cpp" - -// RUN: touch %t.h.gch -// RUN: %clangxx -E -include %t.h %s -### 2> %t.log -// RUN: FileCheck -check-prefix USE -input-file %t.log %s - -// USE: "{{.*}}/clang{{.*}}" {{.*}}"-include-pth" "{{.*}}.h.gch" {{.*}}"-x" "c++" "{{.*}}.cpp" diff --git a/test/Driver/darwin-as.c b/test/Driver/darwin-as.c index 6410df0..7d4cdbf 100644 --- a/test/Driver/darwin-as.c +++ b/test/Driver/darwin-as.c @@ -1,10 +1,16 @@ // RUN: %clang -ccc-host-triple i386-apple-darwin10 -### -x assembler -c %s -static -dynamic 2>%t // RUN: FileCheck -check-prefix=STATIC_AND_DYNAMIC-32 --input-file %t %s - +// // CHECK-STATIC_AND_DYNAMIC-32: as{{(.exe)?}}" "-arch" "i386" "-force_cpusubtype_ALL" "-static" "-o" // RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### -x assembler -c %s -static 2>%t // RUN: FileCheck -check-prefix=STATIC-64 --input-file %t %s - +// // CHECK-STATIC-64: as{{(.exe)?}}" "-arch" "x86_64" "-force_cpusubtype_ALL" "-o" +// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### \ +// RUN: -arch armv6 -x assembler -c %s 2>%t +// RUN: FileCheck -check-prefix=ARMV6 --input-file %t %s +// +// CHECK-ARMV6: as{{(.exe)?}}" "-arch" "armv6" "-o" + diff --git a/test/Driver/darwin-cc.c b/test/Driver/darwin-cc.c index 3cb9df6..b068bb4 100644 --- a/test/Driver/darwin-cc.c +++ b/test/Driver/darwin-cc.c @@ -1,5 +1,5 @@ // RUN: %clang -ccc-no-clang -ccc-host-triple i386-apple-darwin10 -m32 -### -MD -g -fast -Q -dA -mkernel -ansi -aFOO -S -o /tmp/OUTPUTNAME -g0 -gfull -O2 -Werror -pedantic -Wmost -w -std=c99 -trigraphs -v -pg -fFOO -undef -Qn --param a=b -fmudflap -coverage -save-temps -nostdinc -I ARG0 -F ARG1 -I ARG2 -P -MF ARG3 -MG -MP -remap -g3 -H -D ARG4 -U ARG5 -A ARG6 -D ARG7 -U ARG8 -A ARG9 -include ARG10 -pthread %s 2> %t.log -// RUN: grep ' ".*cc1" "-E" "-nostdinc" "-v" "-I" "ARG0" "-FARG1" "-I" "ARG2" "-P" "-MD" "/tmp/OUTPUTNAME.d" "-MF" "ARG3" "-MG" "-MP" "-MQ" "/tmp/OUTPUTNAME" "-remap" "-dD" "-H" "-D__STATIC__" "-D_REENTRANT" "-D" "ARG4" "-U" "ARG5" "-A" "ARG6" "-D" "ARG7" "-U" "ARG8" "-A" "ARG9" "-include" "ARG10" ".*darwin-cc.c" "-D_MUDFLAP" "-include" "mf-runtime.h" "-mmacosx-version-min=10.6.0" "-m32" "-mkernel" "-mtune=core2" "-ansi" "-std=c99" "-trigraphs" "-Werror" "-pedantic" "-Wmost" "-w" "-fast" "-fno-eliminate-unused-debug-symbols" "-fFOO" "-fmudflap" "-O2" "-undef" "-fpch-preprocess" "-o" ".*darwin-cc.i"' %t.log -// RUN: grep ' ".*cc1" "-fpreprocessed" ".*darwin-cc.i" "-O3" "-dumpbase" ".*darwin-cc.c" "-dA" "-mmacosx-version-min=10.6.0" "-m32" "-mkernel" "-mtune=core2" "-ansi" "-aFOO" "-auxbase-strip" "/tmp/OUTPUTNAME" "-g" "-g0" "-g" "-g3" "-O2" "-Werror" "-pedantic" "-Wmost" "-w" "-ansi" "-std=c99" "-trigraphs" "-version" "-p" "-fast" "-fno-eliminate-unused-debug-symbols" "-fFOO" "-fmudflap" "-undef" "-fno-ident" "-o" "/tmp/OUTPUTNAME" "--param" "a=b" "-fno-builtin" "-fno-merge-constants" "-fprofile-arcs" "-ftest-coverage"' %t.log +// RUN: grep ' ".*cc1" "-E" "-nostdinc" "-v" "-I" "ARG0" "-FARG1" "-I" "ARG2" "-P" "-MD" "/tmp/OUTPUTNAME.d" "-MF" "ARG3" "-MG" "-MP" "-MQ" "/tmp/OUTPUTNAME" "-remap" "-dD" "-H" "-D__STATIC__" "-D_REENTRANT" "-D" "ARG4" "-U" "ARG5" "-A" "ARG6" "-D" "ARG7" "-U" "ARG8" "-A" "ARG9" "-include" "ARG10" ".*darwin-cc.c" "-D_MUDFLAP" "-include" "mf-runtime.h" "-m32" "-mkernel" "-mtune=core2" "-mmacosx-version-min=10.6.0" "-ansi" "-std=c99" "-trigraphs" "-Werror" "-pedantic" "-Wmost" "-w" "-fast" "-fno-eliminate-unused-debug-symbols" "-fFOO" "-fmudflap" "-O2" "-undef" "-fpch-preprocess" "-o" ".*darwin-cc.i"' %t.log +// RUN: grep ' ".*cc1" "-fpreprocessed" ".*darwin-cc.i" "-O3" "-dumpbase" ".*darwin-cc.c" "-dA" "-m32" "-mkernel" "-mtune=core2" "-mmacosx-version-min=10.6.0" "-ansi" "-aFOO" "-auxbase-strip" "/tmp/OUTPUTNAME" "-g" "-g0" "-g" "-g3" "-O2" "-Werror" "-pedantic" "-Wmost" "-w" "-ansi" "-std=c99" "-trigraphs" "-version" "-p" "-fast" "-fno-eliminate-unused-debug-symbols" "-fFOO" "-fmudflap" "-undef" "-fno-ident" "-o" "/tmp/OUTPUTNAME" "--param" "a=b" "-fno-builtin" "-fno-merge-constants" "-fprofile-arcs" "-ftest-coverage"' %t.log diff --git a/test/Driver/darwin-debug-flags.c b/test/Driver/darwin-debug-flags.c index 6f24527..3394e4e 100644 --- a/test/Driver/darwin-debug-flags.c +++ b/test/Driver/darwin-debug-flags.c @@ -2,8 +2,8 @@ // <rdar://problem/7256886> // CHECK: !1 = metadata !{ -// CHECK: -mmacosx-version-min=10.5.0 // CHECK: -g -Os +// CHECK: -mmacosx-version-min=10.5.0 // CHECK: [ DW_TAG_compile_unit ] int x; diff --git a/test/Driver/darwin-ld.c b/test/Driver/darwin-ld.c index 4484468..074957d 100644 --- a/test/Driver/darwin-ld.c +++ b/test/Driver/darwin-ld.c @@ -3,20 +3,6 @@ // RUN: %clang -ccc-host-triple i386-apple-darwin9 -arch i386 -arch x86_64 %s -### -o foo 2> %t.log // RUN: grep '".*ld.*" .*"-arch_multiple" "-final_output" "foo"' %t.log -// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -filelist FOO -static 2> %t.log -// RUN: grep '"-lcrt0.o" .*"-lgcc_static"' %t.log -// RUN: grep '"-lgcc"' %t.log | count 0 -// RUN: %clang -ccc-host-triple i386-apple-darwin7 -### -filelist FOO 2> %t.log -// RUN: grep '"-lcrt1.o" .*"-lgcc" "-lSystem"' %t.log -// RUN: grep '"-lgcc_s"' %t.log | count 0 -// RUN: %clang -ccc-host-triple i386-apple-darwin8 -### -filelist FOO 2> %t.log -// RUN: grep '"-lcrt1.o" .*"-lgcc_s.10.4" "-lgcc" "-lSystem"' %t.log -// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -filelist FOO 2> %t.log -// RUN: grep '"-lcrt1.10.5.o" .*"-lgcc_s.10.5" "-lgcc" "-lSystem"' %t.log -// RUN: %clang -ccc-host-triple i386-apple-darwin10 -### -filelist FOO 2> %t.log -// RUN: grep '"-lcrt1.10.6.o" .*"-lSystem" "-lgcc"' %t.log -// RUN: grep '"-lgcc_s"' %t.log | count 0 - // Make sure we run dsymutil on source input files. // RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -g %s -o BAR 2> %t.log // RUN: grep '".*dsymutil" "BAR"' %t.log @@ -82,3 +68,26 @@ // // LINK_EXPLICIT_NO_PIE: ld" // LINK_EXPLICIT_NO_PIE: "-no_pie" + +// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### %t.o \ +// RUN: -mlinker-version=100 2> %t.log +// RUN: FileCheck -check-prefix=LINK_NEWER_DEMANGLE %s < %t.log +// +// LINK_NEWER_DEMANGLE: ld" +// LINK_NEWER_DEMANGLE: "-demangle" + +// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### %t.o \ +// RUN: -mlinker-version=100 -Wl,--no-demangle 2> %t.log +// RUN: FileCheck -check-prefix=LINK_NEWER_NODEMANGLE %s < %t.log +// +// LINK_NEWER_NODEMANGLE: ld" +// LINK_NEWER_NODEMANGLE-NOT: "-demangle" +// LINK_NEWER_NODEMANGLE: "-lSystem" + +// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### %t.o \ +// RUN: -mlinker-version=95 2> %t.log +// RUN: FileCheck -check-prefix=LINK_OLDER_NODEMANGLE %s < %t.log +// +// LINK_OLDER_NODEMANGLE: ld" +// LINK_OLDER_NODEMANGLE-NOT: "-demangle" +// LINK_OLDER_NODEMANGLE: "-lSystem" diff --git a/test/Driver/darwin-xarch.c b/test/Driver/darwin-xarch.c new file mode 100644 index 0000000..cd7fa84 --- /dev/null +++ b/test/Driver/darwin-xarch.c @@ -0,0 +1,8 @@ +// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### \ +// RUN: -arch i386 -Xarch_i386 -mmacosx-version-min=10.4 \ +// RUN: -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 \ +// RUN: -c %s 2> %t +// RUN: FileCheck < %t %s +// +// CHECK: clang{{.*}}" "-cc1" "-triple" "i386-apple-darwin8.0.0" +// CHECK: clang{{.*}}" "-cc1" "-triple" "x86_64-apple-darwin9.0.0" diff --git a/test/Driver/freebsd.c b/test/Driver/freebsd.c index 3deee46..e8bc223 100644 --- a/test/Driver/freebsd.c +++ b/test/Driver/freebsd.c @@ -1,7 +1,21 @@ -// RUN: %clang -ccc-clang-archs "" -ccc-host-triple powerpc64-pc-freebsd8 %s -### 2> %t.log -// RUN: cat %t.log -// RUN: FileCheck -input-file %t.log %s +// RUN: %clang -ccc-clang-archs "" -ccc-host-triple powerpc64-pc-freebsd8 %s -### 2> %t +// RUN: FileCheck --check-prefix=CHECK-PPC < %t %s +// +// CHECK-PPC: clang{{.*}}" "-cc1" "-triple" "powerpc64-pc-freebsd8" +// CHECK-PPC: as{{.*}}" "-o" "{{.*}}.o" "{{.*}}.s +// CHECK-PPC: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o" -// CHECK: clang{{.*}}" "-cc1" "-triple" "powerpc64-pc-freebsd8" -// CHECK: as{{.*}}" "-o" "{{.*}}.o" "{{.*}}.s -// CHECK: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o" + +// Check that -m32 properly adjusts the toolchain flags. +// +// RUN: %clang -ccc-host-triple x86_64-pc-freebsd8 -m32 -### %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-LIB32 < %t %s +// +// CHECK-LIB32: clang{{.*}}" "-cc1" "-triple" "i386-pc-freebsd8" +// CHECK-LIB32: as{{.*}}" "--32" +// CHECK-LIB32: ld{{.*}}" {{.*}} "-m" "elf_i386_fbsd" +// +// RUN: %clang -ccc-host-triple x86_64-pc-freebsd8 -m32 -print-search-dirs %s > %t +// RUN: FileCheck --check-prefix=CHECK-LIB32PATHS < %t %s +// +// CHECK-LIB32PATHS: libraries: ={{.*}}:/usr/lib32 diff --git a/test/Driver/gcc_forward.c b/test/Driver/gcc_forward.c new file mode 100644 index 0000000..c584a4e --- /dev/null +++ b/test/Driver/gcc_forward.c @@ -0,0 +1,13 @@ +// Check that we don't try to forward -Xclang or -mlinker-version to GCC. +// +// RUN: %clang -ccc-host-triple powerpc-unknown-unknown \ +// RUN: -ccc-clang-archs i386 -c %s \ +// RUN: -Xclang foo-bar \ +// RUN: -mlinker-version=10 -### 2> %t +// RUN: FileCheck < %t %s +// +// CHECK: gcc{{.*}}" +// CHECK-NOT: "-mlinker-version=10" +// CHECK-NOT: "-Xclang" +// CHECK-NOT: "foo-bar" +// CHECK: gcc_forward diff --git a/test/Driver/rewrite-objc.m b/test/Driver/rewrite-objc.m index 38993fc..ac77d79 100644 --- a/test/Driver/rewrite-objc.m +++ b/test/Driver/rewrite-objc.m @@ -1,6 +1,10 @@ // RUN: %clang -ccc-host-triple unknown -rewrite-objc %s -o - -### 2>&1 | \ // RUN: FileCheck -check-prefix=TEST0 %s -// TEST0: clang{{.*}}" "-rewrite-objc" +// TEST0: clang{{.*}}" "-cc1" +// TEST0: "-rewrite-objc" +// FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead. +// TEST0: "-fmessage-length" "0" "-fdiagnostics-show-option" +// TEST0: rewrite-objc.m" // RUN: not %clang -ccc-no-clang -ccc-host-triple unknown -rewrite-objc %s -o - -### 2>&1 | \ // RUN: FileCheck -check-prefix=TEST1 %s diff --git a/test/FixIt/fixit.c b/test/FixIt/fixit.c index b799fa3..890fb10 100644 --- a/test/FixIt/fixit.c +++ b/test/FixIt/fixit.c @@ -38,3 +38,6 @@ int test_cond(int y, int fooBar) { int x = y ? 1 4+foobar; return x; } + +// CHECK: typedef int int_t; +typedef typedef int int_t; diff --git a/test/Frontend/Inputs/lit.local.cfg b/test/Frontend/Inputs/lit.local.cfg new file mode 100644 index 0000000..e6f55ee --- /dev/null +++ b/test/Frontend/Inputs/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = [] diff --git a/test/Frontend/Inputs/test.h b/test/Frontend/Inputs/test.h new file mode 100644 index 0000000..98cc459 --- /dev/null +++ b/test/Frontend/Inputs/test.h @@ -0,0 +1 @@ +#include "test2.h" diff --git a/test/Frontend/Inputs/test2.h b/test/Frontend/Inputs/test2.h new file mode 100644 index 0000000..6d1a0d4 --- /dev/null +++ b/test/Frontend/Inputs/test2.h @@ -0,0 +1 @@ +int x; diff --git a/test/Frontend/Inputs/test3.h b/test/Frontend/Inputs/test3.h new file mode 100644 index 0000000..92ff4b8 --- /dev/null +++ b/test/Frontend/Inputs/test3.h @@ -0,0 +1 @@ +int y; diff --git a/test/Frontend/print-header-includes.c b/test/Frontend/print-header-includes.c new file mode 100644 index 0000000..7773d20 --- /dev/null +++ b/test/Frontend/print-header-includes.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -include Inputs/test3.h -E -H -o %t.out %s 2> %t.err +// RUN: FileCheck < %t.err %s + +// CHECK-NOT: test3.h +// CHECK: . {{.*test.h}} +// CHECK: .. {{.*test2.h}} + +#include "Inputs/test.h" diff --git a/test/Headers/x86-intrinsics-headers.c b/test/Headers/x86-intrinsics-headers.c index 08abcef..ba833ec 100644 --- a/test/Headers/x86-intrinsics-headers.c +++ b/test/Headers/x86-intrinsics-headers.c @@ -4,29 +4,16 @@ #if defined(i386) || defined(__x86_64__) -# if defined(__MMX__) -#include <emmintrin.h> +#ifdef __MMX__ #include <mm_malloc.h> -# endif - -# if defined(__SSE__) -#include <xmmintrin.h> -# endif - -# if defined(__SSE3__) -#include <pmmintrin.h> -# endif - -# if defined(__SSSE3__) -#include <tmmintrin.h> -# endif - -# if defined(__SSE4_1__) -#include <smmintrin.h> -# endif +#endif -# if defined(__SSE4_2__) +#ifdef __SSE4_2__ +// nmmintrin forwards to smmintrin. #include <nmmintrin.h> -# endif +#endif + +// immintrin includes all other intel intrinsic headers. +#include <immintrin.h> #endif diff --git a/test/Index/Inputs/crash-recovery-code-complete-remap.c b/test/Index/Inputs/crash-recovery-code-complete-remap.c new file mode 100644 index 0000000..50a8658 --- /dev/null +++ b/test/Index/Inputs/crash-recovery-code-complete-remap.c @@ -0,0 +1,12 @@ +// RUN: echo env CINDEXTEST_EDITING=1 \ +// RUN: not c-index-test -test-load-source-reparse 1 local \ +// RUN: -remap-file="%s;%S/Inputs/crash-recovery-code-complete-remap.c" \ +// RUN: %s 2> %t.err +// RUN: FileCheck < %t.err -check-prefix=CHECK-CODE-COMPLETE-CRASH %s +// CHECK-CODE-COMPLETE-CRASH: Unable to reparse translation unit +// +// XFAIL: win32 + +#warning parsing original file + +#pragma clang __debug crash diff --git a/test/Index/Inputs/crash-recovery-reparse-remap.c b/test/Index/Inputs/crash-recovery-reparse-remap.c new file mode 100644 index 0000000..0357dbe --- /dev/null +++ b/test/Index/Inputs/crash-recovery-reparse-remap.c @@ -0,0 +1,11 @@ + +#warning parsing remapped file + + + +int x; + +#pragma clang __debug crash + +int x; + diff --git a/test/Index/Inputs/preamble-reparse-1.c b/test/Index/Inputs/preamble-reparse-1.c new file mode 100644 index 0000000..139597f --- /dev/null +++ b/test/Index/Inputs/preamble-reparse-1.c @@ -0,0 +1,2 @@ + + diff --git a/test/Index/Inputs/preamble-reparse-2.c b/test/Index/Inputs/preamble-reparse-2.c new file mode 100644 index 0000000..6d1a0d4 --- /dev/null +++ b/test/Index/Inputs/preamble-reparse-2.c @@ -0,0 +1 @@ +int x; diff --git a/test/Index/Inputs/preamble.h b/test/Index/Inputs/preamble.h new file mode 100644 index 0000000..b59c234 --- /dev/null +++ b/test/Index/Inputs/preamble.h @@ -0,0 +1,6 @@ +inline int bar(int i) { + int *ptr = 0; + float *ptr1; + ptr = ptr1; + return 0; +} diff --git a/test/Index/Inputs/prefix.h b/test/Index/Inputs/prefix.h new file mode 100644 index 0000000..82ba2da3 --- /dev/null +++ b/test/Index/Inputs/prefix.h @@ -0,0 +1,4 @@ +#ifndef PREFIX_H +#define PREFIX_H +int foo(int); +#endif diff --git a/test/Index/TestClassDecl.m b/test/Index/TestClassDecl.m index b55c862..09a7d48 100644 --- a/test/Index/TestClassDecl.m +++ b/test/Index/TestClassDecl.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fblocks -emit-pch -x objective-c %s -o %t.ast +// RUN: c-index-test -write-pch %t.ast -fobjc-nonfragile-abi -fblocks -x objective-c %s // RUN: c-index-test -test-file-scan %t.ast %s | FileCheck -check-prefix=scan %s // RUN: c-index-test -test-load-tu %t.ast local | FileCheck -check-prefix=load %s diff --git a/test/Index/annotate-tokens-pp.c b/test/Index/annotate-tokens-pp.c index 485786e..55ee763 100644 --- a/test/Index/annotate-tokens-pp.c +++ b/test/Index/annotate-tokens-pp.c @@ -7,7 +7,25 @@ int BAR STILL_NOTHING; #include "foo.h" #undef BAR -// RUN: c-index-test -test-annotate-tokens=%s:2:1:9:1 -I%S/Inputs %s | FileCheck %s +#define REVERSE_MACRO(x,y) y + x +#define TWICE_MACRO(y) y + y + +void test_macro_args() { + int z = 1; + int t = 2; + int k = REVERSE_MACRO(t,z); + int j = TWICE_MACRO(k + k); + int w = j + j; +} + +#define fun_with_macro_bodies(x, y) do { if (x) y } while (0) + +void test() { + int x = 10; + fun_with_macro_bodies(x, { int z = x; ++z; }); +} + +// RUN: c-index-test -test-annotate-tokens=%s:2:1:26:1 -I%S/Inputs %s | FileCheck %s // CHECK: Punctuation: "#" [2:1 - 2:2] preprocessing directive= // CHECK: Identifier: "define" [2:2 - 2:8] preprocessing directive= // CHECK: Identifier: "STILL_NOTHING" [2:9 - 2:22] macro definition=STILL_NOTHING @@ -56,3 +74,114 @@ int BAR STILL_NOTHING; // CHECK: Punctuation: "#" [8:1 - 8:2] preprocessing directive= // CHECK: Identifier: "undef" [8:2 - 8:7] preprocessing directive= // CHECK: Identifier: "BAR" [8:8 - 8:11] preprocessing directive= +// CHECK: Punctuation: "#" [10:1 - 10:2] preprocessing directive= +// CHECK: Identifier: "define" [10:2 - 10:8] preprocessing directive= +// CHECK: Identifier: "REVERSE_MACRO" [10:9 - 10:22] macro definition=REVERSE_MACRO +// CHECK: Punctuation: "(" [10:22 - 10:23] preprocessing directive= +// CHECK: Identifier: "x" [10:23 - 10:24] preprocessing directive= +// CHECK: Punctuation: "," [10:24 - 10:25] preprocessing directive= +// CHECK: Identifier: "y" [10:25 - 10:26] preprocessing directive= +// CHECK: Punctuation: ")" [10:26 - 10:27] preprocessing directive= +// CHECK: Identifier: "y" [10:28 - 10:29] preprocessing directive= +// CHECK: Punctuation: "+" [10:30 - 10:31] preprocessing directive= +// CHECK: Identifier: "x" [10:32 - 10:33] preprocessing directive= +// CHECK: Punctuation: "#" [11:1 - 11:2] preprocessing directive= +// CHECK: Identifier: "define" [11:2 - 11:8] preprocessing directive= +// CHECK: Identifier: "TWICE_MACRO" [11:9 - 11:20] macro definition=TWICE_MACRO +// CHECK: Punctuation: "(" [11:20 - 11:21] preprocessing directive= +// CHECK: Identifier: "y" [11:21 - 11:22] preprocessing directive= +// CHECK: Punctuation: ")" [11:22 - 11:23] preprocessing directive= +// CHECK: Identifier: "y" [11:24 - 11:25] preprocessing directive= +// CHECK: Punctuation: "+" [11:26 - 11:27] preprocessing directive= +// CHECK: Identifier: "y" [11:28 - 11:29] preprocessing directive= +// CHECK: Keyword: "void" [13:1 - 13:5] FunctionDecl=test_macro_args:13:6 (Definition) +// CHECK: Identifier: "test_macro_args" [13:6 - 13:21] FunctionDecl=test_macro_args:13:6 (Definition) +// CHECK: Punctuation: "(" [13:21 - 13:22] FunctionDecl=test_macro_args:13:6 (Definition) +// CHECK: Punctuation: ")" [13:22 - 13:23] FunctionDecl=test_macro_args:13:6 (Definition) +// CHECK: Punctuation: "{" [13:24 - 13:25] UnexposedStmt= +// CHECK: Keyword: "int" [14:3 - 14:6] VarDecl=z:14:7 (Definition) +// CHECK: Identifier: "z" [14:7 - 14:8] VarDecl=z:14:7 (Definition) +// CHECK: Punctuation: "=" [14:9 - 14:10] VarDecl=z:14:7 (Definition) +// CHECK: Literal: "1" [14:11 - 14:12] UnexposedExpr= +// CHECK: Punctuation: ";" [14:12 - 14:13] UnexposedStmt= +// CHECK: Keyword: "int" [15:3 - 15:6] VarDecl=t:15:7 (Definition) +// CHECK: Identifier: "t" [15:7 - 15:8] VarDecl=t:15:7 (Definition) +// CHECK: Punctuation: "=" [15:9 - 15:10] VarDecl=t:15:7 (Definition) +// CHECK: Literal: "2" [15:11 - 15:12] UnexposedExpr= +// CHECK: Punctuation: ";" [15:12 - 15:13] UnexposedStmt= +// CHECK: Keyword: "int" [16:3 - 16:6] VarDecl=k:16:7 (Definition) +// CHECK: Identifier: "k" [16:7 - 16:8] VarDecl=k:16:7 (Definition) +// CHECK: Punctuation: "=" [16:9 - 16:10] VarDecl=k:16:7 (Definition) +// CHECK: Identifier: "REVERSE_MACRO" [16:11 - 16:24] macro instantiation=REVERSE_MACRO:10:9 +// CHECK: Punctuation: "(" [16:24 - 16:25] UnexposedStmt= +// CHECK: Identifier: "t" [16:25 - 16:26] DeclRefExpr=t:15:7 +// CHECK: Punctuation: "," [16:26 - 16:27] UnexposedStmt= +// CHECK: Identifier: "z" [16:27 - 16:28] DeclRefExpr=z:14:7 +// CHECK: Punctuation: ")" [16:28 - 16:29] UnexposedStmt= +// CHECK: Punctuation: ";" [16:29 - 16:30] UnexposedStmt= +// CHECK: Keyword: "int" [17:3 - 17:6] VarDecl=j:17:7 (Definition) +// CHECK: Identifier: "j" [17:7 - 17:8] VarDecl=j:17:7 (Definition) +// CHECK: Punctuation: "=" [17:9 - 17:10] VarDecl=j:17:7 (Definition) +// CHECK: Identifier: "TWICE_MACRO" [17:11 - 17:22] macro instantiation=TWICE_MACRO:11:9 +// CHECK: Punctuation: "(" [17:22 - 17:23] UnexposedStmt= +// CHECK: Identifier: "k" [17:23 - 17:24] DeclRefExpr=k:16:7 +// CHECK: Punctuation: "+" [17:25 - 17:26] UnexposedStmt= +// CHECK: Identifier: "k" [17:27 - 17:28] DeclRefExpr=k:16:7 +// CHECK: Punctuation: ")" [17:28 - 17:29] UnexposedStmt= +// CHECK: Punctuation: ";" [17:29 - 17:30] UnexposedStmt= +// CHECK: Keyword: "int" [18:3 - 18:6] VarDecl=w:18:7 (Definition) +// CHECK: Identifier: "w" [18:7 - 18:8] VarDecl=w:18:7 (Definition) +// CHECK: Punctuation: "=" [18:9 - 18:10] VarDecl=w:18:7 (Definition) +// CHECK: Identifier: "j" [18:11 - 18:12] DeclRefExpr=j:17:7 +// CHECK: Punctuation: "+" [18:13 - 18:14] UnexposedExpr= +// CHECK: Identifier: "j" [18:15 - 18:16] DeclRefExpr=j:17:7 +// CHECK: Punctuation: ";" [18:16 - 18:17] UnexposedStmt= +// CHECK: Punctuation: "}" [19:1 - 19:2] UnexposedStmt= +// CHECK: Punctuation: "#" [21:1 - 21:2] preprocessing directive= +// CHECK: Identifier: "define" [21:2 - 21:8] preprocessing directive= +// CHECK: Identifier: "fun_with_macro_bodies" [21:9 - 21:30] macro definition=fun_with_macro_bodies +// CHECK: Punctuation: "(" [21:30 - 21:31] preprocessing directive= +// CHECK: Identifier: "x" [21:31 - 21:32] preprocessing directive= +// CHECK: Punctuation: "," [21:32 - 21:33] preprocessing directive= +// CHECK: Identifier: "y" [21:34 - 21:35] preprocessing directive= +// CHECK: Punctuation: ")" [21:35 - 21:36] preprocessing directive= +// CHECK: Keyword: "do" [21:37 - 21:39] preprocessing directive= +// CHECK: Punctuation: "{" [21:40 - 21:41] preprocessing directive= +// CHECK: Keyword: "if" [21:42 - 21:44] preprocessing directive= +// CHECK: Punctuation: "(" [21:45 - 21:46] preprocessing directive= +// CHECK: Identifier: "x" [21:46 - 21:47] preprocessing directive= +// CHECK: Punctuation: ")" [21:47 - 21:48] preprocessing directive= +// CHECK: Identifier: "y" [21:49 - 21:50] preprocessing directive= +// CHECK: Punctuation: "}" [21:51 - 21:52] preprocessing directive= +// CHECK: Keyword: "while" [21:53 - 21:58] preprocessing directive= +// CHECK: Punctuation: "(" [21:59 - 21:60] preprocessing directive= +// CHECK: Literal: "0" [21:60 - 21:61] preprocessing directive= +// CHECK: Punctuation: ")" [21:61 - 21:62] preprocessing directive= +// CHECK: Keyword: "void" [23:1 - 23:5] FunctionDecl=test:23:6 (Definition) +// CHECK: Identifier: "test" [23:6 - 23:10] FunctionDecl=test:23:6 (Definition) +// CHECK: Punctuation: "(" [23:10 - 23:11] FunctionDecl=test:23:6 (Definition) +// CHECK: Punctuation: ")" [23:11 - 23:12] FunctionDecl=test:23:6 (Definition) +// CHECK: Punctuation: "{" [23:13 - 23:14] UnexposedStmt= +// CHECK: Keyword: "int" [24:3 - 24:6] VarDecl=x:24:7 (Definition) +// CHECK: Identifier: "x" [24:7 - 24:8] VarDecl=x:24:7 (Definition) +// CHECK: Punctuation: "=" [24:9 - 24:10] VarDecl=x:24:7 (Definition) +// CHECK: Literal: "10" [24:11 - 24:13] UnexposedExpr= +// CHECK: Punctuation: ";" [24:13 - 24:14] UnexposedStmt= +// CHECK: Identifier: "fun_with_macro_bodies" [25:3 - 25:24] macro instantiation=fun_with_macro_bodies:21:9 +// CHECK: Punctuation: "(" [25:24 - 25:25] UnexposedStmt= +// CHECK: Identifier: "x" [25:25 - 25:26] DeclRefExpr=x:24:7 +// CHECK: Punctuation: "," [25:26 - 25:27] UnexposedStmt= +// CHECK: Punctuation: "{" [25:28 - 25:29] UnexposedStmt= +// CHECK: Keyword: "int" [25:30 - 25:33] UnexposedStmt= +// CHECK: Identifier: "z" [25:34 - 25:35] VarDecl=z:25:3 (Definition) +// CHECK: Punctuation: "=" [25:36 - 25:37] UnexposedStmt= +// CHECK: Identifier: "x" [25:38 - 25:39] DeclRefExpr=x:24:7 +// CHECK: Punctuation: ";" [25:39 - 25:40] UnexposedStmt= +// CHECK: Punctuation: "++" [25:41 - 25:43] UnexposedExpr= +// CHECK: Identifier: "z" [25:43 - 25:44] DeclRefExpr=z:25:3 +// CHECK: Punctuation: ";" [25:44 - 25:45] UnexposedStmt= +// CHECK: Punctuation: "}" [25:46 - 25:47] UnexposedStmt= +// CHECK: Punctuation: ")" [25:47 - 25:48] UnexposedStmt= +// CHECK: Punctuation: ";" [25:48 - 25:49] UnexposedStmt= +// CHECK: Punctuation: "}" [26:1 - 26:2] UnexposedStmt= + diff --git a/test/Index/annotate-tokens.c b/test/Index/annotate-tokens.c index 41f182d..e251596 100644 --- a/test/Index/annotate-tokens.c +++ b/test/Index/annotate-tokens.c @@ -9,7 +9,14 @@ void f(void *ptr) { const char * hello = "Hello"; } -// RUN: c-index-test -test-annotate-tokens=%s:4:1:9:32 %s | FileCheck %s +typedef int Int; +void g(int i, ...) { + __builtin_va_list va; + (void)__builtin_va_arg(va, Int); + (void)__builtin_types_compatible_p(Int, Int); +} + +// RUN: c-index-test -test-annotate-tokens=%s:4:1:17:1 %s | FileCheck %s // CHECK: Identifier: "T" [4:3 - 4:4] TypeRef=T:1:13 // CHECK: Punctuation: "*" [4:4 - 4:5] VarDecl=t_ptr:4:6 (Definition) // CHECK: Identifier: "t_ptr" [4:6 - 4:11] VarDecl=t_ptr:4:6 (Definition) @@ -61,5 +68,11 @@ void f(void *ptr) { // CHECK: Literal: ""Hello"" [9:24 - 9:31] UnexposedExpr= // CHECK: Punctuation: ";" [9:31 - 9:32] UnexposedStmt= // CHECK: Punctuation: "}" [10:1 - 10:2] UnexposedStmt= +// CHECK: Keyword: "__builtin_va_arg" [15:9 - 15:25] UnexposedExpr= +// CHECK: Identifier: "Int" [15:30 - 15:33] TypeRef=Int:12:13 +// CHECK: Keyword: "__builtin_types_compatible_p" [16:9 - 16:37] UnexposedExpr= +// CHECK: Identifier: "Int" [16:38 - 16:41] TypeRef=Int:12:13 +// CHECK: Punctuation: "," [16:41 - 16:42] UnexposedExpr= +// CHECK: Identifier: "Int" [16:43 - 16:46] TypeRef=Int:12:13 // RUN: c-index-test -test-annotate-tokens=%s:4:1:165:32 %s | FileCheck %s // RUN: c-index-test -test-annotate-tokens=%s:4:1:165:38 %s | FileCheck %s diff --git a/test/Index/annotate-tokens.cpp b/test/Index/annotate-tokens.cpp new file mode 100644 index 0000000..dca7af2 --- /dev/null +++ b/test/Index/annotate-tokens.cpp @@ -0,0 +1,23 @@ +struct bonk { }; +void test(bonk X) { + X = X; +} + +// RUN: c-index-test -test-annotate-tokens=%s:1:1:5:5 %s +// CHECK: Keyword: "struct" [1:1 - 1:7] StructDecl=bonk:1:8 (Definition) +// CHECK: Identifier: "bonk" [1:8 - 1:12] StructDecl=bonk:1:8 (Definition) +// CHECK: Punctuation: "{" [1:13 - 1:14] StructDecl=bonk:1:8 (Definition) +// CHECK: Punctuation: "}" [1:15 - 1:16] StructDecl=bonk:1:8 (Definition) +// CHECK: Punctuation: ";" [1:16 - 1:17] +// CHECK: Keyword: "void" [2:1 - 2:5] FunctionDecl=test:2:6 (Definition) +// CHECK: Identifier: "test" [2:6 - 2:10] FunctionDecl=test:2:6 (Definition) +// CHECK: Punctuation: "(" [2:10 - 2:11] FunctionDecl=test:2:6 (Definition) +// CHECK: Identifier: "bonk" [2:11 - 2:15] TypeRef=struct bonk:1:8 +// CHECK: Identifier: "X" [2:16 - 2:17] ParmDecl=X:2:16 (Definition) +// CHECK: Punctuation: ")" [2:17 - 2:18] FunctionDecl=test:2:6 (Definition) +// CHECK: Punctuation: "{" [2:19 - 2:20] UnexposedStmt= +// CHECK: Identifier: "X" [3:5 - 3:6] DeclRefExpr=X:2:16 +// CHECK: Punctuation: "=" [3:7 - 3:8] DeclRefExpr=operator=:1:8 +// CHECK: Identifier: "X" [3:9 - 3:10] DeclRefExpr=X:2:16 +// CHECK: Punctuation: ";" [3:10 - 3:11] UnexposedStmt= +// CHECK: Punctuation: "}" [4:1 - 4:2] UnexposedStmt= diff --git a/test/Index/annotate-tokens.m b/test/Index/annotate-tokens.m index c6e746b..336951b 100644 --- a/test/Index/annotate-tokens.m +++ b/test/Index/annotate-tokens.m @@ -56,7 +56,30 @@ extern int ibaction_test(void); @property IBOutlet int * aPropOutlet; @end -// RUN: c-index-test -test-annotate-tokens=%s:1:1:58:1 %s -DIBOutlet='__attribute__((iboutlet))' -DIBAction='void)__attribute__((ibaction)' | FileCheck %s +// From <rdar://problem/7974151>. The first 'foo:' wasn't being annotated as +// being part of the Objective-C message expression since the argument +// was expanded from a macro. + +#define VAL 0 + +@interface R7974151 +- (int) foo:(int)arg; +- (int) method; +@end + +@implementation R7974151 +- (int) foo:(int)arg { + return arg; +} +- (int) method +{ + int local = [self foo:VAL]; + int second = [self foo:0]; + return local; +} +@end + +// RUN: c-index-test -test-annotate-tokens=%s:1:1:80:4 %s -DIBOutlet='__attribute__((iboutlet))' -DIBAction='void)__attribute__((ibaction)' | FileCheck %s // CHECK: Punctuation: "@" [1:1 - 1:2] ObjCInterfaceDecl=Foo:1:12 // CHECK: Keyword: "interface" [1:2 - 1:11] ObjCInterfaceDecl=Foo:1:12 // CHECK: Identifier: "Foo" [1:12 - 1:15] ObjCInterfaceDecl=Foo:1:12 @@ -224,7 +247,7 @@ extern int ibaction_test(void); // CHECK: Keyword: "interface" [51:2 - 51:11] ObjCInterfaceDecl=IBOutletTests:51:12 // CHECK: Identifier: "IBOutletTests" [51:12 - 51:25] ObjCInterfaceDecl=IBOutletTests:51:12 // CHECK: Punctuation: "{" [52:1 - 52:2] ObjCInterfaceDecl=IBOutletTests:51:12 -// CHECK: Identifier: "IBOutlet" [53:5 - 53:13] macro instantiation=IBOutlet:{{[0-9]+}}:{{[0-9]+}} +// CHECK: Identifier: "IBOutlet" [53:5 - 53:13] macro instantiation=IBOutlet // CHECK: Keyword: "char" [53:14 - 53:18] ObjCIvarDecl=anOutlet:53:21 (Definition) // CHECK: Punctuation: "*" [53:19 - 53:20] ObjCIvarDecl=anOutlet:53:21 (Definition) // CHECK: Identifier: "anOutlet" [53:21 - 53:29] ObjCIvarDecl=anOutlet:53:21 (Definition) @@ -243,11 +266,86 @@ extern int ibaction_test(void); // CHECK: Punctuation: ";" [55:34 - 55:35] ObjCInterfaceDecl=IBOutletTests:51:12 // CHECK: Punctuation: "@" [56:1 - 56:2] ObjCInterfaceDecl=IBOutletTests:51:12 // CHECK: Keyword: "property" [56:2 - 56:10] ObjCInterfaceDecl=IBOutletTests:51:12 -// CHECK: Identifier: "IBOutlet" [56:11 - 56:19] macro instantiation=IBOutlet:{{[0-9]+}}:{{[0-9]+}} +// CHECK: Identifier: "IBOutlet" [56:11 - 56:19] macro instantiation=IBOutlet // CHECK: Keyword: "int" [56:20 - 56:23] ObjCInterfaceDecl=IBOutletTests:51:12 // CHECK: Punctuation: "*" [56:24 - 56:25] ObjCInterfaceDecl=IBOutletTests:51:12 // CHECK: Identifier: "aPropOutlet" [56:26 - 56:37] ObjCPropertyDecl=aPropOutlet:56:26 // CHECK: Punctuation: ";" [56:37 - 56:38] ObjCInterfaceDecl=IBOutletTests:51:12 // CHECK: Punctuation: "@" [57:1 - 57:2] ObjCInterfaceDecl=IBOutletTests:51:12 // CHECK: Keyword: "end" [57:2 - 57:5] ObjCInterfaceDecl=IBOutletTests:51:12 - +// CHECK: Punctuation: "#" [63:1 - 63:2] preprocessing directive= +// CHECK: Identifier: "define" [63:2 - 63:8] preprocessing directive= +// CHECK: Identifier: "VAL" [63:9 - 63:12] macro definition=VAL +// CHECK: Literal: "0" [63:13 - 63:14] preprocessing directive= +// CHECK: Punctuation: "@" [65:1 - 65:2] ObjCInterfaceDecl=R7974151:65:12 +// CHECK: Keyword: "interface" [65:2 - 65:11] ObjCInterfaceDecl=R7974151:65:12 +// CHECK: Identifier: "R7974151" [65:12 - 65:20] ObjCInterfaceDecl=R7974151:65:12 +// CHECK: Punctuation: "-" [66:1 - 66:2] ObjCInstanceMethodDecl=foo::66:1 +// CHECK: Punctuation: "(" [66:3 - 66:4] ObjCInstanceMethodDecl=foo::66:1 +// CHECK: Keyword: "int" [66:4 - 66:7] ObjCInstanceMethodDecl=foo::66:1 +// CHECK: Punctuation: ")" [66:7 - 66:8] ObjCInstanceMethodDecl=foo::66:1 +// CHECK: Identifier: "foo" [66:9 - 66:12] ObjCInstanceMethodDecl=foo::66:1 +// CHECK: Punctuation: ":" [66:12 - 66:13] ObjCInstanceMethodDecl=foo::66:1 +// CHECK: Punctuation: "(" [66:13 - 66:14] ObjCInstanceMethodDecl=foo::66:1 +// CHECK: Keyword: "int" [66:14 - 66:17] ParmDecl=arg:66:18 (Definition) +// CHECK: Punctuation: ")" [66:17 - 66:18] ParmDecl=arg:66:18 (Definition) +// CHECK: Identifier: "arg" [66:18 - 66:21] ParmDecl=arg:66:18 (Definition) +// CHECK: Punctuation: ";" [66:21 - 66:22] ObjCInstanceMethodDecl=foo::66:1 +// CHECK: Punctuation: "-" [67:1 - 67:2] ObjCInstanceMethodDecl=method:67:1 +// CHECK: Punctuation: "(" [67:3 - 67:4] ObjCInstanceMethodDecl=method:67:1 +// CHECK: Keyword: "int" [67:4 - 67:7] ObjCInstanceMethodDecl=method:67:1 +// CHECK: Punctuation: ")" [67:7 - 67:8] ObjCInstanceMethodDecl=method:67:1 +// CHECK: Identifier: "method" [67:9 - 67:15] ObjCInstanceMethodDecl=method:67:1 +// CHECK: Punctuation: ";" [67:15 - 67:16] ObjCInstanceMethodDecl=method:67:1 +// CHECK: Punctuation: "@" [68:1 - 68:2] ObjCInterfaceDecl=R7974151:65:12 +// CHECK: Keyword: "end" [68:2 - 68:5] ObjCInterfaceDecl=R7974151:65:12 +// CHECK: Punctuation: "@" [70:1 - 70:2] ObjCImplementationDecl=R7974151:70:1 (Definition) +// CHECK: Keyword: "implementation" [70:2 - 70:16] ObjCImplementationDecl=R7974151:70:1 (Definition) +// CHECK: Identifier: "R7974151" [70:17 - 70:25] ObjCImplementationDecl=R7974151:70:1 (Definition) +// CHECK: Punctuation: "-" [71:1 - 71:2] ObjCInstanceMethodDecl=foo::71:1 (Definition) +// CHECK: Punctuation: "(" [71:3 - 71:4] ObjCInstanceMethodDecl=foo::71:1 (Definition) +// CHECK: Keyword: "int" [71:4 - 71:7] ObjCInstanceMethodDecl=foo::71:1 (Definition) +// CHECK: Punctuation: ")" [71:7 - 71:8] ObjCInstanceMethodDecl=foo::71:1 (Definition) +// CHECK: Identifier: "foo" [71:9 - 71:12] ObjCInstanceMethodDecl=foo::71:1 (Definition) +// CHECK: Punctuation: ":" [71:12 - 71:13] ObjCInstanceMethodDecl=foo::71:1 (Definition) +// CHECK: Punctuation: "(" [71:13 - 71:14] ObjCInstanceMethodDecl=foo::71:1 (Definition) +// CHECK: Keyword: "int" [71:14 - 71:17] ParmDecl=arg:71:18 (Definition) +// CHECK: Punctuation: ")" [71:17 - 71:18] ParmDecl=arg:71:18 (Definition) +// CHECK: Identifier: "arg" [71:18 - 71:21] ParmDecl=arg:71:18 (Definition) +// CHECK: Punctuation: "{" [71:22 - 71:23] UnexposedStmt= +// CHECK: Keyword: "return" [72:3 - 72:9] UnexposedStmt= +// CHECK: Identifier: "arg" [72:10 - 72:13] DeclRefExpr=arg:71:18 +// CHECK: Punctuation: ";" [72:13 - 72:14] UnexposedStmt= +// CHECK: Punctuation: "}" [73:1 - 73:2] UnexposedStmt= +// CHECK: Punctuation: "-" [74:1 - 74:2] ObjCInstanceMethodDecl=method:74:1 (Definition) +// CHECK: Punctuation: "(" [74:3 - 74:4] ObjCInstanceMethodDecl=method:74:1 (Definition) +// CHECK: Keyword: "int" [74:4 - 74:7] ObjCInstanceMethodDecl=method:74:1 (Definition) +// CHECK: Punctuation: ")" [74:7 - 74:8] ObjCInstanceMethodDecl=method:74:1 (Definition) +// CHECK: Identifier: "method" [74:9 - 74:15] ObjCInstanceMethodDecl=method:74:1 (Definition) +// CHECK: Punctuation: "{" [75:1 - 75:2] UnexposedStmt= +// CHECK: Keyword: "int" [76:5 - 76:8] VarDecl=local:76:9 (Definition) +// CHECK: Identifier: "local" [76:9 - 76:14] VarDecl=local:76:9 (Definition) +// CHECK: Punctuation: "=" [76:15 - 76:16] VarDecl=local:76:9 (Definition) +// CHECK: Punctuation: "[" [76:17 - 76:18] ObjCMessageExpr=foo::66:1 +// CHECK: Identifier: "self" [76:18 - 76:22] DeclRefExpr=self:0:0 +// CHECK: Identifier: "foo" [76:23 - 76:26] ObjCMessageExpr=foo::66:1 +// CHECK: Punctuation: ":" [76:26 - 76:27] ObjCMessageExpr=foo::66:1 +// CHECK: Identifier: "VAL" [76:27 - 76:30] macro instantiation=VAL:63:9 +// CHECK: Punctuation: "]" [76:30 - 76:31] ObjCMessageExpr=foo::66:1 +// CHECK: Punctuation: ";" [76:31 - 76:32] UnexposedStmt= +// CHECK: Keyword: "int" [77:5 - 77:8] VarDecl=second:77:9 (Definition) +// CHECK: Identifier: "second" [77:9 - 77:15] VarDecl=second:77:9 (Definition) +// CHECK: Punctuation: "=" [77:16 - 77:17] VarDecl=second:77:9 (Definition) +// CHECK: Punctuation: "[" [77:18 - 77:19] ObjCMessageExpr=foo::66:1 +// CHECK: Identifier: "self" [77:19 - 77:23] DeclRefExpr=self:0:0 +// CHECK: Identifier: "foo" [77:24 - 77:27] ObjCMessageExpr=foo::66:1 +// CHECK: Punctuation: ":" [77:27 - 77:28] ObjCMessageExpr=foo::66:1 +// CHECK: Literal: "0" [77:28 - 77:29] UnexposedExpr= +// CHECK: Punctuation: "]" [77:29 - 77:30] ObjCMessageExpr=foo::66:1 +// CHECK: Punctuation: ";" [77:30 - 77:31] UnexposedStmt= +// CHECK: Keyword: "return" [78:5 - 78:11] UnexposedStmt= +// CHECK: Identifier: "local" [78:12 - 78:17] DeclRefExpr=local:76:9 +// CHECK: Punctuation: ";" [78:17 - 78:18] UnexposedStmt= +// CHECK: Punctuation: "}" [79:1 - 79:2] UnexposedStmt= +// CHECK: Punctuation: "@" [80:1 - 80:2] ObjCImplementationDecl=R7974151:70:1 (Definition) +// CHECK: Keyword: "end" [80:2 - 80:5] diff --git a/test/Index/c-index-api-loadTU-test.m b/test/Index/c-index-api-loadTU-test.m index 4e5eed4..5fe7cd6 100644 --- a/test/Index/c-index-api-loadTU-test.m +++ b/test/Index/c-index-api-loadTU-test.m @@ -6,7 +6,7 @@ __attribute__((iboutlet)) id myoutlet; } - (void) __attribute__((ibaction)) myMessage:(id)msg; -- foo; +- foo __attribute__((deprecated)); + fooC; @end @@ -56,7 +56,7 @@ int main (int argc, const char * argv[]) { // Test attribute traversal. #define IBOutlet __attribute__((iboutlet)) -#define IBOutletCollection(ClassName) __attribute__((iboutletcollection)) +#define IBOutletCollection(ClassName) __attribute__((iboutletcollection(ClassName))) #define IBAction void)__attribute__((ibaction) @interface TestAttributes { @@ -78,7 +78,7 @@ struct X0 {}; // CHECK: <invalid loc>:0:0: attribute(ibaction)= // CHECK: c-index-api-loadTU-test.m:8:50: ParmDecl=msg:8:50 (Definition) Extent=[8:47 - 8:53] // CHECK: c-index-api-loadTU-test.m:8:47: TypeRef=id:0:0 Extent=[8:47 - 8:49] -// CHECK: c-index-api-loadTU-test.m:9:1: ObjCInstanceMethodDecl=foo:9:1 Extent=[9:1 - 9:7] +// CHECK: c-index-api-loadTU-test.m:9:1: ObjCInstanceMethodDecl=foo:9:1 (deprecated) Extent=[9:1 - 9:35] // CHECK: c-index-api-loadTU-test.m:10:1: ObjCClassMethodDecl=fooC:10:1 Extent=[10:1 - 10:8] // CHECK: c-index-api-loadTU-test.m:14:12: ObjCInterfaceDecl=Bar:14:12 Extent=[14:1 - 18:5] // CHECK: c-index-api-loadTU-test.m:14:18: ObjCSuperClassRef=Foo:4:12 Extent=[14:18 - 14:21] @@ -143,10 +143,15 @@ struct X0 {}; // CHECK: c-index-api-loadTU-test.m:63:19: ObjCIvarDecl=anOutlet:63:19 (Definition) Extent=[63:19 - 63:27] // CHECK: <invalid loc>:0:0: attribute(iboutlet)= // CHECK: c-index-api-loadTU-test.m:64:29: ObjCIvarDecl=anOutletCollection:64:29 (Definition) Extent=[64:29 - 64:47] -// CHECK: <invalid loc>:0:0: attribute(iboutletcollection)= +// CHECK: <invalid loc>:0:0: attribute(iboutletcollection)= [IBOutletCollection=ObjCObjectPointer] // CHECK: c-index-api-loadTU-test.m:64:26: TypeRef=id:0:0 Extent=[64:26 - 64:28] // CHECK: c-index-api-loadTU-test.m:66:1: ObjCInstanceMethodDecl=actionMethod::66:1 Extent=[66:1 - 66:35] // CHECK: <invalid loc>:0:0: attribute(ibaction)= // CHECK: c-index-api-loadTU-test.m:66:31: ParmDecl=arg:66:31 (Definition) Extent=[66:28 - 66:34] // CHECK: c-index-api-loadTU-test.m:66:28: TypeRef=id:0:0 Extent=[66:28 - 66:30] +// CHECK: c-index-api-loadTU-test.m:69:16: StructDecl=X0:69:16 Extent=[69:9 - 69:18] +// CHECK: c-index-api-loadTU-test.m:69:19: TypedefDecl=X1:69:19 (Definition) Extent=[69:19 - 69:21] +// CHECK: c-index-api-loadTU-test.m:69:16: TypeRef=struct X0:71:8 Extent=[69:16 - 69:18] +// CHECK: c-index-api-loadTU-test.m:70:8: StructDecl=X0:70:8 Extent=[70:1 - 70:10] +// CHECK: c-index-api-loadTU-test.m:71:8: StructDecl=X0:71:8 (Definition) Extent=[71:1 - 71:14] diff --git a/test/Index/cindex-from-source.m b/test/Index/cindex-from-source.m index 86e794d..f226e45 100644 --- a/test/Index/cindex-from-source.m +++ b/test/Index/cindex-from-source.m @@ -7,3 +7,6 @@ // CHECK: cindex-from-source.m:9:1: TypeRef=t0:1:13 Extent=[9:1 - 9:3] struct s0 {}; t0 g0; + +// RUN: c-index-test -test-load-source-reparse 5 local %s -include %t.pfx.h > %t +// RUN: FileCheck %s < %t diff --git a/test/Index/code-completion.cpp b/test/Index/code-completion.cpp index 1d50fd3..7b0c8d7 100644 --- a/test/Index/code-completion.cpp +++ b/test/Index/code-completion.cpp @@ -15,9 +15,9 @@ struct Z : X, Y { double member; operator int() const; }; - +struct W { }; struct Z get_Z(); - +namespace N { } void test_Z() { // RUN: c-index-test -code-completion-at=%s:23:11 %s | FileCheck -check-prefix=CHECK-MEMBER %s get_Z().member = 17; @@ -40,28 +40,28 @@ Z::operator int() const { // CHECK-MEMBER: FieldDecl:{ResultType double}{TypedText member} // CHECK-MEMBER: FieldDecl:{ResultType int}{Text X::}{TypedText member} // CHECK-MEMBER: FieldDecl:{ResultType float}{Text Y::}{TypedText member} -// CHECK-MEMBER: FunctionDecl:{ResultType void}{Informative Y::}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )} -// CHECK-MEMBER: FunctionDecl:{ResultType int}{TypedText operator int}{LeftParen (}{RightParen )}{Informative const} -// CHECK-MEMBER: FunctionDecl:{ResultType Z &}{TypedText operator=}{LeftParen (}{Placeholder Z const &}{RightParen )} -// CHECK-MEMBER: FunctionDecl:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder X const &}{RightParen )} -// CHECK-MEMBER: FunctionDecl:{ResultType Y &}{Text Y::}{TypedText operator=}{LeftParen (}{Placeholder Y const &}{RightParen )} +// CHECK-MEMBER: CXXMethod:{ResultType void}{Informative Y::}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )} +// CHECK-MEMBER: CXXConversion:{ResultType int}{TypedText operator int}{LeftParen (}{RightParen )}{Informative const} +// CHECK-MEMBER: CXXMethod:{ResultType Z &}{TypedText operator=}{LeftParen (}{Placeholder Z const &}{RightParen )} +// CHECK-MEMBER: CXXMethod:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder X const &}{RightParen )} +// CHECK-MEMBER: CXXMethod:{ResultType Y &}{Text Y::}{TypedText operator=}{LeftParen (}{Placeholder Y const &}{RightParen )} // CHECK-MEMBER: EnumConstantDecl:{ResultType X::E}{Informative E::}{TypedText Val1} // CHECK-MEMBER: StructDecl:{TypedText X}{Text ::} // CHECK-MEMBER: StructDecl:{TypedText Y}{Text ::} // CHECK-MEMBER: StructDecl:{TypedText Z}{Text ::} -// CHECK-MEMBER: FunctionDecl:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )} -// CHECK-MEMBER: FunctionDecl:{ResultType void}{Informative Y::}{TypedText ~Y}{LeftParen (}{RightParen )} -// CHECK-MEMBER: FunctionDecl:{ResultType void}{TypedText ~Z}{LeftParen (}{RightParen )} +// CHECK-MEMBER: CXXDestructor:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )} +// CHECK-MEMBER: CXXDestructor:{ResultType void}{Informative Y::}{TypedText ~Y}{LeftParen (}{RightParen )} +// CHECK-MEMBER: CXXDestructor:{ResultType void}{TypedText ~Z}{LeftParen (}{RightParen )} // CHECK-OVERLOAD: NotImplemented:{ResultType int &}{Text overloaded}{LeftParen (}{Text Z z}{Comma , }{CurrentParameter int second}{RightParen )} // CHECK-OVERLOAD: NotImplemented:{ResultType float &}{Text overloaded}{LeftParen (}{Text int i}{Comma , }{CurrentParameter long second}{RightParen )} // CHECK-OVERLOAD: NotImplemented:{ResultType double &}{Text overloaded}{LeftParen (}{Text float f}{Comma , }{CurrentParameter int second}{RightParen )} // RUN: c-index-test -code-completion-at=%s:37:10 %s | FileCheck -check-prefix=CHECK-EXPR %s -// CHECK-EXPR: NotImplemented:{TypedText int} (40) -// CHECK-EXPR: NotImplemented:{TypedText long} (40) +// CHECK-EXPR: NotImplemented:{TypedText int} (65) +// CHECK-EXPR: NotImplemented:{TypedText long} (65) // CHECK-EXPR: FieldDecl:{ResultType double}{TypedText member} (10) // CHECK-EXPR: FieldDecl:{ResultType int}{Text X::}{TypedText member} (5) // CHECK-EXPR: FieldDecl:{ResultType float}{Text Y::}{TypedText member} (11) -// CHECK-EXPR: FunctionDecl:{ResultType void}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )} (22) - +// CHECK-EXPR: CXXMethod:{ResultType void}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )} (22) +// CHECK-EXPR: Namespace:{TypedText N}{Text ::} (75) diff --git a/test/Index/complete-at-exprstmt.m b/test/Index/complete-at-exprstmt.m index 8537098..cccfa26 100644 --- a/test/Index/complete-at-exprstmt.m +++ b/test/Index/complete-at-exprstmt.m @@ -9,6 +9,16 @@ @synchronized (@encode(MyClass)) { } } @end + +@interface A ++ (int)add:(int)x to:(int)y; ++ (int)add:(int)x to:(int)y plus:(int)z; +@end + +void f() { + @selector(add:to:); +} + // RUN: c-index-test -code-completion-at=%s:9:4 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s // CHECK-CC1: {TypedText encode}{LeftParen (}{Placeholder type-name}{RightParen )} // CHECK-CC1: {TypedText protocol}{LeftParen (}{Placeholder protocol-name}{RightParen )} @@ -35,3 +45,11 @@ // CHECK-CC3: ObjCInterfaceDecl:{TypedText MyClass} // CHECK-CC3: TypedefDecl:{TypedText SEL} // CHECK-CC3: NotImplemented:{ResultType MyClass *}{TypedText self} +// RUN: c-index-test -code-completion-at=%s:19:13 %s | FileCheck -check-prefix=CHECK-CC4 %s +// CHECK-CC4: NotImplemented:{TypedText add:to:} (30) +// CHECK-CC4: NotImplemented:{TypedText add:to:plus:} (30) +// CHECK-CC4: NotImplemented:{TypedText myMethod:} (30) +// RUN: c-index-test -code-completion-at=%s:19:17 %s | FileCheck -check-prefix=CHECK-CC5 %s +// CHECK-CC5: NotImplemented:{Informative add:}{TypedText to:} (30) +// CHECK-CC5: NotImplemented:{Informative add:}{TypedText to:plus:} (30) + diff --git a/test/Index/complete-blocks.m b/test/Index/complete-blocks.m new file mode 100644 index 0000000..7233efb --- /dev/null +++ b/test/Index/complete-blocks.m @@ -0,0 +1,24 @@ +// The line and column layout of this test is significant. Run lines +// are at the end. +typedef void (^block_t)(float f, double d); +void f(int (^block)(int x, int y)); +void g(block_t b); + +void test_f() { + +} + +@interface A +- method:(int (^)(int x, int y))b; +- method2:(block_t)b; +@end + +void test_A(A *a) { + [a method:0]; +} +// RUN: c-index-test -code-completion-at=%s:8:1 %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText f}{LeftParen (}{Placeholder int (^)(int x, int y)}{RightParen )} (45) +// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText g}{LeftParen (}{Placeholder void (^)(float f, double d)}{RightParen )} (45) +// RUN: c-index-test -code-completion-at=%s:17:6 %s | FileCheck -check-prefix=CHECK-CC2 %s +// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType id}{TypedText method2:}{Placeholder void (^)(float f, double d)} (20) +// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType id}{TypedText method:}{Placeholder int (^)(int x, int y)} (20) diff --git a/test/Index/complete-ctor-inits.cpp b/test/Index/complete-ctor-inits.cpp new file mode 100644 index 0000000..f9cc702 --- /dev/null +++ b/test/Index/complete-ctor-inits.cpp @@ -0,0 +1,40 @@ +// The run lines are below, because this test is line- and +// column-number sensitive. + +template<typename T> +struct X { + X(T); +}; + +struct Virt { }; +struct Y : virtual Virt { }; + +struct Z : public X<int>, public Y { + Z(); + + int a, b, c; +}; + +Z::Z() : ::X<int>(0), Virt(), b(), c() { } + +// RUN: c-index-test -code-completion-at=%s:18:10 %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: NotImplemented:{TypedText a}{LeftParen (}{Placeholder args}{RightParen )} (20) +// CHECK-CC1: NotImplemented:{TypedText b}{LeftParen (}{Placeholder args}{RightParen )} (20) +// CHECK-CC1: NotImplemented:{TypedText c}{LeftParen (}{Placeholder args}{RightParen )} (20) +// CHECK-CC1: NotImplemented:{TypedText Virt}{LeftParen (}{Placeholder args}{RightParen )} (20) +// CHECK-CC1: NotImplemented:{TypedText X<int>}{LeftParen (}{Placeholder args}{RightParen )} (7) +// CHECK-CC1: NotImplemented:{TypedText Y}{LeftParen (}{Placeholder args}{RightParen )} (20) + +// RUN: c-index-test -code-completion-at=%s:18:23 %s | FileCheck -check-prefix=CHECK-CC2 %s +// CHECK-CC2: NotImplemented:{TypedText a}{LeftParen (}{Placeholder args}{RightParen )} (20) +// CHECK-CC2: NotImplemented:{TypedText b}{LeftParen (}{Placeholder args}{RightParen )} (20) +// CHECK-CC2: NotImplemented:{TypedText c}{LeftParen (}{Placeholder args}{RightParen )} (20) +// CHECK-CC2: NotImplemented:{TypedText Virt}{LeftParen (}{Placeholder args}{RightParen )} (20) +// CHECK-CC2: NotImplemented:{TypedText Y}{LeftParen (}{Placeholder args}{RightParen )} (7) + +// RUN: c-index-test -code-completion-at=%s:18:36 %s | FileCheck -check-prefix=CHECK-CC3 %s +// CHECK-CC3: NotImplemented:{TypedText a}{LeftParen (}{Placeholder args}{RightParen )} (20) +// CHECK-CC3-NOT: NotImplemented:{TypedText b}{LeftParen (}{Placeholder args}{RightParen )} +// CHECK-CC3: NotImplemented:{TypedText c}{LeftParen (}{Placeholder args}{RightParen )} (7) +// CHECK-CC3-NOT: NotImplemented:{TypedText Virt}{LeftParen (}{Placeholder args}{RightParen )} +// CHECK-CC3: NotImplemented:{TypedText Y}{LeftParen (}{Placeholder args}{RightParen )} (20) diff --git a/test/Index/complete-declarators.cpp b/test/Index/complete-declarators.cpp new file mode 100644 index 0000000..8fba4db --- /dev/null +++ b/test/Index/complete-declarators.cpp @@ -0,0 +1,39 @@ +// This test is line- and column-sensitive, so test commands are at the bottom. +namespace N { + struct X { + int f(X); + }; +} + +int g(int a); + +struct Y { }; + +struct Z { + int member; + friend int N::X::f(N::X); +}; + +// RUN: c-index-test -code-completion-at=%s:8:5 %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: NotImplemented:{TypedText const} (30) +// CHECK-CC1: Namespace:{TypedText N}{Text ::} (75) +// CHECK-CC1: NotImplemented:{TypedText operator} (30) +// CHECK-CC1: NotImplemented:{TypedText volatile} (30) +// RUN: c-index-test -code-completion-at=%s:8:11 %s | FileCheck -check-prefix=CHECK-CC2 %s +// CHECK-CC2: NotImplemented:{TypedText const} (30) +// CHECK-CC2-NOT: Namespace:{TypedText N}{Text ::} (75) +// CHECK-CC2-NOT: NotImplemented:{TypedText operator} (30) +// CHECK-CC2: NotImplemented:{TypedText volatile} (30) +// RUN: c-index-test -code-completion-at=%s:13:7 %s | FileCheck -check-prefix=CHECK-CC3 %s +// CHECK-CC3: NotImplemented:{TypedText const} (30) +// CHECK-CC3-NOT: Namespace:{TypedText N}{Text ::} (75) +// CHECK-CC3: NotImplemented:{TypedText operator} (30) +// CHECK-CC3: NotImplemented:{TypedText volatile} (30) +// RUN: c-index-test -code-completion-at=%s:14:14 %s | FileCheck -check-prefix=CHECK-CC4 %s +// CHECK-CC4: NotImplemented:{TypedText const} (30) +// CHECK-CC4: Namespace:{TypedText N}{Text ::} (75) +// CHECK-CC4: NotImplemented:{TypedText operator} (30) +// CHECK-CC4: NotImplemented:{TypedText volatile} (30) +// CHECK-CC4: StructDecl:{TypedText Y} (65) +// CHECK-CC4: StructDecl:{TypedText Z} (20) + diff --git a/test/Index/complete-declarators.m b/test/Index/complete-declarators.m new file mode 100644 index 0000000..3a69282 --- /dev/null +++ b/test/Index/complete-declarators.m @@ -0,0 +1,45 @@ +// This test is line- and column-sensitive, so test commands are at the bottom. +@protocol P +- (int)method:(id)param1; +@end + +@interface A <P> +- (int)method:(id)param1; + +@property int prop1; +@end + +@implementation A +- (int)method:(id)param1 { + int q2; + for(id q in param1) { + int y; + } + id q; + for(q in param1) { + int y; + } +} +@end + +// RUN: c-index-test -code-completion-at=%s:7:19 %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1-NOT: NotImplemented:{TypedText extern} (30) +// CHECK-CC1: NotImplemented:{TypedText param1} (30) +// RUN: c-index-test -code-completion-at=%s:9:15 %s | FileCheck -check-prefix=CHECK-CC2 %s +// RUN: c-index-test -code-completion-at=%s:15:10 %s | FileCheck -check-prefix=CHECK-CC2 %s +// RUN: c-index-test -code-completion-at=%s:16:9 %s | FileCheck -check-prefix=CHECK-CC2 %s +// CHECK-CC2: NotImplemented:{TypedText const} (30) +// CHECK-CC2-NOT: int +// CHECK-CC2: NotImplemented:{TypedText restrict} (30) +// CHECK-CC2: NotImplemented:{TypedText volatile} (30) +// RUN: c-index-test -code-completion-at=%s:15:15 %s | FileCheck -check-prefix=CHECK-CC3 %s +// CHECK-CC3: ParmDecl:{ResultType id}{TypedText param1} (8) +// CHECK-CC3-NOT: VarDecl:{ResultType int}{TypedText q2} (8) +// CHECK-CC3-NOT: VarDecl:{ResultType id}{TypedText q} (8) +// CHECK-CC3: NotImplemented:{ResultType A *}{TypedText self} (8) +// CHECK-CC3: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (30) +// RUN: c-index-test -code-completion-at=%s:15:15 %s | FileCheck -check-prefix=CHECK-CC4 %s +// CHECK-CC4: ParmDecl:{ResultType id}{TypedText param1} (8) +// CHECK-CC4-NOT: VarDecl:{ResultType int}{TypedText q2} (8) +// CHECK-CC4: NotImplemented:{ResultType A *}{TypedText self} (8) +// CHECK-CC4: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (30) diff --git a/test/Index/complete-exprs.c b/test/Index/complete-exprs.c index b7bed8c..2a7a1e2 100644 --- a/test/Index/complete-exprs.c +++ b/test/Index/complete-exprs.c @@ -1,27 +1,37 @@ // Note: the run lines follow their respective tests, since line/column // matter in this test. -int f(int); +int f(int) __attribute__((unavailable)); int test(int i, int j, int k, int l) { return i | j | k & l; } -struct X f1 = { 17 }; +struct X __attribute__((deprecated)) f1 = { 17 }; void f2() { f1(17); } const char *str = "Hello, \nWorld"; +void f3(const char*, ...) __attribute__((sentinel(0))); + +#define NULL __null +void f4(const char* str) { + f3(str, NULL); +} // RUN: c-index-test -code-completion-at=%s:7:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s +// RUN: env CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:7:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: NotImplemented:{TypedText __PRETTY_FUNCTION__} (60) // CHECK-CC1: macro definition:{TypedText __VERSION__} (70) -// CHECK-CC1: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (12) -// CHECK-CC1-NOT: NotImplemented:{TypedText float} (40) +// CHECK-CC1: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (12) (unavailable) +// CHECK-CC1-NOT: NotImplemented:{TypedText float} (65) // CHECK-CC1: ParmDecl:{ResultType int}{TypedText j} (2) // CHECK-CC1: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (30) +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s // RUN: c-index-test -code-completion-at=%s:7:14 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s +// RUN: env CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:7:14 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s // CHECK-CC3: macro definition:{TypedText __VERSION__} (70) // CHECK-CC3: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (50) -// CHECK-CC3-NOT: NotImplemented:{TypedText float} (40) +// CHECK-CC3-NOT: NotImplemented:{TypedText float} (65) // CHECK-CC3: ParmDecl:{ResultType int}{TypedText j} (8) // CHECK-CC3: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expressio @@ -30,13 +40,14 @@ const char *str = "Hello, \nWorld"; // RUN: c-index-test -code-completion-at=%s:7:2 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC2 %s // CHECK-CC2: macro definition:{TypedText __VERSION__} (70) // CHECK-CC2: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (50) -// CHECK-CC2: NotImplemented:{TypedText float} (40) +// CHECK-CC2: NotImplemented:{TypedText float} (65) // CHECK-CC2: ParmDecl:{ResultType int}{TypedText j} (8) // CHECK-CC2: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (30) // RUN: c-index-test -code-completion-at=%s:11:16 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC4 %s // CHECK-CC4: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (50) -// CHECK-CC4: VarDecl:{ResultType struct X}{TypedText f1} (50) +// CHECK-CC4: VarDecl:{ResultType struct X}{TypedText f1} (50) (deprecated) -// RUN: c-index-test -code-completion-at=%s:13:28 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC5 %s -// CHECK-CC5: NotImplemented:{TypedText void} (40) -// CHECK-CC5: NotImplemented:{TypedText volatile} (40) +// RUN: c-index-test -code-completion-at=%s:19:3 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC6 %s +// CHECK-CC6: FunctionDecl:{ResultType void}{TypedText f3}{LeftParen (}{Placeholder char const *, ...}{Text , NULL}{RightParen )} (45) +// CHECK-CC6: NotImplemented:{TypedText void} (65) +// CHECK-CC6: NotImplemented:{TypedText volatile} (65) diff --git a/test/Index/complete-hiding.c b/test/Index/complete-hiding.c new file mode 100644 index 0000000..f2e1775 --- /dev/null +++ b/test/Index/complete-hiding.c @@ -0,0 +1,29 @@ +// Note: the run lines follow their respective tests, since line/column +// matter in this test. + +struct StructA { }; +struct StructB { }; +struct StructC { }; +int ValueA; +int ValueB; + +void f() { + + int ValueA = 0; + int StructA = 0; + struct StructB { }; + + struct StructA sa = { }; +} + +// RUN: c-index-test -code-completion-at=%s:16:3 %s | FileCheck -check-prefix=CHECK-CC1 %s +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:16:3 %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: VarDecl:{ResultType int}{TypedText StructA} (8) +// CHECK-CC1: VarDecl:{ResultType int}{TypedText ValueA} (8) +// CHECK-CC1-NOT: VarDecl:{ResultType int}{TypedText ValueA} (50) +// CHECK-CC1: VarDecl:{ResultType int}{TypedText ValueB} (50) +// RUN: c-index-test -code-completion-at=%s:16:10 %s | FileCheck -check-prefix=CHECK-CC2 %s +// CHECK-CC2: StructDecl:{TypedText StructA} (65) +// CHECK-CC2-NOT: StructDecl:{TypedText StructB} (65) +// CHECK-CC2: StructDecl:{TypedText StructC} (65) +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:16:10 %s | FileCheck -check-prefix=CHECK-CC2 %s diff --git a/test/Index/complete-macros.c b/test/Index/complete-macros.c index 9a898e1..26a63b1 100644 --- a/test/Index/complete-macros.c +++ b/test/Index/complete-macros.c @@ -16,9 +16,12 @@ void f2() { } // RUN: c-index-test -code-completion-at=%s:7:1 %s | FileCheck -check-prefix=CHECK-CC1 %s +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:1 %s | FileCheck -check-prefix=CHECK-CC1 %s // CHECK-CC1: macro definition:{TypedText FOO}{LeftParen (}{Placeholder Arg1}{Comma , }{Placeholder Arg2}{RightParen )} // RUN: c-index-test -code-completion-at=%s:13:13 %s | FileCheck -check-prefix=CHECK-CC2 %s // RUN: c-index-test -code-completion-at=%s:14:8 %s | FileCheck -check-prefix=CHECK-CC2 %s +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:14:8 %s | FileCheck -check-prefix=CHECK-CC2 %s // CHECK-CC2: macro definition:{TypedText nil} (30) // RUN: c-index-test -code-completion-at=%s:15:5 %s | FileCheck -check-prefix=CHECK-CC3 %s +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:15:5 %s | FileCheck -check-prefix=CHECK-CC3 %s // CHECK-CC3: macro definition:{TypedText nil} (60) diff --git a/test/Index/complete-memfunc-cvquals.cpp b/test/Index/complete-memfunc-cvquals.cpp new file mode 100644 index 0000000..4e2e820 --- /dev/null +++ b/test/Index/complete-memfunc-cvquals.cpp @@ -0,0 +1,86 @@ +// The run lines are below, because this test is line- and +// column-number sensitive. +struct Foo { + void babble() const volatile; + void bar(); + void baz() const; + void bingo() volatile; + void theend() const volatile; +}; + +template<typename T> +struct smart_ptr { + T *operator->(); + const T* operator->() const; +}; + +void text(Foo f, Foo *fp, const Foo &fc, const Foo *fcp, + smart_ptr<Foo> sf, const smart_ptr<Foo> &sfc, Foo volatile *fvp) { + f.bar(); + fp->bar(); + fc.baz(); + fcp->baz(); + sf->bar(); + sfc->baz(); + fvp->babble(); +} + +void Foo::bar() { + +} + +void Foo::baz() const { + +} + +void Foo::bingo() volatile { + +} + +// Check member access expressions. +// RUN: c-index-test -code-completion-at=%s:19:5 %s | FileCheck -check-prefix=CHECK-NOQUALS %s +// RUN: c-index-test -code-completion-at=%s:20:7 %s | FileCheck -check-prefix=CHECK-NOQUALS %s +// RUN: c-index-test -code-completion-at=%s:23:7 %s | FileCheck -check-prefix=CHECK-NOQUALS %s +// CHECK-NOQUALS: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (20) +// CHECK-NOQUALS: CXXMethod:{ResultType void}{TypedText bar}{LeftParen (}{RightParen )} (19) +// CHECK-NOQUALS: CXXMethod:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative const} (20) +// CHECK-NOQUALS: CXXMethod:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative volatile} (20) +// RUN: c-index-test -code-completion-at=%s:21:6 %s | FileCheck -check-prefix=CHECK-CONST %s +// RUN: c-index-test -code-completion-at=%s:22:8 %s | FileCheck -check-prefix=CHECK-CONST %s +// RUN: c-index-test -code-completion-at=%s:24:8 %s | FileCheck -check-prefix=CHECK-CONST %s +// CHECK-CONST: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (20) +// CHECK-CONST-NOT: bar +// CHECK-CONST: CXXMethod:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative const} (19) +// CHECK-CONST-NOT: bingo +// CHECK-CONST: theend +// RUN: c-index-test -code-completion-at=%s:25:8 %s | FileCheck -check-prefix=CHECK-VOLATILE %s +// CHECK-VOLATILE: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (20) +// CHECK-VOLATILE-NOT: baz +// CHECK-VOLATILE: CXXMethod:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative volatile} (19) + +// Check implicit member access expressions. +// RUN: c-index-test -code-completion-at=%s:29:2 %s | FileCheck -check-prefix=CHECK-IMPLICIT-NOQUALS %s +// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (15) +// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText bar}{LeftParen (}{RightParen )} (14) +// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative const} (15) +// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative volatile} (15) + +// RUN: c-index-test -code-completion-at=%s:33:1 %s | FileCheck -check-prefix=CHECK-IMPLICIT-CONST %s +// CHECK-IMPLICIT-CONST: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (15) +// CHECK-IMPLICIT-CONST-NOT: bar +// CHECK-IMPLICIT-CONST: CXXMethod:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative const} (14) +// CHECK-IMPLICIT-CONST-NOT: bingo +// CHECK-IMPLICIT-CONST: theend + +// RUN: c-index-test -code-completion-at=%s:37:1 %s | FileCheck -check-prefix=CHECK-IMPLICIT-VOLATILE %s +// CHECK-IMPLICIT-VOLATILE: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (15) +// CHECK-IMPLICIT-VOLATILE-NOT: baz +// CHECK-IMPLICIT-VOLATILE: CXXMethod:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative volatile} (14) + +// RUN: c-index-test -code-completion-at=%s:4:17 %s | FileCheck -check-prefix=CHECK-CVQUAL-AFTER %s +// CHECK-CVQUAL-AFTER: NotImplemented:{TypedText const} (30) +// CHECK-CVQUAL-AFTER: NotImplemented:{TypedText volatile} (30) + +// RUN: c-index-test -code-completion-at=%s:4:23 %s | FileCheck -check-prefix=CHECK-CVQUAL-AFTER2 %s +// CHECK-CVQUAL-AFTER2-NOT: NotImplemented:{TypedText const} (30) +// CHECK-CVQUAL-AFTER2: NotImplemented:{TypedText volatile} (30) diff --git a/test/Index/complete-method-decls.m b/test/Index/complete-method-decls.m index a30874b..1324ae4 100644 --- a/test/Index/complete-method-decls.m +++ b/test/Index/complete-method-decls.m @@ -52,43 +52,51 @@ - (int)first:(int)x second2:(float)y third:(double)z; @end +@implementation D +- (int)first:(int)x second2:(float)y third:(double)z { } +@end + +@interface Passing +- (oneway void)method:(in id x); +@end + // RUN: c-index-test -code-completion-at=%s:17:3 %s | FileCheck -check-prefix=CHECK-CC1 %s -// CHECK-CC1: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText abc} -// CHECK-CC1: NotImplemented:{LeftParen (}{Text int}{RightParen )}{TypedText getInt} -// CHECK-CC1: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf} -// CHECK-CC1: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x} -// CHECK-CC1: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y} +// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc} +// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getInt} +// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf} +// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x} +// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y} // RUN: c-index-test -code-completion-at=%s:17:7 %s | FileCheck -check-prefix=CHECK-CC2 %s -// CHECK-CC2: NotImplemented:{TypedText abc} -// CHECK-CC2-NEXT: NotImplemented:{TypedText getSelf} -// CHECK-CC2: NotImplemented:{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x} -// CHECK-CC2: NotImplemented:{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y} +// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText abc} +// CHECK-CC2-NEXT: ObjCInstanceMethodDecl:{TypedText getSelf} +// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x} +// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y} // RUN: c-index-test -code-completion-at=%s:24:7 %s | FileCheck -check-prefix=CHECK-CC3 %s -// CHECK-CC3: NotImplemented:{TypedText abc} -// CHECK-CC3-NEXT: NotImplemented:{TypedText getSelf} -// CHECK-CC3: NotImplemented:{TypedText init} -// CHECK-CC3: NotImplemented:{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x} -// CHECK-CC3: NotImplemented:{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y} +// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText abc} +// CHECK-CC3-NEXT: ObjCInstanceMethodDecl:{TypedText getSelf} +// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText init} +// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x} +// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y} // RUN: c-index-test -code-completion-at=%s:33:3 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC4 %s -// CHECK-CC4: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText abc} -// CHECK-CC4: NotImplemented:{LeftParen (}{Text int}{RightParen )}{TypedText getInt}{HorizontalSpace }{LeftBrace {}{VerticalSpace -// CHECK-CC4: NotImplemented:{LeftParen (}{Text int}{RightParen )}{TypedText getSecondValue}{HorizontalSpace }{LeftBrace {}{VerticalSpace -// CHECK-CC4: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace -// CHECK-CC4: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace -// CHECK-CC4: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace -// CHECK-CC4: NotImplemented:{LeftParen (}{Text int}{RightParen )}{TypedText setValue}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (32) +// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getInt}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getSecondValue}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (30) +// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText setValue}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace // RUN: c-index-test -code-completion-at=%s:33:8 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC5 %s -// CHECK-CC5: NotImplemented:{TypedText getInt}{HorizontalSpace }{LeftBrace {}{VerticalSpace -// CHECK-CC5: NotImplemented:{TypedText getSecondValue}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText getInt}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText getSecondValue}{HorizontalSpace }{LeftBrace {}{VerticalSpace // CHECK-CC5-NOT: {TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace -// CHECK-CC5: NotImplemented:{TypedText setValue}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText setValue}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace // RUN: c-index-test -code-completion-at=%s:37:7 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC6 %s -// CHECK-CC6: NotImplemented:{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace // CHECK-CC6-NOT: getSelf -// CHECK-CC6: NotImplemented:{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace -// CHECK-CC6: NotImplemented:{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace // RUN: c-index-test -code-completion-at=%s:42:3 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC7 %s -// CHECK-CC7: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText categoryFunction}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC7: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText categoryFunction}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace // RUN: c-index-test -code-completion-at=%s:52:21 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC8 %s // CHECK-CC8: ObjCInstanceMethodDecl:{ResultType id}{Informative first:}{TypedText second2:}{Text (float)y2}{HorizontalSpace }{Text third:}{Text (double)z} (20) // CHECK-CC8: ObjCInstanceMethodDecl:{ResultType void *}{Informative first:}{TypedText second3:}{Text (float)y3}{HorizontalSpace }{Text third:}{Text (double)z} (20) @@ -99,5 +107,53 @@ // CHECK-CC9: NotImplemented:{TypedText xxx} (30) // RUN: c-index-test -code-completion-at=%s:52:36 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CCA %s // CHECK-CCA: NotImplemented:{TypedText y2} (30) - - +// RUN: c-index-test -code-completion-at=%s:56:3 %s | FileCheck -check-prefix=CHECK-CCB %s +// CHECK-CCB: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText first}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second2}{Colon :}{LeftParen (}{Text float}{RightParen )}{Text y}{HorizontalSpace }{Text third}{Colon :}{LeftParen (}{Text double}{RightParen )}{Text z} (30) +// RUN: c-index-test -code-completion-at=%s:56:8 %s | FileCheck -check-prefix=CHECK-CCC %s +// CHECK-CCC: ObjCInstanceMethodDecl:{TypedText first}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second2}{Colon :}{LeftParen (}{Text float}{RightParen )}{Text y}{HorizontalSpace }{Text third}{Colon :}{LeftParen (}{Text double}{RightParen )}{Text z} (30) +// RUN: c-index-test -code-completion-at=%s:56:21 %s | FileCheck -check-prefix=CHECK-CCD %s +// FIXME: These results could be more precise. +// CHECK-CCD: ObjCInstanceMethodDecl:{ResultType id}{Informative first:}{TypedText second2:}{Text (float)y2}{HorizontalSpace }{Text third:}{Text (double)z} (20) +// CHECK-CCD: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{TypedText second2:}{Text (float)y}{HorizontalSpace }{Text third:}{Text (double)z} (5) +// CHECK-CCD: ObjCInstanceMethodDecl:{ResultType void *}{Informative first:}{TypedText second3:}{Text (float)y3}{HorizontalSpace }{Text third:}{Text (double)z} (20) +// CHECK-CCD: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{TypedText second:}{Text (float)y}{HorizontalSpace }{Text third:}{Text (double)z} (5) +// RUN: c-index-test -code-completion-at=%s:56:38 %s | FileCheck -check-prefix=CHECK-CCE %s +// CHECK-CCE: ObjCInstanceMethodDecl:{ResultType id}{Informative first:}{Informative second2:}{TypedText third:}{Text (double)z} (20) +// CHECK-CCE: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{Informative second2:}{TypedText third:}{Text (double)z} (5) +// RUN: c-index-test -code-completion-at=%s:60:4 %s | FileCheck -check-prefix=CHECK-CCF %s +// CHECK-CCF: ObjCInterfaceDecl:{TypedText A} (65) +// CHECK-CCF: ObjCInterfaceDecl:{TypedText B} (65) +// CHECK-CCF: NotImplemented:{TypedText bycopy} (30) +// CHECK-CCF: NotImplemented:{TypedText byref} (30) +// CHECK-CCF: NotImplemented:{TypedText in} (30) +// CHECK-CCF: NotImplemented:{TypedText inout} (30) +// CHECK-CCF: NotImplemented:{TypedText oneway} (30) +// CHECK-CCF: NotImplemented:{TypedText out} (30) +// CHECK-CCF: NotImplemented:{TypedText unsigned} (65) +// CHECK-CCF: NotImplemented:{TypedText void} (65) +// CHECK-CCF: NotImplemented:{TypedText volatile} (65) +// RUN: c-index-test -code-completion-at=%s:60:11 %s | FileCheck -check-prefix=CHECK-CCG %s +// CHECK-CCG: ObjCInterfaceDecl:{TypedText A} (65) +// CHECK-CCG: ObjCInterfaceDecl:{TypedText B} (65) +// CHECK-CCG-NOT: NotImplemented:{TypedText bycopy} (30) +// CHECK-CCG-NOT: NotImplemented:{TypedText byref} (30) +// CHECK-CCG: NotImplemented:{TypedText in} (30) +// CHECK-CCG: NotImplemented:{TypedText inout} (30) +// CHECK-CCG-NOT: NotImplemented:{TypedText oneway} (30) +// CHECK-CCG: NotImplemented:{TypedText out} (30) +// CHECK-CCG: NotImplemented:{TypedText unsigned} (65) +// CHECK-CCG: NotImplemented:{TypedText void} (65) +// CHECK-CCG: NotImplemented:{TypedText volatile} (65) +// RUN: c-index-test -code-completion-at=%s:60:24 %s | FileCheck -check-prefix=CHECK-CCF %s +// RUN: c-index-test -code-completion-at=%s:60:26 %s | FileCheck -check-prefix=CHECK-CCH %s +// CHECK-CCH: ObjCInterfaceDecl:{TypedText A} (65) +// CHECK-CCH: ObjCInterfaceDecl:{TypedText B} (65) +// CHECK-CCH: NotImplemented:{TypedText bycopy} (30) +// CHECK-CCH: NotImplemented:{TypedText byref} (30) +// CHECK-CCH-NOT: NotImplemented:{TypedText in} (30) +// CHECK-CCH: NotImplemented:{TypedText inout} (30) +// CHECK-CCH: NotImplemented:{TypedText oneway} (30) +// CHECK-CCH: NotImplemented:{TypedText out} (30) +// CHECK-CCH: NotImplemented:{TypedText unsigned} (65) +// CHECK-CCH: NotImplemented:{TypedText void} (65) +// CHECK-CCH: NotImplemented:{TypedText volatile} (65) diff --git a/test/Index/complete-natural.m b/test/Index/complete-natural.m new file mode 100644 index 0000000..e1aba39 --- /dev/null +++ b/test/Index/complete-natural.m @@ -0,0 +1,56 @@ +// Note: the run lines follow their respective tests, since line/column +// matter in this test. + +const char *in_string = "string"; +char in_char = 'a'; +// in comment +/* in comment */ +#warning blarg +#error blarg +#pragma mark this is the spot +// RUN: c-index-test -code-completion-at=%s:4:32 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// CHECK-CC1-NOT: : +// CHECK-CC1: DONE +// RUN: c-index-test -code-completion-at=%s:5:18 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: c-index-test -code-completion-at=%s:6:7 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: c-index-test -code-completion-at=%s:7:7 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: c-index-test -code-completion-at=%s:8:10 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: c-index-test -code-completion-at=%s:9:9 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: c-index-test -code-completion-at=%s:10:19 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t + +// Same tests as above, but with completion caching. +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:4:32 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:5:18 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:6:7 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:7 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:8:10 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:9:9 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:10:19 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t diff --git a/test/Index/complete-objc-message-id.m b/test/Index/complete-objc-message-id.m index a75ee4a..be42b9b 100644 --- a/test/Index/complete-objc-message-id.m +++ b/test/Index/complete-objc-message-id.m @@ -26,6 +26,11 @@ void message_id(B *b) { [[b superclass] B_method]; } +@implementation Unrelated ++ (id)alloc { + return [A alloc]; +} +@end // RUN: c-index-test -code-completion-at=%s:24:14 %s | FileCheck -check-prefix=CHECK-CC1 %s // CHECK-CC1: ObjCInstanceMethodDecl:{ResultType id}{TypedText autorelease} // CHECK-CC1-NOT: B_method @@ -40,3 +45,10 @@ void message_id(B *b) { // CHECK-CC3: ObjCInstanceMethodDecl:{ResultType id}{TypedText retain} +// RUN: c-index-test -code-completion-at=%s:31:13 %s | FileCheck -check-prefix=CHECK-SELECTOR-PREF %s +// CHECK-SELECTOR-PREF: ObjCClassMethodDecl:{ResultType id}{TypedText alloc} (17) +// CHECK-SELECTOR-PREF: ObjCClassMethodDecl:{ResultType Class}{TypedText class} (20) +// CHECK-SELECTOR-PREF: ObjCClassMethodDecl:{ResultType id}{TypedText init} (20) +// CHECK-SELECTOR-PREF: ObjCClassMethodDecl:{ResultType id}{TypedText new} (20) +// CHECK-SELECTOR-PREF: ObjCClassMethodDecl:{ResultType Class}{TypedText superclass} (20) + diff --git a/test/Index/complete-objc-message.m b/test/Index/complete-objc-message.m index 321d75f..f9d6710 100644 --- a/test/Index/complete-objc-message.m +++ b/test/Index/complete-objc-message.m @@ -1,6 +1,6 @@ // Note: the run lines follow their respective tests, since line/column // matter in this test. - +#define nil (void*)0 @protocol FooTestProtocol + protocolClassMethod; - protocolInstanceMethod : (int)value; @@ -96,9 +96,9 @@ void test_overload(Overload *ovl) { } @interface Ellipsis -- (int)Method:(int)i, ...; +- (int)Method:(int)i, ...; +- (int)SentinelMethod:(int)i, ... __attribute__((sentinel(0,1))); @end - void f(Ellipsis *e) { [e Method:1, 2, 3]; } @@ -122,43 +122,55 @@ void msg_id(id x) { [id Method:1 Arg1:1 OtherArg:ovl]; } +@interface A +- (void)method1; +@end + +@interface B : A +- (void)method2; +@end + +void test_ranking(B *b) { + [b method1]; +} + // RUN: c-index-test -code-completion-at=%s:23:19 %s | FileCheck -check-prefix=CHECK-CC1 %s // CHECK-CC1: {TypedText categoryClassMethod} -// CHECK-CC1: {TypedText classMethod1:}{Placeholder (id)a}{HorizontalSpace }{Text withKeyword:}{Placeholder (int)b} +// CHECK-CC1: {TypedText classMethod1:}{Placeholder (id)}{HorizontalSpace }{Text withKeyword:}{Placeholder (int)} // CHECK-CC1: {TypedText classMethod2} // CHECK-CC1: {TypedText new} // CHECK-CC1: {TypedText protocolClassMethod} // RUN: c-index-test -code-completion-at=%s:24:8 %s | FileCheck -check-prefix=CHECK-CC2 %s // CHECK-CC2: {TypedText categoryInstanceMethod} // CHECK-CC2: {TypedText instanceMethod1} -// CHECK-CC2: {TypedText protocolInstanceMethod:}{Placeholder (int)value} +// CHECK-CC2: {TypedText protocolInstanceMethod:}{Placeholder (int)} // RUN: c-index-test -code-completion-at=%s:61:16 %s | FileCheck -check-prefix=CHECK-CC3 %s -// CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyClassMethod:}{Placeholder (id)obj} +// CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyClassMethod:}{Placeholder (id)} // CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyPrivateMethod} // RUN: c-index-test -code-completion-at=%s:65:16 %s | FileCheck -check-prefix=CHECK-CC4 %s -// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)x}{HorizontalSpace }{Text second:}{Placeholder (id)y} +// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)}{HorizontalSpace }{Text second:}{Placeholder (id)} // CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyPrivateInstMethod} // RUN: c-index-test -code-completion-at=%s:74:9 %s | FileCheck -check-prefix=CHECK-CC5 %s -// CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)x}{HorizontalSpace }{Text second:}{Placeholder (id)y} +// CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)}{HorizontalSpace }{Text second:}{Placeholder (id)} // CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MySubInstMethod} // RUN: c-index-test -code-completion-at=%s:82:8 %s | FileCheck -check-prefix=CHECK-CC6 %s -// CHECK-CC6: ObjCInstanceMethodDecl:{ResultType id}{TypedText protocolInstanceMethod:}{Placeholder (int)value} +// CHECK-CC6: ObjCInstanceMethodDecl:{ResultType id}{TypedText protocolInstanceMethod:}{Placeholder (int)} // CHECK-CC6: ObjCInstanceMethodDecl:{ResultType int}{TypedText secondProtocolInstanceMethod} // RUN: c-index-test -code-completion-at=%s:95:8 %s | FileCheck -check-prefix=CHECK-CC7 %s // CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method} -// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i} -// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} -// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} -// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} -// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} +// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)} +// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)}{HorizontalSpace }{Text Arg1:}{Placeholder (int)}{HorizontalSpace }{Text Arg2:}{Placeholder (int)} +// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)}{HorizontalSpace }{Text Arg1:}{Placeholder (int)}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)} +// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)} +// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)}{HorizontalSpace }{Text Arg1:}{Placeholder (int)}{HorizontalSpace }{Text Arg2:}{Placeholder (int)} // RUN: c-index-test -code-completion-at=%s:95:17 %s | FileCheck -check-prefix=CHECK-CC8 %s // CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText } -// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} -// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} -// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} +// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)}{HorizontalSpace }{Text Arg2:}{Placeholder (int)} +// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)} +// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText SomeArg:}{Placeholder (int)}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)} // RUN: c-index-test -code-completion-at=%s:95:24 %s | FileCheck -check-prefix=CHECK-CC9 %s -// CHECK-CC9: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText Arg2:}{Placeholder (int)i2} -// CHECK-CC9: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText OtherArg:}{Placeholder (id)obj} +// CHECK-CC9: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText Arg2:}{Placeholder (int)} +// CHECK-CC9: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText OtherArg:}{Placeholder (id)} // RUN: c-index-test -code-completion-at=%s:61:11 %s | FileCheck -check-prefix=CHECK-CCA %s // CHECK-CCA: TypedefDecl:{TypedText Class} // CHECK-CCA-NEXT: ObjCInterfaceDecl:{TypedText Foo} @@ -170,22 +182,23 @@ void msg_id(id x) { // CHECK-CCA: {ResultType Class}{TypedText self} // CHECK-CCA: {TypedText super} // RUN: c-index-test -code-completion-at=%s:103:6 %s | FileCheck -check-prefix=CHECK-CCB %s -// CHECK-CCB: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i}{Placeholder , ...} +// CHECK-CCB: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int), ...} +// CHECK-CCB: ObjCInstanceMethodDecl:{ResultType int}{TypedText SentinelMethod:}{Placeholder (int), ...}{Text , nil} // RUN: c-index-test -code-completion-at=%s:116:14 %s | FileCheck -check-prefix=CHECK-CCC %s // CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method} -// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i} -// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} -// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} -// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} -// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} +// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)} +// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)}{HorizontalSpace }{Text Arg1:}{Placeholder (int)}{HorizontalSpace }{Text Arg2:}{Placeholder (int)} +// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)}{HorizontalSpace }{Text Arg1:}{Placeholder (int)}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)} +// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)} +// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)}{HorizontalSpace }{Text Arg1:}{Placeholder (int)}{HorizontalSpace }{Text Arg2:}{Placeholder (int)} // RUN: c-index-test -code-completion-at=%s:116:23 %s | FileCheck -check-prefix=CHECK-CCD %s // CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText } -// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} -// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} -// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} +// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)}{HorizontalSpace }{Text Arg2:}{Placeholder (int)} +// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)} +// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText SomeArg:}{Placeholder (int)}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)} // RUN: c-index-test -code-completion-at=%s:116:30 %s | FileCheck -check-prefix=CHECK-CCE %s -// CHECK-CCE: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText Arg2:}{Placeholder (int)i2} -// CHECK-CCE: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText OtherArg:}{Placeholder (id)obj} +// CHECK-CCE: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText Arg2:}{Placeholder (int)} +// CHECK-CCE: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText OtherArg:}{Placeholder (id)} // RUN: c-index-test -code-completion-at=%s:61:11 %s | FileCheck -check-prefix=CHECK-CCF %s // CHECK-CCF: TypedefDecl:{TypedText Class} // CHECK-CCF: ObjCInterfaceDecl:{TypedText Foo} @@ -199,31 +212,25 @@ void msg_id(id x) { // CHECK-CCG: ObjCInstanceMethodDecl:{ResultType id}{TypedText categoryInstanceMethod} // CHECK-CCG: ObjCInstanceMethodDecl:{ResultType id}{TypedText instanceMethod1} // CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method} -// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i} -// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} -// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} -// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} -// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)x}{HorizontalSpace }{Text second:}{Placeholder (id)y} +// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)}{HorizontalSpace }{Text second:}{Placeholder (id)} // CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyPrivateInstMethod} // CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MySubInstMethod} -// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MySubInstMethod:}{Placeholder (id)obj} -// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} -// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType id}{TypedText protocolInstanceMethod:}{Placeholder (int)value} +// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType id}{TypedText protocolInstanceMethod:}{Placeholder (int)} // CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText secondProtocolInstanceMethod} // RUN: c-index-test -code-completion-at=%s:121:14 %s | FileCheck -check-prefix=CHECK-CCG %s // RUN: c-index-test -code-completion-at=%s:122:7 %s | FileCheck -check-prefix=CHECK-CCH %s // CHECK-CCH: ObjCClassMethodDecl:{ResultType id}{TypedText categoryClassMethod} -// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod1:}{Placeholder (id)a}{HorizontalSpace }{Text withKeyword:}{Placeholder (int)b} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod1:}{Placeholder (id)}{HorizontalSpace }{Text withKeyword:}{Placeholder (int)} // CHECK-CCH: ObjCClassMethodDecl:{ResultType void}{TypedText classMethod2} // CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method} -// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i} -// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} -// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} -// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} -// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MyClassMethod:}{Placeholder (id)obj} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MyClassMethod:}{Placeholder (id)} // CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MyPrivateMethod} // CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MySubClassMethod} // CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MySubPrivateMethod} // CHECK-CCH: ObjCClassMethodDecl:{ResultType id}{TypedText new} -// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)}{HorizontalSpace }{Text Arg1:}{Placeholder (int)}{HorizontalSpace }{Text Arg2:}{Placeholder (int)} // CHECK-CCH: ObjCClassMethodDecl:{ResultType id}{TypedText protocolClassMethod} +// RUN: c-index-test -code-completion-at=%s:134:6 %s | FileCheck -check-prefix=CHECK-CCI %s +// CHECK-CCI: ObjCInstanceMethodDecl:{ResultType void}{TypedText method1} (22) +// CHECK-CCI: ObjCInstanceMethodDecl:{ResultType void}{TypedText method2} (20) diff --git a/test/Index/complete-pch.m b/test/Index/complete-pch.m index 09192ae..517d49c 100644 --- a/test/Index/complete-pch.m +++ b/test/Index/complete-pch.m @@ -16,11 +16,11 @@ void msg_id(id x) { // Run the actual tests // RUN: c-index-test -code-completion-at=%s:10:7 -include %t.h %s | FileCheck -check-prefix=CHECK-CC1 %s -// CHECK-CC1: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod1:}{Placeholder (double)d} -// CHECK-CC1: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod2:}{Placeholder (float)f} -// CHECK-CC1: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod3:}{Placeholder (float)f} +// CHECK-CC1: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod1:}{Placeholder (double)} +// CHECK-CC1: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod2:}{Placeholder (float)} +// CHECK-CC1: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod3:}{Placeholder (float)} // RUN: c-index-test -code-completion-at=%s:11:6 -include %t.h %s | FileCheck -check-prefix=CHECK-CC2 %s -// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType int}{TypedText instanceMethod1:}{Placeholder (int)x} -// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType int}{TypedText instanceMethod2:}{Placeholder (int)x} -// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType int}{TypedText instanceMethod3:}{Placeholder (int)x} +// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType int}{TypedText instanceMethod1:}{Placeholder (int)} +// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType int}{TypedText instanceMethod2:}{Placeholder (int)} +// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType int}{TypedText instanceMethod3:}{Placeholder (int)} diff --git a/test/Index/complete-preprocessor.m b/test/Index/complete-preprocessor.m new file mode 100644 index 0000000..1873dad --- /dev/null +++ b/test/Index/complete-preprocessor.m @@ -0,0 +1,80 @@ +// The line and column layout of this test is significant. Run lines +// are at the end. + +#if 1 +#endif + +#define FOO(a, b) a##b +#define BAR +#ifdef FOO +#endif +#if defined(FOO) +#endif + +FOO(in,t) value; + +// RUN: c-index-test -code-completion-at=%s:4:2 %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: NotImplemented:{TypedText define}{HorizontalSpace }{Placeholder macro} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText define}{HorizontalSpace }{Placeholder macro}{LeftParen (}{Placeholder args}{RightParen )} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText error}{HorizontalSpace }{Placeholder message} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText if}{HorizontalSpace }{Placeholder condition} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText ifdef}{HorizontalSpace }{Placeholder macro} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText ifndef}{HorizontalSpace }{Placeholder macro} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText import}{HorizontalSpace }{Text "}{Placeholder header}{Text "} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText import}{HorizontalSpace }{Text <}{Placeholder header}{Text >} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText include}{HorizontalSpace }{Text "}{Placeholder header}{Text "} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText include}{HorizontalSpace }{Text <}{Placeholder header}{Text >} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText include_next}{HorizontalSpace }{Text "}{Placeholder header}{Text "} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText include_next}{HorizontalSpace }{Text <}{Placeholder header}{Text >} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText line}{HorizontalSpace }{Placeholder number} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText line}{HorizontalSpace }{Placeholder number}{HorizontalSpace }{Text "}{Placeholder filename}{Text "} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText pragma}{HorizontalSpace }{Placeholder arguments} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText undef}{HorizontalSpace }{Placeholder macro} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText warning}{HorizontalSpace }{Placeholder message} (30) +// RUN: c-index-test -code-completion-at=%s:5:2 %s | FileCheck -check-prefix=CHECK-CC2 %s +// CHECK-CC2: NotImplemented:{TypedText define}{HorizontalSpace }{Placeholder macro} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText define}{HorizontalSpace }{Placeholder macro}{LeftParen (}{Placeholder args}{RightParen )} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText elif}{HorizontalSpace }{Placeholder condition} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText else} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText endif} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText error}{HorizontalSpace }{Placeholder message} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText if}{HorizontalSpace }{Placeholder condition} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText ifdef}{HorizontalSpace }{Placeholder macro} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText ifndef}{HorizontalSpace }{Placeholder macro} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText import}{HorizontalSpace }{Text "}{Placeholder header}{Text "} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText import}{HorizontalSpace }{Text <}{Placeholder header}{Text >} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText include}{HorizontalSpace }{Text "}{Placeholder header}{Text "} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText include}{HorizontalSpace }{Text <}{Placeholder header}{Text >} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText include_next}{HorizontalSpace }{Text "}{Placeholder header}{Text "} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText include_next}{HorizontalSpace }{Text <}{Placeholder header}{Text >} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText line}{HorizontalSpace }{Placeholder number} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText line}{HorizontalSpace }{Placeholder number}{HorizontalSpace }{Text "}{Placeholder filename}{Text "} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText pragma}{HorizontalSpace }{Placeholder arguments} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText undef}{HorizontalSpace }{Placeholder macro} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText warning}{HorizontalSpace }{Placeholder message} (30) +// RUN: c-index-test -code-completion-at=%s:9:8 %s | FileCheck -check-prefix=CHECK-CC3 %s +// CHECK-CC3: NotImplemented:{TypedText BAR} (30) +// CHECK-CC3: NotImplemented:{TypedText FOO} (30) +// RUN: c-index-test -code-completion-at=%s:11:12 %s | FileCheck -check-prefix=CHECK-CC3 %s +// RUN: c-index-test -code-completion-at=%s:11:13 %s | FileCheck -check-prefix=CHECK-CC3 %s +// RUN: c-index-test -code-completion-at=%s:11:5 %s | FileCheck -check-prefix=CHECK-CC4 %s +// CHECK-CC4: macro definition:{TypedText BAR} (70) +// CHECK-CC4: macro definition:{TypedText FOO}{LeftParen (}{Placeholder a}{Comma , }{Placeholder b}{RightParen )} (70) +// RUN: c-index-test -code-completion-at=%s:14:5 %s | FileCheck -check-prefix=CHECK-CC5 %s +// CHECK-CC5: NotImplemented:{TypedText const} (65) +// CHECK-CC5: NotImplemented:{TypedText double} (65) +// CHECK-CC5: NotImplemented:{TypedText enum} (65) +// CHECK-CC5: NotImplemented:{TypedText extern} (30) +// CHECK-CC5: NotImplemented:{TypedText float} (65) +// CHECK-CC5: macro definition:{TypedText FOO}{LeftParen (}{Placeholder a}{Comma , }{Placeholder b}{RightParen )} (70) +// CHECK-CC5: TypedefDecl:{TypedText id} (65) +// CHECK-CC5: NotImplemented:{TypedText inline} (30) +// CHECK-CC5: NotImplemented:{TypedText int} (65) +// CHECK-CC5: NotImplemented:{TypedText long} (65) + +// Same tests as above, but with completion caching. +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:4:2 %s | FileCheck -check-prefix=CHECK-CC1 %s +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:5:2 %s | FileCheck -check-prefix=CHECK-CC2 %s +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:9:8 %s | FileCheck -check-prefix=CHECK-CC3 %s +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:11:5 %s | FileCheck -check-prefix=CHECK-CC4 %s +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:14:5 %s | FileCheck -check-prefix=CHECK-CC5 %s diff --git a/test/Index/complete-recovery.m b/test/Index/complete-recovery.m index e03834e..fbd92c7 100644 --- a/test/Index/complete-recovery.m +++ b/test/Index/complete-recovery.m @@ -18,7 +18,7 @@ // CHECK-CC1: VarDecl:{ResultType A *}{TypedText a} // CHECK-CC1: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} -// RUN: c-index-test -code-completion-at=%s:10:24 -Xclang -code-completion-patterns %s 2>%t | FileCheck -check-prefix=CHECK-CC2 %s +// RUN: c-index-test -code-completion-at=%s:10:24 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC2 %s // CHECK-CC2: NotImplemented:{TypedText @encode}{LeftParen (}{Placeholder type-name}{RightParen )} // CHECK-CC2: NotImplemented:{TypedText _Bool} // CHECK-CC2: VarDecl:{ResultType A *}{TypedText a} diff --git a/test/Index/complete-super.cpp b/test/Index/complete-super.cpp new file mode 100644 index 0000000..49f94e4 --- /dev/null +++ b/test/Index/complete-super.cpp @@ -0,0 +1,33 @@ +// The run lines are below, because this test is line- and +// column-number sensitive. + +struct A { + virtual void foo(int x, int y); + virtual void bar(double x); + virtual void bar(float x); +}; + +struct B : A { + void foo(int a, int b); + void bar(float real); +}; + +void B::foo(int a, int b) { + A::foo(a, b); +} + +void B::bar(float real) { + A::bar(real); +} + +// RUN: c-index-test -code-completion-at=%s:16:3 %s | FileCheck -check-prefix=CHECK-FOO-UNQUAL %s +// CHECK-FOO-UNQUAL: CXXMethod:{Text A::}{TypedText foo}{LeftParen (}{Placeholder a}{Comma , }{Placeholder b}{RightParen )} (8) + +// RUN: c-index-test -code-completion-at=%s:20:3 %s | FileCheck -check-prefix=CHECK-BAR-UNQUAL %s +// CHECK-BAR-UNQUAL: CXXMethod:{Text A::}{TypedText bar}{LeftParen (}{Placeholder real}{RightParen )} (8) +// CHECK-BAR-UNQUAL: CXXMethod:{ResultType void}{TypedText bar}{LeftParen (}{Placeholder float real}{RightParen )} (14) +// CHECK-BAR-UNQUAL: CXXMethod:{ResultType void}{Text A::}{TypedText bar}{LeftParen (}{Placeholder double x}{RightParen )} (16) + +// RUN: c-index-test -code-completion-at=%s:16:6 %s | FileCheck -check-prefix=CHECK-FOO-QUAL %s +// CHECK-FOO-QUAL: CXXMethod:{TypedText foo}{LeftParen (}{Placeholder a}{Comma , }{Placeholder b}{RightParen )} (8) + diff --git a/test/Index/complete-super.m b/test/Index/complete-super.m new file mode 100644 index 0000000..fc60c6c --- /dev/null +++ b/test/Index/complete-super.m @@ -0,0 +1,55 @@ +// Note: the run lines follow their respective tests, since line/column +// matter in this test. + +typedef int Bool; + +@interface A +- (void)add:(int)x to:(int)y; ++ (void)select:(Bool)condition first:(int)x second:(int)y; +- (void)last; ++ (void)last; +@end + +@interface B : A +- (void)add:(int)x to:(int)y; ++ (void)select:(Bool)condition first:(int)x second:(int)y; +@end + +@implementation B +- (void)add:(int)a to:(int)b { + [super add:a to:b]; +} + ++ (void)select:(Bool)condition first:(int)a second:(int)b { + [super selector:condition first:a second:b]; +} +@end + +// Check "super" completion as a message receiver. +// RUN: c-index-test -code-completion-at=%s:20:4 %s | FileCheck -check-prefix=CHECK-ADD-RECEIVER %s +// CHECK-ADD-RECEIVER: ObjCInstanceMethodDecl:{ResultType void}{TypedText super}{HorizontalSpace }{Text add:}{Placeholder a}{HorizontalSpace }{Text to:}{Placeholder b} (8) + +// RUN: c-index-test -code-completion-at=%s:24:4 %s | FileCheck -check-prefix=CHECK-SELECT-RECEIVER %s +// CHECK-SELECT-RECEIVER: ObjCClassMethodDecl:{ResultType void}{TypedText super}{HorizontalSpace }{Text select:}{Placeholder condition}{HorizontalSpace }{Text first:}{Placeholder a}{HorizontalSpace }{Text second:}{Placeholder b} (8) + +// Check "super" completion at the first identifier +// RUN: c-index-test -code-completion-at=%s:20:10 %s | FileCheck -check-prefix=CHECK-ADD-ADD %s +// CHECK-ADD-ADD: ObjCInstanceMethodDecl:{ResultType void}{TypedText add:}{Placeholder a}{HorizontalSpace }{Text to:}{Placeholder b} (8) +// CHECK-ADD-ADD-NOT: add +// CHECK-ADD-ADD: ObjCInstanceMethodDecl:{ResultType void}{TypedText last} (20) + +// RUN: c-index-test -code-completion-at=%s:24:10 %s | FileCheck -check-prefix=CHECK-SELECTOR-SELECTOR %s +// CHECK-SELECTOR-SELECTOR-NOT: x +// CHECK-SELECTOR-SELECTOR: ObjCClassMethodDecl:{ResultType void}{TypedText last} (20) +// CHECK-SELECTOR-SELECTOR: ObjCClassMethodDecl:{ResultType void}{TypedText select:}{Placeholder condition}{HorizontalSpace }{Text first:}{Placeholder a}{HorizontalSpace }{Text second:}{Placeholder b} (8) + +// Check "super" completion at the second identifier +// RUN: c-index-test -code-completion-at=%s:20:16 %s | FileCheck -check-prefix=CHECK-ADD-TO %s +// CHECK-ADD-TO: ObjCInstanceMethodDecl:{ResultType void}{Informative add:}{TypedText to:}{Placeholder b} (8) + +// RUN: c-index-test -code-completion-at=%s:24:28 %s | FileCheck -check-prefix=CHECK-SELECTOR-FIRST %s +// CHECK-SELECTOR-FIRST: ObjCClassMethodDecl:{ResultType void}{Informative select:}{TypedText first:}{Placeholder a}{HorizontalSpace }{Text second:}{Placeholder b} (8) + +// Check "super" completion at the third identifier +// RUN: c-index-test -code-completion-at=%s:24:37 %s | FileCheck -check-prefix=CHECK-SELECTOR-SECOND %s +// CHECK-SELECTOR-SECOND: ObjCClassMethodDecl:{ResultType void}{Informative select:}{Informative first:}{TypedText second:}{Placeholder b} (8) diff --git a/test/Index/complete-templates.cpp b/test/Index/complete-templates.cpp new file mode 100644 index 0000000..2f2302d --- /dev/null +++ b/test/Index/complete-templates.cpp @@ -0,0 +1,19 @@ +// Tests are line- and column-sensive, so run lines are below. + +template<typename T> +class X { + X(); + X(const X&); + + template<typename U> X(U); +}; + +template<typename T> void f(T); + +void test() { + +} + +// RUN: c-index-test -code-completion-at=%s:14:2 %s | FileCheck %s +// CHECK: FunctionTemplate:{ResultType void}{TypedText f}{LeftParen (}{Placeholder T}{RightParen )} (45) +// CHECK: ClassTemplate:{TypedText X}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50) diff --git a/test/Index/complete-unterminated.c b/test/Index/complete-unterminated.c new file mode 100644 index 0000000..56e6ae1 --- /dev/null +++ b/test/Index/complete-unterminated.c @@ -0,0 +1,30 @@ +typedef int Integer; + +#if 0 + + +#endif + +/* blah */ + +void f0(const char*); +void f1(char); + +const char *hello = "Hello, world"; +const char a = 'a'; + +#define FOO(a, b) a b + +FOO(int, x); + +// RUN: c-index-test -code-completion-at=%s:5:1 -pedantic %s 2> %t.err | FileCheck %s +// RUN: not grep error %t.err +// CHECK: {TypedText Integer} +// RUN: c-index-test -code-completion-at=%s:8:6 -pedantic %s 2> %t.err +// RUN: not grep error %t.err +// RUN: c-index-test -code-completion-at=%s:10:28 -pedantic %s 2> %t.err +// RUN: not grep unterminated %t.err +// RUN: c-index-test -code-completion-at=%s:11:17 -pedantic %s 2> %t.err +// RUN: not grep unterminated %t.err +// RUN: c-index-test -code-completion-at=%s:18:10 -pedantic %s 2> %t.err +// RUN: not grep unterminated %t.err diff --git a/test/Index/crash-recovery-code-complete.c b/test/Index/crash-recovery-code-complete.c new file mode 100644 index 0000000..a80bdc2 --- /dev/null +++ b/test/Index/crash-recovery-code-complete.c @@ -0,0 +1,10 @@ +// RUN: env CINDEXTEST_EDITING=1 \ +// RUN: not c-index-test -code-completion-at=%s:20:1 \ +// RUN: "-remap-file=%s;%S/Inputs/crash-recovery-code-complete-remap.c" \ +// RUN: %s 2> %t.err +// RUN: FileCheck < %t.err -check-prefix=CHECK-CODE-COMPLETE-CRASH %s +// CHECK-CODE-COMPLETE-CRASH: Unable to perform code completion! +// +// REQUIRES: crash-recovery + +#warning parsing original file diff --git a/test/Index/crash-recovery-reparse.c b/test/Index/crash-recovery-reparse.c new file mode 100644 index 0000000..e394bd1 --- /dev/null +++ b/test/Index/crash-recovery-reparse.c @@ -0,0 +1,10 @@ +// RUN: env CINDEXTEST_EDITING=1 \ +// RUN: not c-index-test -test-load-source-reparse 1 local \ +// RUN: -remap-file="%s;%S/Inputs/crash-recovery-reparse-remap.c" \ +// RUN: %s 2> %t.err +// RUN: FileCheck < %t.err -check-prefix=CHECK-REPARSE-SOURCE-CRASH %s +// CHECK-REPARSE-SOURCE-CRASH: Unable to reparse translation unit +// +// REQUIRES: crash-recovery + +#warning parsing original file diff --git a/test/Index/crash-recovery.c b/test/Index/crash-recovery.c new file mode 100644 index 0000000..b7f6e0b --- /dev/null +++ b/test/Index/crash-recovery.c @@ -0,0 +1,7 @@ +// RUN: not c-index-test -test-load-source all %s 2> %t.err +// RUN: FileCheck < %t.err -check-prefix=CHECK-LOAD-SOURCE-CRASH %s +// CHECK-LOAD-SOURCE-CRASH: Unable to load translation unit +// +// REQUIRES: crash-recovery + +#pragma clang __debug crash diff --git a/test/Index/index-templates.cpp b/test/Index/index-templates.cpp new file mode 100644 index 0000000..a4f1ee8 --- /dev/null +++ b/test/Index/index-templates.cpp @@ -0,0 +1,147 @@ +// Test is line- and column-sensitive. See run lines below. + +template<typename T, T Value, template<typename U, U ValU> class X> +void f(X<T, Value> x); + +template<typename T> class allocator; + +template<typename T, typename Alloc = allocator<T> > +class vector { + void clear(); +}; + +template<typename T> +class vector<T*> { }; + +struct Z1 { }; + +template class vector<Z1>; + +struct Z2 { }; + +template<> +class vector<Z2> { + void clear(); +}; + +template<typename T, typename U> +struct Y { + using typename T::type; + using U::operator Z2; +}; + +struct Z3 { }; + +const unsigned OneDimension = 1; +template<typename T, unsigned Dimensions = OneDimension> +struct array { }; + +template<template<typename, unsigned> class DataStructure = array> +struct storage { }; + +typedef unsigned Unsigned; + +template<typename T, Unsigned Value> +struct value_c; + +template class vector<int*>; + +struct Z4 { + template<typename T> T getAs(); +}; + +void template_exprs() { + f<Unsigned, OneDimension, array>(array<Unsigned, OneDimension>()); + Z4().getAs<Unsigned>(); +} + +// RUN: c-index-test -test-load-source all %s | FileCheck -check-prefix=CHECK-LOAD %s +// CHECK-LOAD: index-templates.cpp:4:6: FunctionTemplate=f:4:6 Extent=[3:1 - 4:22] +// CHECK-LOAD: index-templates.cpp:3:19: TemplateTypeParameter=T:3:19 (Definition) Extent=[3:19 - 3:20] +// CHECK-LOAD: index-templates.cpp:3:24: NonTypeTemplateParameter=Value:3:24 (Definition) Extent=[3:22 - 3:29] +// FIXME: Need the template type parameter here +// CHECK-LOAD: index-templates.cpp:3:66: TemplateTemplateParameter=X:3:66 (Definition) Extent=[3:31 - 3:67] +// CHECK-LOAD: index-templates.cpp:4:20: ParmDecl=x:4:20 (Definition) Extent=[4:8 - 4:21] +// CHECK-LOAD: index-templates.cpp:4:8: TemplateRef=X:3:66 Extent=[4:8 - 4:9] +// FIXME: Need the template type parameter here +// CHECK-LOAD: index-templates.cpp:4:13: DeclRefExpr=Value:3:24 Extent=[4:13 - 4:18] +// CHECK-LOAD: index-templates.cpp:6:28: ClassTemplate=allocator:6:28 Extent=[6:1 - 6:37] +// CHECK-LOAD: index-templates.cpp:6:19: TemplateTypeParameter=T:6:19 (Definition) Extent=[6:19 - 6:20] +// CHECK-LOAD: index-templates.cpp:9:7: ClassTemplate=vector:9:7 (Definition) Extent=[8:1 - 11:2] +// CHECK-LOAD: index-templates.cpp:8:19: TemplateTypeParameter=T:8:19 (Definition) Extent=[8:19 - 8:20] +// CHECK-LOAD: index-templates.cpp:8:31: TemplateTypeParameter=Alloc:8:31 (Definition) Extent=[8:31 - 8:36] +// CHECK-LOAD: index-templates.cpp:8:39: TemplateRef=allocator:6:28 Extent=[8:39 - 8:48] +// CHECK-LOAD: index-templates.cpp:10:8: CXXMethod=clear:10:8 Extent=[10:8 - 10:15] +// CHECK-LOAD: index-templates.cpp:14:7: ClassTemplatePartialSpecialization=vector:14:7 (Definition) [Specialization of vector:9:7] Extent=[13:1 - 14:21] +// CHECK-LOAD: index-templates.cpp:13:19: TemplateTypeParameter=T:13:19 (Definition) Extent=[13:19 - 13:20] +// CHECK-LOAD: index-templates.cpp:16:8: StructDecl=Z1:16:8 (Definition) Extent=[16:1 - 16:14] +// CHECK-LOAD: index-templates.cpp:18:16: ClassDecl=vector:18:16 (Definition) [Specialization of vector:9:7] Extent=[18:1 - 18:22] +// CHECK-LOAD: index-templates.cpp:18:23: TypeRef=struct Z1:16:8 Extent=[18:23 - 18:25] +// CHECK-LOAD-NOT: CXXMethod=clear +// CHECK-LOAD: index-templates.cpp:20:8: StructDecl=Z2:20:8 (Definition) Extent=[20:1 - 20:14] +// CHECK-LOAD: index-templates.cpp:23:7: ClassDecl=vector:23:7 (Definition) [Specialization of vector:9:7] Extent=[22:1 - 25:2] +// CHECK-LOAD: index-templates.cpp:23:14: TypeRef=struct Z2:20:8 Extent=[23:14 - 23:16] +// CHECK-LOAD: index-templates.cpp:24:8: CXXMethod=clear:24:8 Extent=[24:8 - 24:15] +// CHECK-LOAD: index-templates.cpp:28:8: ClassTemplate=Y:28:8 (Definition) Extent=[27:1 - 31:2] +// CHECK-LOAD: index-templates.cpp:27:19: TemplateTypeParameter=T:27:19 (Definition) Extent=[27:19 - 27:20] +// CHECK-LOAD: index-templates.cpp:27:31: TemplateTypeParameter=U:27:31 (Definition) Extent=[27:31 - 27:32] +// CHECK-LOAD: index-templates.cpp:29:21: UsingDeclaration=type:29:21 Extent=[29:3 - 29:25] +// CHECK-LOAD: index-templates.cpp:30:12: UsingDeclaration=operator Z2:30:12 Extent=[30:3 - 30:23] +// CHECK-LOAD: index-templates.cpp:30:21: TypeRef=struct Z2:20:8 Extent=[30:21 - 30:23] +// CHECK-LOAD: index-templates.cpp:35:16: VarDecl=OneDimension:35:16 (Definition) Extent=[35:7 - 35:32] +// CHECK-LOAD: index-templates.cpp:35:31: UnexposedExpr= Extent=[35:31 - 35:32] +// CHECK-LOAD: index-templates.cpp:35:31: UnexposedExpr= Extent=[35:31 - 35:32] +// CHECK-LOAD: index-templates.cpp:37:8: ClassTemplate=array:37:8 (Definition) Extent=[36:1 - 37:17] +// CHECK-LOAD: index-templates.cpp:36:19: TemplateTypeParameter=T:36:19 (Definition) Extent=[36:19 - 36:20] +// CHECK-LOAD: index-templates.cpp:36:31: NonTypeTemplateParameter=Dimensions:36:31 (Definition) Extent=[36:22 - 36:41] +// CHECK-LOAD: index-templates.cpp:36:44: DeclRefExpr=OneDimension:35:16 Extent=[36:44 - 36:56] +// CHECK-LOAD: index-templates.cpp:40:8: ClassTemplate=storage:40:8 (Definition) Extent=[39:1 - 40:19] +// CHECK-LOAD: index-templates.cpp:39:45: TemplateTemplateParameter=DataStructure:39:45 (Definition) Extent=[39:10 - 39:66] +// CHECK-LOAD: index-templates.cpp:39:19: TemplateTypeParameter=:39:19 (Definition) Extent=[39:19 - 39:27] +// CHECK-LOAD: index-templates.cpp:39:37: NonTypeTemplateParameter=:39:37 (Definition) Extent=[39:29 - 39:38] +// CHECK-LOAD: index-templates.cpp:39:61: TemplateRef=array:37:8 Extent=[39:61 - 39:66] +// CHECK-LOAD: index-templates.cpp:42:18: TypedefDecl=Unsigned:42:18 (Definition) Extent=[42:18 - 42:26] +// CHECK-LOAD: index-templates.cpp:45:8: ClassTemplate=value_c:45:8 Extent=[44:1 - 45:15] +// CHECK-LOAD: index-templates.cpp:44:19: TemplateTypeParameter=T:44:19 (Definition) Extent=[44:19 - 44:20] +// CHECK-LOAD: index-templates.cpp:44:31: NonTypeTemplateParameter=Value:44:31 (Definition) Extent=[44:22 - 44:36] +// CHECK-LOAD: index-templates.cpp:44:22: TypeRef=Unsigned:42:18 Extent=[44:22 - 44:30] +// CHECK-LOAD: index-templates.cpp:47:16: ClassDecl=vector:47:16 (Definition) [Specialization of vector:14:7] Extent=[47:1 - 47:22] +// CHECK-LOAD: index-templates.cpp:49:8: StructDecl=Z4:49:8 (Definition) Extent=[49:1 - 51:2] +// CHECK-LOAD: index-templates.cpp:50:26: FunctionTemplate=getAs:50:26 Extent=[50:3 - 50:33] +// CHECK-LOAD: index-templates.cpp:50:21: TemplateTypeParameter=T:50:21 (Definition) Extent=[50:21 - 50:22] +// CHECK-LOAD: index-templates.cpp:53:6: FunctionDecl=template_exprs:53:6 (Definition) +// CHECK-LOAD: <invalid loc>:0:0: UnexposedStmt= +// CHECK-LOAD: index-templates.cpp:54:3: CallExpr=f:4:6 Extent=[54:3 - 54:68] +// CHECK-LOAD: index-templates.cpp:54:3: UnexposedExpr=f:4:6 Extent=[54:3 - 54:35] +// CHECK-LOAD: index-templates.cpp:54:3: DeclRefExpr=f:4:6 Extent=[54:3 - 54:35] +// CHECK-LOAD: index-templates.cpp:54:5: TypeRef=Unsigned:42:18 Extent=[54:5 - 54:13] +// CHECK-LOAD: index-templates.cpp:54:15: DeclRefExpr=OneDimension:35:16 Extent=[54:15 - 54:27] +// CHECK-LOAD: index-templates.cpp:54:29: TemplateRef=array:37:8 Extent=[54:29 - 54:34] +// CHECK-LOAD: index-templates.cpp:55:8: MemberRefExpr=getAs:50:26 Extent=[55:3 - 55:23] +// CHECK-LOAD: index-templates.cpp:55:3: CallExpr= Extent=[55:3 - 55:7] +// CHECK-LOAD: index-templates.cpp:55:14: TypeRef=Unsigned:42:18 Extent=[55:14 - 55:22] + +// RUN: c-index-test -test-load-source-usrs all %s | FileCheck -check-prefix=CHECK-USRS %s +// CHECK-USRS: index-templates.cpp c:@FT@>3#T#Nt0.0#t>2#T#Nt1.0f#>t0.22t0.0# Extent=[3:1 - 4:22] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@79 Extent=[3:19 - 3:20] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@82 Extent=[3:22 - 3:29] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@91 Extent=[3:31 - 3:67] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@136@FT@>3#T#Nt0.0#t>2#T#Nt1.0f#>t0.22t0.0#@x Extent=[4:8 - 4:21] +// CHECK-USRS: index-templates.cpp c:@CT>1#T@allocator Extent=[6:1 - 6:37] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@171 Extent=[6:19 - 6:20] +// CHECK-USRS: index-templates.cpp c:@CT>2#T#T@vector Extent=[8:1 - 11:2] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@210 Extent=[8:19 - 8:20] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@222 Extent=[8:31 - 8:36] +// CHECK-USRS: index-templates.cpp c:@CT>2#T#T@vector@F@clear# Extent=[10:8 - 10:15] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@280@CP>1#T@vector>#*t0.0#>@CT>1#T@allocator1*t0.0 Extent=[13:1 - 14:21] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@298 Extent=[13:19 - 13:20] +// CHECK-USRS: index-templates.cpp c:@S@Z1 Extent=[16:1 - 16:14] +// CHECK-USRS: index-templates.cpp c:@C@vector>#$@S@Z1#$@C@allocator>#$@S@Z1 Extent=[18:1 - 18:22] +// CHECK-USRS: index-templates.cpp c:@S@Z2 Extent=[20:1 - 20:14] +// CHECK-USRS: index-templates.cpp c:@C@vector>#$@S@Z2#$@C@allocator>#$@S@Z2 Extent=[22:1 - 25:2] +// CHECK-USRS: index-templates.cpp c:@C@vector>#$@S@Z2#$@C@allocator>#$@S@Z2@F@clear# Extent=[24:8 - 24:15] +// CHECK-USRS: index-templates.cpp c:@ST>2#T#T@Y Extent=[27:1 - 31:2] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@452 Extent=[27:19 - 27:20] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@464 Extent=[27:31 - 27:32] +// CHECK-USRS-NOT: type +// CHECK-USRS: index-templates.cpp c:@S@Z3 Extent=[33:1 - 33:14] diff --git a/test/Index/invalid-rdar-8236270.cpp b/test/Index/invalid-rdar-8236270.cpp new file mode 100644 index 0000000..6fd088d --- /dev/null +++ b/test/Index/invalid-rdar-8236270.cpp @@ -0,0 +1,11 @@ +// RUN: c-index-test -test-load-source all %s 2>&1 | FileCheck %s + +// This test case previously just crashed the frontend. + +struct abc *P; +int main( + +// CHECK: StructDecl=abc:5:8 Extent=[5:1 - 5:11] +// CHECK: VarDecl=P:5:13 (Definition) Extent=[5:8 - 5:14] +// CHECK: VarDecl=main:6:5 (Definition) Extent=[6:1 - 6:9] + diff --git a/test/Index/load-classes.cpp b/test/Index/load-classes.cpp new file mode 100644 index 0000000..349ebde --- /dev/null +++ b/test/Index/load-classes.cpp @@ -0,0 +1,28 @@ +// Test is line- and column-sensitive; see below. + +struct X { + X(int value); + X(const X& x); + ~X(); + operator X*(); +}; + +X::X(int value) { +} + +// RUN: c-index-test -test-load-source all %s | FileCheck %s +// CHECK: load-classes.cpp:3:8: StructDecl=X:3:8 (Definition) Extent=[3:1 - 8:2] +// CHECK: load-classes.cpp:4:3: CXXConstructor=X:4:3 Extent=[4:3 - 4:15] +// FIXME: missing TypeRef in the constructor name +// CHECK: load-classes.cpp:4:9: ParmDecl=value:4:9 (Definition) Extent=[4:5 - 4:14] +// CHECK: load-classes.cpp:5:3: CXXConstructor=X:5:3 Extent=[5:3 - 5:16] +// FIXME: missing TypeRef in the constructor name +// CHECK: load-classes.cpp:5:14: ParmDecl=x:5:14 (Definition) Extent=[5:11 - 5:15] +// CHECK: load-classes.cpp:5:11: TypeRef=struct X:3:8 Extent=[5:11 - 5:12] +// CHECK: load-classes.cpp:6:3: CXXDestructor=~X:6:3 Extent=[6:3 - 6:7] +// FIXME: missing TypeRef in the destructor name +// CHECK: load-classes.cpp:7:3: CXXConversion=operator struct X *:7:3 Extent=[7:3 - 7:16] +// CHECK: load-classes.cpp:7:12: TypeRef=struct X:3:8 Extent=[7:12 - 7:13] +// CHECK: load-classes.cpp:10:4: CXXConstructor=X:10:4 (Definition) Extent=[10:4 - 11:2] +// CHECK: load-classes.cpp:10:1: TypeRef=struct X:3:8 Extent=[10:1 - 10:2] +// CHECK: load-classes.cpp:10:10: ParmDecl=value:10:10 (Definition) Extent=[10:6 - 10:15] diff --git a/test/Index/load-decls.c b/test/Index/load-decls.c new file mode 100644 index 0000000..cf88f42 --- /dev/null +++ b/test/Index/load-decls.c @@ -0,0 +1,16 @@ +enum Color { + Red, + Green, + Blue, + + Rouge = Red +}; + +// RUN: c-index-test -test-load-source all %s | FileCheck %s +// CHECK: load-decls.c:1:6: EnumDecl=Color:1:6 (Definition) Extent=[1:1 - 7:2] +// CHECK: load-decls.c:2:3: EnumConstantDecl=Red:2:3 (Definition) Extent=[2:3 - 2:6] +// CHECK: load-decls.c:3:3: EnumConstantDecl=Green:3:3 (Definition) Extent=[3:3 - 3:8] +// CHECK: load-decls.c:4:3: EnumConstantDecl=Blue:4:3 (Definition) Extent=[4:3 - 4:7] +// CHECK: load-decls.c:6:3: EnumConstantDecl=Rouge:6:3 (Definition) Extent=[6:3 - 6:14] +// CHECK: load-decls.c:6:11: UnexposedExpr=Red:2:3 Extent=[6:11 - 6:14] +// CHECK: load-decls.c:6:11: DeclRefExpr=Red:2:3 Extent=[6:11 - 6:14] diff --git a/test/Index/load-namespaces.cpp b/test/Index/load-namespaces.cpp new file mode 100644 index 0000000..241e241 --- /dev/null +++ b/test/Index/load-namespaces.cpp @@ -0,0 +1,50 @@ +// Test is line- and column-sensitive; see below. + +namespace std { + namespace rel_ops { + void f(); + } +} + +namespace std { + void g(); +} + +namespace std98 = std; +namespace std0x = std98; + +using namespace std0x; + +namespace std { + int g(int); +} + +using std::g; + +void std::g() { +} + +namespace my_rel_ops = std::rel_ops; + +// RUN: c-index-test -test-load-source all %s | FileCheck %s +// CHECK: load-namespaces.cpp:3:11: Namespace=std:3:11 (Definition) Extent=[3:11 - 7:2] +// CHECK: load-namespaces.cpp:4:13: Namespace=rel_ops:4:13 (Definition) Extent=[4:13 - 6:4] +// CHECK: load-namespaces.cpp:5:10: FunctionDecl=f:5:10 Extent=[5:10 - 5:13] +// CHECK: load-namespaces.cpp:9:11: Namespace=std:9:11 (Definition) Extent=[9:11 - 11:2] +// CHECK: load-namespaces.cpp:10:8: FunctionDecl=g:10:8 Extent=[10:8 - 10:11] +// CHECK: load-namespaces.cpp:13:11: NamespaceAlias=std98:13:11 Extent=[13:1 - 13:22] +// CHECK: load-namespaces.cpp:13:19: NamespaceRef=std:3:11 Extent=[13:19 - 13:22] +// CHECK: load-namespaces.cpp:14:11: NamespaceAlias=std0x:14:11 Extent=[14:1 - 14:24] +// CHECK: load-namespaces.cpp:14:19: NamespaceRef=std98:13:11 Extent=[14:19 - 14:24] +// CHECK: load-namespaces.cpp:16:17: UsingDirective=:16:17 Extent=[16:1 - 16:22] +// CHECK: load-namespaces.cpp:16:17: NamespaceRef=std0x:14:11 Extent=[16:17 - 16:22] +// CHECK: load-namespaces.cpp:18:11: Namespace=std:18:11 (Definition) Extent=[18:11 - 20:2] +// CHECK: load-namespaces.cpp:19:7: FunctionDecl=g:19:7 Extent=[19:7 - 19:13] +// CHECK: load-namespaces.cpp:19:12: ParmDecl=:19:12 (Definition) Extent=[19:9 - 19:13] +// CHECK: load-namespaces.cpp:22:12: UsingDeclaration=g:22:12 Extent=[22:1 - 22:13] +// CHECK: load-namespaces.cpp:22:7: NamespaceRef=std:18:11 Extent=[22:7 - 22:10] +// CHECK: load-namespaces.cpp:24:11: FunctionDecl=g:24:11 (Definition) Extent=[24:11 - 25:2] +// CHECK: load-namespaces.cpp:24:6: NamespaceRef=std:18:11 Extent=[24:6 - 24:9] +// CHECK: load-namespaces.cpp:27:11: NamespaceAlias=my_rel_ops:27:11 Extent=[27:1 - 27:36] +// CHECK: load-namespaces.cpp:27:24: NamespaceRef=std:18:11 Extent=[27:24 - 27:27] +// CHECK: load-namespaces.cpp:27:29: NamespaceRef=rel_ops:4:13 Extent=[27:29 - 27:36] diff --git a/test/Index/load-stmts.cpp b/test/Index/load-stmts.cpp index cb99aee..503219f 100644 --- a/test/Index/load-stmts.cpp +++ b/test/Index/load-stmts.cpp @@ -10,6 +10,66 @@ void f(int x) { } } +// Test handling of C++ base specifiers. +class A { + void doA(); +}; + +class B { + void doB(); +}; + +class C : public A, private B { + void doC(); +}; + +class D : virtual public C, virtual private A {}; + +namespace std { + class type_info { }; +} + +void test_exprs(C *c) { + int typeid_marker; + typeid(C); + typeid(c); + typedef int Integer; + Integer *int_ptr; + int_ptr->Integer::~Integer(); +} + +namespace N { + int f(int); + float f(float); + + template<typename T> T g(T); + template<typename T> T g(T*); +} + +template<typename T> +void test_dependent_exprs(T t) { + N::f(t); + typedef T type; + N::g<type>(t); + type::template f<type*>(t); + t->type::template f<type*>(); +} + +struct Y { + int f(int); + float f(float); + + template<typename T> T g(T); + template<typename T> T g(T*); +}; + +template<typename T> +void test_more_dependent_exprs(T t, Y y) { + y.Y::f(t); + typedef T type; + y.g<type>(t); +} + // RUN: c-index-test -test-load-source all %s | FileCheck %s // CHECK: load-stmts.cpp:1:13: TypedefDecl=T:1:13 (Definition) Extent=[1:13 - 1:14] // CHECK: load-stmts.cpp:2:8: StructDecl=X:2:8 (Definition) Extent=[2:1 - 2:23] @@ -56,4 +116,47 @@ void f(int x) { // CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[9:3 - 9:17] // CHECK: load-stmts.cpp:9:8: UnexposedExpr= Extent=[9:8 - 9:10] // CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[9:12 - 9:17] - +// CHECK: load-stmts.cpp:14:7: ClassDecl=A:14:7 (Definition) Extent=[14:1 - 16:2] +// CHECK: load-stmts.cpp:15:8: CXXMethod=doA:15:8 Extent=[15:8 - 15:13] +// CHECK: load-stmts.cpp:18:7: ClassDecl=B:18:7 (Definition) Extent=[18:1 - 20:2] +// CHECK: load-stmts.cpp:19:8: CXXMethod=doB:19:8 Extent=[19:8 - 19:13] +// CHECK: load-stmts.cpp:22:7: ClassDecl=C:22:7 (Definition) Extent=[22:1 - 24:2] +// CHECK: <invalid loc>:0:0: C++ base class specifier=class A:14:7 [access=public isVirtual=false] +// CHECK: <invalid loc>:0:0: C++ base class specifier=class B:18:7 [access=private isVirtual=false] +// CHECK: load-stmts.cpp:23:8: CXXMethod=doC:23:8 Extent=[23:8 - 23:13] +// CHECK: load-stmts.cpp:26:7: ClassDecl=D:26:7 (Definition) Extent=[26:1 - 26:49] +// CHECK: <invalid loc>:0:0: C++ base class specifier=class C:22:7 [access=public isVirtual=true] +// CHECK: <invalid loc>:0:0: C++ base class specifier=class A:14:7 [access=private isVirtual=true] +// CHECK: load-stmts.cpp:33:7: VarDecl=typeid_marker:33:7 (Definition) +// CHECK: load-stmts.cpp:34:10: TypeRef=class C:22:7 Extent=[34:10 - 34:11] +// CHECK: load-stmts.cpp:35:10: DeclRefExpr=c:32:20 Extent=[35:10 - 35:11] +// CHECK: load-stmts.cpp:37:12: VarDecl=int_ptr:37:12 (Definition) Extent=[37:3 - 37:19] +// CHECK: load-stmts.cpp:37:3: TypeRef=Integer:36:15 Extent=[37:3 - 37:10] +// CHECK: load-stmts.cpp:38:3: DeclRefExpr=int_ptr:37:12 Extent=[38:3 - 38:10] +// CHECK: load-stmts.cpp:38:12: TypeRef=Integer:36:15 Extent=[38:12 - 38:19] +// CHECK: load-stmts.cpp:38:22: TypeRef=Integer:36:15 Extent=[38:22 - 38:29] +// CHECK: load-stmts.cpp:50:6: FunctionTemplate=test_dependent_exprs:50:6 (Definition) +// CHECK: load-stmts.cpp:51:3: CallExpr= Extent=[51:3 - 51:10] +// CHECK: load-stmts.cpp:51:3: NamespaceRef=N:41:11 Extent=[51:3 - 51:4] +// CHECK: load-stmts.cpp:51:8: DeclRefExpr=t:50:29 Extent=[51:8 - 51:9] +// CHECK: load-stmts.cpp:52:13: TypedefDecl=type:52:13 (Definition) Extent=[52:13 - 52:17] +// CHECK: load-stmts.cpp:53:3: CallExpr= Extent=[53:3 - 53:16] +// CHECK: load-stmts.cpp:53:3: NamespaceRef=N:41:11 Extent=[53:3 - 53:4] +// CHECK: load-stmts.cpp:53:8: TypeRef=type:52:13 Extent=[53:8 - 53:12] +// CHECK: load-stmts.cpp:53:14: DeclRefExpr=t:50:29 Extent=[53:14 - 53:15] +// CHECK: load-stmts.cpp:54:3: CallExpr= Extent=[54:3 - 54:29] +// CHECK: load-stmts.cpp:54:3: TypeRef=type:52:13 Extent=[54:3 - 54:7] +// CHECK: load-stmts.cpp:54:20: TypeRef=type:52:13 Extent=[54:20 - 54:24] +// CHECK: load-stmts.cpp:54:27: DeclRefExpr=t:50:29 Extent=[54:27 - 54:28] +// CHECK: load-stmts.cpp:55:3: CallExpr= Extent=[55:3 - 55:31] +// CHECK: load-stmts.cpp:55:3: DeclRefExpr=t:50:29 Extent=[55:3 - 55:4] +// CHECK: load-stmts.cpp:55:23: TypeRef=type:52:13 Extent=[55:23 - 55:27] +// CHECK: load-stmts.cpp:67:6: FunctionTemplate=test_more_dependent_exprs:67:6 (Definition) +// CHECK: load-stmts.cpp:68:3: CallExpr= Extent=[68:3 - 68:12] +// CHECK: load-stmts.cpp:68:3: DeclRefExpr=y:67:39 Extent=[68:3 - 68:4] +// CHECK: load-stmts.cpp:68:5: TypeRef=struct Y:58:8 Extent=[68:5 - 68:6] +// CHECK: load-stmts.cpp:68:10: DeclRefExpr=t:67:34 Extent=[68:10 - 68:11] +// CHECK: load-stmts.cpp:70:3: CallExpr= Extent=[70:3 - 70:15] +// CHECK: load-stmts.cpp:70:3: DeclRefExpr=y:67:39 Extent=[70:3 - 70:4] +// CHECK: load-stmts.cpp:70:7: TypeRef=type:69:13 Extent=[70:7 - 70:11] +// CHECK: load-stmts.cpp:70:13: DeclRefExpr=t:67:34 Extent=[70:13 - 70:14] diff --git a/test/Index/local-symbols.m b/test/Index/local-symbols.m index 8557e7f..b9f4fe2 100644 --- a/test/Index/local-symbols.m +++ b/test/Index/local-symbols.m @@ -15,6 +15,17 @@ } @end +// From: <rdar://problem/8380046> + +@protocol Prot8380046 +@end + +@interface R8380046 +@end + +@interface R8380046 () <Prot8380046> +@end + // CHECK: local-symbols.m:6:12: ObjCInterfaceDecl=Foo:6:12 Extent=[6:1 - 10:5] // CHECK: local-symbols.m:7:6: ObjCIvarDecl=x:7:6 (Definition) Extent=[7:6 - 7:7] // CHECK: local-symbols.m:7:3: TypeRef=id:0:0 Extent=[7:3 - 7:5] @@ -23,4 +34,11 @@ // CHECK: local-symbols.m:12:1: ObjCImplementationDecl=Foo:12:1 (Definition) Extent=[12:1 - 16:2] // CHECK: local-symbols.m:13:1: ObjCInstanceMethodDecl=bar:13:1 (Definition) Extent=[13:1 - 15:2] // CHECK: local-symbols.m:13:4: TypeRef=id:0:0 Extent=[13:4 - 13:6] +// CHECK: local-symbols.m:14:10: UnexposedExpr= Extent=[14:10 - 14:11] +// CHECK: local-symbols.m:14:10: UnexposedExpr= Extent=[14:10 - 14:11] +// CHECK: local-symbols.m:20:1: ObjCProtocolDecl=Prot8380046:20:1 (Definition) Extent=[20:1 - 21:5] +// CHECK: local-symbols.m:23:12: ObjCInterfaceDecl=R8380046:23:12 Extent=[23:1 - 24:5] +// CHECK: local-symbols.m:26:12: ObjCCategoryDecl=:26:12 Extent=[26:1 - 27:5] +// CHECK: local-symbols.m:26:12: ObjCClassRef=R8380046:23:12 Extent=[26:12 - 26:20] +// CHECK: local-symbols.m:26:25: ObjCProtocolRef=Prot8380046:20:1 Extent=[26:25 - 26:36] diff --git a/test/Index/preamble-reparse.c b/test/Index/preamble-reparse.c new file mode 100644 index 0000000..5bd03b3f --- /dev/null +++ b/test/Index/preamble-reparse.c @@ -0,0 +1,2 @@ +// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 local "-remap-file=%S/Inputs/preamble-reparse-1.c;%S/Inputs/preamble-reparse-2.c" %S/Inputs/preamble-reparse-1.c | FileCheck %s +// CHECK: preamble-reparse-1.c:1:5: VarDecl=x:1:5 Extent=[1:1 - 1:6] diff --git a/test/Index/preamble.c b/test/Index/preamble.c new file mode 100644 index 0000000..54abf99 --- /dev/null +++ b/test/Index/preamble.c @@ -0,0 +1,28 @@ +#include "prefix.h" +#include "preamble.h" +int wibble(int); + +void f(int x) { + +} +// RUN: c-index-test -write-pch %t.pch -x c-header %S/Inputs/prefix.h +// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 local -I %S/Inputs -include %t %s 2> %t.stderr.txt | FileCheck %s +// RUN: FileCheck -check-prefix CHECK-DIAG %s < %t.stderr.txt +// CHECK: preamble.h:1:12: FunctionDecl=bar:1:12 (Definition) Extent=[1:12 - 6:2] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[1:23 - 6:2] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[2:3 - 2:16] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[3:3 - 3:15] +// CHECK: preamble.h:4:3: UnexposedExpr= Extent=[4:3 - 4:13] +// CHECK: preamble.h:4:3: DeclRefExpr=ptr:2:8 Extent=[4:3 - 4:6] +// CHECK: preamble.h:4:9: UnexposedExpr=ptr1:3:10 Extent=[4:9 - 4:13] +// CHECK: preamble.h:4:9: DeclRefExpr=ptr1:3:10 Extent=[4:9 - 4:13] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[5:3 - 5:11] +// CHECK: preamble.h:5:10: UnexposedExpr= Extent=[5:10 - 5:11] +// CHECK: preamble.c:3:5: FunctionDecl=wibble:3:5 Extent=[3:5 - 3:16] +// CHECK: preamble.c:3:15: ParmDecl=:3:15 (Definition) Extent=[3:12 - 3:16] +// CHECK-DIAG: preamble.h:4:7:{4:9-4:13}: warning: incompatible pointer types assigning to 'int *' from 'float *' +// RUN: env CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:6:1 -I %S/Inputs -include %t %s 2> %t.stderr.txt | FileCheck -check-prefix CHECK-CC %s +// CHECK-CC: FunctionDecl:{ResultType int}{TypedText bar}{LeftParen (}{Placeholder int i}{RightParen )} (50) +// CHECK-CC: FunctionDecl:{ResultType void}{TypedText f}{LeftParen (}{Placeholder int x}{RightParen )} (45) +// CHECK-CC: FunctionDecl:{ResultType int}{TypedText foo}{LeftParen (}{Placeholder int}{RightParen )} (50) +// CHECK-CC: FunctionDecl:{ResultType int}{TypedText wibble}{LeftParen (}{Placeholder int}{RightParen )} (50) diff --git a/test/Index/print-typekind.c b/test/Index/print-typekind.c index 13b4119..18189c3 100644 --- a/test/Index/print-typekind.c +++ b/test/Index/print-typekind.c @@ -6,15 +6,20 @@ int *f(int *p, char *x, FooType z) { } // RUN: c-index-test -test-print-typekind %s | FileCheck %s -// CHECK: TypedefDecl=FooType:1:13 (Definition) typekind=Typedef [canonical=Int] -// CHECK: VarDecl=p:2:6 typekind=Pointer -// CHECK: FunctionDecl=f:3:6 (Definition) typekind=FunctionProto [canonical=FunctionProto] [result=Pointer] -// CHECK: ParmDecl=p:3:13 (Definition) typekind=Pointer -// CHECK: ParmDecl=x:3:22 (Definition) typekind=Pointer -// CHECK: ParmDecl=z:3:33 (Definition) typekind=Typedef [canonical=Int] -// CHECK: VarDecl=w:4:11 (Definition) typekind=Typedef [canonical=Int] -// CHECK: DeclRefExpr=z:3:33 typekind=Typedef [canonical=Int] -// CHECK: UnexposedExpr= typekind=Pointer -// CHECK: DeclRefExpr=p:3:13 typekind=Pointer -// CHECK: DeclRefExpr=z:3:33 typekind=Typedef [canonical=Int] +// CHECK: TypedefDecl=FooType:1:13 (Definition) typekind=Typedef [canonical=Int] [isPOD=1] +// CHECK: VarDecl=p:2:6 typekind=Pointer [isPOD=1] +// CHECK: FunctionDecl=f:3:6 (Definition) typekind=FunctionProto [canonical=FunctionProto] [result=Pointer] [isPOD=0] +// CHECK: ParmDecl=p:3:13 (Definition) typekind=Pointer [isPOD=1] +// CHECK: ParmDecl=x:3:22 (Definition) typekind=Pointer [isPOD=1] +// CHECK: ParmDecl=z:3:33 (Definition) typekind=Typedef [canonical=Int] [isPOD=1] +// CHECK: TypeRef=FooType:1:13 typekind=Invalid [isPOD=0] +// CHECK: UnexposedStmt= typekind=Invalid [isPOD=0] +// CHECK: UnexposedStmt= typekind=Invalid [isPOD=0] +// CHECK: VarDecl=w:4:11 (Definition) typekind=Typedef [canonical=Int] [isPOD=1] +// CHECK: TypeRef=FooType:1:13 typekind=Invalid [isPOD=0] +// CHECK: DeclRefExpr=z:3:33 typekind=Typedef [canonical=Int] [isPOD=1] +// CHECK: UnexposedStmt= typekind=Invalid [isPOD=0] +// CHECK: UnexposedExpr= typekind=Pointer [isPOD=1] +// CHECK: DeclRefExpr=p:3:13 typekind=Pointer [isPOD=1] +// CHECK: DeclRefExpr=z:3:33 typekind=Typedef [canonical=Int] [isPOD=1] diff --git a/test/Index/rdar-8288645-invalid-code.mm b/test/Index/rdar-8288645-invalid-code.mm new file mode 100644 index 0000000..3405f0a --- /dev/null +++ b/test/Index/rdar-8288645-invalid-code.mm @@ -0,0 +1,8 @@ +// RUN: c-index-test -test-load-source all %s 2>&1 | FileCheck %s + +// This test case previously crashed Sema. + +extern "C" { @implementation Foo - (id)initWithBar:(Baz<WozBar>)pepper { + +// CHECK: warning: cannot find interface declaration for 'Foo' +// CHECK: warning: '@end' is missing in implementation context diff --git a/test/Index/usrs.cpp b/test/Index/usrs.cpp index b6a6d3d..698aded 100644 --- a/test/Index/usrs.cpp +++ b/test/Index/usrs.cpp @@ -55,23 +55,35 @@ extern "C" { void rez(int a, int b); } +namespace foo_alias = foo; + +using namespace foo; + +namespace foo_alias2 = foo; + +using foo::ClsB; + +namespace foo_alias3 = foo; + // RUN: c-index-test -test-load-source-usrs all %s | FileCheck %s // CHECK: usrs.cpp c:@N@foo Extent=[1:11 - 4:2] // CHECK: usrs.cpp c:@N@foo@x Extent=[2:3 - 2:8] // CHECK: usrs.cpp c:@N@foo@F@bar#I# Extent=[3:8 - 3:18] -// CHECK: usrs.cpp c:usrs.cpp@3:12@N@foo@F@bar#I#@z Extent=[3:12 - 3:17] +// CHECK: usrs.cpp c:usrs.cpp@36@N@foo@F@bar#I#@z Extent=[3:12 - 3:17] // CHECK: usrs.cpp c:@N@bar Extent=[5:11 - 8:2] -// CHECK: usrs.cpp c:usrs.cpp@6:15@N@bar@T@QType Extent=[6:15 - 6:20] +// CHECK: usrs.cpp c:usrs.cpp@76@N@bar@T@QType Extent=[6:15 - 6:20] // CHECK: usrs.cpp c:@N@bar@F@bar#I# Extent=[7:8 - 7:20] -// CHECK: usrs.cpp c:usrs.cpp@7:12@N@bar@F@bar#I#@z Extent=[7:12 - 7:19] +// CHECK: usrs.cpp c:usrs.cpp@94@N@bar@F@bar#I#@z Extent=[7:12 - 7:19] // CHECK: usrs.cpp c:@C@ClsA Extent=[10:1 - 14:2] +// CHECK: usrs.cpp c: Extent=[11:1 - 11:8] // CHECK: usrs.cpp c:@C@ClsA@FI@a Extent=[12:7 - 12:8] // CHECK: usrs.cpp c:@C@ClsA@FI@b Extent=[12:10 - 12:11] // CHECK: usrs.cpp c:@C@ClsA@F@ClsA#I#I# Extent=[13:3 - 13:37] -// CHECK: usrs.cpp c:usrs.cpp@13:8@C@ClsA@F@ClsA#I#I#@A Extent=[13:8 - 13:13] -// CHECK: usrs.cpp c:usrs.cpp@13:15@C@ClsA@F@ClsA#I#I#@B Extent=[13:15 - 13:20] +// CHECK: usrs.cpp c:usrs.cpp@147@C@ClsA@F@ClsA#I#I#@A Extent=[13:8 - 13:13] +// CHECK: usrs.cpp c:usrs.cpp@154@C@ClsA@F@ClsA#I#I#@B Extent=[13:15 - 13:20] // CHECK: usrs.cpp c:@N@foo Extent=[16:11 - 22:2] // CHECK: usrs.cpp c:@N@foo@C@ClsB Extent=[17:3 - 21:4] +// CHECK: usrs.cpp c: Extent=[18:3 - 18:10] // CHECK: usrs.cpp c:@N@foo@C@ClsB@F@ClsB# Extent=[19:5 - 19:27] // CHECK: usrs.cpp c:@N@foo@C@ClsB@F@result#1 Extent=[20:9 - 20:17] // CHECK: usrs.cpp c:@N@foo@C@ClsB@F@result#1 Extent=[24:16 - 26:2] @@ -81,27 +93,32 @@ extern "C" { // CHECK: usrs.cpp c:@N@foo Extent=[35:11 - 40:2] // CHECK: usrs.cpp c:@N@foo@N@taz Extent=[35:27 - 39:2] // CHECK: usrs.cpp c:@N@foo@N@taz@x Extent=[36:3 - 36:8] -// CHECK: usrs.cpp c:usrs.cpp@37:21@N@foo@N@taz@F@add#I#I# Extent=[37:21 - 37:56] -// CHECK: usrs.cpp c:usrs.cpp@37:25@N@foo@N@taz@F@add#I#I#@a Extent=[37:25 - 37:30] -// CHECK: usrs.cpp c:usrs.cpp@37:32@N@foo@N@taz@F@add#I#I#@b Extent=[37:32 - 37:37] +// CHECK: usrs.cpp c:usrs.cpp@475@N@foo@N@taz@F@add#I#I# Extent=[37:21 - 37:56] +// CHECK: usrs.cpp c:usrs.cpp@479@N@foo@N@taz@F@add#I#I#@a Extent=[37:25 - 37:30] +// CHECK: usrs.cpp c:usrs.cpp@486@N@foo@N@taz@F@add#I#I#@b Extent=[37:32 - 37:37] // CHECK: usrs.cpp c:@N@foo@N@taz@F@sub#I#I# Extent=[38:8 - 38:25] -// CHECK: usrs.cpp c:usrs.cpp@38:12@N@foo@N@taz@F@sub#I#I#@a Extent=[38:12 - 38:17] -// CHECK: usrs.cpp c:usrs.cpp@38:19@N@foo@N@taz@F@sub#I#I#@b Extent=[38:19 - 38:24] +// CHECK: usrs.cpp c:usrs.cpp@522@N@foo@N@taz@F@sub#I#I#@a Extent=[38:12 - 38:17] +// CHECK: usrs.cpp c:usrs.cpp@529@N@foo@N@taz@F@sub#I#I#@b Extent=[38:19 - 38:24] // CHECK: usrs.cpp c:@N@foo Extent=[42:11 - 52:3] // CHECK: usrs.cpp c:@N@foo@N@taz Extent=[42:27 - 52:2] // CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD Extent=[43:3 - 51:4] +// CHECK: usrs.cpp c: Extent=[44:3 - 44:10] // CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@operator=#I# Extent=[45:11 - 45:52] -// CHECK: usrs.cpp c:usrs.cpp@45:21@N@foo@N@taz@C@ClsD@F@operator=#I#@x Extent=[45:21 - 45:26] +// CHECK: usrs.cpp c:usrs.cpp@638@N@foo@N@taz@C@ClsD@F@operator=#I#@x Extent=[45:21 - 45:26] // CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@operator=#d# Extent=[46:11 - 46:61] -// CHECK: usrs.cpp c:usrs.cpp@46:21@N@foo@N@taz@C@ClsD@F@operator=#d#@x Extent=[46:21 - 46:29] +// CHECK: usrs.cpp c:usrs.cpp@690@N@foo@N@taz@C@ClsD@F@operator=#d#@x Extent=[46:21 - 46:29] // CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@operator=#&1$@N@foo@N@taz@C@ClsD# Extent=[47:11 - 47:62] -// CHECK: usrs.cpp c:usrs.cpp@47:27@N@foo@N@taz@C@ClsD@F@operator=#&1$@N@foo@N@taz@C@ClsD#@x Extent=[47:27 - 47:34] +// CHECK: usrs.cpp c:usrs.cpp@757@N@foo@N@taz@C@ClsD@F@operator=#&1$@N@foo@N@taz@C@ClsD#@x Extent=[47:27 - 47:34] // CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@qux#S Extent=[48:16 - 48:21] // CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@uz#I.#S Extent=[49:16 - 49:30] -// CHECK: usrs.cpp c:usrs.cpp@49:19@N@foo@N@taz@C@ClsD@F@uz#I.#S@z Extent=[49:19 - 49:24] +// CHECK: usrs.cpp c:usrs.cpp@833@N@foo@N@taz@C@ClsD@F@uz#I.#S@z Extent=[49:19 - 49:24] // CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@operator==#&1$@N@foo@N@taz@C@ClsD#1 Extent=[50:10 - 50:62] -// CHECK: usrs.cpp c:usrs.cpp@50:27@N@foo@N@taz@C@ClsD@F@operator==#&1$@N@foo@N@taz@C@ClsD#1@x Extent=[50:27 - 50:34] +// CHECK: usrs.cpp c:usrs.cpp@872@N@foo@N@taz@C@ClsD@F@operator==#&1$@N@foo@N@taz@C@ClsD#1@x Extent=[50:27 - 50:34] // CHECK: usrs.cpp c:@F@rez Extent=[55:8 - 55:25] -// CHECK: usrs.cpp c:usrs.cpp@55:12@F@rez@a Extent=[55:12 - 55:17] -// CHECK: usrs.cpp c:usrs.cpp@55:19@F@rez@b Extent=[55:19 - 55:24] - +// CHECK: usrs.cpp c:usrs.cpp@941@F@rez@a Extent=[55:12 - 55:17] +// CHECK: usrs.cpp c:usrs.cpp@948@F@rez@b Extent=[55:19 - 55:24] +// CHECK: usrs.cpp c:@NA@foo_alias +// CHECK-NOT: foo +// CHECK: usrs.cpp c:@NA@foo_alias2 +// CHECK-NOT: ClsB +// CHECK: usrs.cpp c:@NA@foo_alias3 diff --git a/test/Index/usrs.m b/test/Index/usrs.m index 0b56cca..4b3de5c 100644 --- a/test/Index/usrs.m +++ b/test/Index/usrs.m @@ -49,27 +49,39 @@ int z; static int local_func(int x) { return x; } @interface CWithExt +- (id) meth1; @end @interface CWithExt () +- (id) meth2; @end @interface CWithExt () +- (id) meth3; +@end +@interface CWithExt (Bar) +- (id) meth4; @end @implementation CWithExt +- (id) meth1 { return 0; } +- (id) meth2 { return 0; } +- (id) meth3 { return 0; } +@end +@implementation CWithExt (Bar) +- (id) meth4 { return 0; } @end -// CHECK: usrs.m c:usrs.m@3:19@F@my_helper Extent=[3:19 - 3:60] -// CHECK: usrs.m c:usrs.m@3:29@F@my_helper@x Extent=[3:29 - 3:34] -// CHECK: usrs.m c:usrs.m@3:36@F@my_helper@y Extent=[3:36 - 3:41] -// CHECK: usrs.m c:usrs.m@5:1@Ea Extent=[5:1 - 8:2] -// CHECK: usrs.m c:usrs.m@5:1@Ea@ABA Extent=[6:3 - 6:6] -// CHECK: usrs.m c:usrs.m@5:1@Ea@CADABA Extent=[7:3 - 7:9] -// CHECK: usrs.m c:usrs.m@10:1@Ea Extent=[10:1 - 13:2] -// CHECK: usrs.m c:usrs.m@10:1@Ea@FOO Extent=[11:3 - 11:6] -// CHECK: usrs.m c:usrs.m@10:1@Ea@BAR Extent=[12:3 - 12:6] +// CHECK: usrs.m c:usrs.m@85@F@my_helper Extent=[3:19 - 3:60] +// CHECK: usrs.m c:usrs.m@95@F@my_helper@x Extent=[3:29 - 3:34] +// CHECK: usrs.m c:usrs.m@102@F@my_helper@y Extent=[3:36 - 3:41] +// CHECK: usrs.m c:usrs.m@128@Ea Extent=[5:1 - 8:2] +// CHECK: usrs.m c:usrs.m@128@Ea@ABA Extent=[6:3 - 6:6] +// CHECK: usrs.m c:usrs.m@128@Ea@CADABA Extent=[7:3 - 7:9] +// CHECK: usrs.m c:usrs.m@155@Ea Extent=[10:1 - 13:2] +// CHECK: usrs.m c:usrs.m@155@Ea@FOO Extent=[11:3 - 11:6] +// CHECK: usrs.m c:usrs.m@155@Ea@BAR Extent=[12:3 - 12:6] // CHECK: usrs.m c:@SA@MyStruct Extent=[15:9 - 18:2] // CHECK: usrs.m c:@SA@MyStruct@FI@wa Extent=[16:7 - 16:9] // CHECK: usrs.m c:@SA@MyStruct@FI@moo Extent=[17:7 - 17:10] -// CHECK: usrs.m c:usrs.m@18:3@T@MyStruct Extent=[18:3 - 18:11] +// CHECK: usrs.m c:usrs.m@219@T@MyStruct Extent=[18:3 - 18:11] // CHECK: usrs.m c:@E@Pizza Extent=[20:1 - 23:2] // CHECK: usrs.m c:@E@Pizza@CHEESE Extent=[21:3 - 21:9] // CHECK: usrs.m c:@E@Pizza@MUSHROOMS Extent=[22:3 - 22:12] @@ -81,21 +93,30 @@ static int local_func(int x) { return x; } // CHECK: usrs.m c:objc(cs)Foo(cm)kingkong Extent=[30:1 - 30:17] // CHECK: usrs.m c:objc(cs)Foo(im)d1 Extent=[31:15 - 31:17] // CHECK: usrs.m c:objc(cs)Foo(im)setD1: Extent=[31:15 - 31:17] -// CHECK: usrs.m c:usrs.m@31:15objc(cs)Foo(im)setD1:@d1 Extent=[31:15 - 31:17] +// CHECK: usrs.m c:usrs.m@352objc(cs)Foo(im)setD1:@d1 Extent=[31:15 - 31:17] // CHECK: usrs.m c:objc(cs)Foo Extent=[34:1 - 45:2] // CHECK: usrs.m c:objc(cs)Foo(im)godzilla Extent=[35:1 - 39:2] -// CHECK: usrs.m c:usrs.m@36:10objc(cs)Foo(im)godzilla@a Extent=[36:10 - 36:19] +// CHECK: usrs.m c:usrs.m@409objc(cs)Foo(im)godzilla@a Extent=[36:10 - 36:19] // CHECK: usrs.m c:objc(cs)Foo(im)godzilla@z Extent=[37:10 - 37:15] // CHECK: usrs.m c:objc(cs)Foo(cm)kingkong Extent=[40:1 - 43:2] -// CHECK: usrs.m c:usrs.m@41:3objc(cs)Foo(cm)kingkong@local_var Extent=[41:3 - 41:16] +// CHECK: usrs.m c:usrs.m@470objc(cs)Foo(cm)kingkong@local_var Extent=[41:3 - 41:16] // CHECK: usrs.m c:objc(cs)Foo@d1 Extent=[44:13 - 44:15] // CHECK: usrs.m c:objc(cs)Foo(py)d1 Extent=[44:1 - 44:15] // CHECK: usrs.m c:@z Extent=[47:1 - 47:6] -// CHECK: usrs.m c:usrs.m@49:12@F@local_func Extent=[49:12 - 49:43] -// CHECK: usrs.m c:usrs.m@49:23@F@local_func@x Extent=[49:23 - 49:28] -// CHECK: usrs.m c:objc(cs)CWithExt Extent=[51:1 - 52:5] -// CHECK: usrs.m c:objc(cy)CWithExt@ Extent=[53:1 - 54:5] -// CHECK: usrs.m c:objc(cy)CWithExt@ Extent=[55:1 - 56:5] -// CHECK: usrs.m c:objc(cs)CWithExt Extent=[57:1 - 58:2] - +// CHECK: usrs.m c:usrs.m@540@F@local_func Extent=[49:12 - 49:43] +// CHECK: usrs.m c:usrs.m@551@F@local_func@x Extent=[49:23 - 49:28] +// CHECK: usrs.m c:objc(cs)CWithExt Extent=[51:1 - 53:5] +// CHECK: usrs.m c:objc(cs)CWithExt(im)meth1 Extent=[52:1 - 52:14] +// CHECK: usrs.m c:objc(ext)CWithExt@usrs.m@612 Extent=[54:1 - 56:5] +// CHECK: usrs.m c:objc(cs)CWithExt(im)meth2 Extent=[55:1 - 55:14] +// CHECK: usrs.m c:objc(ext)CWithExt@usrs.m@654 Extent=[57:1 - 59:5] +// CHECK: usrs.m c:objc(cs)CWithExt(im)meth3 Extent=[58:1 - 58:14] +// CHECK: usrs.m c:objc(cy)CWithExt@Bar Extent=[60:1 - 62:5] +// CHECK: usrs.m c:objc(cy)CWithExt@Bar(im)meth4 Extent=[61:1 - 61:14] +// CHECK: usrs.m c:objc(cs)CWithExt Extent=[63:1 - 67:2] +// CHECK: usrs.m c:objc(cs)CWithExt(im)meth1 Extent=[64:1 - 64:27] +// CHECK: usrs.m c:objc(cs)CWithExt(im)meth2 Extent=[65:1 - 65:27] +// CHECK: usrs.m c:objc(cs)CWithExt(im)meth3 Extent=[66:1 - 66:27] +// CHECK: usrs.m c:objc(cy)CWithExt@Bar Extent=[68:1 - 70:2] +// CHECK: usrs.m c:objc(cy)CWithExt@Bar(im)meth4 Extent=[69:1 - 69:27] diff --git a/test/Lexer/c90.c b/test/Lexer/c90.c index 6293d42..f191397 100644 --- a/test/Lexer/c90.c +++ b/test/Lexer/c90.c @@ -11,3 +11,19 @@ b;} // comment accepted as extension /* expected-error {{// comments are not allowed in this language}} +void test2() { + const char * str = + "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds" // expected-error{{string literal of length 845 exceeds maximum length 509 that C90 compilers are required to support}} + "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds" + "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds" + "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds" + "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds" + "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds" + "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds" + "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds" + "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds" + "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds" + "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds" + "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds" + "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds"; +} diff --git a/test/Lexer/constants.c b/test/Lexer/constants.c index 2602ec2..de0962e 100644 --- a/test/Lexer/constants.c +++ b/test/Lexer/constants.c @@ -62,3 +62,6 @@ double t1[] = { -1.9e500, // expected-warning {{too large}} -1.9e-500 // expected-warning {{too small}} }; + +// PR7888 +double g = 1e100000000; // expected-warning {{too large}} diff --git a/test/Lexer/has_feature_cxx0x.cpp b/test/Lexer/has_feature_cxx0x.cpp index 650e577..cc2ae28 100644 --- a/test/Lexer/has_feature_cxx0x.cpp +++ b/test/Lexer/has_feature_cxx0x.cpp @@ -99,3 +99,13 @@ int no_variadic_templates(); // CHECK-0X: no_variadic_templates // CHECK-NO-0X: no_variadic_templates + + +#if __has_feature(cxx_inline_namespaces) +int inline_namespaces(); +#else +int no_inline_namespaces(); +#endif + +// CHECK-0X: inline_namespaces +// CHECK-NO-0X: inline_namespaces diff --git a/test/Lexer/constants-ms.c b/test/Lexer/ms-extensions.c index 97e6600..8b7d2e1 100644 --- a/test/Lexer/constants-ms.c +++ b/test/Lexer/ms-extensions.c @@ -23,3 +23,19 @@ void a() { unsigned short s = USHORT; unsigned char c = UCHAR; } + +void pr_7968() +{ + int var1 = 0x1111111e+1; + int var2 = 0X1111111e+1; + int var3 = 0xe+1; + int var4 = 0XE+1; + + int var5= 0\ +x1234e+1; + + int var6= + /*expected-warning {{backslash and newline separated by space}} */ 0\ +x1234e+1; +} + diff --git a/test/Lexer/preamble.c b/test/Lexer/preamble.c new file mode 100644 index 0000000..69cdbb7 --- /dev/null +++ b/test/Lexer/preamble.c @@ -0,0 +1,37 @@ +// Preamble detection test: see below for comments and test commands. +// +#include <blah> +#ifndef FOO +#else +#ifdef BAR +#elif WIBBLE +#endif +#pragma unknown +#endif +#ifdef WIBBLE +#include "honk" +#else +int foo(); +#endif + +// This test checks for detection of the preamble of a file, which +// includes all of the starting comments and #includes. Note that any +// changes to the preamble part of this file must be mirrored in +// Inputs/preamble.txt, since we diff against it. + +// RUN: %clang_cc1 -print-preamble %s > %t +// RUN: echo END. >> %t +// RUN: FileCheck < %t %s +// XFAIL: win32 + +// CHECK: // Preamble detection test: see below for comments and test commands. +// CHECK-NEXT: // +// CHECK-NEXT: #include <blah> +// CHECK-NEXT: #ifndef FOO +// CHECK-NEXT: #else +// CHECK-NEXT: #ifdef BAR +// CHECK-NEXT: #elif WIBBLE +// CHECK-NEXT: #endif +// CHECK-NEXT: #pragma unknown +// CHECK-NEXT: #endif +// CHECK-NEXT: END. diff --git a/test/Makefile b/test/Makefile index ba3a640..5bb50c6 100644 --- a/test/Makefile +++ b/test/Makefile @@ -50,8 +50,4 @@ lit.site.cfg: FORCE clean:: @ find . -name Output | xargs rm -fr -# Daniel hates Chris. -chris-lit: - make LIT_ARGS='-j16 -s' - .PHONY: all report clean diff --git a/test/PCH/Inputs/chain-cxx1.h b/test/PCH/Inputs/chain-cxx1.h new file mode 100644 index 0000000..7ea3ffb --- /dev/null +++ b/test/PCH/Inputs/chain-cxx1.h @@ -0,0 +1,19 @@ +// Primary header for C++ chained PCH test + +void f(); + +// Name not appearing in dependent +void pf(); + +namespace ns { + void g(); + + void pg(); +} + +template <typename T> +struct S { typedef int G; }; + +// Partially specialize +template <typename T> +struct S<T *> { typedef int H; }; diff --git a/test/PCH/Inputs/chain-cxx2.h b/test/PCH/Inputs/chain-cxx2.h new file mode 100644 index 0000000..adc10fd --- /dev/null +++ b/test/PCH/Inputs/chain-cxx2.h @@ -0,0 +1,32 @@ +// Dependent header for C++ chained PCH test + +// Overload function from primary +void f(int); + +// Add function with different name +void f2(); + +// Reopen namespace +namespace ns { + // Overload function from primary + void g(int); + + // Add different name + void g2(); +} + +// Specialize template from primary +template <> +struct S<int> { typedef int I; }; + +// Partially specialize +template <typename T> +struct S<T &> { typedef int J; }; + +// Specialize previous partial specialization +template <> +struct S<int *> { typedef int K; }; + +// Specialize the partial specialization from this file +template <> +struct S<int &> { typedef int L; }; diff --git a/test/PCH/Inputs/chain-decls1.h b/test/PCH/Inputs/chain-decls1.h new file mode 100644 index 0000000..9de4461 --- /dev/null +++ b/test/PCH/Inputs/chain-decls1.h @@ -0,0 +1,11 @@ +void f(); + +struct one {}; +void two(); + +void many(int i); +struct many; +void many(int j); +struct many; + +void noret(); diff --git a/test/PCH/Inputs/chain-decls2.h b/test/PCH/Inputs/chain-decls2.h new file mode 100644 index 0000000..b8b7d04 --- /dev/null +++ b/test/PCH/Inputs/chain-decls2.h @@ -0,0 +1,12 @@ +void g(); + +struct two {}; +void one(); +struct three {}; // for verification + +void many(int k); +struct many; +void many(int l); +struct many {}; + +void noret() __attribute__((noreturn)); diff --git a/test/PCH/Inputs/chain-ext_vector1.h b/test/PCH/Inputs/chain-ext_vector1.h new file mode 100644 index 0000000..5109336 --- /dev/null +++ b/test/PCH/Inputs/chain-ext_vector1.h @@ -0,0 +1,3 @@ +// First header file for chain-ext_vector.c PCH test + +typedef __attribute__((ext_vector_type(2))) float float2; diff --git a/test/PCH/Inputs/chain-ext_vector2.h b/test/PCH/Inputs/chain-ext_vector2.h new file mode 100644 index 0000000..bdaeccc --- /dev/null +++ b/test/PCH/Inputs/chain-ext_vector2.h @@ -0,0 +1,3 @@ +// Second header file for chain-ext_vector.c PCH test + +typedef __attribute__((ext_vector_type(4))) float float4; diff --git a/test/PCH/Inputs/chain-external-defs1.h b/test/PCH/Inputs/chain-external-defs1.h new file mode 100644 index 0000000..36a2653 --- /dev/null +++ b/test/PCH/Inputs/chain-external-defs1.h @@ -0,0 +1,13 @@ +// Helper 1 for chain-external-defs.c test + +// Tentative definitions +int x; +int x2; + +// Should not show up +static int z; + +int incomplete_array[]; +int incomplete_array2[]; + +struct S s; diff --git a/test/PCH/Inputs/chain-external-defs2.h b/test/PCH/Inputs/chain-external-defs2.h new file mode 100644 index 0000000..72af92f --- /dev/null +++ b/test/PCH/Inputs/chain-external-defs2.h @@ -0,0 +1,11 @@ +// Helper 2 for chain-external-defs.c test + +// Tentative definitions +int y; +int y2; + +// Should still not show up +static int z; + +int incomplete_array[]; +int incomplete_array3[]; diff --git a/test/PCH/Inputs/chain-macro-override1.h b/test/PCH/Inputs/chain-macro-override1.h new file mode 100644 index 0000000..4f9321d --- /dev/null +++ b/test/PCH/Inputs/chain-macro-override1.h @@ -0,0 +1,4 @@ +void f() __attribute__((unavailable)); +void g(); +#define g() f() +#define h() f() diff --git a/test/PCH/Inputs/chain-macro-override2.h b/test/PCH/Inputs/chain-macro-override2.h new file mode 100644 index 0000000..f279e2a --- /dev/null +++ b/test/PCH/Inputs/chain-macro-override2.h @@ -0,0 +1,4 @@ +#define f() g() +#undef g +#undef h +#define h() g() diff --git a/test/PCH/Inputs/chain-macro1.h b/test/PCH/Inputs/chain-macro1.h new file mode 100644 index 0000000..2e80e47 --- /dev/null +++ b/test/PCH/Inputs/chain-macro1.h @@ -0,0 +1 @@ +#define FOOBAR void f(); diff --git a/test/PCH/Inputs/chain-macro2.h b/test/PCH/Inputs/chain-macro2.h new file mode 100644 index 0000000..e888228 --- /dev/null +++ b/test/PCH/Inputs/chain-macro2.h @@ -0,0 +1 @@ +#define BARFOO void g(); diff --git a/test/PCH/Inputs/chain-selectors1.h b/test/PCH/Inputs/chain-selectors1.h new file mode 100644 index 0000000..37c1c00 --- /dev/null +++ b/test/PCH/Inputs/chain-selectors1.h @@ -0,0 +1,12 @@ +@interface X + -(void)f; + -(void)f2; + -(void)g:(int)p; + -(void)h:(int)p1 foo:(int)p2; +@end + +void foo1() { + // FIXME: Can't verify warnings in headers + //(void)@selector(x); + (void)@selector(f); +} diff --git a/test/PCH/Inputs/chain-selectors2.h b/test/PCH/Inputs/chain-selectors2.h new file mode 100644 index 0000000..4d6b556 --- /dev/null +++ b/test/PCH/Inputs/chain-selectors2.h @@ -0,0 +1,11 @@ +@interface Y + -(void)f; + -(double)f2; + -(void)e; +@end + +void foo2() { + // FIXME: Can't verify warnings in headers + //(void)@selector(y); + //(void)@selector(e); +} diff --git a/test/PCH/Inputs/chain-trivial1.h b/test/PCH/Inputs/chain-trivial1.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/PCH/Inputs/chain-trivial1.h diff --git a/test/PCH/Inputs/chain-trivial2.h b/test/PCH/Inputs/chain-trivial2.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/PCH/Inputs/chain-trivial2.h diff --git a/test/PCH/Inputs/preamble.h b/test/PCH/Inputs/preamble.h new file mode 100644 index 0000000..aee330a --- /dev/null +++ b/test/PCH/Inputs/preamble.h @@ -0,0 +1 @@ +int f(int); diff --git a/test/PCH/chain-cxx.cpp b/test/PCH/chain-cxx.cpp new file mode 100644 index 0000000..3e46214 --- /dev/null +++ b/test/PCH/chain-cxx.cpp @@ -0,0 +1,28 @@ +// Test C++ chained PCH functionality + +// Without PCH +// RUN: %clang_cc1 -fsyntax-only -verify -include %S/Inputs/chain-cxx1.h -include %S/Inputs/chain-cxx2.h %s + +// With PCH +// RUN: %clang_cc1 -x c++ -emit-pch -o %t1 %S/Inputs/chain-cxx1.h +// RUN: %clang_cc1 -x c++ -emit-pch -o %t2 %S/Inputs/chain-cxx2.h -include-pch %t1 -chained-pch +// RUN: %clang_cc1 -fsyntax-only -verify -include-pch %t2 %s + +void test() { + f(); + f(1); + pf(); + f2(); + + ns::g(); + ns::g(1); + ns::pg(); + ns::g2(); + + typedef S<double>::G T1; + typedef S<double *>::H T2; + typedef S<int>::I T3; + typedef S<double &>::J T4; + typedef S<int *>::K T5; + typedef S<int &>::L T6; +} diff --git a/test/PCH/chain-decls.c b/test/PCH/chain-decls.c new file mode 100644 index 0000000..b3daa4a --- /dev/null +++ b/test/PCH/chain-decls.c @@ -0,0 +1,27 @@ +// Test this without pch. +// RUN: %clang_cc1 -include %S/Inputs/chain-decls1.h -include %S/Inputs/chain-decls2.h -fsyntax-only -verify %s + +// Test with pch. +// RUN: %clang_cc1 -emit-pch -o %t1 %S/Inputs/chain-decls1.h +// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-decls2.h -include-pch %t1 -chained-pch +// RUN: %clang_cc1 -include-pch %t2 -fsyntax-only -verify %s +// RUN: %clang_cc1 -ast-print -include-pch %t2 %s | FileCheck %s + +// CHECK: void f(); +// CHECK: void g(); + +int h() { + f(); + g(); + + struct one x; + one(); + struct two y; + two(); + struct three z; + + many(0); + struct many m; + + noret(); +} diff --git a/test/PCH/chain-ext_vector.c b/test/PCH/chain-ext_vector.c new file mode 100644 index 0000000..2635070 --- /dev/null +++ b/test/PCH/chain-ext_vector.c @@ -0,0 +1,11 @@ +// Test this without pch. +// RUN: %clang_cc1 -include %S/Inputs/chain-ext_vector1.h -include %S/Inputs/chain-ext_vector2.h -fsyntax-only -verify %s + +// Test with pch. +// RUN: %clang_cc1 -emit-pch -o %t1 %S/Inputs/chain-ext_vector1.h +// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-ext_vector2.h -include-pch %t1 -chained-pch +// RUN: %clang_cc1 -include-pch %t2 -fsyntax-only -verify %s + +int test(float4 f4) { + return f4.xy; // expected-error{{float2}} +} diff --git a/test/PCH/chain-external-defs.c b/test/PCH/chain-external-defs.c new file mode 100644 index 0000000..dd92d8e --- /dev/null +++ b/test/PCH/chain-external-defs.c @@ -0,0 +1,54 @@ +// Test with pch. +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t1.pch %S/Inputs/chain-external-defs1.h +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t2.pch %S/Inputs/chain-external-defs2.h -include-pch %t1.pch -chained-pch +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -include-pch %t2.pch -emit-llvm -o %t %s +// RUN: echo FINI >> %t +// RUN: FileCheck -input-file=%t -check-prefix=Z %s +// RUN: FileCheck -input-file=%t -check-prefix=XA %s +// RUN: FileCheck -input-file=%t -check-prefix=YA %s +// RUN: FileCheck -input-file=%t -check-prefix=XB %s +// RUN: FileCheck -input-file=%t -check-prefix=YB %s +// RUN: FileCheck -input-file=%t -check-prefix=AA %s +// RUN: FileCheck -input-file=%t -check-prefix=AB %s +// RUN: FileCheck -input-file=%t -check-prefix=AC %s +// RUN: FileCheck -input-file=%t -check-prefix=S %s + +// Z-NOT: @z + +// XA: @x = common global i32 0 +// XA-NOT: @x = common global i32 0 + +// YA: @y = common global i32 0 +// YA-NOT: @y = common global i32 0 + +// XB: @x2 = global i32 19 +// XB-NOT: @x2 = global i32 19 +int x2 = 19; +// YB: @y2 = global i32 18 +// YB-NOT: @y2 = global i32 18 +int y2 = 18; + +// AA: @incomplete_array = common global [1 x i32] +// AA-NOT: @incomplete_array = common global [1 x i32] +// AB: @incomplete_array2 = common global [17 x i32] +// AB-NOT: @incomplete_array2 = common global [17 x i32] +int incomplete_array2[17]; +// AC: @incomplete_array3 = common global [1 x i32] +// AC-NOT: @incomplete_array3 = common global [1 x i32] +int incomplete_array3[]; + +// S: @s = common global %struct.S +// S-NOT: @s = common global %struct.S +struct S { + int x, y; +}; + +// Z: FINI +// XA: FINI +// YA: FINI +// XB: FINI +// YB: FINI +// AA: FINI +// AB: FINI +// AC: FINI +// S: FINI diff --git a/test/PCH/chain-macro-override.c b/test/PCH/chain-macro-override.c new file mode 100644 index 0000000..14478af --- /dev/null +++ b/test/PCH/chain-macro-override.c @@ -0,0 +1,13 @@ +// Test this without pch. +// RUN: %clang_cc1 -include %S/Inputs/chain-macro-override1.h -include %S/Inputs/chain-macro-override2.h -fsyntax-only -verify %s + +// Test with pch. +// RUN: %clang_cc1 -emit-pch -o %t1 %S/Inputs/chain-macro-override1.h +// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-macro-override2.h -include-pch %t1 -chained-pch +// RUN: %clang_cc1 -include-pch %t2 -fsyntax-only -verify %s + +void foo() { + f(); + g(); + h(); +} diff --git a/test/PCH/chain-macro.c b/test/PCH/chain-macro.c new file mode 100644 index 0000000..b4dcdfe --- /dev/null +++ b/test/PCH/chain-macro.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -emit-pch -o %t1 %S/Inputs/chain-macro1.h +// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-macro2.h -include-pch %t1 -chained-pch +// RUN: %clang_cc1 -fsyntax-only -verify -include-pch %t2 %s +// RUN: %clang_cc1 -ast-print -include-pch %t2 %s | FileCheck %s + +// CHECK: void f(); +FOOBAR +// CHECK: void g(); +BARFOO diff --git a/test/PCH/chain-predecl.h b/test/PCH/chain-predecl.h new file mode 100644 index 0000000..bd332ff --- /dev/null +++ b/test/PCH/chain-predecl.h @@ -0,0 +1,3 @@ +// First header for chain-predecl.m +@class Foo; +@protocol Pro; diff --git a/test/PCH/chain-predecl.m b/test/PCH/chain-predecl.m new file mode 100644 index 0000000..2b0444e --- /dev/null +++ b/test/PCH/chain-predecl.m @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -emit-pch -o %t1 %S/chain-predecl.h -x objective-c +// RUN: %clang_cc1 -emit-pch -o %t2 %s -x objective-c -include-pch %t1 -chained-pch + +// Test predeclarations across chained PCH. +@interface Foo +-(void)bar; +@end +@interface Boom +-(void)bar; +@end +@protocol Pro +-(void)baz; +@end +@protocol Kaboom +-(void)baz; +@end diff --git a/test/PCH/chain-selectors.m b/test/PCH/chain-selectors.m new file mode 100644 index 0000000..60db3f9 --- /dev/null +++ b/test/PCH/chain-selectors.m @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -Wselector -include %S/Inputs/chain-selectors1.h -include %S/Inputs/chain-selectors2.h + +// RUN: %clang_cc1 -x objective-c -emit-pch -o %t1 %S/Inputs/chain-selectors1.h +// RUN: %clang_cc1 -x objective-c -emit-pch -o %t2 %S/Inputs/chain-selectors2.h -include-pch %t1 -chained-pch +// RUN: %clang_cc1 -fsyntax-only -verify %s -Wselector -include-pch %t2 + +@implementation X +-(void)f {} +-(void)f2 {} +-(void)g: (int)p {} +-(void)h: (int)p1 foo: (int)p2 {} +@end + +void bar() { + id a = 0; + [a nothing]; // expected-warning {{method '-nothing' not found}} + [a f]; + // FIXME: Can't verify notes in headers + //[a f2]; + + (void)@selector(x); // expected-warning {{unimplemented selector}} + (void)@selector(y); // expected-warning {{unimplemented selector}} + (void)@selector(e); // expected-warning {{unimplemented selector}} +} diff --git a/test/PCH/chain-trivial.c b/test/PCH/chain-trivial.c new file mode 100644 index 0000000..c78b0e4 --- /dev/null +++ b/test/PCH/chain-trivial.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-pch -o %t1 %S/Inputs/chain-trivial1.h +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-pch -o %t2 -include-pch %t1 -chained-pch %S/Inputs/chain-trivial2.h +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-print -include-pch %t2 %s | FileCheck %s +// CHECK: struct __va_list_tag { diff --git a/test/PCH/cxx-offsetof-base.cpp b/test/PCH/cxx-offsetof-base.cpp new file mode 100644 index 0000000..18265de --- /dev/null +++ b/test/PCH/cxx-offsetof-base.cpp @@ -0,0 +1,2 @@ +// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-offsetof-base.h +// RUN: %clang_cc1 -include-pch %t -fsyntax-only %s diff --git a/test/PCH/cxx-offsetof-base.h b/test/PCH/cxx-offsetof-base.h new file mode 100644 index 0000000..7c78101 --- /dev/null +++ b/test/PCH/cxx-offsetof-base.h @@ -0,0 +1,5 @@ +// Header for PCH test cxx-offsetof-base.cpp + +struct Base { int x; }; +struct Derived : Base { int y; }; +int o = __builtin_offsetof(Derived, x); diff --git a/test/PCH/cxx-required-decls.cpp b/test/PCH/cxx-required-decls.cpp new file mode 100644 index 0000000..8c4b11c --- /dev/null +++ b/test/PCH/cxx-required-decls.cpp @@ -0,0 +1,10 @@ +// Test this without pch. +// RUN: %clang_cc1 -include %S/cxx-required-decls.h %s -emit-llvm -o - | FileCheck %s + +// Test with pch. +// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-required-decls.h +// RUN: %clang_cc1 -include-pch %t %s -emit-llvm -o - | FileCheck %s + +// CHECK: @_ZL5globS = internal global %struct.S zeroinitializer +// CHECK: @_ZL3bar = internal global i32 0, align 4 +// CHECK: @glob_var = global i32 0 diff --git a/test/PCH/cxx-required-decls.h b/test/PCH/cxx-required-decls.h new file mode 100644 index 0000000..099d2da --- /dev/null +++ b/test/PCH/cxx-required-decls.h @@ -0,0 +1,12 @@ +// Header for PCH test cxx-required-decls.cpp + +struct S { + S(); +}; + +static S globS; + +extern int ext_foo; +static int bar = ++ext_foo; + +int glob_var; diff --git a/test/PCH/cxx-static_assert.cpp b/test/PCH/cxx-static_assert.cpp new file mode 100644 index 0000000..3440921 --- /dev/null +++ b/test/PCH/cxx-static_assert.cpp @@ -0,0 +1,11 @@ +// Test this without pch. +// RUN: %clang_cc1 -include %S/cxx-static_assert.h -verify -std=c++0x %s + +// Test with pch. +// RUN: %clang_cc1 -x c++-header -std=c++0x -emit-pch -o %t %S/cxx-static_assert.h +// RUN: %clang_cc1 -include-pch %t -verify -std=c++0x %s + +// expected-error {{static_assert failed "N is not 2!"}} + +T<1> t1; // expected-note {{in instantiation of template class 'T<1>' requested here}} +T<2> t2; diff --git a/test/PCH/cxx-static_assert.h b/test/PCH/cxx-static_assert.h new file mode 100644 index 0000000..ba41ab8 --- /dev/null +++ b/test/PCH/cxx-static_assert.h @@ -0,0 +1,9 @@ +// Header for PCH test cxx-static_assert.cpp + + + + + +template<int N> struct T { + static_assert(N == 2, "N is not 2!"); +}; diff --git a/test/PCH/cxx-templates.cpp b/test/PCH/cxx-templates.cpp index f127427..a862ea5 100644 --- a/test/PCH/cxx-templates.cpp +++ b/test/PCH/cxx-templates.cpp @@ -1,9 +1,14 @@ // Test this without pch. -// RUN: %clang_cc1 -include %S/cxx-templates.h -verify %s -ast-dump +// RUN: %clang_cc1 -include %S/cxx-templates.h -verify %s -ast-dump -o - +// RUN: %clang_cc1 -include %S/cxx-templates.h %s -emit-llvm -o - | FileCheck %s // Test with pch. // RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-templates.h -// RUN: %clang_cc1 -include-pch %t -verify %s -ast-dump +// RUN: %clang_cc1 -include-pch %t -verify %s -ast-dump -o - +// RUN: %clang_cc1 -include-pch %t %s -emit-llvm -o - | FileCheck %s + +// CHECK: define weak_odr void @_ZN2S4IiE1mEv +// CHECK: define linkonce_odr void @_ZN2S3IiE1mEv struct A { typedef int type; @@ -22,4 +27,9 @@ void test() { Dep<A>::Ty ty; Dep<A> a; a.f(); + + S3<int> s3; + s3.m(); } + +template struct S4<int>; diff --git a/test/PCH/cxx-templates.h b/test/PCH/cxx-templates.h index 3968536..978d768 100644 --- a/test/PCH/cxx-templates.h +++ b/test/PCH/cxx-templates.h @@ -88,7 +88,8 @@ template<unsigned N> bool isInt(int x); template<> bool isInt<8>(int x) { - return true; + try { ++x; } catch(...) { --x; } + return true; } template<typename _CharT> @@ -100,3 +101,37 @@ class basic_streambuf friend int __copy_streambufs_eof<>(int); }; +// PR 7660 +template<typename T> struct S_PR7660 { void g(void (*)(T)); }; + template<> void S_PR7660<int>::g(void(*)(int)) {} + +// PR 7670 +template<typename> class C_PR7670; +template<> class C_PR7670<int>; +template<> class C_PR7670<int>; + +template <bool B> +struct S2 { + static bool V; +}; + +extern template class S2<true>; + +template <typename T> +struct S3 { + void m(); +}; + +template <typename T> +inline void S3<T>::m() { } + +template <typename T> +struct S4 { + void m() { } +}; +extern template struct S4<int>; + +void S4ImplicitInst() { + S4<int> s; + s.m(); +} diff --git a/test/PCH/cxx-traits.cpp b/test/PCH/cxx-traits.cpp new file mode 100644 index 0000000..69c6475 --- /dev/null +++ b/test/PCH/cxx-traits.cpp @@ -0,0 +1,8 @@ +// Test this without pch. +// RUN: %clang_cc1 -include %S/cxx-traits.h -fsyntax-only -verify %s + +// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-traits.h +// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s + +bool _Is_pod_comparator = __is_pod<int>::__value; +bool _Is_empty_check = __is_empty<int>::__value; diff --git a/test/PCH/cxx-traits.h b/test/PCH/cxx-traits.h new file mode 100644 index 0000000..62722ab --- /dev/null +++ b/test/PCH/cxx-traits.h @@ -0,0 +1,11 @@ +// Header for PCH test cxx-traits.cpp + +template<typename _Tp> +struct __is_pod { + enum { __value }; +}; + +template<typename _Tp> +struct __is_empty { + enum { __value }; +}; diff --git a/test/PCH/cxx-typeid.cpp b/test/PCH/cxx-typeid.cpp new file mode 100644 index 0000000..41dd544 --- /dev/null +++ b/test/PCH/cxx-typeid.cpp @@ -0,0 +1,9 @@ +// Test this without pch. +// RUN: %clang -include %S/cxx-typeid.h -fsyntax-only -Xclang -verify %s + +// RUN: %clang -ccc-pch-is-pch -x c++-header -o %t.gch %S/cxx-typeid.h +// RUN: %clang -ccc-pch-is-pch -include %t -fsyntax-only -Xclang -verify %s + +void f() { + (void)typeid(int); +} diff --git a/test/PCH/cxx-typeid.h b/test/PCH/cxx-typeid.h new file mode 100644 index 0000000..aa3b16a --- /dev/null +++ b/test/PCH/cxx-typeid.h @@ -0,0 +1,3 @@ +// Header for PCH test cxx-typeid.cpp + +#include <typeinfo> diff --git a/test/PCH/namespaces.cpp b/test/PCH/namespaces.cpp index 532d627..b8a22e5 100644 --- a/test/PCH/namespaces.cpp +++ b/test/PCH/namespaces.cpp @@ -37,7 +37,6 @@ void(*funp2)() = ext; using N1::used_func; void (*pused)() = used_func; -// FIXME: Disabled until CXXRecord serialization is re-added. -// using N1::used_cls; -// used_cls s1; -// used_cls* ps1 = &s1; +using N1::used_cls; +used_cls s1; +used_cls* ps1 = &s1; diff --git a/test/PCH/objcxx-ivar-class.h b/test/PCH/objcxx-ivar-class.h new file mode 100644 index 0000000..50ebda7 --- /dev/null +++ b/test/PCH/objcxx-ivar-class.h @@ -0,0 +1,15 @@ +struct S { + S(); + S(const S&); + S& operator= (const S&); +}; + +@interface C { + S position; +} +@property(assign, nonatomic) S position; +@end + +@implementation C + @synthesize position; +@end diff --git a/test/PCH/objcxx-ivar-class.mm b/test/PCH/objcxx-ivar-class.mm new file mode 100644 index 0000000..89d3e08 --- /dev/null +++ b/test/PCH/objcxx-ivar-class.mm @@ -0,0 +1,15 @@ +// Test this without pch. +// RUN: %clang_cc1 -include %S/objcxx-ivar-class.h -verify %s -emit-llvm -o - | FileCheck %s + +// Test with pch. +// RUN: %clang_cc1 -x objective-c++-header -emit-pch -o %t %S/objcxx-ivar-class.h +// RUN: %clang_cc1 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s + +// CHECK: [C position] +// CHECK: call void @_ZN1SC1ERKS_ + +// CHECK: [C setPosition:] +// CHECK: call %struct.S* @_ZN1SaSERKS_ + +// CHECK: [C .cxx_destruct] +// CHECK: [C .cxx_construct] diff --git a/test/PCH/pragma-weak.c b/test/PCH/pragma-weak.c new file mode 100644 index 0000000..18b45c8 --- /dev/null +++ b/test/PCH/pragma-weak.c @@ -0,0 +1,10 @@ +// Test this without pch. +// RUN: %clang_cc1 -include %S/pragma-weak.h %s -verify -emit-llvm -o - | FileCheck %s + +// Test with pch. +// RUN: %clang_cc1 -x c-header -emit-pch -o %t %S/pragma-weak.h +// RUN: %clang_cc1 -include-pch %t %s -verify -emit-llvm -o - | FileCheck %s + +// CHECK: @weakvar = weak global i32 0 +int weakvar; +// expected-warning {{weak identifier 'undeclaredvar' never declared}} diff --git a/test/PCH/pragma-weak.h b/test/PCH/pragma-weak.h new file mode 100644 index 0000000..42ecd50 --- /dev/null +++ b/test/PCH/pragma-weak.h @@ -0,0 +1,10 @@ +// Header for PCH test pragma-weak.c + +#pragma weak weakvar + + + + + + +#pragma weak undeclaredvar diff --git a/test/PCH/preamble.c b/test/PCH/preamble.c new file mode 100644 index 0000000..bdc0aea --- /dev/null +++ b/test/PCH/preamble.c @@ -0,0 +1,21 @@ +// Check that using the preamble option actually skips the preamble. + +// RUN: %clang_cc1 -emit-pch -o %t %S/Inputs/preamble.h +// RUN: %clang_cc1 -include-pch %t -preamble-bytes=278,1 -DFOO=f -verify %s + +float f(int); // Not an error, because we skip this via the preamble! + + + + + + + + + + + + +int g(int x) { + return FOO(x); +} diff --git a/test/PCH/pth.c b/test/PCH/pth.c new file mode 100644 index 0000000..1262f8a --- /dev/null +++ b/test/PCH/pth.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-pth -o %t %S/pth.h +// RUN: %clang_cc1 -triple i386-unknown-unknown -include-pth %t -fsyntax-only %s 2>&1 | FileCheck %s + +#error This is the only diagnostic + +// CHECK: This is the only diagnostic +// CHECK: 1 error generated.
\ No newline at end of file diff --git a/test/PCH/pth.h b/test/PCH/pth.h new file mode 100644 index 0000000..9ae7021 --- /dev/null +++ b/test/PCH/pth.h @@ -0,0 +1,12 @@ +// This case came up when using PTH with Boost (<rdar://problem/8227989>). + +# ifndef R8227989_PREPROCESSOR_CONFIG_CONFIG_HPP +# ifndef R8227989_PP_CONFIG_FLAGS +# endif +# +# ifndef R8227989_PP_CONFIG_ERRORS +# ifdef NDEBUG +# endif +# endif +# endif + diff --git a/test/PCH/reinclude.cpp b/test/PCH/reinclude.cpp new file mode 100644 index 0000000..6ab1002 --- /dev/null +++ b/test/PCH/reinclude.cpp @@ -0,0 +1,8 @@ +// Test without PCH +// RUN: %clang_cc1 %s -include %S/reinclude1.h -include %S/reinclude2.h -fsyntax-only -verify + +// RUN: %clang_cc1 -x c++-header %S/reinclude1.h -emit-pch -o %t1 +// RUN: %clang_cc1 -x c++-header %S/reinclude2.h -include-pch %t1 -emit-pch -o %t2 +// RUN: %clang_cc1 %s -include-pch %t2 -fsyntax-only -verify + +int q2 = A::y; diff --git a/test/PCH/reinclude1.h b/test/PCH/reinclude1.h new file mode 100644 index 0000000..4c8ccae --- /dev/null +++ b/test/PCH/reinclude1.h @@ -0,0 +1,4 @@ +namespace A { + int x; + int y; +} diff --git a/test/PCH/reinclude2.h b/test/PCH/reinclude2.h new file mode 100644 index 0000000..2aa6d31 --- /dev/null +++ b/test/PCH/reinclude2.h @@ -0,0 +1 @@ +int q1 = A::x; diff --git a/test/PCH/selector-warning.h b/test/PCH/selector-warning.h new file mode 100644 index 0000000..bd41929 --- /dev/null +++ b/test/PCH/selector-warning.h @@ -0,0 +1,24 @@ +typedef struct objc_selector *SEL; + +@interface Foo +- (void) NotOK; +@end + +@implementation Foo +- (void) foo +{ + SEL a = @selector(b1ar); + a = @selector(b1ar); + a = @selector(bar); + a = @selector(ok); // expected-warning {{unimplemented selector 'ok'}} + a = @selector(ok); + a = @selector(NotOK); // expected-warning {{unimplemented selector 'NotOK'}} + a = @selector(NotOK); + + a = @selector(clNotOk); // expected-warning {{unimplemented selector 'clNotOk'}} + + a = @selector (cl1); + a = @selector (cl2); + a = @selector (instNotOk); // expected-warning {{unimplemented selector 'instNotOk'}} +} +@end diff --git a/test/PCH/selector-warning.m b/test/PCH/selector-warning.m new file mode 100644 index 0000000..413f64f --- /dev/null +++ b/test/PCH/selector-warning.m @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -x objective-c -emit-pch -o %t.h.pch %S/selector-warning.h +// RUN: %clang_cc1 -include-pch %t.h.pch %s + +@interface Bar ++ (void) clNotOk; +- (void) instNotOk; ++ (void) cl1; +@end + +@implementation Bar +- (void) bar {} ++ (void) cl1 {} ++ (void) cl2 {} +@end + +@implementation Bar(CAT) +- (void) b1ar {} +@end + diff --git a/test/Parser/2008-10-31-parse-noop-failure.c b/test/Parser/2008-10-31-parse-noop-failure.c deleted file mode 100755 index 6df508e..0000000 --- a/test/Parser/2008-10-31-parse-noop-failure.c +++ /dev/null @@ -1,4 +0,0 @@ -// RUN: %clang_cc1 -verify -parse-noop %s - -void add_attribute(id) int id; {} - diff --git a/test/Parser/MicrosoftExtensions.c b/test/Parser/MicrosoftExtensions.c index 0b2733e..ec272cd 100644 --- a/test/Parser/MicrosoftExtensions.c +++ b/test/Parser/MicrosoftExtensions.c @@ -1,8 +1,9 @@ -// RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -verify -fms-extensions -x objective-c++ %s +// RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -verify -fms-extensions -Wno-missing-declarations -x objective-c++ %s __stdcall int func0(); int __stdcall func(); typedef int (__cdecl *tptr)(); void (*__fastcall fastpfunc)(); +struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) __declspec(novtable) IUnknown {}; extern __declspec(dllimport) void __stdcall VarR4FromDec(); __declspec(deprecated) __declspec(deprecated) char * __cdecl ltoa( long _Val, char * _DstBuf, int _Radix); __declspec(noalias) __declspec(restrict) void * __cdecl xxx( void * _Memory ); @@ -34,3 +35,4 @@ typedef bool (__stdcall __stdcall *blarg)(int); #define FOO(x) #@x char x = FOO(a); +typedef enum E { e1 }; diff --git a/test/Parser/asm-constraints-pr7869.c b/test/Parser/asm-constraints-pr7869.c new file mode 100644 index 0000000..d6f1725 --- /dev/null +++ b/test/Parser/asm-constraints-pr7869.c @@ -0,0 +1,45 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +int a, b, c, d, e, f, g, h, i, j, k, l; + +void +f1 (void) +{ + __asm__ volatile ("" + : [a] "+r" (a), [b] "+r" (b), [c] "+r" (c), [d] "+r" (d), + [e] "+r" (e), [f] "+r" (f), [g] "+r" (g), [h] "+r" (h), + [i] "+r" (i), [j] "+r" (j), [k] "+r" (k), [l] "+r" (l)); +} + +void +f2 (void) +{ + __asm__ volatile ("" + : [a] "+r,m" (a), [b] "+r,m" (b), [c] "+r,m" (c), [d] "+r,m" (d), + [e] "+r,m" (e), [f] "+r,m" (f), [g] "+r,m" (g), [h] "+r,m" (h), + [i] "+r,m" (i), [j] "+r,m" (j), [k] "+r,m" (k), [l] "+r,m" (l)); +} + +void +f3 (void) +{ + __asm__ volatile ("" + : [a] "=r" (a), [b] "=r" (b), [c] "=r" (c), [d] "=r" (d), + [e] "=r" (e), [f] "=r" (f), [g] "=r" (g), [h] "=r" (h), + [i] "=r" (i), [j] "=r" (j), [k] "=r" (k), [l] "=r" (l) + : "[a]" (a), "[b]" (b), "[c]" (c), "[d]" (d), + "[e]" (e), "[f]" (f), "[g]" (g), "[h]" (h), + "[i]" (i), "[j]" (j), "[k]" (k), "[l]" (l)); +} + +void +f4 (void) +{ + __asm__ volatile ("" + : [a] "=r,m" (a), [b] "=r,m" (b), [c] "=r,m" (c), [d] "=r,m" (d), + [e] "=r,m" (e), [f] "=r,m" (f), [g] "=r,m" (g), [h] "=r,m" (h), + [i] "=r,m" (i), [j] "=r,m" (j), [k] "=r,m" (k), [l] "=r,m" (l) + : "[a],m" (a), "[b],m" (b), "[c],m" (c), "[d],m" (d), + "[e],m" (e), "[f],m" (f), "[g],m" (g), "[h],m" (h), + "[i],m" (i), "[j],m" (j), "[k],m" (k), "[l],m" (l)); +} diff --git a/test/Parser/asm.c b/test/Parser/asm.c index df2e16f..9081826 100644 --- a/test/Parser/asm.c +++ b/test/Parser/asm.c @@ -1,7 +1,8 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s void f1() { - asm ("ret" : : :); // expected-error {{expected string literal}} + // PR7673: Some versions of GCC support an empty clobbers section. + asm ("ret" : : :); } void f2() { diff --git a/test/Parser/block-block-storageclass.c b/test/Parser/block-block-storageclass.c index a4efc44..97ba113 100644 --- a/test/Parser/block-block-storageclass.c +++ b/test/Parser/block-block-storageclass.c @@ -1,5 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -parse-noop %s -#if 0 +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s int printf(const char *, ...); void _Block_byref_release(void*src){} @@ -16,4 +15,3 @@ int main() { return X; } -#endif diff --git a/test/Parser/block-pointer-decl.c b/test/Parser/block-pointer-decl.c index 2979b01..a8cc258 100644 --- a/test/Parser/block-pointer-decl.c +++ b/test/Parser/block-pointer-decl.c @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -parse-noop -fblocks %s +// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s + +int printf(char const *, ...); struct blockStruct { int (^a)(float, int); diff --git a/test/Parser/cxx-altivec.cpp b/test/Parser/cxx-altivec.cpp index a70eea0..8f46330 100644 --- a/test/Parser/cxx-altivec.cpp +++ b/test/Parser/cxx-altivec.cpp @@ -126,3 +126,38 @@ vector char v3 = (vector char)((vector int)('a', 'b', 'c', 'd')); vector int v4 = (vector int)(1, 2, 3, 4); vector float v5 = (vector float)(1.0f, 2.0f, 3.0f, 4.0f); vector char v6 = (vector char)((vector int)(1+2, -2, (int)(2.0 * 3), -(5-3))); + +#if 0 // Not ready yet. +// bug 7553 - Problem with '==' and vectors +void func() { + vector int v10i = (vector int)(1, 2, 3, 4); + vector int v11i = (vector int)(1, 2, 3, 4); + bool r10ieq = (v10i == v11i); + bool r10ine = (v10i != v11i); + bool r10igt = (v10i > v11i); + bool r10ige = (v10i >= v11i); + bool r10ilt = (v10i < v11i); + bool r10ile = (v10i <= v11i); + vector float v10f = (vector float)(1.0f, 2.0f, 3.0f, 4.0f); + vector float v11f = (vector float)(1.0f, 2.0f, 3.0f, 4.0f); + bool r10feq = (v10f == v11f); + bool r10fne = (v10f != v11f); + bool r10fgt = (v10f > v11f); + bool r10fge = (v10f >= v11f); + bool r10flt = (v10f < v11f); + bool r10fle = (v10f <= v11f); +} +#endif + +// vecreturn attribute test +struct Vector +{ + __vector float xyzw; +} __attribute__((vecreturn)); + +Vector Add(Vector lhs, Vector rhs) +{ + Vector result; + result.xyzw = vec_add(lhs.xyzw, rhs.xyzw); + return result; // This will (eventually) be returned in a register +} diff --git a/test/Parser/cxx-ambig-decl-expr-xfail.cpp b/test/Parser/cxx-ambig-decl-expr-xfail.cpp new file mode 100644 index 0000000..ac4accb --- /dev/null +++ b/test/Parser/cxx-ambig-decl-expr-xfail.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// XFAIL: * +struct X { + template<typename T> X(T); + X(int, int); + + X operator()(int, int) const; +}; + +template<typename T, typename U> struct Y { }; + +X *x; +void f() { + int y = 0; + X (*x)(int(y), int(y)) = Y<int, float>(), ++y; +} diff --git a/test/Parser/cxx-ambig-decl-expr.cpp b/test/Parser/cxx-ambig-decl-expr.cpp new file mode 100644 index 0000000..b5ff728 --- /dev/null +++ b/test/Parser/cxx-ambig-decl-expr.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +struct X { + template<typename T, typename U> + static void f(int, int); +}; + +void f() { + void (*ptr)(int, int) = &X::f<int, int>; +} diff --git a/test/Parser/cxx-attributes.cpp b/test/Parser/cxx-attributes.cpp index 192193a..8603b30 100644 --- a/test/Parser/cxx-attributes.cpp +++ b/test/Parser/cxx-attributes.cpp @@ -1,9 +1,9 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s
-
-class c {
- virtual void f1(const char* a, ...)
- __attribute__ (( __format__(__printf__,2,3) )) = 0;
- virtual void f2(const char* a, ...)
- __attribute__ (( __format__(__printf__,2,3) )) {}
-};
-
+// RUN: %clang_cc1 -fsyntax-only -verify %s + +class c { + virtual void f1(const char* a, ...) + __attribute__ (( __format__(__printf__,2,3) )) = 0; + virtual void f2(const char* a, ...) + __attribute__ (( __format__(__printf__,2,3) )) {} +}; + diff --git a/test/Parser/cxx-condition.cpp b/test/Parser/cxx-condition.cpp index a3991c4..552d823 100644 --- a/test/Parser/cxx-condition.cpp +++ b/test/Parser/cxx-condition.cpp @@ -1,11 +1,11 @@ -// RUN: %clang_cc1 -parse-noop -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s void f() { int a; while (a) ; while (int x) ; // expected-error {{expected '=' after declarator}} while (float x = 0) ; - if (const int x = a) ; + if (const int x = a) ; // expected-warning{{empty body}} switch (int x = a+10) {} for (; int x = ++a; ) ; } diff --git a/test/Parser/cxx-decl.cpp b/test/Parser/cxx-decl.cpp index e4c703c..e00ffd0 100644 --- a/test/Parser/cxx-decl.cpp +++ b/test/Parser/cxx-decl.cpp @@ -76,3 +76,10 @@ class Class2 { } // no ; typedef Class1<Class2> Type1; // expected-error {{cannot combine with previous 'class' declaration specifier}} + +// rdar : // 8307865 +struct CodeCompleteConsumer { +}; + +void CodeCompleteConsumer::() { // expected-error {{xpected unqualified-id}} +} diff --git a/test/Parser/cxx-default-args.cpp b/test/Parser/cxx-default-args.cpp index a084fb0..7fe8474 100644 --- a/test/Parser/cxx-default-args.cpp +++ b/test/Parser/cxx-default-args.cpp @@ -7,3 +7,10 @@ class C { void m(int x = undecl + 0); // expected-error {{use of undeclared identifier 'undecl'}} }; +typedef struct Inst { + void m(int x=0); +} *InstPtr; + +struct X { + void f(int x = 1:); // expected-error {{unexpected end of default argument expression}} +}; diff --git a/test/Parser/cxx-namespace-alias.cpp b/test/Parser/cxx-namespace-alias.cpp index 2e4d7af..9b90aab 100644 --- a/test/Parser/cxx-namespace-alias.cpp +++ b/test/Parser/cxx-namespace-alias.cpp @@ -1,8 +1,9 @@ -// RUN: %clang_cc1 -parse-noop -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s -namespace A = B; +namespace A = B; // expected-error{{namespace name}} namespace A = !; // expected-error {{expected namespace name}} -namespace A = A::!; // expected-error {{expected namespace name}} +namespace A = A::!; // expected-error {{expected namespace name}} \ + // expected-error{{use of undeclared identifier 'A'}} diff --git a/test/Parser/cxx-typeof.cpp b/test/Parser/cxx-typeof.cpp index 7e89101..4c598e9 100644 --- a/test/Parser/cxx-typeof.cpp +++ b/test/Parser/cxx-typeof.cpp @@ -5,3 +5,9 @@ static void test() { int x; typeof pi[x] y; } + +// Part of rdar://problem/8347416; from the gcc test suite. +struct S { + int i; + __typeof(S::i) foo(); // expected-error {{invalid use of nonstatic data member 'i'}} +}; diff --git a/test/Parser/declarators.c b/test/Parser/declarators.c index fb69fa9..e245adb 100644 --- a/test/Parser/declarators.c +++ b/test/Parser/declarators.c @@ -94,3 +94,6 @@ void test14() // expected-error {{expected ';' after top level declarator}} void test14a(); void *test14b = (void*)test14a; // Make sure test14a didn't get skipped. + +// rdar://problem/8358508 +long struct X { int x; } test15(); // expected-error {{'long struct' is invalid}} diff --git a/test/Parser/expressions.c b/test/Parser/expressions.c index 44ebe66..ffc5c83 100644 --- a/test/Parser/expressions.c +++ b/test/Parser/expressions.c @@ -1,19 +1,17 @@ -// RUN: %clang_cc1 -parse-noop -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s void test1() { - if (sizeof (int){ 1}); // sizeof compound literal - if (sizeof (int)); // sizeof type + if (sizeof (int){ 1}) {} // sizeof compound literal + if (sizeof (int)) {} // sizeof type - (int)4; // cast. - (int){4}; // compound literal. + (void)(int)4; // cast. + (void)(int){4}; // compound literal. - // FIXME: change this to the struct version when we can. - //int A = (struct{ int a;}){ 1}.a; - int A = (int){ 1}.a; + int A = (struct{ int a;}){ 1}.a; } int test2(int a, int b) { - return a ? a,b : a; + return a ? (void)a,b : a; } int test3(int a, int b, int c) { @@ -22,23 +20,27 @@ int test3(int a, int b, int c) { int test4() { test4(); + return 0; } +struct X0 { struct { struct { int c[10][9]; } b; } a; }; + int test_offsetof() { - // FIXME: change into something that is semantically correct. - __builtin_offsetof(int, a.b.c[4][5]); + (void)__builtin_offsetof(struct X0, a.b.c[4][5]); + return 0; } void test_sizeof(){ int arr[10]; - sizeof arr[0]; - sizeof(arr[0]); - sizeof(arr)[0]; + (void)sizeof arr[0]; + (void)sizeof(arr[0]); + (void)sizeof(arr)[0]; } // PR3418 int test_leading_extension() { __extension__ (*(char*)0) = 1; + return 0; } // PR3972 diff --git a/test/Parser/expressions.m b/test/Parser/expressions.m index e27f405..1f1005a 100644 --- a/test/Parser/expressions.m +++ b/test/Parser/expressions.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -parse-noop %s +// RUN: %clang_cc1 -fsyntax-only -verify %s void test1() { @"s"; // expected-warning {{expression result unused}} diff --git a/test/Parser/method-prototype-1.m b/test/Parser/method-prototype-1.m index d2d9563..a32bc2e 100644 --- a/test/Parser/method-prototype-1.m +++ b/test/Parser/method-prototype-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -parse-noop +// RUN: %clang_cc1 %s -fsyntax-only @interface MyObject - (void) bycopy : (int) woodo, ... ; - (void) break : (int) woodo, ... ; diff --git a/test/Parser/objc-messaging-1.m b/test/Parser/objc-messaging-1.m index 511290e..82450df 100644 --- a/test/Parser/objc-messaging-1.m +++ b/test/Parser/objc-messaging-1.m @@ -1,19 +1,26 @@ -// RUN: %clang_cc1 %s -parse-noop +// RUN: %clang_cc1 %s -fsyntax-only -verify int main () { int i,j; struct S *p; id a, b, c; - [p ii]; - [p if: 1 :2]; - [p inout: 1 :2 another:(2,3,4)]; - [p inout: 1 :2 another:(2,3,4), 6,6,8]; - [p inout: 1 :2 another:(2,3,4), (6,4,5),6,8]; - [p inout: 1 :2 another:(i+10), (i,j-1,5),6,8]; - [p long: 1 :2 another:(i+10), (i,j-1,5),6,8]; - [p : "Hello\n" :2 another:(i+10), (i,j-1,5),6,8]; + [a ii]; // expected-warning{{not found}} + [a if: 1 :2]; // expected-warning{{not found}} + [a inout: 1 :2 another:(2,3,4)]; // expected-warning{{not found}} \ + // expected-warning 2{{expression result unused}} + [a inout: 1 :2 another:(2,3,4), 6,6,8]; // expected-warning{{not found}} \ + // expected-warning 2{{expression result unused}} + [a inout: 1 :2 another:(2,3,4), (6,4,5),6,8]; // expected-warning{{not found}} \ + // expected-warning 4{{expression result unused}} + [a inout: 1 :2 another:(i+10), (i,j-1,5),6,8]; // expected-warning{{not found}} \ + // expected-warning 2{{expression result unused}} + [a long: 1 :2 another:(i+10), (i,j-1,5),6,8]; // expected-warning{{not found}} \ + // expected-warning 2{{expression result unused}} + [a : "Hello\n" :2 another:(i+10), (i,j-1,5),6,8]; // expected-warning{{not found}} \ + // expected-warning 2{{expression result unused}} // Comma expression as receiver (rdar://6222856) - [a, b, c foo]; + [a, b, c foo]; // expected-warning{{not found}} \ + // expected-warning 2{{expression result unused}} } diff --git a/test/Parser/pragma-options.c b/test/Parser/pragma-options.c index daf385d..7844e71 100644 --- a/test/Parser/pragma-options.c +++ b/test/Parser/pragma-options.c @@ -10,3 +10,13 @@ #pragma options align=reset #pragma options align=mac68k #pragma options align=power + +/* expected-warning {{expected '=' following '#pragma align'}} */ #pragma align +/* expected-warning {{expected identifier in '#pragma align'}} */ #pragma align = +/* expected-warning {{invalid alignment option in '#pragma align'}} */ #pragma align = foo +/* expected-warning {{extra tokens at end of '#pragma align'}} */ #pragma align = reset foo + +#pragma align=natural +#pragma align=reset +#pragma align=mac68k +#pragma align=power diff --git a/test/Parser/pragma-visibility.c b/test/Parser/pragma-visibility.c new file mode 100644 index 0000000..cfc3d9e --- /dev/null +++ b/test/Parser/pragma-visibility.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +#pragma GCC visibility foo // expected-warning{{expected identifier in '#pragma visibility' - ignored}} +#pragma GCC visibility pop foo // expected-warning{{extra tokens at end of '#pragma visibility' - ignored}} +#pragma GCC visibility push // expected-warning{{missing '(' after '#pragma visibility'}} +#pragma GCC visibility push( // expected-warning{{expected identifier in '#pragma visibility' - ignored}} +#pragma GCC visibility push(hidden // expected-warning{{missing ')' after '#pragma visibility' - ignoring}} +#pragma GCC visibility push(hidden) +#pragma GCC visibility pop diff --git a/test/Parser/selector-1.m b/test/Parser/selector-1.m index 1f9cad6..0f35ce7 100644 --- a/test/Parser/selector-1.m +++ b/test/Parser/selector-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -parse-noop %s +// RUN: %clang_cc1 -fsyntax-only -verify %s int main() { SEL s = @selector(retain); diff --git a/test/Parser/typeof.c b/test/Parser/typeof.c index cf0e47a..7953a69 100644 --- a/test/Parser/typeof.c +++ b/test/Parser/typeof.c @@ -17,3 +17,10 @@ static void test() { int xx; int *i; } + +// <rdar://problem/8237491> +void test2() { + int a; + short b; + __typeof__(a) (*f)(__typeof__(b)); +} diff --git a/test/Parser/types.c b/test/Parser/types.c index 0e8a63d..53b9dd5 100644 --- a/test/Parser/types.c +++ b/test/Parser/types.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -parse-noop +// RUN: %clang_cc1 %s -fsyntax-only -verify // Test the X can be overloaded inside the struct. typedef int X; diff --git a/test/Preprocessor/dump-macros-undef.c b/test/Preprocessor/dump-macros-undef.c new file mode 100644 index 0000000..358fd17 --- /dev/null +++ b/test/Preprocessor/dump-macros-undef.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -E -dD %s | FileCheck %s +// PR7818 + +// CHECK: # 1 "{{.+}}.c" +#define X 3 +// CHECK: #define X 3 +#undef X +// CHECK: #undef X diff --git a/test/Preprocessor/init.c b/test/Preprocessor/init.c index 8283671..6c27a6c 100644 --- a/test/Preprocessor/init.c +++ b/test/Preprocessor/init.c @@ -74,9 +74,10 @@ // C94:#define __STDC_VERSION__ 199409L // // -// RUN: %clang_cc1 -fms-extensions -E -dM < /dev/null | FileCheck -check-prefix MSEXT %s +// RUN: %clang_cc1 -fms-extensions -triple i686-pc-win32 -E -dM < /dev/null | FileCheck -check-prefix MSEXT %s // // MSEXT-NOT:#define __STDC__ +// MSEXT:#define _INTEGRAL_MAX_BITS 64 // MSEXT:#define __int16 __INT16_TYPE__ // MSEXT:#define __int32 __INT32_TYPE__ // MSEXT:#define __int64 __INT64_TYPE__ @@ -117,6 +118,13 @@ // SCHAR-NOT:#define __UNSIGNED_CHAR__ // SCHAR:#define __clang__ 1 // +// RUN: %clang_cc1 -E -dM -fshort-wchar < /dev/null | FileCheck -check-prefix SHORTWCHAR %s +// +// SHORTWCHAR: #define __SIZEOF_WCHAR_T__ 2 +// SHORTWCHAR: #define __WCHAR_MAX__ 65535U +// SHORTWCHAR: #define __WCHAR_TYPE__ unsigned short +// SHORTWCHAR: #define __WCHAR_WIDTH__ 16 +// // RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-none < /dev/null | FileCheck -check-prefix ARM %s // // ARM:#define __APCS_32__ 1 diff --git a/test/Preprocessor/macro_fn_comma_swallow.c b/test/Preprocessor/macro_fn_comma_swallow.c index 5742591..726a889 100644 --- a/test/Preprocessor/macro_fn_comma_swallow.c +++ b/test/Preprocessor/macro_fn_comma_swallow.c @@ -1,21 +1,28 @@ // Test the GNU comma swallowing extension. -// RUN: %clang_cc1 %s -E | grep 'foo{A, }' -// RUN: %clang_cc1 %s -E | grep 'fo2{A,}' -// RUN: %clang_cc1 %s -E | grep '{foo}' +// RUN: %clang_cc1 %s -E | FileCheck -strict-whitespace %s +// CHECK: 1: foo{A, } #define X(Y) foo{A, Y} -X() +1: X() + +// CHECK: 2: fo2{A,} #define X2(Y) fo2{A,##Y} -X2() +2: X2() // should eat the comma. +// CHECK: 3: {foo} #define X3(b, ...) {b, ## __VA_ARGS__} -X3(foo) +3: X3(foo) -// RUN: %clang_cc1 %s -E | grep 'AA BB' // PR3880 +// CHECK: 4: AA BB #define X4(...) AA , ## __VA_ARGS__ BB -X4() +4: X4() + +// PR7943 +// CHECK: 5: 1 +#define X5(x,...) x##,##__VA_ARGS__ +5: X5(1) diff --git a/test/Preprocessor/macro_paste_mscomment.c b/test/Preprocessor/macro_paste_msextensions.c index 7132406..c5b4213 100644 --- a/test/Preprocessor/macro_paste_mscomment.c +++ b/test/Preprocessor/macro_paste_msextensions.c @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -P -E -fms-extensions %s | FileCheck -strict-whitespace %s + // This horrible stuff should preprocess into (other than whitespace): // int foo; // int bar; @@ -24,3 +25,10 @@ nested(baz) rise of the dead tokens // CHECK: int baz // CHECK: ; + +// rdar://8197149 - VC++ allows invalid token pastes: (##baz +#define foo(x) abc(x) +#define bar(y) foo(##baz(y)) +bar(q) + +// CHECK: abc(baz(q)) diff --git a/test/Preprocessor/pragma-pushpop-macro.c b/test/Preprocessor/pragma-pushpop-macro.c new file mode 100644 index 0000000..87cceaa --- /dev/null +++ b/test/Preprocessor/pragma-pushpop-macro.c @@ -0,0 +1,33 @@ +/* Test pragma pop_macro and push_macro directives from + http://msdn.microsoft.com/en-us/library/hsttss76.aspx */ + +// pop_macro: Sets the value of the macro_name macro to the value on the top of +// the stack for this macro. +// #pragma pop_macro("macro_name") +// push_macro: Saves the value of the macro_name macro on the top of the stack +// for this macro. +// #pragma push_macro("macro_name") +// +// RUN: %clang_cc1 -fms-extensions -E %s -o - | FileCheck %s + +#define X 1 +#define Y 2 +int pmx0 = X; +int pmy0 = Y; +#define Y 3 +#pragma push_macro("Y") +#pragma push_macro("X") +int pmx1 = X; +#define X 2 +int pmx2 = X; +#pragma pop_macro("X") +int pmx3 = X; +#pragma pop_macro("Y") +int pmy1 = Y; + +// CHECK: int pmx0 = 1 +// CHECK: int pmy0 = 2 +// CHECK: int pmx1 = 1 +// CHECK: int pmx2 = 2 +// CHECK: int pmx3 = 1 +// CHECK: int pmy1 = 3 diff --git a/test/Preprocessor/pragma_diagnostic.c b/test/Preprocessor/pragma_diagnostic.c index d157406..818f02f 100644 --- a/test/Preprocessor/pragma_diagnostic.c +++ b/test/Preprocessor/pragma_diagnostic.c @@ -20,9 +20,8 @@ #endif - #define foo error -#pragma GCC diagnostic foo "-Wundef" // expected-warning {{pragma diagnostic expected 'error', 'warning', 'ignored', or 'fatal'}} +#pragma GCC diagnostic foo "-Wundef" // expected-warning {{pragma diagnostic expected 'error', 'warning', 'ignored', 'fatal', 'push', or 'pop'}} #pragma GCC diagnostic error 42 // expected-warning {{unexpected token in pragma diagnostic}} diff --git a/test/Preprocessor/pragma_microsoft.c b/test/Preprocessor/pragma_microsoft.c index 0201c45..b68d6e3 100644 --- a/test/Preprocessor/pragma_microsoft.c +++ b/test/Preprocessor/pragma_microsoft.c @@ -18,3 +18,23 @@ #pragma comment(user, "foo\abar\nbaz\tsome thing") + +// __pragma + +__pragma(comment(linker," bar=" BAR)) + +#define MACRO_WITH__PRAGMA { \ + __pragma(warning(push)); \ + __pragma(warning(disable: 10000)); \ + 2+2; \ + __pragma(warning(pop)); \ +} + +void f() +{ + __pragma() + + // If we ever actually *support* __pragma(warning(disable: x)), + // this warning should go away. + MACRO_WITH__PRAGMA // expected-warning {{expression result unused}} +} diff --git a/test/Preprocessor/pushable-diagnostics.c b/test/Preprocessor/pushable-diagnostics.c index 6c861a1..567a866f 100644 --- a/test/Preprocessor/pushable-diagnostics.c +++ b/test/Preprocessor/pushable-diagnostics.c @@ -2,7 +2,7 @@ #pragma clang diagnostic pop // expected-warning{{pragma diagnostic pop could not pop, no matching push}} -#pragma clang diagnostic puhs // expected-warning{{pragma diagnostic expected 'error', 'warning', 'ignored', 'fatal' 'push', or 'pop'}} +#pragma clang diagnostic puhs // expected-warning {{pragma diagnostic expected 'error', 'warning', 'ignored', 'fatal', 'push', or 'pop'}} char a = 'df'; // expected-warning{{multi-character character constant}} diff --git a/test/Rewriter/rewrite-block-consts.mm b/test/Rewriter/rewrite-block-consts.mm new file mode 100644 index 0000000..c74873f --- /dev/null +++ b/test/Rewriter/rewrite-block-consts.mm @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// rdar:// 8243071 + +void x(int y) {} +void f() { + const int bar = 3; + int baz = 4; + __block int bab = 4; + __block const int bas = 5; + void (^b)() = ^{ + x(bar); + x(baz); + x(bab); + x(bas); + b(); + }; + b(); +} diff --git a/test/Rewriter/rewrite-constructor-init.mm b/test/Rewriter/rewrite-constructor-init.mm new file mode 100644 index 0000000..534e7fa --- /dev/null +++ b/test/Rewriter/rewrite-constructor-init.mm @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// rdar : // 8213998 + +typedef unsigned int NSUInteger; + +typedef struct _NSRange { + NSUInteger location; + NSUInteger length; +} NSRange; + +static __inline NSRange NSMakeRange(NSUInteger loc, NSUInteger len) { + NSRange r; + r.location = loc; + r.length = len; + return r; +} + +void bar() { + __block NSRange previousRange = NSMakeRange(0, 0); + void (^blk)() = ^{ + previousRange = NSMakeRange(1, 0); + }; +} diff --git a/test/Sema/altivec-init.c b/test/Sema/altivec-init.c index 57abc93..b5758bc 100644 --- a/test/Sema/altivec-init.c +++ b/test/Sema/altivec-init.c @@ -14,3 +14,22 @@ v8 foo(void) { // FIXME: test that (type)(fn)(args) still works with -faltivec // FIXME: test that c++ overloaded commas still work -faltivec } + +void __attribute__((__overloadable__)) f(v4 a) +{ +} + +void __attribute__((__overloadable__)) f(int a) +{ +} + +void test() +{ + v4 vGCC; + vector int vAltiVec; + + f(vAltiVec); + vGCC = vAltiVec; + vGCC = vGCC > vAltiVec; + vAltiVec = 0 ? vGCC : vGCC; +} diff --git a/test/Sema/array-init.c b/test/Sema/array-init.c index f93b087..0ee22c0 100644 --- a/test/Sema/array-init.c +++ b/test/Sema/array-init.c @@ -210,7 +210,7 @@ struct bittest bittestvar = {1, 2, 3, 4}; //expected-warning{{excess elements in // Not completely sure what should happen here... int u1 = {}; //expected-warning{{use of GNU empty initializer extension}} expected-error{{scalar initializer cannot be empty}} -int u2 = {{3}}; //expected-error{{too many braces around scalar initializer}} +int u2 = {{3}}; //expected-warning{{too many braces around scalar initializer}} // PR2362 void varArray() { @@ -218,7 +218,8 @@ void varArray() { } // PR2151 -void emptyInit() {struct {} x[] = {6};} //expected-warning{{empty struct extension}} expected-error{{initializer for aggregate with no elements}} +void emptyInit() {struct {} x[] = {6};} //expected-warning{{empty struct (accepted as an extension) has size 0 in C, size 1 in C++}} \ +// expected-error{{initializer for aggregate with no elements}} void noNamedInit() { struct {int:5;} x[] = {6}; //expected-error{{initializer for aggregate with no elements}} @@ -241,7 +242,8 @@ struct soft_segment_descriptor gdt_segs[] = { }; static void sppp_ipv6cp_up(); -const struct {} ipcp = { sppp_ipv6cp_up }; //expected-warning{{empty struct extension}} expected-warning{{excess elements in struct initializer}} +const struct {} ipcp = { sppp_ipv6cp_up }; //expected-warning{{empty struct (accepted as an extension) has size 0 in C, size 1 in C++}} \ +// expected-warning{{excess elements in struct initializer}} struct _Matrix { union { float m[4][4]; }; }; //expected-warning{{anonymous unions are a GNU extension in C}} typedef struct _Matrix Matrix; diff --git a/test/Sema/array-size-64.c b/test/Sema/array-size-64.c new file mode 100644 index 0000000..f22e8e7 --- /dev/null +++ b/test/Sema/array-size-64.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin -verify %s + +void f() { + int a[2147483647U][2147483647U]; // expected-error{{array is too large}} + int b[1073741825U - 1U][2147483647U]; + int c[18446744073709551615U/sizeof(int)/2]; +} diff --git a/test/Sema/array-size.c b/test/Sema/array-size.c new file mode 100644 index 0000000..7580e3e --- /dev/null +++ b/test/Sema/array-size.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -triple i686-apple-darwin -verify %s + +void f() { + int x0[1073741824]; // expected-error{{array is too large}} + int x1[1073741824 + 1]; // expected-error{{array is too large}} + int x2[(unsigned)1073741824]; // expected-error{{array is too large}} + int x3[(unsigned)1073741824 + 1]; // expected-error{{array is too large}} + int x4[1073741824 - 1]; +} + diff --git a/test/Sema/block-misc.c b/test/Sema/block-misc.c index 92be5b1..ec74a63 100644 --- a/test/Sema/block-misc.c +++ b/test/Sema/block-misc.c @@ -221,3 +221,8 @@ void test21() { (void)b[1]; // expected-error {{cannot refer to declaration with an array type inside block}} }(); } + +// rdar ://8218839 +const char * (^func)(void) = ^{ return __func__; }; +const char * (^function)(void) = ^{ return __FUNCTION__; }; +const char * (^pretty)(void) = ^{ return __PRETTY_FUNCTION__; }; diff --git a/test/Sema/builtins-arm.c b/test/Sema/builtins-arm.c new file mode 100644 index 0000000..4dd31e7 --- /dev/null +++ b/test/Sema/builtins-arm.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple armv7 -fsyntax-only -verify -DTEST0 %s +// RUN: %clang_cc1 -triple armv7 -fsyntax-only -verify -DTEST1 %s + +#ifdef TEST0 +void __clear_cache(char*, char*); +#endif + +#ifdef TEST1 +void __clear_cache(void*, void*); +#endif + diff --git a/test/Sema/builtins.c b/test/Sema/builtins.c index c0a2131..787630c 100644 --- a/test/Sema/builtins.c +++ b/test/Sema/builtins.c @@ -44,6 +44,11 @@ void test9(short v) { // PR7600: Pointers are implicitly casted to integers and back. void *old_ptr = __sync_val_compare_and_swap((void**)0, 0, 0); + + // Ensure the return type is correct even when implicit casts are stripped + // away. This triggers an assertion while checking the comparison otherwise. + if (__sync_fetch_and_add(&old, 1) == 1) { + } } @@ -75,3 +80,18 @@ void test12(void) { void test_unknown_builtin(int a, int b) { __builtin_foo(a, b); // expected-error{{use of unknown builtin}} } + +int test13() { + __builtin_eh_return(0, 0); // no warning, eh_return never returns. +} + +// <rdar://problem/8228293> +void test14() { + int old; + old = __sync_fetch_and_min((volatile int *)&old, 1); +} + +// <rdar://problem/8336581> +void test15(const char *s) { + __builtin_printf("string is %s\n", s); +} diff --git a/test/Sema/cast-incomplete.c b/test/Sema/cast-incomplete.c new file mode 100644 index 0000000..dd10e00 --- /dev/null +++ b/test/Sema/cast-incomplete.c @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only %s -verify +// PR5692 + +enum x; // expected-note {{forward declaration}} +extern struct y a; // expected-note {{forward declaration}} +extern union z b; // expected-note 2 {{forward declaration}} + +void foo() { + (enum x)1; // expected-error {{cast to incomplete type}} + (struct y)a; // expected-error {{cast to incomplete type}} + (union z)b; // expected-error {{cast to incomplete type}} + (union z)1; // expected-error {{cast to incomplete type}} +} + diff --git a/test/Sema/compound-literal.c b/test/Sema/compound-literal.c index 08c30b3..aade464 100644 --- a/test/Sema/compound-literal.c +++ b/test/Sema/compound-literal.c @@ -11,7 +11,7 @@ static int x = (int){1}; static int *p2 = (int []){2,x}; // -expected-error {{initializer element is not a compile-time constant}} static long *p3 = (long []){2,"x"}; // -expected-warning {{incompatible pointer to integer conversion initializing 'long' with an expression of type 'char [2]'}} -typedef struct { } cache_t; // -expected-warning{{use of empty struct extension}} +typedef struct { } cache_t; // -expected-warning{{empty struct (accepted as an extension) has size 0 in C, size 1 in C++}} static cache_t clo_I1_cache = ((cache_t) { } ); // -expected-warning{{use of GNU empty initializer extension}} typedef struct Test {int a;int b;} Test; diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c index c132b34..42097e7 100644 --- a/test/Sema/const-eval.c +++ b/test/Sema/const-eval.c @@ -74,5 +74,9 @@ const _Bool constbool = 0; EVAL_EXPR(35, constbool) EVAL_EXPR(36, constbool) -EVAL_EXPR(37, (1,2.0) == 2.0) // expected-warning {{expression result unused}} -EVAL_EXPR(38, __builtin_expect(1,1) == 1) +EVAL_EXPR(37, (1,2.0) == 2.0 ? 1 : -1) +EVAL_EXPR(38, __builtin_expect(1,1) == 1 ? 1 : -1) + +// PR7884 +EVAL_EXPR(39, __real__(1.f) == 1 ? 1 : -1) +EVAL_EXPR(40, __imag__(1.f) == 0 ? 1 : -1) diff --git a/test/Sema/enum.c b/test/Sema/enum.c index 0570150..64aa31b 100644 --- a/test/Sema/enum.c +++ b/test/Sema/enum.c @@ -96,3 +96,9 @@ char * s = (an_enum) an_enumerator; // expected-warning {{incompatible integer t // PR4515 enum PR4515 {PR4515a=1u,PR4515b=(PR4515a-2)/2}; int CheckPR4515[PR4515b==0?1:-1]; + +// PR7911 +extern enum PR7911T PR7911V; // expected-warning{{ISO C forbids forward references to 'enum' types}} +void PR7911F() { + switch (PR7911V); // expected-error {{statement requires expression of integer type}} +} diff --git a/test/Sema/expr-comma-c89.c b/test/Sema/expr-comma-c89.c index dc42702..d0883ba 100644 --- a/test/Sema/expr-comma-c89.c +++ b/test/Sema/expr-comma-c89.c @@ -11,7 +11,7 @@ int B[sizeof((a.c)) == 17 ? 1 : -1]; // comma does array/function promotion in c99. -int X[sizeof(0, (foo().c)) == sizeof(char*) ? 1 : -1]; // expected-warning {{expression result unused}} -int Y[sizeof(0, (a,b).c) == sizeof(char*) ? 1 : -1]; // expected-warning {{expression result unused}} expected-warning {{expression result unused}} -int Z[sizeof(0, (a=b).c) == sizeof(char*) ? 1 : -1]; // expected-warning {{expression result unused}} +int X[sizeof(0, (foo().c)) == sizeof(char*) ? 1 : -1]; +int Y[sizeof(0, (a,b).c) == sizeof(char*) ? 1 : -1]; +int Z[sizeof(0, (a=b).c) == sizeof(char*) ? 1 : -1]; diff --git a/test/Sema/expr-comma.c b/test/Sema/expr-comma.c index b004fc1..d3e4020 100644 --- a/test/Sema/expr-comma.c +++ b/test/Sema/expr-comma.c @@ -11,7 +11,7 @@ int B[sizeof((a.c)) == 17 ? 1 : -1]; // comma does not promote array/function in c90 unless they are lvalues. -int W[sizeof(0, a.c) == sizeof(char*) ? 1 : -1]; // expected-warning {{expression result unused}} -int X[sizeof(0, (foo().c)) == 17 ? 1 : -1]; // expected-warning {{expression result unused}} -int Y[sizeof(0, (a,b).c) == 17 ? 1 : -1]; // expected-warning {{expression result unused}} // expected-warning {{expression result unused}} -int Z[sizeof(0, (a=b).c) == 17 ? 1 : -1]; // expected-warning {{expression result unused}} +int W[sizeof(0, a.c) == sizeof(char*) ? 1 : -1]; +int X[sizeof(0, (foo().c)) == 17 ? 1 : -1]; +int Y[sizeof(0, (a,b).c) == 17 ? 1 : -1]; +int Z[sizeof(0, (a=b).c) == 17 ? 1 : -1]; diff --git a/test/Sema/exprs.c b/test/Sema/exprs.c index 9d3da90..56a52be 100644 --- a/test/Sema/exprs.c +++ b/test/Sema/exprs.c @@ -145,5 +145,8 @@ void test19() { int test20(int x) { return x && 4; // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}} - return x && sizeof(int) == 4; // no warning. + return x && sizeof(int) == 4; // no warning, RHS is logical op. + + // no warning, this is an idiom for "true" in old C style. + return x && (signed char)1; } diff --git a/test/Sema/ext_vector_casts.c b/test/Sema/ext_vector_casts.c index 7681953..75d41ca 100644 --- a/test/Sema/ext_vector_casts.c +++ b/test/Sema/ext_vector_casts.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -fno-lax-vector-conversions %s typedef __attribute__(( ext_vector_type(2) )) float float2; typedef __attribute__(( ext_vector_type(4) )) int int4; diff --git a/test/Sema/format-strings-scanf.c b/test/Sema/format-strings-scanf.c new file mode 100644 index 0000000..42b6c03 --- /dev/null +++ b/test/Sema/format-strings-scanf.c @@ -0,0 +1,34 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral %s + +typedef __typeof(sizeof(int)) size_t; +typedef struct _FILE FILE; +typedef __WCHAR_TYPE__ wchar_t; + +int fscanf(FILE * restrict, const char * restrict, ...) ; +int scanf(const char * restrict, ...) ; +int sscanf(const char * restrict, const char * restrict, ...) ; + +void test(const char *s, int *i) { + scanf(s, i); // expected-warning{{ormat string is not a string literal}} + scanf("%0d", i); // expected-warning{{zero field width in scanf format string is unused}} + scanf("%00d", i); // expected-warning{{zero field width in scanf format string is unused}} + scanf("%d%[asdfasdfd", i, s); // expected-warning{{no closing ']' for '%[' in scanf format string}} + + unsigned short s_x; + scanf ("%" "hu" "\n", &s_x); // no-warning + scanf("%y", i); // expected-warning{{invalid conversion specifier 'y'}} + scanf("%%"); // no-warning + scanf("%%%1$d", i); // no-warning + scanf("%1$d%%", i); // no-warning + scanf("%d", i, i); // expected-warning{{data argument not used by format string}} + scanf("%*d", i); // // expected-warning{{data argument not used by format string}} + scanf("%*d", i); // // expected-warning{{data argument not used by format string}} + scanf("%*d%1$d", i); // no-warning +} + +void bad_length_modifiers(char *s, void *p, wchar_t *ws, long double *ld) { + scanf("%hhs", "foo"); // expected-warning{{length modifier 'hh' results in undefined behavior or no effect with 's' conversion specifier}} + scanf("%1$zp", p); // expected-warning{{length modifier 'z' results in undefined behavior or no effect with 'p' conversion specifier}} + scanf("%ls", ws); // no-warning + scanf("%#.2Lf", ld); // expected-warning{{invalid conversion specifier '#'}} +} diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c index c6dee68..2325454 100644 --- a/test/Sema/format-strings.c +++ b/test/Sema/format-strings.c @@ -239,6 +239,8 @@ void test_positional_arguments() { printf("%1$2.2d", (int) 2); // no-warning printf("%2$*1$.2d", (int) 2, (int) 3); // no-warning printf("%2$*8$d", (int) 2, (int) 3); // expected-warning{{specified field width is missing a matching 'int' argument}} + printf("%%%1$d", (int) 2); // no-warning + printf("%1$d%%", (int) 2); // no-warning } // PR 6697 - Handle format strings where the data argument is not adjacent to the format string @@ -284,3 +286,18 @@ void bug7377_bad_length_mod_usage() { printf("%-0f", 1.23); // expected-warning{{flag '0' is ignored when flag '-' is present}} printf("%-+f", 1.23); // no-warning } + +// PR 7981 - handle '%lc' (wint_t) +#ifndef wint_t +typedef int __darwin_wint_t; +typedef __darwin_wint_t wint_t; +#endif + +void pr7981(wint_t c, wchar_t c2) { + printf("%lc", c); // no-warning + printf("%lc", 1.0); // expected-warning{{the argument has type 'double'}} + printf("%lc", (char) 1); // no-warning + printf("%lc", &c); // expected-warning{{the argument has type 'wint_t *' (aka 'int *')}} + printf("%lc", c2); // no-warning +} + diff --git a/test/Sema/knr-def-call.c b/test/Sema/knr-def-call.c index 8ae0550..66f2ec0 100644 --- a/test/Sema/knr-def-call.c +++ b/test/Sema/knr-def-call.c @@ -16,3 +16,14 @@ void f2(x) float x; { } // expected-warning{{promoted type 'double' of K&R funct typedef void (*f3)(void); f3 t3(int b) { return b? f0 : f1; } // okay + +// <rdar://problem/8193107> +void f4() { + char *rindex(); +} + +char *rindex(s, c) + register char *s, c; // expected-warning{{promoted type 'char *' of K&R function parameter is not compatible with the parameter type 'char const *' declared in a previous prototype}} +{ + return 0; +} diff --git a/test/Sema/overloadable.c b/test/Sema/overloadable.c index 28c3e4c..8fb41a9 100644 --- a/test/Sema/overloadable.c +++ b/test/Sema/overloadable.c @@ -41,7 +41,6 @@ double promote(float) __attribute__((__overloadable__)); // expected-note {{cand double promote(double) __attribute__((__overloadable__)); // expected-note {{candidate}} long double promote(long double) __attribute__((__overloadable__)); // expected-note {{candidate}} -void promote() __attribute__((__overloadable__)); // expected-error{{'overloadable' function 'promote' must have a prototype}} void promote(...) __attribute__((__overloadable__, __unavailable__)); // \ // expected-note{{candidate function}} @@ -60,3 +59,13 @@ double magnitude(IntVec) __attribute__((__overloadable__)); double test_p6600(DoubleVec d) { return magnitude(d) * magnitude(d); } + +// PR7738 +extern int __attribute__((overloadable)) f0(); // expected-error{{'overloadable' function 'f0' must have a prototype}} +typedef int f1_type(); +f1_type __attribute__((overloadable)) f1; // expected-error{{'overloadable' function 'f1' must have a prototype}} + +void test() { + f0(); + f1(); +} diff --git a/test/Sema/pragma-align-packed.c b/test/Sema/pragma-align-packed.c index 30b87bf..74fbd13 100644 --- a/test/Sema/pragma-align-packed.c +++ b/test/Sema/pragma-align-packed.c @@ -21,3 +21,10 @@ struct s2 { }; extern int a[sizeof(struct s2) == 5 ? 1 : -1]; #pragma options align=reset + +#pragma pack(1) +struct s3_0 { unsigned char f0; unsigned int f1; }; +int t3_0[sizeof(struct s3_0) == 5 ? 1 : -1]; +#pragma options align=reset +struct s3_1 { unsigned char f0; unsigned int f1; }; +int t3_1[sizeof(struct s3_1) == 8 ? 1 : -1]; diff --git a/test/Sema/recover-goto.c b/test/Sema/recover-goto.c index 0d665f9..0e8f6d3 100644 --- a/test/Sema/recover-goto.c +++ b/test/Sema/recover-goto.c @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only %s -verify -void a() {goto A; // expected-error {{use of undeclared label}} +void a() { // expected-note {{to match this '{'}} + goto A; // expected-error {{use of undeclared label}} // expected-error {{expected '}'}} diff --git a/test/Sema/scope-check.c b/test/Sema/scope-check.c index f3881ed..4ccb64c 100644 --- a/test/Sema/scope-check.c +++ b/test/Sema/scope-check.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify -fblocks -std=gnu99 %s -Wno-unreachable-code int test1(int x) { - goto L; // expected-error{{illegal goto into protected scope}} + goto L; // expected-error{{goto into protected scope}} int a[x]; // expected-note {{jump bypasses initialization of variable length array}} int b[x]; // expected-note {{jump bypasses initialization of variable length array}} L: @@ -9,7 +9,7 @@ int test1(int x) { } int test2(int x) { - goto L; // expected-error{{illegal goto into protected scope}} + goto L; // expected-error{{goto into protected scope}} typedef int a[x]; // expected-note {{jump bypasses initialization of VLA typedef}} L: return sizeof(a); @@ -18,14 +18,14 @@ int test2(int x) { void test3clean(int*); int test3() { - goto L; // expected-error{{illegal goto into protected scope}} + goto L; // expected-error{{goto into protected scope}} int a __attribute((cleanup(test3clean))); // expected-note {{jump bypasses initialization of variable with __attribute__((cleanup))}} L: return a; } int test4(int x) { - goto L; // expected-error{{illegal goto into protected scope}} + goto L; // expected-error{{goto into protected scope}} int a[x]; // expected-note {{jump bypasses initialization of variable length array}} test4(x); L: @@ -50,7 +50,7 @@ void test7(int x) { switch (x) { case 1: ; int a[x]; // expected-note {{jump bypasses initialization of variable length array}} - case 2: // expected-error {{illegal switch case into protected scope}} + case 2: // expected-error {{switch case is in protected scope}} a[1] = 2; break; } @@ -58,17 +58,17 @@ void test7(int x) { int test8(int x) { // For statement. - goto L2; // expected-error {{illegal goto into protected scope}} + goto L2; // expected-error {{goto into protected scope}} for (int arr[x]; // expected-note {{jump bypasses initialization of variable length array}} ; ++x) L2:; // Statement expressions. - goto L3; // expected-error {{illegal goto into protected scope}} + goto L3; // expected-error {{goto into protected scope}} int Y = ({ int a[x]; // expected-note {{jump bypasses initialization of variable length array}} L3: 4; }); - goto L4; // expected-error {{illegal goto into protected scope}} + goto L4; // expected-error {{goto into protected scope}} { int A[x], // expected-note {{jump bypasses initialization of variable length array}} B[x]; // expected-note {{jump bypasses initialization of variable length array}} @@ -91,7 +91,7 @@ int test8(int x) { int A[x], B = ({ if (x) goto L7; else - goto L8; // expected-error {{illegal goto into protected scope}} + goto L8; // expected-error {{goto into protected scope}} 4; }), C[x]; // expected-note {{jump bypasses initialization of variable length array}} L8:; // bad @@ -103,7 +103,7 @@ int test8(int x) { goto L9; else // FIXME: - goto L10; // fixme-error {{illegal goto into protected scope}} + goto L10; // fixme-error {{goto into protected scope}} 4; })]; L10:; // bad } @@ -123,7 +123,7 @@ int test8(int x) { } // Statement expressions 2. - goto L1; // expected-error {{illegal goto into protected scope}} + goto L1; // expected-error {{goto into protected scope}} return x == ({ int a[x]; // expected-note {{jump bypasses initialization of variable length array}} L1: @@ -151,14 +151,14 @@ L4: } void test10(int n, void *P) { - goto L0; // expected-error {{illegal goto into protected scope}} + goto L0; // expected-error {{goto into protected scope}} typedef int A[n]; // expected-note {{jump bypasses initialization of VLA typedef}} L0: - goto L1; // expected-error {{illegal goto into protected scope}} + goto L1; // expected-error {{goto into protected scope}} A b, c[10]; // expected-note 2 {{jump bypasses initialization of variable length array}} L1: - goto L2; // expected-error {{illegal goto into protected scope}} + goto L2; // expected-error {{goto into protected scope}} A d[n]; // expected-note {{jump bypasses initialization of variable length array}} L2: return; @@ -171,7 +171,7 @@ void test11(int n) { case 2: case 3:; int Arr[n]; // expected-note {{jump bypasses initialization of variable length array}} - case 4: // expected-error {{illegal switch case into protected scope}} + case 4: // expected-error {{switch case is in protected scope}} return; } }; @@ -185,7 +185,7 @@ void test12(int n) { L1: goto L2; L2: - goto L3; // expected-error {{illegal goto into protected scope}} + goto L3; // expected-error {{goto into protected scope}} int Arr[n]; // expected-note {{jump bypasses initialization of variable length array}} L3: goto L4; diff --git a/test/Sema/switch.c b/test/Sema/switch.c index 4e39e0f..bb48229 100644 --- a/test/Sema/switch.c +++ b/test/Sema/switch.c @@ -50,14 +50,12 @@ void test4() } switch (cond) { - case g() && 0: // expected-error {{expression is not an integer constant expression}} // expected-note {{subexpression not valid in an integer constant expression}} \ - expected-warning {{use of logical && with constant operand}} + case g() && 0: // expected-error {{expression is not an integer constant expression}} // expected-note {{subexpression not valid in an integer constant expression}} break; } switch (cond) { - case 0 ... g() || 1: // expected-error {{expression is not an integer constant expression}} // expected-note {{subexpression not valid in an integer constant expression}} \\ - expected-warning {{use of logical || with constant operand}} + case 0 ... g() || 1: // expected-error {{expression is not an integer constant expression}} // expected-note {{subexpression not valid in an integer constant expression}} break; } } diff --git a/test/Sema/typedef-variable-type.c b/test/Sema/typedef-variable-type.c index f298968..b805b1e 100644 --- a/test/Sema/typedef-variable-type.c +++ b/test/Sema/typedef-variable-type.c @@ -1,3 +1,8 @@ -// RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic +// RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic -Wno-typedef-redefinition +// Make sure we accept a single typedef +typedef int (*a)[!.0]; // expected-warning{{size of static array must be an integer constant expression}} + +// And make sure we accept identical redefinitions in system headers +// (The test uses -Wno-typedef-redefinition to simulate this.) typedef int (*a)[!.0]; // expected-warning{{size of static array must be an integer constant expression}} diff --git a/test/Sema/vector-ops.c b/test/Sema/vector-ops.c new file mode 100644 index 0000000..20575ec --- /dev/null +++ b/test/Sema/vector-ops.c @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversions +typedef unsigned int v2u __attribute__ ((vector_size (8))); +typedef int v2s __attribute__ ((vector_size (8))); +typedef float v2f __attribute__ ((vector_size(8))); + +void test1(v2u v2ua, v2s v2sa, v2f v2fa) { + // Bitwise binary operators + (void)(v2ua & v2ua); + (void)(v2fa & v2fa); // expected-error{{invalid operands to binary expression}} + + // Unary operators + (void)(~v2ua); + (void)(~v2fa); // expected-error{{invalid argument type 'v2f' to unary}} + + // Arrays + int array1[v2ua]; // expected-error{{size of array has non-integer type 'v2u'}} + int array2[17]; + // FIXME: error message below needs type! + (void)(array2[v2ua]); // expected-error{{array subscript is not an integer}} + + v2u *v2u_ptr = 0; + v2s *v2s_ptr; + v2s_ptr = v2u_ptr; // expected-warning{{converts between pointers to integer types with different sign}} +} + diff --git a/test/Sema/warn-cast-align.c b/test/Sema/warn-cast-align.c new file mode 100644 index 0000000..11e3c41 --- /dev/null +++ b/test/Sema/warn-cast-align.c @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -Wcast-align -verify %s + +// Simple casts. +void test0(char *P) { + char *a = (char*) P; + short *b = (short*) P; // expected-warning {{cast from 'char *' to 'short *' increases required alignment from 1 to 2}} + int *c = (int*) P; // expected-warning {{cast from 'char *' to 'int *' increases required alignment from 1 to 4}} +} + +// Casts from void* are a special case. +void test1(void *P) { + char *a = (char*) P; + short *b = (short*) P; + int *c = (int*) P; + + const volatile void *P2 = P; + char *d = (char*) P2; + short *e = (short*) P2; + int *f = (int*) P2; + + const char *g = (const char*) P2; + const short *h = (const short*) P2; + const int *i = (const int*) P2; + + const volatile char *j = (const volatile char*) P2; + const volatile short *k = (const volatile short*) P2; + const volatile int *l = (const volatile int*) P2; +} + +// Aligned struct. +__attribute__((align(16))) struct A { + char buffer[16]; +}; +void test2(char *P) { + struct A *a = (struct A*) P; // expected-warning {{cast from 'char *' to 'struct A *' increases required alignment from 1 to 16}} +} + +// Incomplete type. +void test3(char *P) { + struct B *b = (struct B*) P; +} diff --git a/test/Sema/warn-unused-function.c b/test/Sema/warn-unused-function.c index d5e676b..24d4fad 100644 --- a/test/Sema/warn-unused-function.c +++ b/test/Sema/warn-unused-function.c @@ -35,3 +35,15 @@ void bar2(void) { } __attribute__((destructor)) static void bar3(void); void bar3(void) { } + +static void f10(void); // expected-warning{{unused}} +static void f10(void); + +static void f11(void); +static void f11(void) { } // expected-warning{{unused}} + +static void f12(void) { } // expected-warning{{unused}} +static void f12(void); + +// PR7923 +static void unused(void) { unused(); } // expected-warning{{unused}} diff --git a/test/Sema/warn-write-strings.c b/test/Sema/warn-write-strings.c index 04af00c..c936a12 100644 --- a/test/Sema/warn-write-strings.c +++ b/test/Sema/warn-write-strings.c @@ -2,3 +2,9 @@ // PR4804 char* x = "foo"; // expected-warning {{initializing 'char *' with an expression of type 'char const [4]' discards qualifiers}} + +// PR7192 +#include <stddef.h> +void test(wchar_t *dst) { + dst[0] = 0; // Ok. +} diff --git a/test/SemaCXX/MicrosoftExtensions.cpp b/test/SemaCXX/MicrosoftExtensions.cpp new file mode 100644 index 0000000..fb3107f --- /dev/null +++ b/test/SemaCXX/MicrosoftExtensions.cpp @@ -0,0 +1,44 @@ +// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions -fexceptions + + +// ::type_info is predeclared with forward class declartion +void f(const type_info &a); + +// The following three are all equivalent when ms-extensions are on +void foo() throw(int); +void foo() throw(int, long); +void foo() throw(...); +void foo(); // expected-note {{previous declaration}} + +// Only nothrow specification is treated specially. +void foo() throw(); // expected-error {{exception specification in declaration does not match previous declaration}} + +// throw(...) +void r3(); +void r3() throw(...); + +void r6() throw(...); +void r6() throw(int); // okay + +struct Base { + virtual void f2(); + virtual void f3() throw(...); +}; + +struct Derived : Base { + virtual void f2() throw(...); + virtual void f3(); +}; + +// __stdcall handling +struct M { + int __stdcall addP(); + float __stdcall subtractP(); +}; + +template<typename T> void h1(T (__stdcall M::* const )()) { } + +void m1() { + h1<int>(&M::addP); + h1(&M::subtractP); +} diff --git a/test/SemaCXX/abstract.cpp b/test/SemaCXX/abstract.cpp index f64fda4..ad079c2 100644 --- a/test/SemaCXX/abstract.cpp +++ b/test/SemaCXX/abstract.cpp @@ -67,20 +67,23 @@ class F { virtual void f() = 0; // expected-note {{pure virtual function 'f'}} }; +// Diagnosing in these cases is prohibitively expensive. We still +// diagnose at the function definition, of course. + class Abstract; -void t7(Abstract a); // expected-error {{parameter type 'Abstract' is an abstract class}} +void t7(Abstract a); void t8() { - void h(Abstract a); // expected-error {{parameter type 'Abstract' is an abstract class}} + void h(Abstract a); } namespace N { -void h(Abstract a); // expected-error {{parameter type 'Abstract' is an abstract class}} +void h(Abstract a); } class Abstract { - virtual void f() = 0; // expected-note {{pure virtual function 'f'}} + virtual void f() = 0; }; // <rdar://problem/6854087> @@ -186,3 +189,63 @@ namespace test1 { C c; } } + +// rdar://problem/8302168 +namespace test2 { + struct X1 { + virtual void xfunc(void) = 0; // expected-note {{pure virtual function}} + void g(X1 parm7); // expected-error {{parameter type 'test2::X1' is an abstract class}} + void g(X1 parm8[2]); // expected-error {{array of abstract class type 'test2::X1'}} + }; + + template <int N> + struct X2 { + virtual void xfunc(void) = 0; // expected-note {{pure virtual function}} + void g(X2 parm10); // expected-error {{parameter type 'X2<N>' is an abstract class}} + void g(X2 parm11[2]); // expected-error {{array of abstract class type 'X2<N>'}} + }; +} + +namespace test3 { + struct A { // expected-note {{not complete until}} + A x; // expected-error {{field has incomplete type}} + virtual void abstract() = 0; + }; + + struct B { // expected-note {{not complete until}} + virtual void abstract() = 0; + B x; // expected-error {{field has incomplete type}} + }; + + struct C { + static C x; // expected-error {{abstract class}} + virtual void abstract() = 0; // expected-note {{pure virtual function}} + }; + + struct D { + virtual void abstract() = 0; // expected-note {{pure virtual function}} + static D x; // expected-error {{abstract class}} + }; +} + +namespace test4 { + template <class T> struct A { + A x; // expected-error {{abstract class}} + virtual void abstract() = 0; // expected-note {{pure virtual function}} + }; + + template <class T> struct B { + virtual void abstract() = 0; // expected-note {{pure virtual function}} + B x; // expected-error {{abstract class}} + }; + + template <class T> struct C { + static C x; // expected-error {{abstract class}} + virtual void abstract() = 0; // expected-note {{pure virtual function}} + }; + + template <class T> struct D { + virtual void abstract() = 0; // expected-note {{pure virtual function}} + static D x; // expected-error {{abstract class}} + }; +} diff --git a/test/SemaCXX/access-member-pointer.cpp b/test/SemaCXX/access-member-pointer.cpp new file mode 100644 index 0000000..676eb10 --- /dev/null +++ b/test/SemaCXX/access-member-pointer.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// PR7694 + +class A { }; +class B : private A { public: void foo(); }; // expected-note {{declared private here}} +void B::foo() { + (void)static_cast<void(A::*)()>(&B::foo); +} +void bar() { + (void)static_cast<void(A::*)()>(&B::foo); // expected-error {{cannot cast 'B' to its private base class 'A'}} +} diff --git a/test/SemaCXX/addr-of-overloaded-function.cpp b/test/SemaCXX/addr-of-overloaded-function.cpp index f8b00df..b581b8a 100644 --- a/test/SemaCXX/addr-of-overloaded-function.cpp +++ b/test/SemaCXX/addr-of-overloaded-function.cpp @@ -86,3 +86,13 @@ namespace test0 { myFunction(bar); } } + +namespace PR7971 { + struct S { + void g() { + f(&g); + } + void f(bool (*)(int, char)); + static bool g(int, char); + }; +} diff --git a/test/SemaCXX/altivec.cpp b/test/SemaCXX/altivec.cpp new file mode 100644 index 0000000..cdfc00a --- /dev/null +++ b/test/SemaCXX/altivec.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -faltivec -fno-lax-vector-conversions -triple powerpc-unknown-unknown -verify %s + +typedef int V4i __attribute__((vector_size(16))); + +void f(V4i a) +{ +} + +void test() +{ + V4i vGCC; + vector int vAltiVec; + + f(vAltiVec); + vGCC = vAltiVec; + vGCC = vGCC > vAltiVec; + vAltiVec = 0 ? vGCC : vGCC; +} diff --git a/test/SemaCXX/anonymous-struct.cpp b/test/SemaCXX/anonymous-struct.cpp new file mode 100644 index 0000000..dfa284a --- /dev/null +++ b/test/SemaCXX/anonymous-struct.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +struct S { + S(); // expected-note {{because type 'S' has a user-declared constructor}} +}; + +struct E { + struct { + S x; // expected-error {{anonymous struct member 'x' has a non-trivial constructor}} + }; +}; diff --git a/test/SemaCXX/attr-unavailable.cpp b/test/SemaCXX/attr-unavailable.cpp index 8b381df..6f5aa5e 100644 --- a/test/SemaCXX/attr-unavailable.cpp +++ b/test/SemaCXX/attr-unavailable.cpp @@ -12,9 +12,9 @@ void test_foo(short* sp) { double &dr = foo(1.0); foo(sp); // expected-error{{call to unavailable function 'foo'}} - void (*fp)(...) = &bar; // expected-warning{{'bar' is unavailable}} - void (*fp2)(...) = bar; // expected-warning{{'bar' is unavailable}} + void (*fp)(...) = &bar; // expected-error{{'bar' is unavailable}} + void (*fp2)(...) = bar; // expected-error{{'bar' is unavailable}} int &(*fp3)(int) = foo; - void (*fp4)(...) = foo; // expected-warning{{'foo' is unavailable}} + void (*fp4)(...) = foo; // expected-error{{'foo' is unavailable}} } diff --git a/test/SemaCXX/blocks.cpp b/test/SemaCXX/blocks.cpp index baa79e7..adbff55 100644 --- a/test/SemaCXX/blocks.cpp +++ b/test/SemaCXX/blocks.cpp @@ -41,3 +41,30 @@ namespace test2 { return Power(2).calculate(10); } } + +// rdar: // 8382559 +namespace radar8382559 { + void func(bool& outHasProperty); + + int test3() { + __attribute__((__blocks__(byref))) bool hasProperty = false; + bool has = true; + + bool (^b)() = ^ { + func(hasProperty); + if (hasProperty) + hasProperty = 0; + if (has) + hasProperty = 1; + return hasProperty; + }; + func(hasProperty); + func(has); + b(); + if (hasProperty) + hasProperty = 1; + if (has) + has = 2; + return hasProperty = 1; + } +} diff --git a/test/SemaCXX/borland-extensions.cpp b/test/SemaCXX/borland-extensions.cpp new file mode 100644 index 0000000..c33527c --- /dev/null +++ b/test/SemaCXX/borland-extensions.cpp @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 %s -fsyntax-only -verify -fborland-extensions + +// Borland extensions + +// 1. test -fborland-extensions +int dummy_function() { return 0; } + +// 2. test __pascal +int _pascal f2(); + +float __pascal gi2(int, int); +template<typename T> T g2(T (__pascal * const )(int, int)) { return 0; } + +struct M { + int __pascal addP(); + float __pascal subtractP(); +}; +template<typename T> int h2(T (__pascal M::* const )()) { return 0; } +void m2() { + int i; float f; + i = f2(); + f = gi2(2, i); + f = g2(gi2); + i = h2<int>(&M::addP); + f = h2(&M::subtractP); +} diff --git a/test/SemaCXX/constructor-initializer.cpp b/test/SemaCXX/constructor-initializer.cpp index cf309f5..31d5330 100644 --- a/test/SemaCXX/constructor-initializer.cpp +++ b/test/SemaCXX/constructor-initializer.cpp @@ -221,3 +221,17 @@ namespace PR7402 { S s(3); } } + +// <rdar://problem/8308215>: don't crash. +// Lots of questionable recovery here; errors can change. +namespace test3 { + class A : public std::exception {}; // expected-error {{undeclared identifier}} expected-error {{expected class name}} expected-note 3 {{candidate}} expected-note {{passing argument}} + class B : public A { + public: + B(const String& s, int e=0) // expected-error {{unknown type name}} + : A(e), m_String(s) , m_ErrorStr(__null) {} // expected-error {{no matching constructor}} expected-error {{does not name}} + B(const B& e) + : A(e), m_String(e.m_String), m_ErrorStr(__null) { // expected-error {{no viable conversion}} expected-error {{does not name}} + } + }; +} diff --git a/test/SemaCXX/conversion-function.cpp b/test/SemaCXX/conversion-function.cpp index 3e96d02..07281e1 100644 --- a/test/SemaCXX/conversion-function.cpp +++ b/test/SemaCXX/conversion-function.cpp @@ -97,9 +97,7 @@ void f(Yb& a) { class AutoPtrRef { }; class AutoPtr { - // FIXME: Using 'unavailable' since we do not have access control yet. - // FIXME: The error message isn't so good. - AutoPtr(AutoPtr &) __attribute__((unavailable)); // expected-note{{explicitly marked}} + AutoPtr(AutoPtr &); // expected-note{{declared private here}} public: AutoPtr(); @@ -115,7 +113,7 @@ AutoPtr test_auto_ptr(bool Cond) { AutoPtr p; if (Cond) - return p; // expected-error{{call to deleted constructor}} + return p; // expected-error{{calling a private constructor}} return AutoPtr(); } @@ -125,11 +123,12 @@ struct A1 { ~A1(); private: - A1(const A1&) __attribute__((unavailable)); // expected-note{{here}} + A1(const A1&); // expected-note 2 {{declared private here}} }; A1 f() { - return "Hello"; // expected-error{{invokes deleted constructor}} + // FIXME: redundant diagnostics! + return "Hello"; // expected-error {{calling a private constructor}} expected-warning {{an accessible copy constructor}} } namespace source_locations { @@ -215,3 +214,114 @@ struct Other { void test_any() { Any any = Other(); // expected-error{{cannot pass object of non-POD type 'Other' through variadic constructor; call will abort at runtime}} } + +namespace PR7055 { + // Make sure that we don't allow too many conversions in an + // auto_ptr-like template. In particular, we can't create multiple + // temporary objects when binding to a reference. + struct auto_ptr { + struct auto_ptr_ref { }; + + auto_ptr(auto_ptr&); + auto_ptr(auto_ptr_ref); + explicit auto_ptr(int *); + + operator auto_ptr_ref(); + }; + + struct X { + X(auto_ptr); + }; + + X f() { + X x(auto_ptr(new int)); + return X(auto_ptr(new int)); + } + + auto_ptr foo(); + + X e(foo()); + + struct Y { + Y(X); + }; + + Y f2(foo()); +} + +namespace PR7934 { + typedef unsigned char uint8; + + struct MutablePtr { + MutablePtr() : ptr(0) {} + void *ptr; + + operator void*() { return ptr; } + + private: + operator uint8*() { return reinterpret_cast<uint8*>(ptr); } + operator const char*() const { return reinterpret_cast<const char*>(ptr); } + }; + + void fake_memcpy(const void *); + + void use() { + MutablePtr ptr; + fake_memcpy(ptr); + } +} + +namespace rdar8018274 { + struct X { }; + struct Y { + operator const struct X *() const; + }; + + struct Z : Y { + operator struct X * (); + }; + + void test() { + Z x; + (void) (x != __null); + } + + + struct Base { + operator int(); + }; + + struct Derived1 : Base { }; + + struct Derived2 : Base { }; + + struct SuperDerived : Derived1, Derived2 { + using Derived1::operator int; + }; + + struct UeberDerived : SuperDerived { + operator long(); + }; + + void test2(UeberDerived ud) { + int i = ud; // expected-error{{ambiguous conversion from derived class 'rdar8018274::SuperDerived' to base class 'rdar8018274::Base'}} + } + + struct Base2 { + operator int(); + }; + + struct Base3 { + operator int(); + }; + + struct Derived23 : Base2, Base3 { + using Base2::operator int; + }; + + struct ExtraDerived23 : Derived23 { }; + + void test3(ExtraDerived23 ed) { + int i = ed; + } +} diff --git a/test/SemaCXX/copy-assignment.cpp b/test/SemaCXX/copy-assignment.cpp index bfe1501..5730b2a 100644 --- a/test/SemaCXX/copy-assignment.cpp +++ b/test/SemaCXX/copy-assignment.cpp @@ -97,3 +97,15 @@ void test() { i = a; // expected-error{{assigning to 'int' from incompatible type 'A'}} } +// <rdar://problem/8315440>: Don't crash +// FIXME: the recovery here is really bad. +namespace test1 { + template<typename T> class A : public unknown::X { // expected-error {{undeclared identifier 'unknown'}} expected-error {{expected class name}} + A(UndeclaredType n) : X(n) {} // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{undeclared identifier 'n'}} expected-error {{expected ';' at end}} expected-error {{field has incomplete type}} + }; + template<typename T> class B : public A<T> { + virtual void foo() {} + }; + extern template class A<char>; // expected-note {{in instantiation}} expected-note {{not complete}} + extern template class B<char>; +} diff --git a/test/SemaCXX/crash-PR7625.cpp b/test/SemaCXX/crash-PR7625.cpp new file mode 100644 index 0000000..3ddf5e5 --- /dev/null +++ b/test/SemaCXX/crash-PR7625.cpp @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +template<typename T> struct a : T { + struct x : T { + int aa() { return p; } // expected-error{{use of undeclared identifier 'p'}} + }; +}; diff --git a/test/SemaCXX/decltype.cpp b/test/SemaCXX/decltype.cpp new file mode 100644 index 0000000..d4ef7e3 --- /dev/null +++ b/test/SemaCXX/decltype.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +// PR5290 +int const f0(); +void f0_test() { + decltype(0, f0()) i = 0; + i = 0; +} + +struct A { int a[1]; A() { } }; +typedef A const AC; +int &f1(int*); +float &f2(int const*); + +void test_f2() { + float &fr = f2(AC().a); +} + diff --git a/test/SemaCXX/default-constructor-initializers.cpp b/test/SemaCXX/default-constructor-initializers.cpp index 757332d..9da8556 100644 --- a/test/SemaCXX/default-constructor-initializers.cpp +++ b/test/SemaCXX/default-constructor-initializers.cpp @@ -43,7 +43,6 @@ Y4 y4; // More tests - struct Z1 { // expected-error {{must explicitly initialize the reference member 'z'}} \ // expected-error {{must explicitly initialize the const member 'c1'}} int& z; // expected-note {{declared here}} @@ -51,5 +50,12 @@ struct Z1 { // expected-error {{must explicitly initialize the reference member volatile int v1; }; +// Test default initialization which *requires* a constructor call for non-POD. Z1 z1; // expected-note {{first required here}} +// Ensure that value initialization doesn't use trivial implicit constructors. +namespace PR7948 { + // Note that this is also non-POD to ensure we don't just special case PODs. + struct S { const int x; ~S(); }; + const S arr[2] = { { 42 } }; +} diff --git a/test/SemaCXX/destructor.cpp b/test/SemaCXX/destructor.cpp index 4f6c76b..cdcae2e 100644 --- a/test/SemaCXX/destructor.cpp +++ b/test/SemaCXX/destructor.cpp @@ -103,5 +103,19 @@ namespace test6 { }; class B : A<int> { B(); }; - B::B() {} + B::B() {} // expected-note {{in instantiation of member function 'test6::A<int>::~A' requested here}} +} + +// Make sure classes are marked invalid when they have invalid +// members. This avoids a crash-on-invalid. +namespace test7 { + struct A { + ~A() const; // expected-error {{'const' qualifier is not allowed on a destructor}} + }; + struct B : A {}; + + void test() { + B *b; + b->~B(); + } } diff --git a/test/SemaCXX/enum.cpp b/test/SemaCXX/enum.cpp index 0690ead..1dc55e3 100644 --- a/test/SemaCXX/enum.cpp +++ b/test/SemaCXX/enum.cpp @@ -85,3 +85,8 @@ namespace PR7051 { // PR7466 enum { }; // expected-warning{{declaration does not declare anything}} typedef enum { }; // expected-warning{{typedef requires a name}} + +// PR7921 +enum PR7921E { + PR7921V = (PR7921E)(123) // expected-error {{expression is not an integer constant expression}} +}; diff --git a/test/SemaCXX/exception-spec.cpp b/test/SemaCXX/exception-spec.cpp index 498611e..b4bc78a 100644 --- a/test/SemaCXX/exception-spec.cpp +++ b/test/SemaCXX/exception-spec.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions -fms-extensions %s +// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s // Straight from the standard: // Plain function with spec @@ -43,18 +43,12 @@ void r2() throw(int); void r2() throw(INT); // throw-any spec and no spec at all are semantically equivalent -void r3(); -void r3() throw(...); - void r4() throw(int, float); void r4() throw(float, int); void r5() throw(int); // expected-note {{previous declaration}} void r5(); // expected-warning {{missing exception specification}} -void r6() throw(...); // expected-note {{previous declaration}} -void r6() throw(int); // expected-error {{exception specification in declaration does not match}} - void r7() throw(int); // expected-note {{previous declaration}} void r7() throw(float); // expected-error {{exception specification in declaration does not match}} @@ -89,8 +83,6 @@ struct P : private A struct Base { virtual void f1() throw(); - virtual void f2(); - virtual void f3() throw(...); virtual void f4() throw(int, float); virtual void f5() throw(int, float); @@ -107,8 +99,6 @@ struct Base struct Derived : Base { virtual void f1() throw(); - virtual void f2() throw(...); - virtual void f3(); virtual void f4() throw(float, int); virtual void f5() throw(float); diff --git a/test/SemaCXX/expressions.cpp b/test/SemaCXX/expressions.cpp index f3a05c1..b51194a 100644 --- a/test/SemaCXX/expressions.cpp +++ b/test/SemaCXX/expressions.cpp @@ -7,3 +7,10 @@ void test() { // Result of ! must be type bool. int i = choice(!1); } + +// rdar://8018252 +void f0() { + extern void f0_1(int*); + register int x; + f0_1(&x); +} diff --git a/test/SemaCXX/flexible-array-test.cpp b/test/SemaCXX/flexible-array-test.cpp index 02e3f83..95d8bb1 100644 --- a/test/SemaCXX/flexible-array-test.cpp +++ b/test/SemaCXX/flexible-array-test.cpp @@ -43,3 +43,13 @@ struct X { int blah; S strings[]; // expected-error {{flexible array member 'strings' of non-POD element type 'S []'}} }; + +class A { + int s; + char c[]; +}; + +union B { + int s; + char c[]; // expected-error {{field has incomplete type 'char []'}} +}; diff --git a/test/SemaCXX/i-c-e-cxx.cpp b/test/SemaCXX/i-c-e-cxx.cpp index 9672a42..2d08ea9 100644 --- a/test/SemaCXX/i-c-e-cxx.cpp +++ b/test/SemaCXX/i-c-e-cxx.cpp @@ -16,7 +16,7 @@ void f() { } int a() { - const int t=t; // expected-note {{subexpression not valid}} + const int t=t; switch(1) { // expected-warning {{no case matching constant switch condition '1'}} case t:; // expected-error {{not an integer constant expression}} } diff --git a/test/SemaCXX/inc-decrement-qualifiers.cpp b/test/SemaCXX/increment-decrement.cpp index ba837a9..11b7d1e 100644 --- a/test/SemaCXX/inc-decrement-qualifiers.cpp +++ b/test/SemaCXX/increment-decrement.cpp @@ -7,3 +7,8 @@ const int &dec = i--; const int &incfail = ++i; // expected-error {{drops qualifiers}} const int &decfail = --i; // expected-error {{drops qualifiers}} + +// PR7794 +void f0(int e) { + ++(int&)e; +} diff --git a/test/SemaCXX/linkage-spec.cpp b/test/SemaCXX/linkage-spec.cpp index 57730a6..86c3d3e 100644 --- a/test/SemaCXX/linkage-spec.cpp +++ b/test/SemaCXX/linkage-spec.cpp @@ -54,3 +54,35 @@ extern "C" return f2((char *)0); } } + +// PR6991 +extern "C" typedef int (*PutcFunc_t)(int); + + +// PR7859 +extern "C" void pr7859_a(int) {} // expected-note {{previous definition}} +extern "C" void pr7859_a(int) {} // expected-error {{redefinition}} + +extern "C" void pr7859_b() {} // expected-note {{previous definition}} +extern "C" void pr7859_b(int) {} // expected-error {{conflicting}} + +extern "C" void pr7859_c(short) {} // expected-note {{previous definition}} +extern "C" void pr7859_c(int) {} // expected-error {{conflicting}} + +// <rdar://problem/8318976> +extern "C" { + struct s0 { + private: + s0(); + s0(const s0 &); + }; +} + +//PR7754 +extern "C++" template <class T> int pr7754(T param); + +namespace N { + int value; +} + +extern "C++" using N::value; diff --git a/test/SemaCXX/member-expr.cpp b/test/SemaCXX/member-expr.cpp index 6830c5f..953ee48 100644 --- a/test/SemaCXX/member-expr.cpp +++ b/test/SemaCXX/member-expr.cpp @@ -101,3 +101,17 @@ namespace PR7508 { a.PopCleanupScope(); // expected-error{{no member named 'PopCleanupScope' in 'PR7508::A'}} } } + +namespace rdar8231724 { + namespace N { + template<typename T> struct X1; + int i; + } + + struct X { }; + struct Y : X { }; + + void f(Y *y) { + y->N::X1<int>; // expected-error{{'rdar8231724::N::X1' is not a member of class 'rdar8231724::Y'}} + } +} diff --git a/test/SemaCXX/member-pointer-ms.cpp b/test/SemaCXX/member-pointer-ms.cpp new file mode 100644 index 0000000..3b2d0fc --- /dev/null +++ b/test/SemaCXX/member-pointer-ms.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -cxx-abi microsoft -fsyntax-only -verify %s + +// Test that we reject pointers to members of incomplete classes (for now) +struct A; //expected-note{{forward declaration of 'A'}} +int A::*pai1; //expected-error{{incomplete type 'A'}} + +// Test that we don't allow reinterpret_casts from pointers of one size to +// pointers of a different size. +struct A {}; +struct B {}; +struct C: A, B {}; + +void (A::*paf)(); +void (C::*pcf)() = reinterpret_cast<void (C::*)()>(paf); //expected-error{{cannot reinterpret_cast from member pointer type}} diff --git a/test/SemaCXX/member-pointer.cpp b/test/SemaCXX/member-pointer.cpp index 9d5cd2f..795c0b9 100644 --- a/test/SemaCXX/member-pointer.cpp +++ b/test/SemaCXX/member-pointer.cpp @@ -79,7 +79,7 @@ void g() { void (HasMembers::*pmf)() = &HasMembers::f; void (*pnf)() = &Fake::f; - &hm.f; // expected-error {{must explicitly qualify}} expected-warning{{result unused}} + &hm.f; // expected-error {{cannot create a non-constant pointer to member function}} void (HasMembers::*pmgv)() = &HasMembers::g; void (HasMembers::*pmgi)(int) = &HasMembers::g; @@ -142,8 +142,8 @@ namespace pr5985 { void f() { void (c::*p)(); p = &h; // expected-error {{must explicitly qualify}} - p = &this->h; // expected-error {{must explicitly qualify}} - p = &(*this).h; // expected-error {{must explicitly qualify}} + p = &this->h; // expected-error {{cannot create a non-constant pointer to member function}} + p = &(*this).h; // expected-error {{cannot create a non-constant pointer to member function}} } }; } @@ -174,3 +174,99 @@ namespace PR7176 { void m() { (void)(Condition) &base::Continuous::cond; } } + +namespace rdar8358512 { + // We can't call this with an overload set because we're not allowed + // to look into overload sets unless the parameter has some kind of + // function type. + template <class F> void bind(F f); // expected-note 12 {{candidate template ignored}} + template <class F, class T> void bindmem(F (T::*f)()); // expected-note 4 {{candidate template ignored}} + template <class F> void bindfn(F (*f)()); // expected-note 4 {{candidate template ignored}} + + struct A { + void nonstat(); + void nonstat(int); + + void mixed(); + static void mixed(int); + + static void stat(); + static void stat(int); + + template <typename T> struct Test0 { + void test() { + bind(&nonstat); // expected-error {{no matching function for call}} + bind(&A::nonstat); // expected-error {{no matching function for call}} + + bind(&mixed); // expected-error {{no matching function for call}} + bind(&A::mixed); // expected-error {{no matching function for call}} + + bind(&stat); // expected-error {{no matching function for call}} + bind(&A::stat); // expected-error {{no matching function for call}} + } + }; + + template <typename T> struct Test1 { + void test() { + bindmem(&nonstat); // expected-error {{no matching function for call}} + bindmem(&A::nonstat); + + bindmem(&mixed); // expected-error {{no matching function for call}} + bindmem(&A::mixed); + + bindmem(&stat); // expected-error {{no matching function for call}} + bindmem(&A::stat); // expected-error {{no matching function for call}} + } + }; + + template <typename T> struct Test2 { + void test() { + bindfn(&nonstat); // expected-error {{no matching function for call}} + bindfn(&A::nonstat); // expected-error {{no matching function for call}} + + bindfn(&mixed); // expected-error {{no matching function for call}} + bindfn(&A::mixed); // expected-error {{no matching function for call}} + + bindfn(&stat); + bindfn(&A::stat); + } + }; + }; + + template <class T> class B { + void nonstat(); + void nonstat(int); + + void mixed(); + static void mixed(int); + + static void stat(); + static void stat(int); + + // None of these can be diagnosed yet, because the arguments are + // still dependent. + void test0a() { + bind(&nonstat); + bind(&B::nonstat); + + bind(&mixed); + bind(&B::mixed); + + bind(&stat); + bind(&B::stat); + } + + void test0b() { + bind(&nonstat); // expected-error {{no matching function for call}} + bind(&B::nonstat); // expected-error {{no matching function for call}} + + bind(&mixed); // expected-error {{no matching function for call}} + bind(&B::mixed); // expected-error {{no matching function for call}} + + bind(&stat); // expected-error {{no matching function for call}} + bind(&B::stat); // expected-error {{no matching function for call}} + } + }; + + template void B<int>::test0b(); // expected-note {{in instantiation}} +} diff --git a/test/SemaCXX/new-delete.cpp b/test/SemaCXX/new-delete.cpp index 25bf823..9a64e4c 100644 --- a/test/SemaCXX/new-delete.cpp +++ b/test/SemaCXX/new-delete.cpp @@ -310,3 +310,47 @@ namespace rdar8018245 { template int *f<X1>(); // expected-note{{in instantiation of}} } + +// <rdar://problem/8248780> +namespace Instantiate { + template<typename T> struct X { + operator T*(); + }; + + void f(X<int> &xi) { + delete xi; + } +} + +namespace PR7810 { + struct X { + // cv is ignored in arguments + static void operator delete(void *const); + }; + struct Y { + // cv is ignored in arguments + static void operator delete(void *volatile); + }; +} + +// Don't crash on template delete operators +namespace TemplateDestructors { + struct S { + virtual ~S() {} + + void* operator new(const size_t size); + template<class T> void* operator new(const size_t, const int, T*); + void operator delete(void*, const size_t); + template<class T> void operator delete(void*, const size_t, const int, T*); + }; +} + +namespace DeleteParam { + struct X { + void operator delete(X*); // expected-error{{first parameter of 'operator delete' must have type 'void *'}} + }; + + struct Y { + void operator delete(void* const); + }; +} diff --git a/test/SemaCXX/offsetof.cpp b/test/SemaCXX/offsetof.cpp index 639d7fa..17cee62 100644 --- a/test/SemaCXX/offsetof.cpp +++ b/test/SemaCXX/offsetof.cpp @@ -53,3 +53,16 @@ struct Derived2 : public Base1, public Base2 { int derived1[__builtin_offsetof(Derived2, x) == 0? 1 : -1]; int derived2[__builtin_offsetof(Derived2, y) == 4? 1 : -1]; int derived3[__builtin_offsetof(Derived2, z) == 8? 1 : -1]; + +// offsetof referring to anonymous struct in base. +// PR7769 +struct foo { + struct { + int x; + }; +}; + +struct bar : public foo { +}; + +int anonstruct[__builtin_offsetof(bar, x) == 0 ? 1 : -1]; diff --git a/test/SemaCXX/overload-call-copycon.cpp b/test/SemaCXX/overload-call-copycon.cpp index f57484e..6720cb6 100644 --- a/test/SemaCXX/overload-call-copycon.cpp +++ b/test/SemaCXX/overload-call-copycon.cpp @@ -1,40 +1,44 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -Wnon-pod-varargs -class X { }; +class X { }; // expected-note {{the implicit copy constructor}} \ + // expected-note{{the implicit default constructor}} -int& copycon(X x); +int& copycon(X x); // expected-note{{passing argument to parameter}} float& copycon(...); void test_copycon(X x, X const xc, X volatile xv) { int& i1 = copycon(x); int& i2 = copycon(xc); - float& f1 = copycon(xv); + copycon(xv); // expected-error{{no matching constructor}} } class A { public: - A(A&); + A(A&); // expected-note{{would lose const qualifier}} \ + // expected-note{{no known conversion}} }; -class B : public A { }; +class B : public A { }; // expected-note{{would lose const qualifier}} \ +// expected-note{{would lose volatile qualifier}} \ +// expected-note 2{{requires 0 arguments}} -short& copycon2(A a); -int& copycon2(B b); +short& copycon2(A a); // expected-note{{passing argument to parameter}} +int& copycon2(B b); // expected-note 2{{passing argument to parameter}} float& copycon2(...); void test_copycon2(A a, const A ac, B b, B const bc, B volatile bv) { int& i1 = copycon2(b); - float& f1 = copycon2(bc); // expected-warning {{cannot pass object of non-POD type}} - float& f2 = copycon2(bv); // expected-warning {{cannot pass object of non-POD type}} + copycon2(bc); // expected-error{{no matching constructor}} + copycon2(bv); // expected-error{{no matching constructor}} short& s1 = copycon2(a); - float& f3 = copycon2(ac); // expected-warning {{cannot pass object of non-POD type}} + copycon2(ac); // expected-error{{no matching constructor}} } -int& copycon3(A a); +int& copycon3(A a); // expected-note{{passing argument to parameter 'a' here}} float& copycon3(...); void test_copycon3(B b, const B bc) { int& i1 = copycon3(b); - float& f1 = copycon3(bc); // expected-warning {{cannot pass object of non-POD type}} + copycon3(bc); // expected-error{{no matching constructor}} } class C : public B { }; diff --git a/test/SemaCXX/qualified-member-enum.cpp b/test/SemaCXX/qualified-member-enum.cpp new file mode 100644 index 0000000..83b0a591 --- /dev/null +++ b/test/SemaCXX/qualified-member-enum.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// Check that this doesn't crash. +struct A { + enum {LABEL}; +}; +int f() { + return A().A::LABEL; +} + diff --git a/test/SemaCXX/return-noreturn.cpp b/test/SemaCXX/return-noreturn.cpp index 9242d12..dfd5487 100644 --- a/test/SemaCXX/return-noreturn.cpp +++ b/test/SemaCXX/return-noreturn.cpp @@ -7,9 +7,12 @@ namespace PR6884 { ~abort_struct() __attribute__((noreturn)); }; + // FIXME: Should either of these actually warn, since the destructor is + // marked noreturn? + int f() { abort_struct(); - } + } // expected-warning{{control reaches end of non-void function}} int f2() { abort_struct s; diff --git a/test/SemaCXX/return-stack-addr.cpp b/test/SemaCXX/return-stack-addr.cpp index ba64765..7d4cb96 100644 --- a/test/SemaCXX/return-stack-addr.cpp +++ b/test/SemaCXX/return-stack-addr.cpp @@ -108,5 +108,16 @@ int* ret_cpp_const_cast(const int x) { return const_cast<int*>(&x); // expected-warning {{address of stack memory}} } +// PR 7999 - handle the case where a field is itself a reference. +template <typename T> struct PR7999 { + PR7999(T& t) : value(t) {} + T& value; +}; + +struct PR7999_X {}; + +PR7999_X& PR7999_f(PR7999<PR7999_X> s) { return s.value; } // no-warning +void test_PR7999(PR7999_X& x) { (void)PR7999_f(x); } // no-warning + // TODO: test case for dynamic_cast. clang does not yet have // support for C++ classes to write such a test case. diff --git a/test/SemaCXX/scope-check.cpp b/test/SemaCXX/scope-check.cpp index cef64f6..cdc3868 100644 --- a/test/SemaCXX/scope-check.cpp +++ b/test/SemaCXX/scope-check.cpp @@ -121,3 +121,33 @@ namespace test6 { } } +// C++0x says it's okay to skip non-trivial initializers on static +// locals, and we implement that in '03 as well. +namespace test7 { + struct C { C(); }; + + void test() { + goto foo; + static C c; + foo: + return; + } +} + +// PR7789 +namespace test8 { + void test1(int c) { + switch (c) { + case 0: + int x = 56; // expected-note {{jump bypasses variable initialization}} + case 1: // expected-error {{switch case is in protected scope}} + x = 10; + } + } + + void test2() { + goto l2; // expected-error {{goto into protected scope}} + l1: int x = 5; // expected-note {{jump bypasses variable initialization}} + l2: x++; + } +} diff --git a/test/SemaCXX/switch.cpp b/test/SemaCXX/switch.cpp index 54240dc..fc13630 100644 --- a/test/SemaCXX/switch.cpp +++ b/test/SemaCXX/switch.cpp @@ -8,8 +8,7 @@ void test() { } int n = 3; - switch (n && 1) { // expected-warning {{bool}} \ - // expected-warning {{use of logical && with constant operand}} + switch (n && 1) { // expected-warning {{bool}} case 1: break; } diff --git a/test/SemaCXX/type-traits.cpp b/test/SemaCXX/type-traits.cpp index 85bd596..b05dd07 100644 --- a/test/SemaCXX/type-traits.cpp +++ b/test/SemaCXX/type-traits.cpp @@ -34,6 +34,37 @@ typedef Derives NonPODAr[10]; typedef HasVirt VirtAr[10]; union NonPODUnion { int i; Derives n; }; +struct HasNoThrowCopyAssign { + void operator =(const HasNoThrowCopyAssign&) throw(); +}; +struct HasMultipleCopyAssign { + void operator =(const HasMultipleCopyAssign&) throw(); + void operator =(volatile HasMultipleCopyAssign&); +}; +struct HasMultipleNoThrowCopyAssign { + void operator =(const HasMultipleNoThrowCopyAssign&) throw(); + void operator =(volatile HasMultipleNoThrowCopyAssign&) throw(); +}; + +struct HasNoThrowConstructor { HasNoThrowConstructor() throw(); }; +struct HasNoThrowConstructorWithArgs { + HasNoThrowConstructorWithArgs(HasCons i = HasCons(0)) throw(); +}; + +struct HasNoThrowCopy { HasNoThrowCopy(const HasNoThrowCopy&) throw(); }; +struct HasMultipleCopy { + HasMultipleCopy(const HasMultipleCopy&) throw(); + HasMultipleCopy(volatile HasMultipleCopy&); +}; +struct HasMultipleNoThrowCopy { + HasMultipleNoThrowCopy(const HasMultipleNoThrowCopy&) throw(); + HasMultipleNoThrowCopy(volatile HasMultipleNoThrowCopy&) throw(); +}; + +struct HasVirtDest { virtual ~HasVirtDest(); }; +struct DerivedVirtDest : HasVirtDest {}; +typedef HasVirtDest VirtDestAr[1]; + void is_pod() { int t01[T(__is_pod(int))]; @@ -258,3 +289,102 @@ void f() { int t01[T(!__has_trivial_destructor(A))]; int t02[T(!__has_trivial_destructor(B<int>))]; } + +void has_nothrow_assign() { + int t01[T(__has_nothrow_assign(Int))]; + int t02[T(__has_nothrow_assign(IntAr))]; + int t03[T(__has_nothrow_assign(Union))]; + int t04[T(__has_nothrow_assign(UnionAr))]; + int t05[T(__has_nothrow_assign(POD))]; + int t06[T(__has_nothrow_assign(Derives))]; + int t07[F(__has_nothrow_assign(ConstIntAr))]; + int t08[F(__has_nothrow_assign(ConstIntArAr))]; + int t09[T(__has_nothrow_assign(HasDest))]; + int t10[T(__has_nothrow_assign(HasPriv))]; + int t11[T(__has_nothrow_assign(HasCons))]; + int t12[T(__has_nothrow_assign(HasRef))]; + int t13[T(__has_nothrow_assign(HasCopy))]; + int t14[F(__has_nothrow_assign(IntRef))]; + int t15[F(__has_nothrow_assign(HasCopyAssign))]; + int t16[F(__has_nothrow_assign(const Int))]; + int t17[F(__has_nothrow_assign(NonPODAr))]; + int t18[F(__has_nothrow_assign(VirtAr))]; + + int t19[T(__has_nothrow_assign(HasNoThrowCopyAssign))]; + int t20[F(__has_nothrow_assign(HasMultipleCopyAssign))]; + int t21[T(__has_nothrow_assign(HasMultipleNoThrowCopyAssign))]; +} + +void has_nothrow_copy() { + int t01[T(__has_nothrow_copy(Int))]; + int t02[T(__has_nothrow_copy(IntAr))]; + int t03[T(__has_nothrow_copy(Union))]; + int t04[T(__has_nothrow_copy(UnionAr))]; + int t05[T(__has_nothrow_copy(POD))]; + int t06[T(__has_nothrow_copy(Derives))]; + int t07[T(__has_nothrow_copy(ConstIntAr))]; + int t08[T(__has_nothrow_copy(ConstIntArAr))]; + int t09[T(__has_nothrow_copy(HasDest))]; + int t10[T(__has_nothrow_copy(HasPriv))]; + int t11[T(__has_nothrow_copy(HasCons))]; + int t12[T(__has_nothrow_copy(HasRef))]; + int t13[F(__has_nothrow_copy(HasCopy))]; + int t14[T(__has_nothrow_copy(IntRef))]; + int t15[T(__has_nothrow_copy(HasCopyAssign))]; + int t16[T(__has_nothrow_copy(const Int))]; + int t17[F(__has_nothrow_copy(NonPODAr))]; + int t18[F(__has_nothrow_copy(VirtAr))]; + + int t19[T(__has_nothrow_copy(HasNoThrowCopy))]; + int t20[F(__has_nothrow_copy(HasMultipleCopy))]; + int t21[T(__has_nothrow_copy(HasMultipleNoThrowCopy))]; +} + +void has_nothrow_constructor() { + int t01[T(__has_nothrow_constructor(Int))]; + int t02[T(__has_nothrow_constructor(IntAr))]; + int t03[T(__has_nothrow_constructor(Union))]; + int t04[T(__has_nothrow_constructor(UnionAr))]; + int t05[T(__has_nothrow_constructor(POD))]; + int t06[T(__has_nothrow_constructor(Derives))]; + int t07[T(__has_nothrow_constructor(ConstIntAr))]; + int t08[T(__has_nothrow_constructor(ConstIntArAr))]; + int t09[T(__has_nothrow_constructor(HasDest))]; + int t10[T(__has_nothrow_constructor(HasPriv))]; + int t11[F(__has_nothrow_constructor(HasCons))]; + int t12[F(__has_nothrow_constructor(HasRef))]; + int t13[F(__has_nothrow_constructor(HasCopy))]; + int t14[F(__has_nothrow_constructor(IntRef))]; + int t15[T(__has_nothrow_constructor(HasCopyAssign))]; + int t16[T(__has_nothrow_constructor(const Int))]; + int t17[T(__has_nothrow_constructor(NonPODAr))]; + // int t18[T(__has_nothrow_constructor(VirtAr))]; // not implemented + + int t19[T(__has_nothrow_constructor(HasNoThrowConstructor))]; + int t20[F(__has_nothrow_constructor(HasNoThrowConstructorWithArgs))]; +} + +void has_virtual_destructor() { + int t01[F(__has_virtual_destructor(Int))]; + int t02[F(__has_virtual_destructor(IntAr))]; + int t03[F(__has_virtual_destructor(Union))]; + int t04[F(__has_virtual_destructor(UnionAr))]; + int t05[F(__has_virtual_destructor(POD))]; + int t06[F(__has_virtual_destructor(Derives))]; + int t07[F(__has_virtual_destructor(ConstIntAr))]; + int t08[F(__has_virtual_destructor(ConstIntArAr))]; + int t09[F(__has_virtual_destructor(HasDest))]; + int t10[F(__has_virtual_destructor(HasPriv))]; + int t11[F(__has_virtual_destructor(HasCons))]; + int t12[F(__has_virtual_destructor(HasRef))]; + int t13[F(__has_virtual_destructor(HasCopy))]; + int t14[F(__has_virtual_destructor(IntRef))]; + int t15[F(__has_virtual_destructor(HasCopyAssign))]; + int t16[F(__has_virtual_destructor(const Int))]; + int t17[F(__has_virtual_destructor(NonPODAr))]; + int t18[F(__has_virtual_destructor(VirtAr))]; + + int t19[T(__has_virtual_destructor(HasVirtDest))]; + int t20[T(__has_virtual_destructor(DerivedVirtDest))]; + int t21[F(__has_virtual_destructor(VirtDestAr))]; +} diff --git a/test/SemaCXX/unary-real-imag.cpp b/test/SemaCXX/unary-real-imag.cpp new file mode 100644 index 0000000..91b63e3 --- /dev/null +++ b/test/SemaCXX/unary-real-imag.cpp @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +struct A {}; +int i = __real__ A(); // expected-error {{invalid type 'A' to __real operator}} +int j = __imag__ A(); // expected-error {{invalid type 'A' to __imag operator}} + diff --git a/test/SemaCXX/unreachable-code.cpp b/test/SemaCXX/unreachable-code.cpp index 528bba7..40d0c00 100644 --- a/test/SemaCXX/unreachable-code.cpp +++ b/test/SemaCXX/unreachable-code.cpp @@ -39,3 +39,20 @@ void test3() { bar(); // expected-warning {{will never be executed}} } } + +// PR 6130 - Don't warn about bogus unreachable code with throw's and +// temporary objects. +class PR6130 { +public: + PR6130(); + ~PR6130(); +}; + +int pr6130(unsigned i) { + switch(i) { + case 0: return 1; + case 1: return 2; + default: + throw PR6130(); // no-warning + } +} diff --git a/test/SemaCXX/vector-no-lax.cpp b/test/SemaCXX/vector-no-lax.cpp new file mode 100644 index 0000000..32dcacf --- /dev/null +++ b/test/SemaCXX/vector-no-lax.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fno-lax-vector-conversions -verify %s +typedef unsigned int __attribute__((vector_size (16))) vUInt32; +typedef int __attribute__((vector_size (16))) vSInt32; + +vSInt32 foo (vUInt32 a) { + vSInt32 b = { 0, 0, 0, 0 }; + b += a; // expected-error{{can't convert between vector values}} + return b; +} diff --git a/test/SemaCXX/vector.cpp b/test/SemaCXX/vector.cpp index 66b2d68..9ae2c82 100644 --- a/test/SemaCXX/vector.cpp +++ b/test/SemaCXX/vector.cpp @@ -51,10 +51,10 @@ void conditional(bool Cond, char16 c16, longlong16 ll16, char16_e c16e, __typeof__(Cond? ll16 : ll16e) *ll16ep2 = &ll16e; __typeof__(Cond? ll16e : ll16) *ll16ep3 = &ll16e; - // Conditional operators with incompatible types. - (void)(Cond? c16 : ll16); // expected-error{{can't convert between vector values}} - (void)(Cond? ll16e : c16e); // expected-error{{can't convert between vector values}} - (void)(Cond? ll16e : c16); // expected-error{{can't convert between vector values}} + // Conditional operators with compatible types under -flax-vector-conversions (default) + (void)(Cond? c16 : ll16); + (void)(Cond? ll16e : c16e); + (void)(Cond? ll16e : c16); } // Test C++ cast'ing of vector types. @@ -183,8 +183,10 @@ void test_implicit_conversions(bool Cond, char16 c16, longlong16 ll16, (void)(Cond? to_c16 : to_c16e); (void)(Cond? to_ll16e : to_ll16); - (void)(Cond? to_c16 : to_ll16); // expected-error{{can't convert between vector values of different size}} - (void)(Cond? to_c16e : to_ll16e); // expected-error{{can't convert between vector values of different size}} + + // These 2 are convertable with -flax-vector-conversions (default) + (void)(Cond? to_c16 : to_ll16); + (void)(Cond? to_c16e : to_ll16e); } typedef float fltx2 __attribute__((__vector_size__(8))); diff --git a/test/SemaCXX/virtual-base-used.cpp b/test/SemaCXX/virtual-base-used.cpp new file mode 100644 index 0000000..d147b13 --- /dev/null +++ b/test/SemaCXX/virtual-base-used.cpp @@ -0,0 +1,42 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// PR7800 + +class NoDestroy { ~NoDestroy(); }; // expected-note 3 {{declared private here}} +struct A { + virtual ~A(); +}; + +struct B : public virtual A { + NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}} +}; +struct D : public virtual B { + virtual void foo(); + ~D(); +}; +void D::foo() { // expected-note {{implicit default destructor for 'B' first required here}} +} + +struct E : public virtual A { + NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}} +}; +struct F : public E { // expected-note {{implicit default destructor for 'E' first required here}} +}; +struct G : public virtual F { + virtual void foo(); + ~G(); +}; +void G::foo() { // expected-note {{implicit default destructor for 'F' first required here}} +} + +struct H : public virtual A { + NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}} +}; +struct I : public virtual H { + ~I(); +}; +struct J : public I { + virtual void foo(); + ~J(); +}; +void J::foo() { // expected-note {{implicit default destructor for 'H' first required here}} +} diff --git a/test/SemaCXX/warn-cast-align.cpp b/test/SemaCXX/warn-cast-align.cpp new file mode 100644 index 0000000..68acbdd --- /dev/null +++ b/test/SemaCXX/warn-cast-align.cpp @@ -0,0 +1,45 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -Wcast-align -verify %s + +// Simple casts. +void test0(char *P) { + char *a; short *b; int *c; + + a = (char*) P; + a = static_cast<char*>(P); + a = reinterpret_cast<char*>(P); + typedef char *CharPtr; + a = CharPtr(P); + + b = (short*) P; // expected-warning {{cast from 'char *' to 'short *' increases required alignment from 1 to 2}} + b = reinterpret_cast<short*>(P); + typedef short *ShortPtr; + b = ShortPtr(P); // expected-warning {{cast from 'char *' to 'ShortPtr' (aka 'short *') increases required alignment from 1 to 2}} + + c = (int*) P; // expected-warning {{cast from 'char *' to 'int *' increases required alignment from 1 to 4}} + c = reinterpret_cast<int*>(P); + typedef int *IntPtr; + c = IntPtr(P); // expected-warning {{cast from 'char *' to 'IntPtr' (aka 'int *') increases required alignment from 1 to 4}} +} + +// Casts from void* are a special case. +void test1(void *P) { + char *a; short *b; int *c; + + a = (char*) P; + a = static_cast<char*>(P); + a = reinterpret_cast<char*>(P); + typedef char *CharPtr; + a = CharPtr(P); + + b = (short*) P; + b = static_cast<short*>(P); + b = reinterpret_cast<short*>(P); + typedef short *ShortPtr; + b = ShortPtr(P); + + c = (int*) P; + c = static_cast<int*>(P); + c = reinterpret_cast<int*>(P); + typedef int *IntPtr; + c = IntPtr(P); +} diff --git a/test/SemaCXX/warn-for-var-in-else.cpp b/test/SemaCXX/warn-for-var-in-else.cpp deleted file mode 100644 index 1307c43..0000000 --- a/test/SemaCXX/warn-for-var-in-else.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// rdar://6425550 -int bar(); -void do_something(int); -int *get_ptr(); - -int foo() { - if (int X = bar()) { - return X; - } else { - do_something(X); // expected-warning{{'X' is always zero in this context}} - return 0; - } -} - -bool foo2() { - if (bool B = bar()) { - if (int Y = bar()) { - return B; - } else { - do_something(Y); // expected-warning{{'Y' is always zero in this context}} - return B; - } - } else { - if (bool B2 = B) { // expected-warning{{'B' is always false in this context}} - do_something(B); // expected-warning{{'B' is always false in this context}} - } else if (B2) { // expected-warning{{'B2' is always false in this context}} - do_something(B); // expected-warning{{'B' is always false in this context}} - do_something(B2); // expected-warning{{'B2' is always false in this context}} - } - return B; // expected-warning{{'B' is always false in this context}} - } -} - -void foo3() { - if (int *P1 = get_ptr()) - do_something(*P1); - else if (int *P2 = get_ptr()) { - do_something(*P1); // expected-warning{{'P1' is always NULL in this context}} - do_something(*P2); - } else { - do_something(*P1); // expected-warning{{'P1' is always NULL in this context}} - do_something(*P2); // expected-warning{{'P2' is always NULL in this context}} - } -} diff --git a/test/SemaCXX/warn-global-constructors.cpp b/test/SemaCXX/warn-global-constructors.cpp new file mode 100644 index 0000000..107bbe1 --- /dev/null +++ b/test/SemaCXX/warn-global-constructors.cpp @@ -0,0 +1,81 @@ +// RUN: %clang_cc1 -fsyntax-only -Wglobal-constructors %s -verify + +int opaque_int(); + +namespace test0 { + // These should never require global constructors. + int a; + int b = 20; + float c = 5.0f; + + // This global constructor is avoidable based on initialization order. + int d = b; // expected-warning {{global constructor}} + + // These global constructors are unavoidable. + int e = opaque_int(); // expected-warning {{global constructor}} + int f = b; // expected-warning {{global constructor}} +} + +namespace test1 { + struct A { int x; }; + A a; + A b = A(); + A c = { 10 }; + A d = { opaque_int() }; // expected-warning {{global constructor}} + A e = A(A()); + A f = A(a); // expected-warning {{global constructor}} + A g(a); // expected-warning {{global constructor}} + A h((A())); // expected-warning {{global constructor}} + A i((A(A()))); // expected-warning {{global constructor}} +} + +namespace test2 { + struct A { A(); }; + A a; // expected-warning {{global constructor}} + A b[10]; // expected-warning {{global constructor}} + A c[10][10]; // expected-warning {{global constructor}} + + A &d = a; + A &e = b[5]; + A &f = c[5][7]; +} + +namespace test3 { + struct A { ~A(); }; + A a; // expected-warning {{global destructor}} + A b[10]; // expected-warning {{global destructor}} + A c[10][10]; // expected-warning {{global destructor}} + + A &d = a; + A &e = b[5]; + A &f = c[5][7]; +} + +namespace test4 { + char a[] = "hello"; + char b[5] = "hello"; + char c[][5] = { "hello" }; +} + +namespace test5 { + struct A { A(); }; + + void f1() { + static A a; + } + void f2() { + static A& a = *new A; + } +} + +namespace test6 { + struct A { ~A(); }; + + void f1() { + static A a; // expected-warning {{global destructor}} + } + void f2() { + static A& a = *new A; + } + +}
\ No newline at end of file diff --git a/test/SemaCXX/warn-unused-filescoped.cpp b/test/SemaCXX/warn-unused-filescoped.cpp new file mode 100644 index 0000000..75fc6a4 --- /dev/null +++ b/test/SemaCXX/warn-unused-filescoped.cpp @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function %s + +static void f1(); // expected-warning{{unused}} + +namespace { + void f2(); // expected-warning{{unused}} + + void f3() { } // expected-warning{{unused}} + + struct S { + void m1() { } // expected-warning{{unused}} + void m2(); // expected-warning{{unused}} + void m3(); + S(const S&); + void operator=(const S&); + }; + + template <typename T> + struct TS { + void m(); + }; + template <> void TS<int>::m() { } // expected-warning{{unused}} + + template <typename T> + void tf() { } + template <> void tf<int>() { } // expected-warning{{unused}} + + struct VS { + virtual void vm() { } + }; + + struct SVS : public VS { + void vm() { } + }; +} + +void S::m3() { } // expected-warning{{unused}} + +static inline void f4() { } +const unsigned int cx = 0; + +static int x1; // expected-warning{{unused}} + +namespace { + int x2; // expected-warning{{unused}} + + struct S2 { + static int x; // expected-warning{{unused}} + }; + + template <typename T> + struct TS2 { + static int x; + }; + template <> int TS2<int>::x; // expected-warning{{unused}} +} diff --git a/test/SemaObjC/block-type-safety.m b/test/SemaObjC/block-type-safety.m index 402a658..c13e806 100644 --- a/test/SemaObjC/block-type-safety.m +++ b/test/SemaObjC/block-type-safety.m @@ -104,3 +104,20 @@ void test3() { f4(^(NSArray<P2>* a) { }); // expected-error {{incompatible block pointer types passing 'void (^)(NSArray<P2> *)' to parameter of type 'void (^)(id<P>)'}} } +// rdar : //8302845 +@protocol Foo @end + +@interface Baz @end + +@interface Baz(FooConformance) <Foo> +@end + +@implementation Baz @end + +int test4 () { + id <Foo> (^b)() = ^{ // Doesn't work + return (Baz *)0; + }; + return 0; +} + diff --git a/test/SemaObjC/compare-qualified-class.m b/test/SemaObjC/compare-qualified-class.m new file mode 100644 index 0000000..cb2b26a --- /dev/null +++ b/test/SemaObjC/compare-qualified-class.m @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// rdar:// 8191774 + +@protocol SomeProtocol +@end + +@protocol SomeProtocol1 +@end + +@interface SomeObject <SomeProtocol> +@end + +int main () { + Class <SomeProtocol> classA; + Class <SomeProtocol> classB; + Class <SomeProtocol, SomeProtocol1> classC; + Class <SomeProtocol1> classD; + void * pv = 0; + Class c = (Class)0;; + if (pv) + return classA == pv; + + if (c) + return classA == c; + + return classA == classB || classA == classC || + classC == classA || + classA == classD; // expected-warning {{comparison of distinct pointer types ('Class<SomeProtocol> *' and 'Class<SomeProtocol1> *')}} +} + diff --git a/test/SemaObjC/comptypes-5.m b/test/SemaObjC/comptypes-5.m index aaf6446..46300e3 100644 --- a/test/SemaObjC/comptypes-5.m +++ b/test/SemaObjC/comptypes-5.m @@ -26,8 +26,8 @@ int main() MyOtherClass<MyProtocol> *obj_c_super_p_q = nil; MyClass<MyProtocol> *obj_c_cat_p_q = nil; - obj_c_cat_p = obj_id_p; - obj_c_super_p = obj_id_p; + obj_c_cat_p = obj_id_p; + obj_c_super_p = obj_id_p; obj_id_p = obj_c_cat_p; /* Ok */ obj_id_p = obj_c_super_p; /* Ok */ diff --git a/test/SemaObjC/conflict-nonfragile-abi2.m b/test/SemaObjC/conflict-nonfragile-abi2.m new file mode 100644 index 0000000..e4b513f --- /dev/null +++ b/test/SemaObjC/conflict-nonfragile-abi2.m @@ -0,0 +1,34 @@ +// RUN: %clang_cc1 -fobjc-nonfragile-abi -verify -fsyntax-only %s +// rdar : // 8225011 + +int glob; // expected-note {{global variable declared here}} + +@interface I +@property int glob; // expected-note {{property declared here}} +@property int p; +@property int le; +@property int l; +@property int ls; +@property int r; +@end + +@implementation I +- (int) Meth { return glob; } // expected-warning {{when default property synthesis is on, 'glob' lookup will access}} +@synthesize glob; +// rdar: // 8248681 +- (int) Meth1: (int) p { + extern int le; + int l = 1; + static int ls; + register int r; + p = le + ls + r; + return l; +} +@dynamic p; +@dynamic le; +@dynamic l; +@dynamic ls; +@dynamic r; +@end + + diff --git a/test/SemaObjC/crash-label.m b/test/SemaObjC/crash-label.m index d0a5ae4..ffcb463 100644 --- a/test/SemaObjC/crash-label.m +++ b/test/SemaObjC/crash-label.m @@ -2,8 +2,9 @@ - (NSDictionary*) _executeScript:(NSString *)source { // expected-error 2 {{expected a type}} \ // expected-error {{missing context for method declaration}} - Exit: [nilArgs release]; // expected-error {{use of undeclared identifier}} - } - - (NSDictionary *) _setupKernelStandardMode:(NSString *)source { // expected-error 2 {{expected a type}} \ -expected-error {{missing context for method declaration}} - Exit: if(_ciKernel && !success ) { // expected-error {{use of undeclared identifier}} // expected-error 2 {{expected}} +Exit: [nilArgs release]; // expected-error {{use of undeclared identifier}} +} +- (NSDictionary *) _setupKernelStandardMode:(NSString *)source { // expected-error 2 {{expected a type}} \ +expected-error {{missing context for method declaration}} \ +expected-note{{to match this '{'}} + Exit: if(_ciKernel && !success ) { // expected-error {{use of undeclared identifier}} // expected-error 2 {{expected}} expected-note{{to match this '{'}} diff --git a/test/SemaObjC/default-synthesize-1.m b/test/SemaObjC/default-synthesize-1.m new file mode 100644 index 0000000..374fa83 --- /dev/null +++ b/test/SemaObjC/default-synthesize-1.m @@ -0,0 +1,116 @@ +// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi2 -verify %s + +@interface NSObject +- (void) release; +- (id) retain; +@end +@class NSString; + +@interface SynthItAll : NSObject +@property int howMany; +@property (retain) NSString* what; +@end + +@implementation SynthItAll +//@synthesize howMany, what; +@end + + +@interface SynthSetter : NSObject +@property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair +@property (nonatomic, retain) NSString* what; +@end + +@implementation SynthSetter +//@synthesize howMany, what; + +- (int) howMany { + return howMany; +} +// - (void) setHowMany: (int) value + +- (NSString*) what { + return what; +} +// - (void) setWhat: (NSString*) value +@end + + +@interface SynthGetter : NSObject +@property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair +@property (nonatomic, retain) NSString* what; +@end + +@implementation SynthGetter +//@synthesize howMany, what; + +// - (int) howMany +- (void) setHowMany: (int) value { + howMany = value; +} + +// - (NSString*) what +- (void) setWhat: (NSString*) value { + if (what != value) { + [what release]; + what = [value retain]; + } +} +@end + + +@interface SynthNone : NSObject +@property int howMany; +@property (retain) NSString* what; +@end + +@implementation SynthNone +//@synthesize howMany, what; // REM: Redundant anyway + +- (int) howMany { + return howMany; +} +- (void) setHowMany: (int) value { + howMany = value; +} + +- (NSString*) what { + return what; +} +- (void) setWhat: (NSString*) value { + if (what != value) { + [what release]; + what = [value retain]; + } +} +@end + +// rdar://8349319 +// No default synthesis if implementation has getter (readonly) and setter(readwrite) methods. +@interface DSATextSearchResult +@property(assign,readonly) float relevance; +@property(assign,readonly) char isTitleMatch; +@end + +@interface DSANodeSearchResult : DSATextSearchResult {} +@end + + +@implementation DSATextSearchResult +-(char)isTitleMatch { + return (char)0; +} + +-(float)relevance { + return 0.0; +} +@end + +@implementation DSANodeSearchResult +-(id)initWithNode:(id )node relevance:(float)relevance isTitleMatch:(char)isTitleMatch { + relevance = 0.0; + isTitleMatch = 'a'; + return self; +} +@end + diff --git a/test/SemaObjC/deref-interface.m b/test/SemaObjC/deref-interface.m index c7096bd..255e1d0 100644 --- a/test/SemaObjC/deref-interface.m +++ b/test/SemaObjC/deref-interface.m @@ -6,7 +6,7 @@ @implementation NSView - (id)initWithView:(id)realView { - *(NSView *)self = *(NSView *)realView; // expected-error {{indirection cannot be to an interface in non-fragile ABI}} + *(NSView *)self = *(NSView *)realView; // expected-error {{cannot assign to class object in non-fragile ABI}} } @end diff --git a/test/SemaObjC/iboutletcollection-attr.m b/test/SemaObjC/iboutletcollection-attr.m new file mode 100644 index 0000000..fb64e3a --- /dev/null +++ b/test/SemaObjC/iboutletcollection-attr.m @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s +// rdar: // 8308053 + +@interface I { + __attribute__((iboutletcollection(I))) id ivar1; + __attribute__((iboutletcollection(id))) id ivar2; + __attribute__((iboutletcollection())) id ivar3; + __attribute__((iboutletcollection)) id ivar4; +} +@property (nonatomic, retain) __attribute__((iboutletcollection(I))) id prop1; +@property (nonatomic, retain) __attribute__((iboutletcollection(id))) id prop2; +@property (nonatomic, retain) __attribute__((iboutletcollection())) id prop3; +@property (nonatomic, retain) __attribute__((iboutletcollection)) id prop4; +@end + +typedef void *PV; +@interface BAD { + __attribute__((iboutletcollection(I, 1))) id ivar1; // expected-error {{attribute requires 1 argument(s)}} + __attribute__((iboutletcollection(B))) id ivar2; // expected-error {{invalid type 'B' as argument of iboutletcollection attribute}} + __attribute__((iboutletcollection(PV))) id ivar3; // expected-error {{invalid type 'PV' as argument of iboutletcollection attribute}} + __attribute__((iboutletcollection(PV))) void *ivar4; // expected-error {{ivar with iboutletcollection attribute must have object type (invalid 'void *')}} + __attribute__((iboutletcollection(int))) id ivar5; // expected-error {{type argument of iboutletcollection attribute cannot be a builtin type}} +} +@property (nonatomic, retain) __attribute__((iboutletcollection(I,2,3))) id prop1; // expected-error {{attribute requires 1 argument(s)}} +@property (nonatomic, retain) __attribute__((iboutletcollection(B))) id prop2; // expected-error {{invalid type 'B' as argument of iboutletcollection attribute}} + +@property __attribute__((iboutletcollection(BAD))) int prop3; // expected-error {{property with iboutletcollection attribute must have object type (invalid 'int')}} +@end + diff --git a/test/SemaObjC/method-lookup-3.m b/test/SemaObjC/method-lookup-3.m index 18a9982..882b3d1 100644 --- a/test/SemaObjC/method-lookup-3.m +++ b/test/SemaObjC/method-lookup-3.m @@ -50,3 +50,8 @@ void f4(id a0, Abstract *a1) { void f5(id a0, Abstract *a1) { [ a0 setZ: a1]; } + +// pr7861 +void f6(id<A> a0) { + Abstract *l = [a0 x]; +} diff --git a/test/SemaObjC/method-no-context.m b/test/SemaObjC/method-no-context.m index c88205df..3c45bee 100644 --- a/test/SemaObjC/method-no-context.m +++ b/test/SemaObjC/method-no-context.m @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -- im0 { int a; return 0; // expected-error{{missing context for method declaration}} +- im0 { // expected-note{{to match this '{'}} expected-error{{missing context for method declaration}} + int a; return 0; // expected-error{{expected '}'}} diff --git a/test/SemaObjC/nonnull.m b/test/SemaObjC/nonnull.m index 642f50f..15fee74 100644 --- a/test/SemaObjC/nonnull.m +++ b/test/SemaObjC/nonnull.m @@ -43,3 +43,5 @@ foo (int i1, int i2, int i3, void (^cp1)(), void (^cp2)(), void (^cp3)()) func6((NSObject*) 0); // no-warning func7((NSObject*) 0); // no-warning } + +void func5(int) __attribute__((nonnull)); // expected-warning{{'nonnull' attribute applied to function with no pointer arguments}} diff --git a/test/SemaObjC/property-and-ivar-use.m b/test/SemaObjC/property-and-ivar-use.m new file mode 100644 index 0000000..b9235c1 --- /dev/null +++ b/test/SemaObjC/property-and-ivar-use.m @@ -0,0 +1,36 @@ +// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi2 -verify %s +// Do not issue error if 'ivar' used previously belongs to the inherited class +// and has same name as @dynalic property in current class. + +typedef signed char BOOL; + +@protocol IDEBuildable +@property (readonly) BOOL hasRecursiveDependencyCycle; +@end + +@protocol IDEBuildableProduct <IDEBuildable> +@end + +@interface IDEBuildableSupportMixIn +@property (readonly) BOOL hasRecursiveDependencyCycle; +@end + +@interface Xcode3TargetBuildable <IDEBuildable> +{ + IDEBuildableSupportMixIn *_buildableMixIn; +} +@end + +@interface Xcode3TargetProduct : Xcode3TargetBuildable <IDEBuildableProduct> +@end + +@implementation Xcode3TargetBuildable +- (BOOL)hasRecursiveDependencyCycle +{ + return [_buildableMixIn hasRecursiveDependencyCycle]; +} +@end + +@implementation Xcode3TargetProduct +@dynamic hasRecursiveDependencyCycle; +@end diff --git a/test/SemaObjC/property-not-lvalue.m b/test/SemaObjC/property-not-lvalue.m index 55eec3e..3d95d26 100644 --- a/test/SemaObjC/property-not-lvalue.m +++ b/test/SemaObjC/property-not-lvalue.m @@ -15,8 +15,8 @@ typedef struct NSSize { void foo() { Foo *f; - f.size.width = 2.2; // expected-error {{expression is not assignable using property assignment syntax}} - f.size.inner.dim = 200; // expected-error {{expression is not assignable using property assignment syntax}} + f.size.width = 2.2; // expected-error {{expression is not assignable}} + f.size.inner.dim = 200; // expected-error {{expression is not assignable}} } // radar 7628953 @@ -28,7 +28,7 @@ void foo() { @implementation Gorf - (void)MyView_sharedInit { - self.size.width = 2.2; // expected-error {{expression is not assignable using property assignment syntax}} + self.size.width = 2.2; // expected-error {{expression is not assignable}} } - (NSSize)size {} @end diff --git a/test/SemaObjC/protocol-attribute.m b/test/SemaObjC/protocol-attribute.m index e04a39b..52c9803 100644 --- a/test/SemaObjC/protocol-attribute.m +++ b/test/SemaObjC/protocol-attribute.m @@ -3,7 +3,7 @@ __attribute ((unavailable)) @protocol FwProto; // expected-note{{marked unavailable}} -Class <FwProto> cFw = 0; // expected-warning {{'FwProto' is unavailable}} +Class <FwProto> cFw = 0; // expected-error {{'FwProto' is unavailable}} __attribute ((deprecated)) @protocol MyProto1 @@ -35,12 +35,12 @@ Class <MyProto1> clsP1 = 0; // expected-warning {{'MyProto1' is deprecated}} @protocol FwProto @end // expected-note{{marked unavailable}} -@interface MyClass2 <FwProto> // expected-warning {{'FwProto' is unavailable}} +@interface MyClass2 <FwProto> // expected-error {{'FwProto' is unavailable}} @end __attribute ((unavailable)) __attribute ((deprecated)) @protocol XProto; // expected-note{{marked unavailable}} -id <XProto> idX = 0; // expected-warning {{'XProto' is unavailable}} expected-warning {{'XProto' is deprecated}} +id <XProto> idX = 0; // expected-error {{'XProto' is unavailable}} expected-warning {{'XProto' is deprecated}} int main () { diff --git a/test/SemaObjC/protocols.m b/test/SemaObjC/protocols.m index 8447fe2..ca38f20 100644 --- a/test/SemaObjC/protocols.m +++ b/test/SemaObjC/protocols.m @@ -61,3 +61,7 @@ @protocol B < A > // expected-error{{protocol has circular dependency}} @end +@protocol P +- (int)test:(int)param, ..; // expected-warning{{type specifier missing}} \ + // expected-error{{expected ';' after method prototype}} +@end diff --git a/test/SemaObjC/static-ivar-ref-1.m b/test/SemaObjC/static-ivar-ref-1.m index cd5e055..d9f99f5 100644 --- a/test/SemaObjC/static-ivar-ref-1.m +++ b/test/SemaObjC/static-ivar-ref-1.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple i386-unknown-unknown -ast-print %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -ast-print %s +// RUN: %clang_cc1 -triple i386-unknown-unknown -ast-print %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -ast-print %s 2>&1 | FileCheck %s @interface current { @@ -14,5 +14,17 @@ current *pc; int foo() { - return pc->ivar2 + (*pc).ivar + pc->ivar1; + return pc->ivar2 + (*pc).ivar + pc->ivar1; } + +// CHECK: @interface current{ +// CHECK: int ivar; +// CHECK: int ivar1; +// CHECK: int ivar2; +// CHECK: } +// CHECK: @end +// CHECK: current *pc; +// CHECK: int foo() { +// CHECK: return pc->ivar2 + (*pc).ivar + pc->ivar1; +// CHECK: } + diff --git a/test/SemaObjC/synth-provisional-ivars.m b/test/SemaObjC/synth-provisional-ivars.m new file mode 100644 index 0000000..973c771 --- /dev/null +++ b/test/SemaObjC/synth-provisional-ivars.m @@ -0,0 +1,50 @@ +// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi2 -verify %s + +int bar; + +@interface I +{ + int _bar; +} +@property int PROP; +@property int PROP1; +@property int PROP2; +@property int PROP3; +@property int PROP4; + +@property int bar; +@property int bar1; + +@end + +@implementation I +- (int) Meth { return PROP; } // expected-note {{'PROP' declared here}} + +@dynamic PROP1; +- (int) Meth1 { return PROP1; } // expected-error {{use of undeclared identifier 'PROP1'}} + +- (int) Meth2 { return PROP2; } // expected-error {{use of undeclared identifier 'PROP2'}} +@dynamic PROP2; + +- (int) Meth3 { return PROP3; } // expected-error {{use of undeclared identifier 'PROP3'}} +@synthesize PROP3=IVAR; + +- (int) Meth4 { return PROP4; } +@synthesize PROP4=PROP4; + +- (int) Meth5 { return bar; } // expected-error {{use of undeclared identifier 'bar'}} +@synthesize bar = _bar; + +- (int) Meth6 { return bar1; } + +@end + +@implementation I(CAT) +- (int) Meth { return PROP1; } // expected-error {{use of undeclared identifier 'PROP1'}} +@end + +@implementation I(r8251648) +- (int) Meth1: (int) bar { + return bar; // expected-warning {{local declaration of 'bar' hides instance variable}} +} +@end diff --git a/test/SemaObjC/warn-strict-selector-match.m b/test/SemaObjC/warn-strict-selector-match.m new file mode 100644 index 0000000..8ac0ca4 --- /dev/null +++ b/test/SemaObjC/warn-strict-selector-match.m @@ -0,0 +1,75 @@ +// RUN: %clang_cc1 -Wstrict-selector-match -fsyntax-only -verify %s + +@interface Foo +-(int) method; // expected-note {{using}} +@end + +@interface Bar +-(float) method; // expected-note {{also found}} +@end + +int main() { [(id)0 method]; } // expected-warning {{multiple methods named 'method' found [-Wstrict-selector-match]}} + +@interface Object @end + +@interface Class1 +- (void)setWindow:(Object *)wdw; // expected-note {{using}} +@end + +@interface Class2 +- (void)setWindow:(Class1 *)window; // expected-note {{also found}} +@end + +id foo(void) { + Object *obj = 0; + id obj2 = obj; + [obj setWindow:0]; // expected-warning {{Object' may not respond to 'setWindow:'}} + [obj2 setWindow:0]; // expected-warning {{multiple methods named 'setWindow:' found [-Wstrict-selector-match]}} + return obj; +} + +@protocol MyObject +- (id)initWithData:(Object *)data; // expected-note {{using}} \ + // expected-note {{passing argument to parameter 'data' here}} +@end + +@protocol SomeOther +- (id)initWithData:(int)data; // expected-note {{also found}} +@end + +@protocol MyCoding +- (id)initWithData:(id<MyObject, MyCoding>)data; // expected-note {{also found}} +@end + +@interface NTGridDataObject: Object <MyCoding> +{ + Object<MyCoding> *_data; +} ++ (NTGridDataObject*)dataObject:(id<MyObject, MyCoding>)data; +@end + +@implementation NTGridDataObject +- (id)initWithData:(id<MyObject, MyCoding>)data { + return data; +} ++ (NTGridDataObject*)dataObject:(id<MyObject, MyCoding>)data +{ + NTGridDataObject *result = [(id)0 initWithData:data]; // expected-warning {{multiple methods named 'initWithData:' found [-Wstrict-selector-match]}} \ + expected-warning {{sending 'id<MyObject,MyCoding>' to parameter of incompatible type 'Object *'}} + return result; +} +@end + +@interface Base +- (unsigned)port; +@end + +@interface Derived: Base +- (Object *)port; ++ (Protocol *)port; +@end + +void foo1(void) { + [(Class)0 port]; // OK - gcc issues warning but there is only one Class method so no ambiguity to warn +} + diff --git a/test/SemaObjCXX/conversion-to-objc-pointer-2.mm b/test/SemaObjCXX/conversion-to-objc-pointer-2.mm index 5277d10..b03d4d8 100644 --- a/test/SemaObjCXX/conversion-to-objc-pointer-2.mm +++ b/test/SemaObjCXX/conversion-to-objc-pointer-2.mm @@ -82,6 +82,7 @@ int main (int argc, const char * argv[]) { TNSAutoRef<NSObject*> object2([[NSObject alloc] init]); TNSAutoRef<TBar*> bar([[TBar alloc] init]); [bar setBlah: object1]; // <== Does not compile. It should. - [bar setBlah: object2]; // <== Does not compile. It should. + if (object1 == object2) + [bar setBlah: object2]; // <== Does not compile. It should. return 0; } diff --git a/test/SemaObjCXX/cxxoperator-selector.mm b/test/SemaObjCXX/cxxoperator-selector.mm new file mode 100644 index 0000000..6dd36a8 --- /dev/null +++ b/test/SemaObjCXX/cxxoperator-selector.mm @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// rdar:// 8328250 + +@class NSDate; + +@interface XSGraphDataSet +- and; +- xor; +- or; + +- ||; // expected-error {{expected selector for Objective-C method}} + +- &&; // expected-error {{expected selector for Objective-C method}} + +- (void)dataSetForValuesBetween:(NSDate *)startDate and:(NSDate *)endDate; +@end + +@implementation XSGraphDataSet +- (id) and{return 0; }; +- (id) xor{return 0; }; +- (id) or{return 0; }; + +- (void)dataSetForValuesBetween:(NSDate *)startDate and:(NSDate *)endDate { return; } +@end diff --git a/test/SemaObjCXX/deduction.mm b/test/SemaObjCXX/deduction.mm index 6dd449d..220f368 100644 --- a/test/SemaObjCXX/deduction.mm +++ b/test/SemaObjCXX/deduction.mm @@ -56,3 +56,10 @@ namespace test1 { template struct tester<Test1Class>; // expected-note {{in instantiation}} template struct tester<Test1Class<Test1Protocol> >; // expected-note {{in instantiation}} } + +namespace test2 { + template <typename T> void foo(const T* t) {} + void test(id x) { + foo(x); + } +} diff --git a/test/SemaObjCXX/exceptions-fragile.mm b/test/SemaObjCXX/exceptions-fragile.mm new file mode 100644 index 0000000..11dd8e9 --- /dev/null +++ b/test/SemaObjCXX/exceptions-fragile.mm @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +@interface NSException @end +void opaque(); + +namespace test0 { + void test() { + try { + } catch (NSException *e) { // expected-error {{can't catch Objective C exceptions in C++ in the non-unified exception model}} + } + } +} diff --git a/test/SemaObjCXX/expr-objcxx.mm b/test/SemaObjCXX/expr-objcxx.mm new file mode 100644 index 0000000..e70a001 --- /dev/null +++ b/test/SemaObjCXX/expr-objcxx.mm @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only + +// rdar://8366474 +void *P = @selector(foo::bar::); diff --git a/test/SemaObjCXX/foreach-block.mm b/test/SemaObjCXX/foreach-block.mm new file mode 100644 index 0000000..91bd0c8 --- /dev/null +++ b/test/SemaObjCXX/foreach-block.mm @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s +// rdar://8295106 + +int main() { +id array; + + for (int (^b)(void) in array) { + if (b() == 10000) { + return 1; + } + } + + int (^b)(void) in array; // expected-error {{expected ';' at end of declaration}} +} diff --git a/test/SemaObjCXX/instantiate-stmt.mm b/test/SemaObjCXX/instantiate-stmt.mm index e92f8e8..5e8ec61 100644 --- a/test/SemaObjCXX/instantiate-stmt.mm +++ b/test/SemaObjCXX/instantiate-stmt.mm @@ -25,6 +25,7 @@ template void synchronized_test(int); // expected-note{{in instantiation of}} // fast enumeration @interface NSArray +- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount; @end @interface NSString diff --git a/test/SemaObjCXX/message.mm b/test/SemaObjCXX/message.mm index 76bde6f..f92518a 100644 --- a/test/SemaObjCXX/message.mm +++ b/test/SemaObjCXX/message.mm @@ -38,7 +38,7 @@ I2 *operator+(I2_holder, int); return 0; } + (void)method { - [ivar method]; // expected-error{{receiver type 'ivar' (aka 'ivar') is not an Objective-C class}} + [ivar method]; // expected-error{{receiver type 'ivar' is not an Objective-C class}} } @end diff --git a/test/SemaObjCXX/objc-decls-inside-namespace.mm b/test/SemaObjCXX/objc-decls-inside-namespace.mm index 9953ec3..f68078b 100644 --- a/test/SemaObjCXX/objc-decls-inside-namespace.mm +++ b/test/SemaObjCXX/objc-decls-inside-namespace.mm @@ -23,5 +23,10 @@ namespace C { @implementation A(C) //expected-error{{Objective-C declarations may only appear in global scope}} @end +@interface B @end //expected-error{{Objective-C declarations may only appear in global scope}} +@implementation B //expected-error{{Objective-C declarations may only appear in global scope}} ++ (void) foo {} +@end + } diff --git a/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm b/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm index 80383eb..d0f8404 100644 --- a/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm +++ b/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm @@ -19,3 +19,31 @@ void a() { } + +// pr7936 +@interface I1 @end + +class Wrapper { +public: + operator id() const { return (id)_value; } + operator Class() const { return (Class)_value; } + operator I1*() const { return (I1*)_value; } + + bool Compare(id obj) { return *this == obj; } + bool CompareClass(Class obj) { return *this == obj; } + bool CompareI1(I1* obj) { return *this == obj; } + + Wrapper &operator*(); + Wrapper &operator[](int); + Wrapper& operator->*(int); + +private: + long _value; +}; + +void f() { + Wrapper w; + w[0]; + *w; + w->*(0); +} diff --git a/test/SemaObjCXX/references.mm b/test/SemaObjCXX/references.mm index 70ce827..15033f6 100644 --- a/test/SemaObjCXX/references.mm +++ b/test/SemaObjCXX/references.mm @@ -24,3 +24,39 @@ int f2(A *a) { return f0(a.p1); // expected-error {{property 'p1' not found on object of type 'A *'}} } +// PR7740 +@class NSString; + +void f3(id); +void f4(NSString &tmpstr) { + f3(&tmpstr); +} + +// PR7741 +@protocol P1 @end +@protocol P2 @end +@protocol P3 @end +@interface foo<P1> {} @end +@interface bar : foo <P1, P2> {} @end +typedef bar baz; + +struct ToBar { + operator bar&() const; +}; + +void f5(foo&); +void f5b(foo<P1>&); +void f5c(foo<P2>&); +void f5d(foo<P3>&); +void f6(baz* x) { + f5(*x); + f5b(*x); + f5c(*x); + f5d(*x); + (void)((foo&)*x); + f5(ToBar()); + f5b(ToBar()); + f5c(ToBar()); + f5d(ToBar()); + (void)((foo&)ToBar()); +} diff --git a/test/SemaObjCXX/warn-strict-selector-match.mm b/test/SemaObjCXX/warn-strict-selector-match.mm new file mode 100644 index 0000000..6d315db --- /dev/null +++ b/test/SemaObjCXX/warn-strict-selector-match.mm @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -Wstrict-selector-match -fsyntax-only -verify %s + +@interface Base +- (id) meth1: (Base *)arg1; // expected-note {{using}} +- (id) window; // expected-note {{using}} +@end + +@interface Derived: Base +- (id) meth1: (Derived *)arg1; // expected-note {{also found}} +- (Base *) window; // expected-note {{also found}} +@end + +void foo(void) { + id r; + + [r meth1:r]; // expected-warning {{multiple methods named 'meth1:' found [-Wstrict-selector-match]}} + [r window]; // expected-warning {{multiple methods named 'window' found [-Wstrict-selector-match]}} +} diff --git a/test/SemaTemplate/class-template-id.cpp b/test/SemaTemplate/class-template-id.cpp index df5ef55..50e0b00 100644 --- a/test/SemaTemplate/class-template-id.cpp +++ b/test/SemaTemplate/class-template-id.cpp @@ -41,3 +41,7 @@ typedef N::C<float> c2; template<typename T> struct Foo { }; // expected-note{{template is declared here}} void f(void) { Foo bar; } // expected-error{{without a template argument list}} + +// rdar://problem/8254267 +template <typename T> class Party; +template <> class Party<T> { friend struct Party<>; }; // expected-error {{use of undeclared identifier 'T'}} diff --git a/test/SemaTemplate/crash-8204126.cpp b/test/SemaTemplate/crash-8204126.cpp new file mode 100644 index 0000000..eb96560 --- /dev/null +++ b/test/SemaTemplate/crash-8204126.cpp @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +struct A +{ + template<int> template<typename T> friend void foo(T) {} // expected-error{{extraneous template parameter list}} + void bar() { foo(0); } // expected-error{{use of undeclared identifier 'foo'}} +}; diff --git a/test/SemaTemplate/current-instantiation.cpp b/test/SemaTemplate/current-instantiation.cpp index c631dd7..8caac93 100644 --- a/test/SemaTemplate/current-instantiation.cpp +++ b/test/SemaTemplate/current-instantiation.cpp @@ -164,3 +164,38 @@ namespace ConstantInCurrentInstantiation { template<typename T> int X<T>::array[X<T>::value] = { 1, 2 }; } + +namespace Expressions { + template <bool b> + struct Bool { + enum anonymous_enum { value = b }; + }; + struct True : public Bool<true> {}; + struct False : public Bool<false> {}; + + template <typename T1, typename T2> + struct Is_Same : public False {}; + template <typename T> + struct Is_Same<T, T> : public True {}; + + template <bool b, typename T = void> + struct Enable_If {}; + template <typename T> + struct Enable_If<true, T> { + typedef T type; + }; + + template <typename T> + class Class { + public: + template <typename U> + typename Enable_If<Is_Same<U, Class>::value, void>::type + foo(); + }; + + + template <typename T> + template <typename U> + typename Enable_If<Is_Same<U, Class<T> >::value, void>::type + Class<T>::foo() {} +} diff --git a/test/SemaTemplate/deduction-crash.cpp b/test/SemaTemplate/deduction-crash.cpp index 1860c75..8f4b728 100644 --- a/test/SemaTemplate/deduction-crash.cpp +++ b/test/SemaTemplate/deduction-crash.cpp @@ -4,7 +4,7 @@ // Note that the error count below doesn't matter. We just want to // make sure that the parser doesn't crash. -// CHECK: 16 errors +// CHECK: 15 errors template<a> struct int_; diff --git a/test/SemaTemplate/deduction.cpp b/test/SemaTemplate/deduction.cpp index e8ff8d3..9400a0a 100644 --- a/test/SemaTemplate/deduction.cpp +++ b/test/SemaTemplate/deduction.cpp @@ -105,3 +105,32 @@ namespace PR7463 { template <typename T_> void g (T_&); // expected-note{{T_ = int}} void h (void) { g(f()); } // expected-error{{no matching function for call}} } + +namespace test0 { + template <class T> void make(const T *(*fn)()); // expected-note {{candidate template ignored: can't deduce a type for 'T' which would make 'T const' equal 'char'}} + char *char_maker(); + void test() { + make(char_maker); // expected-error {{no matching function for call to 'make'}} + } +} + +namespace test1 { + template<typename T> void foo(const T a[3][3]); + void test() { + int a[3][3]; + foo(a); + } +} + +// PR7708 +namespace test2 { + template<typename T> struct Const { typedef void const type; }; + + template<typename T> void f(T, typename Const<T>::type*); + template<typename T> void f(T, void const *); + + void test() { + void *p = 0; + f(0, p); + } +} diff --git a/test/SemaTemplate/dependent-base-member-init.cpp b/test/SemaTemplate/dependent-base-member-init.cpp index 1f13149..1d4fed3 100644 --- a/test/SemaTemplate/dependent-base-member-init.cpp +++ b/test/SemaTemplate/dependent-base-member-init.cpp @@ -57,3 +57,12 @@ template<typename T, typename U> struct X0 : T::template apply<U> { X0(int i) : T::template apply<U>(i) { } }; + +// PR7698 +namespace PR7698 { + template<typename Type> + class A { + char mA[sizeof(Type *)]; + A(): mA() {} + }; +} diff --git a/test/SemaTemplate/dependent-class-member-operator.cpp b/test/SemaTemplate/dependent-class-member-operator.cpp new file mode 100644 index 0000000..d70a60c --- /dev/null +++ b/test/SemaTemplate/dependent-class-member-operator.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// PR7837 + +template<class T> struct C1 { void operator()(T); }; +template<class T> struct C2; // expected-note {{template is declared here}} +template<class T> void foo(T); +void wrap() { + foo(&C1<int>::operator()); + foo(&C1<int>::operator+); // expected-error {{no member named 'operator+' in 'C1<int>'}} + foo(&C2<int>::operator+); // expected-error {{implicit instantiation of undefined template 'C2<int>'}} +} diff --git a/test/SemaTemplate/dependent-expr.cpp b/test/SemaTemplate/dependent-expr.cpp index 9fa7571..e25afce 100644 --- a/test/SemaTemplate/dependent-expr.cpp +++ b/test/SemaTemplate/dependent-expr.cpp @@ -40,3 +40,8 @@ namespace PR7198 { } }; } + +namespace PR7724 { + template<typename OT> int myMethod() + { return 2 && sizeof(OT); } +} diff --git a/test/SemaTemplate/inject-templated-friend-post.cpp b/test/SemaTemplate/inject-templated-friend-post.cpp new file mode 100644 index 0000000..98ac38e --- /dev/null +++ b/test/SemaTemplate/inject-templated-friend-post.cpp @@ -0,0 +1,72 @@ +// RUN: %clang %s -S -emit-llvm -o - | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE" +// RUN: %clang %s -S -emit-llvm -o - -DPROTOTYPE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE" +// RUN: %clang %s -S -emit-llvm -o - -DINSTANTIATE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE" +// RUN: %clang %s -S -emit-llvm -o - -DPROTOTYPE -DINSTANTIATE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE" +// RUN: %clang -cc1 %s -DREDEFINE -verify +// RUN: %clang -cc1 %s -DPROTOTYPE -DREDEFINE -verify +// PR8007: friend function not instantiated, reordered version. +// Corresponds to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38392 + +struct std_ostream +{ + int dummy; +}; + +std_ostream cout; + +template <typename STRUCT_TYPE> +struct Streamer; + +typedef struct Foo {} Foo; + +std_ostream& operator << (std_ostream&, const Streamer<Foo>&); + +void test(const Streamer<Foo>& foo) +{ + cout << foo; +} + +template <typename STRUCT_TYPE> +struct Streamer +{ + friend std_ostream& operator << (std_ostream& o, const Streamer& f) // expected-error{{redefinition of 'operator<<'}} + { + Streamer s(f); + s(o); + return o; + } + + Streamer(const STRUCT_TYPE& s) : s(s) {} + + const STRUCT_TYPE& s; + void operator () (std_ostream&) const; +}; + +#ifdef PROTOTYPE +std_ostream& operator << (std_ostream&, const Streamer<Foo>&); +#endif + +#ifdef INSTANTIATE +template struct Streamer<Foo>; +#endif + +#ifdef REDEFINE +std_ostream& operator << (std_ostream& o, const Streamer<Foo>&) // expected-note{{is here}} +{ + return o; +} +#endif + +#ifndef INSTANTIATE +template <> +void Streamer<Foo>::operator () (std_ostream& o) const // expected-note{{requested here}} +{ +} +#endif + +int main(void) +{ + Foo foo; + test(foo); +} + diff --git a/test/SemaTemplate/inject-templated-friend.cpp b/test/SemaTemplate/inject-templated-friend.cpp new file mode 100644 index 0000000..fbe86d9 --- /dev/null +++ b/test/SemaTemplate/inject-templated-friend.cpp @@ -0,0 +1,48 @@ +// RUN: %clang %s -S -emit-llvm -o - | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE" +// RUN: %clang -cc1 %s -DREDEFINE -verify +// PR8007: friend function not instantiated. + +struct std_ostream +{ + int dummy; +}; + +std_ostream cout; + +template <typename STRUCT_TYPE> +struct Streamer +{ + friend std_ostream& operator << (std_ostream& o, const Streamer& f) // expected-error{{redefinition of 'operator<<'}} + { + Streamer s(f); + s(o); + return o; + } + + Streamer(const STRUCT_TYPE& s) : s(s) {} + + const STRUCT_TYPE& s; + void operator () (std_ostream&) const; +}; + +typedef struct Foo {} Foo; + +std_ostream& operator << (std_ostream&, const Streamer<Foo>&); +#ifdef REDEFINE +std_ostream& operator << (std_ostream& o, const Streamer<Foo>&) // expected-note{{is here}} +{ + // Sema should flag this as a redefinition + return o; +} +#endif + +template <> +void Streamer<Foo>::operator () (std_ostream& o) const // expected-note{{requested here}} +{ +} + +int main(void) +{ + Foo foo; + cout << foo; +} diff --git a/test/SemaTemplate/instantiate-anonymous-union.cpp b/test/SemaTemplate/instantiate-anonymous-union.cpp index 255454b..f2862db 100644 --- a/test/SemaTemplate/instantiate-anonymous-union.cpp +++ b/test/SemaTemplate/instantiate-anonymous-union.cpp @@ -47,3 +47,22 @@ namespace PR7088 { template void f<double>(); } + +// Check for problems related to PR7402 that occur when template instantiation +// instantiates implicit initializers. +namespace PR7402 { + struct X { + union { + struct { + int x; + int y; + }; + int v[2]; + }; + + // Check that this requirement survives instantiation. + template <typename T> X(const T& t) : x(t), y(t) {} + }; + + X x(42.0); +} diff --git a/test/SemaTemplate/instantiate-attr.cpp b/test/SemaTemplate/instantiate-attr.cpp index e8291ed..bbadb63 100644 --- a/test/SemaTemplate/instantiate-attr.cpp +++ b/test/SemaTemplate/instantiate-attr.cpp @@ -11,3 +11,16 @@ struct A { int a[sizeof(A<int>) == 16 ? 1 : -1]; int a2[sizeof(A<int>::B) == 16 ? 1 : -1]; +// rdar://problem/8243419 +namespace test1 { + template <typename T> struct A { + int a; + T b[0]; + } __attribute__((packed)); + + typedef A<unsigned long> type; + + int test0[sizeof(type) == 4 ? 1 : -1]; + int test1[__builtin_offsetof(type, a) == 0 ? 1 : -1]; + int test2[__builtin_offsetof(type, b) == 4 ? 1 : -1]; +} diff --git a/test/SemaTemplate/instantiate-clang.cpp b/test/SemaTemplate/instantiate-clang.cpp index cef2b70..34d68c4 100644 --- a/test/SemaTemplate/instantiate-clang.cpp +++ b/test/SemaTemplate/instantiate-clang.cpp @@ -24,7 +24,7 @@ template<typename T, typename U, int N, int M> struct ShuffleVector0 { void f(T t, U u, double2 a, double2 b) { (void)__builtin_shufflevector(t, u, N, M); // expected-error{{index}} - (void)__builtin_shufflevector(a, b, N, M); + (void)__builtin_shufflevector(a, b, N, M); // expected-error{{index}} (void)__builtin_shufflevector(a, b, 2, 1); } }; diff --git a/test/SemaTemplate/instantiate-declref.cpp b/test/SemaTemplate/instantiate-declref.cpp index 2d27075..ced56df 100644 --- a/test/SemaTemplate/instantiate-declref.cpp +++ b/test/SemaTemplate/instantiate-declref.cpp @@ -95,3 +95,13 @@ namespace test0 { }; void g() { X<2>(); } } + +// <rdar://problem/8302161> +namespace test1 { + template <typename T> void f(T const &t) { + union { char c; T t_; }; + c = 'a'; // <- this shouldn't silently fail to instantiate + T::foo(); // expected-error {{has no members}} + } + template void f(int const &); // expected-note {{requested here}} +} diff --git a/test/SemaTemplate/instantiate-expr-3.cpp b/test/SemaTemplate/instantiate-expr-3.cpp index d506b19..ca88b003 100644 --- a/test/SemaTemplate/instantiate-expr-3.cpp +++ b/test/SemaTemplate/instantiate-expr-3.cpp @@ -63,7 +63,11 @@ template struct Conditional0<int, int, int>; template<typename T> struct StatementExpr0 { void f(T t) { - (void)({ if (t) t = t + 17; t + 12;}); // expected-error{{contextually convertible}} + (void)({ + if (t) // expected-error{{contextually convertible}} + t = t + 17; + t + 12; // expected-error{{invalid operands}} + }); } }; @@ -106,8 +110,8 @@ struct VaArg1 { VaList va; __builtin_va_start(va, n); // expected-error{{int}} for (int i = 0; i != n; ++i) - (void)__builtin_va_arg(va, ArgType); - __builtin_va_end(va); + (void)__builtin_va_arg(va, ArgType); // expected-error{{int}} + __builtin_va_end(va); // expected-error{{int}} } }; diff --git a/test/SemaTemplate/instantiate-expr-4.cpp b/test/SemaTemplate/instantiate-expr-4.cpp index 8cd7342..adae1da 100644 --- a/test/SemaTemplate/instantiate-expr-4.cpp +++ b/test/SemaTemplate/instantiate-expr-4.cpp @@ -115,7 +115,7 @@ template<typename T> struct Delete0 { void f(T t) { delete t; // expected-error{{cannot delete}} - ::delete [] t; + ::delete [] t; // expected-error{{cannot delete}} } }; diff --git a/test/SemaTemplate/instantiate-function-1.cpp b/test/SemaTemplate/instantiate-function-1.cpp index a293e9a..651c02c 100644 --- a/test/SemaTemplate/instantiate-function-1.cpp +++ b/test/SemaTemplate/instantiate-function-1.cpp @@ -72,7 +72,7 @@ template<typename T, typename U, typename V> struct X6 { if (T x = t) { t = x; } - return v; + return v; // expected-error{{cannot initialize return object of type}} } }; @@ -178,10 +178,10 @@ template<typename T> struct IndirectGoto0 { prior: T prior_label; - prior_label = &&prior; + prior_label = &&prior; // expected-error{{assigning to 'int'}} T later_label; - later_label = &&later; + later_label = &&later; // expected-error{{assigning to 'int'}} later: (void)(1+1); diff --git a/test/SemaTemplate/instantiate-member-template.cpp b/test/SemaTemplate/instantiate-member-template.cpp index 24a3f31..8f4063b 100644 --- a/test/SemaTemplate/instantiate-member-template.cpp +++ b/test/SemaTemplate/instantiate-member-template.cpp @@ -189,3 +189,17 @@ namespace PR7587 { }; } + +namespace PR7669 { + template<class> struct X { + template<class> struct Y { + template<int,class> struct Z; + template<int Dummy> struct Z<Dummy,int> {}; + }; + }; + + void a() + { + X<int>::Y<int>::Z<0,int>(); + } +} diff --git a/test/SemaTemplate/member-access-expr.cpp b/test/SemaTemplate/member-access-expr.cpp index 24db791..16b9515 100644 --- a/test/SemaTemplate/member-access-expr.cpp +++ b/test/SemaTemplate/member-access-expr.cpp @@ -121,3 +121,14 @@ namespace test4 { } }; } + +namespace test5 { + template<typename T> + struct X { + using T::value; + + T &getValue() { + return &value; + } + }; +} diff --git a/test/SemaTemplate/member-template-access-expr.cpp b/test/SemaTemplate/member-template-access-expr.cpp index ea17cdb..dbd27c4 100644 --- a/test/SemaTemplate/member-template-access-expr.cpp +++ b/test/SemaTemplate/member-template-access-expr.cpp @@ -123,3 +123,22 @@ namespace PR6021 { }; }; } + +namespace rdar8198511 { + template<int, typename U> + struct Base { + void f(); + }; + + template<typename T> + struct X0 : Base<1, T> { }; + + template<typename T> + struct X1 { + X0<int> x0; + + void f() { + this->x0.Base<1, int>::f(); + } + }; +} diff --git a/test/SemaTemplate/nested-name-spec-template.cpp b/test/SemaTemplate/nested-name-spec-template.cpp index 12ab486..9c72845 100644 --- a/test/SemaTemplate/nested-name-spec-template.cpp +++ b/test/SemaTemplate/nested-name-spec-template.cpp @@ -88,3 +88,14 @@ namespace PR7385 { has_xxx0<int>::type t; // expected-note{{instantiation of}} } + +namespace PR7725 { + template<class ignored> struct TypedefProvider; + template<typename T> + struct TemplateClass : public TypedefProvider<T> + { + void PrintSelf() { + TemplateClass::Test::PrintSelf(); + } + }; +} diff --git a/test/SemaTemplate/recovery-crash.cpp b/test/SemaTemplate/recovery-crash.cpp new file mode 100644 index 0000000..0ed3258 --- /dev/null +++ b/test/SemaTemplate/recovery-crash.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// We don't expect a fix-it to be applied in this case. Clang used to crash +// trying to recover while adding 'this->' before Work(x); + +template <typename> struct A { + static void Work(int); // expected-note{{must qualify identifier}} +}; + +template <typename T> struct B : public A<T> { + template <typename T2> B(T2 x) { + Work(x); // expected-error{{use of undeclared identifier}} + } +}; + +void Test() { + B<int> b(0); // expected-note{{in instantiation of function template}} +} + diff --git a/test/SemaTemplate/temp.cpp b/test/SemaTemplate/temp.cpp index 961b9c8..e037f0f 100644 --- a/test/SemaTemplate/temp.cpp +++ b/test/SemaTemplate/temp.cpp @@ -1,5 +1,19 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -// p3 -template<typename T> int foo(T), bar(T, T); // expected-error{{single entity}} +namespace test0 { + // p3 + template<typename T> int foo(T), bar(T, T); // expected-error{{single entity}} +} + +// PR7252 +namespace test1 { + namespace A { template<typename T> struct Base { typedef T t; }; } // expected-note {{member found}} + namespace B { template<typename T> struct Base { typedef T t; }; } // expected-note {{member found}} + + template<typename T> struct Derived : A::Base<char>, B::Base<int> { + // FIXME: the syntax error here is unfortunate + typename Derived::Base<float>::t x; // expected-error {{found in multiple base classes of different types}} \ + // expected-error {{expected member name or ';'}} + }; +} diff --git a/test/SemaTemplate/temp_arg_nontype.cpp b/test/SemaTemplate/temp_arg_nontype.cpp index d351eb4..6f51591 100644 --- a/test/SemaTemplate/temp_arg_nontype.cpp +++ b/test/SemaTemplate/temp_arg_nontype.cpp @@ -203,3 +203,43 @@ namespace PR6964 { struct as_nview<Sequence, I0> // expected-note{{while checking a default template argument used here}} { }; } + +// rdar://problem/8302138 +namespace test8 { + template <int* ip> struct A { + int* p; + A() : p(ip) {} + }; + + void test0() { + extern int i00; + A<&i00> a00; + } + + extern int i01; + void test1() { + A<&i01> a01; + } + + + struct C { + int x; + char y; + double z; + }; + + template <C* cp> struct B { + C* p; + B() : p(cp) {} + }; + + void test2() { + extern C c02; + B<&c02> b02; + } + + extern C c03; + void test3() { + B<&c03> b03; + } +} diff --git a/test/SemaTemplate/temp_arg_template.cpp b/test/SemaTemplate/temp_arg_template.cpp index 6671225..944acac 100644 --- a/test/SemaTemplate/temp_arg_template.cpp +++ b/test/SemaTemplate/temp_arg_template.cpp @@ -33,3 +33,21 @@ A<f> *a9; // expected-error{{must be a class template}} // FIXME: The code below is ill-formed, because of the evil digraph '<:'. // We should provide a much better error message than we currently do. // A<::N::Z> *a10; + +// PR7807 +namespace N { + template <typename, typename = int> + struct X + { }; + + template <typename ,int> + struct Y + { X<int> const_ref(); }; + + template <template<typename,int> class TT, typename T, int N> + int operator<<(int, TT<T, N> a) { // expected-note{{candidate template ignored}} + 0 << a.const_ref(); // expected-error{{invalid operands to binary expression ('int' and 'X<int>')}} + } + + void f0( Y<int,1> y){ 1 << y; } // expected-note{{in instantiation of function template specialization 'N::operator<<<Y, int, 1>' requested here}} +} diff --git a/test/SemaTemplate/temp_arg_type.cpp b/test/SemaTemplate/temp_arg_type.cpp index 3876c25..3970942 100644 --- a/test/SemaTemplate/temp_arg_type.cpp +++ b/test/SemaTemplate/temp_arg_type.cpp @@ -24,11 +24,11 @@ A<ns::B> a8; // expected-error{{use of class template ns::B requires template ar // [temp.arg.type]p2 void f() { class X { }; - A<X> * a = 0; // expected-error{{template argument uses local type 'X'}} + A<X> * a = 0; // expected-warning{{template argument uses local type 'X'}} } struct { int x; } Unnamed; // expected-note{{unnamed type used in template argument was declared here}} -A<__typeof__(Unnamed)> *a9; // expected-error{{template argument uses unnamed type}} +A<__typeof__(Unnamed)> *a9; // expected-warning{{template argument uses unnamed type}} template<typename T, unsigned N> struct Array { diff --git a/test/lit.cfg b/test/lit.cfg index 42de5cb..80f8d5a 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -146,3 +146,9 @@ config.substitutions.append( config.substitutions.append( (' %clang-cc1 ', """*** invalid substitution, use '%clang_cc1'. ***""") ) + +### + +# Set available features we allow tests to conditionalize on. +if platform.system() != 'Windows': + config.available_features.add('crash-recovery') |