summaryrefslogtreecommitdiffstats
path: root/test/Coverage
diff options
context:
space:
mode:
Diffstat (limited to 'test/Coverage')
-rw-r--r--test/Coverage/ast-printing.c6
-rw-r--r--test/Coverage/ast-printing.cpp6
-rw-r--r--test/Coverage/ast-printing.m5
-rw-r--r--test/Coverage/c-language-features.inc181
-rw-r--r--test/Coverage/codegen-gnu.m3
-rw-r--r--test/Coverage/codegen-next.m4
-rw-r--r--test/Coverage/codegen.c7
-rw-r--r--test/Coverage/cxx-language-features.inc21
-rw-r--r--test/Coverage/html-diagnostics.c15
-rw-r--r--test/Coverage/html-print.c3
-rw-r--r--test/Coverage/objc-language-features.inc81
-rw-r--r--test/Coverage/parse-callbacks.c4
-rw-r--r--test/Coverage/parse-callbacks.m4
-rw-r--r--test/Coverage/targets.c18
-rw-r--r--test/Coverage/verbose.c1
15 files changed, 359 insertions, 0 deletions
diff --git a/test/Coverage/ast-printing.c b/test/Coverage/ast-printing.c
new file mode 100644
index 0000000..efa9509
--- /dev/null
+++ b/test/Coverage/ast-printing.c
@@ -0,0 +1,6 @@
+// RUN: clang-cc --fsyntax-only %s &&
+// RUN: clang-cc --ast-print %s &&
+// RUN: clang-cc --ast-dump %s &&
+// RUN: clang-cc --ast-print-xml -o %t %s
+
+#include "c-language-features.inc"
diff --git a/test/Coverage/ast-printing.cpp b/test/Coverage/ast-printing.cpp
new file mode 100644
index 0000000..10d01c7
--- /dev/null
+++ b/test/Coverage/ast-printing.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-cc --fsyntax-only %s &&
+// RUN: clang-cc --ast-print %s &&
+// RUN: clang-cc --ast-dump %s
+// FIXME: clang-cc --ast-print-xml -o %t %s
+
+#include "cxx-language-features.inc"
diff --git a/test/Coverage/ast-printing.m b/test/Coverage/ast-printing.m
new file mode 100644
index 0000000..85bbd43
--- /dev/null
+++ b/test/Coverage/ast-printing.m
@@ -0,0 +1,5 @@
+// RUN: clang-cc --fsyntax-only %s &&
+// RUN: clang-cc --ast-print %s &&
+// RUN: clang-cc --ast-dump %s
+
+#include "objc-language-features.inc"
diff --git a/test/Coverage/c-language-features.inc b/test/Coverage/c-language-features.inc
new file mode 100644
index 0000000..bcf4127
--- /dev/null
+++ b/test/Coverage/c-language-features.inc
@@ -0,0 +1,181 @@
+//-*- C -*-
+
+/* This is a
+ multiline comment */
+
+// Intended to exercise all syntactic parts of the C language.
+
+int g0;
+int g1, g2;
+
+struct s0;
+
+struct s0 {
+ int x;
+};
+
+int g3 = 10;
+
+__asm("");
+
+typedef int td0;
+
+td0 g4;
+
+enum e0 {
+ ec0
+};
+
+static void f0(int x) {
+}
+
+inline void f0_0(int x) {
+ ;
+}
+
+extern void f0_1(int x) {
+}
+
+void f1(int, ...);
+
+// Statements.
+void f2() {
+ for (;;) {
+ break;
+ continue;
+ }
+
+ while (0) {
+ }
+
+ do {
+ } while (0);
+
+ void *label = &&theif;
+ goto *label;
+
+ goto theif;
+theif:
+ if (0) {
+ ;
+ } else if (0) {
+ } else {
+ }
+
+ switch(0) {
+ case 0:
+ case 1 ... 2:
+ break;
+ default:
+ break;
+ }
+
+ asm ("nop");
+
+ return;
+}
+
+// Expressions.
+
+#include <stdarg.h>
+
+typedef struct ipair {
+ int first, second;
+} ipair;
+
+void f4(int a0, int a1, int a2, va_list ap) {
+ int t0 = a0 ? a1 : a2;
+ float t1 = (float) a0;
+ ipair t2 = {1, 2};
+ ipair t2a = { .second = 2 };
+ int t3 = sizeof(ipair);
+ ipair t4;
+ t4 = (ipair) {1, 2};
+ extern int g(int);
+ int t5 = g(a0);
+ int t6 = t4.first;
+ int t7[10];
+ int t8 = t7[a0];
+ t8++;
+ const char *t9 = __FUNCTION__;
+ char t10 = 'x';
+ int t11 = __builtin_offsetof(ipair, first);
+ int t12 = __builtin_types_compatible_p(ipair, int);
+ int t12_0 = __builtin_classify_type(t0);
+ int t12_1 = __builtin_classify_type(t1);
+ int t12_2 = __builtin_classify_type(t2);
+ // FIXME: Add _Complex and aggregate cases.
+ int t13 = va_arg(ap, int);
+ va_list t13_0;
+ va_copy(t13_0, ap);
+ int t14 = __extension__(t13);
+ int t15 = +t13;
+ unsigned t16 = t14 ^ t15;
+ int t17 = t14 % t15;
+ int t17_0 = t16 % t16;
+ float t18;
+ int t19 = t18 ? 0 : 1;
+ char *t20; ++t20; --t20;
+ float t21; ++t21; --t21;
+ double t22; ++t22; --t22;
+ long double t23; ++t23; --t23;
+ int t24 = !t19;
+ int t25 = __real t24;
+ int t26 = __imag t24;
+ const char *t27 = t9;
+ t27 += (unsigned char) 0xFF;
+ t27 += (signed char) 0xFF;
+
+ struct { char f0[10]; } *t28;
+ int t29 = t28 - t28;
+ char *t30 = &t28->f0[1];
+
+ struct s1 { int f0; };
+ struct s1 t31_a, t31_b;
+ int t31_cond;
+ int t31 = (t31_cond ? t31_a : t31_b).f0;
+
+ _Complex float t32_a, t32_b;
+ int t32_cond;
+ int t32 = __real (t32_cond ? t32_a : t32_b);
+
+ struct { int x, y; } t33, *t34, t35[12], t36(int, float);
+ float t37, *t38, t39[9], t40(double);
+}
+
+// Extended vectors
+
+typedef __attribute__((ext_vector_type(2))) float float2;
+typedef __attribute__((ext_vector_type(4))) float float4;
+
+void f5() {
+ float4 t0 = (float4) { 0, 1, 2, 3 };
+ float4 t1 = t0;
+ t0.lo.even = t1.hi.x;
+
+ // irgen doesn't support this yet.
+#if 0
+ int t2_cond;
+ float2 t2 = (t2_cond ? t0 : t1).lo;
+#endif
+}
+
+void f6() {
+ const char *s0 = __func__;
+ const char *s1 = __FUNCTION__;
+ const char *s2 = __PRETTY_FUNCTION__;
+}
+
+// Arg mismatch with passed type.
+void f7(x)
+ float x;
+{
+}
+
+void f8(x)
+ short x;
+{
+}
+
+// Function which inputs an array
+void f9(int x[]) { }
diff --git a/test/Coverage/codegen-gnu.m b/test/Coverage/codegen-gnu.m
new file mode 100644
index 0000000..bc8d6d6
--- /dev/null
+++ b/test/Coverage/codegen-gnu.m
@@ -0,0 +1,3 @@
+// RUN: clang-cc -triple i386-unknown-unknown -fgnu-runtime -emit-llvm -o %t %s
+
+#include "objc-language-features.inc"
diff --git a/test/Coverage/codegen-next.m b/test/Coverage/codegen-next.m
new file mode 100644
index 0000000..bca83cb
--- /dev/null
+++ b/test/Coverage/codegen-next.m
@@ -0,0 +1,4 @@
+// RUN: clang-cc -fnext-runtime -emit-llvm -o %t %s &&
+// RUN: clang-cc -g -fnext-runtime -emit-llvm -o %t %s
+
+#include "objc-language-features.inc"
diff --git a/test/Coverage/codegen.c b/test/Coverage/codegen.c
new file mode 100644
index 0000000..543c361
--- /dev/null
+++ b/test/Coverage/codegen.c
@@ -0,0 +1,7 @@
+// RUN: clang-cc -triple i386-unknown-unknown -emit-llvm -o %t %s &&
+// RUN: clang-cc -triple i386-unknown-unknown -emit-llvm-bc -o %t %s &&
+// RUN: clang-cc -triple i386-unknown-unknown -g -emit-llvm-bc -o %t %s &&
+// RUN: clang-cc -triple x86_64-unknown-unknown -emit-llvm-bc -o %t %s &&
+// RUN: clang-cc -triple x86_64-unknown-unknown -g -emit-llvm-bc -o %t %s
+
+#include "c-language-features.inc"
diff --git a/test/Coverage/cxx-language-features.inc b/test/Coverage/cxx-language-features.inc
new file mode 100644
index 0000000..51c1104
--- /dev/null
+++ b/test/Coverage/cxx-language-features.inc
@@ -0,0 +1,21 @@
+//-*- C++ -*-
+
+// Intended to exercise all syntactic parts of the C++ language that
+// aren't part of C.
+
+namespace std {
+ namespace debug {
+ }
+}
+
+using namespace std::debug;
+using namespace std;
+
+namespace safestl = ::std::debug;
+
+class Base1 {
+};
+
+class Base2 { };
+
+class Derived1 : Base1, virtual public Base2 { };
diff --git a/test/Coverage/html-diagnostics.c b/test/Coverage/html-diagnostics.c
new file mode 100644
index 0000000..6144f2f
--- /dev/null
+++ b/test/Coverage/html-diagnostics.c
@@ -0,0 +1,15 @@
+// RUN: rm -rf %t &&
+// RUN: clang-cc --html-diags=%t -checker-simple %s
+
+void f0(int x) {
+ int *p = &x;
+
+ if (x > 10) {
+ if (x == 22)
+ p = 0;
+ }
+
+ *p = 10;
+}
+
+
diff --git a/test/Coverage/html-print.c b/test/Coverage/html-print.c
new file mode 100644
index 0000000..dab156b
--- /dev/null
+++ b/test/Coverage/html-print.c
@@ -0,0 +1,3 @@
+// RUN: clang-cc -emit-html -o %t %s
+
+#include "c-language-features.inc"
diff --git a/test/Coverage/objc-language-features.inc b/test/Coverage/objc-language-features.inc
new file mode 100644
index 0000000..dd57dfb
--- /dev/null
+++ b/test/Coverage/objc-language-features.inc
@@ -0,0 +1,81 @@
+//-*- ObjC -*-
+
+@protocol P0;
+
+@protocol P1
+-(void) fm0;
+@end
+
+@class B;
+
+@interface Root
+@end
+
+@interface A : Root <P1> {
+ int iv0;
+ B *iv1;
+}
+
+@property(readonly) int p0;
+@property(assign,nonatomic,readwrite) int p1;
+@property(copy) id p2;
+@property(retain) id p3;
+@property(assign, getter=getme, setter=setme:) id p4;
+@end
+
+@implementation A
+@dynamic p0;
+@synthesize p1 = iv0;
++(void) fm0 {
+ [super fm0];
+}
+-(void) im0 {
+ const char *s0 = __func__;
+ const char *s1 = __FUNCTION__;
+ const char *s2 = __PRETTY_FUNCTION__;
+ [super im0];
+ int x = super.p0;
+}
+-(void) im1: (int) x, ... {
+}
+@end
+
+@implementation C : A
+@end
+
+@interface A (Cat)
+@end
+
+@implementation A (Cat)
+@end
+
+@interface B
+@end
+
+int f0(id x) {
+ @synchronized(x) {
+ }
+
+ @try {
+ @throw x;
+
+ } @catch(A *e) {
+ @throw;
+
+ // @catch param doesn't require name.
+ } @catch(B *) {
+
+ } @finally {
+ ;
+ }
+
+ for (id y in x) {
+ break;
+ }
+}
+
+#ifndef __OBJC2__
+struct s0 {
+ @defs(A);
+};
+#endif
diff --git a/test/Coverage/parse-callbacks.c b/test/Coverage/parse-callbacks.c
new file mode 100644
index 0000000..309074d
--- /dev/null
+++ b/test/Coverage/parse-callbacks.c
@@ -0,0 +1,4 @@
+// RUN: clang-cc --parse-noop %s &&
+// RUN: clang-cc --parse-print-callbacks %s
+
+#include "c-language-features.inc"
diff --git a/test/Coverage/parse-callbacks.m b/test/Coverage/parse-callbacks.m
new file mode 100644
index 0000000..dc1dcfc
--- /dev/null
+++ b/test/Coverage/parse-callbacks.m
@@ -0,0 +1,4 @@
+// RUN: clang-cc --parse-noop %s &&
+// RUN: clang-cc --parse-print-callbacks %s
+
+#include "objc-language-features.inc"
diff --git a/test/Coverage/targets.c b/test/Coverage/targets.c
new file mode 100644
index 0000000..5a547a5
--- /dev/null
+++ b/test/Coverage/targets.c
@@ -0,0 +1,18 @@
+// RUN: clang-cc -g -triple i686-unknown-unknown -emit-llvm -o %t %s &&
+// RUN: clang-cc -g -triple i686-pc-linux-gnu -emit-llvm -o %t %s &&
+// RUN: clang-cc -g -triple i686-unknown-dragonfly -emit-llvm -o %t %s &&
+// RUN: clang-cc -g -triple i686-unknown-win32 -emit-llvm -o %t %s &&
+// RUN: clang-cc -g -triple i686-apple-darwin9 -emit-llvm -o %t %s &&
+// RUN: clang-cc -g -triple x86_64-unknown-unknown -emit-llvm -o %t %s &&
+// RUN: clang-cc -g -triple x86_64-pc-linux-gnu -emit-llvm -o %t %s &&
+// RUN: clang-cc -g -triple x86_64-apple-darwin9 -emit-llvm -o %t %s &&
+// RUN: clang-cc -g -triple ppc-unknown-unknown -emit-llvm -o %t %s &&
+// RUN: clang-cc -g -triple ppc-apple-darwin9 -emit-llvm -o %t %s &&
+// RUN: clang-cc -g -triple ppc64-unknown-unknown -emit-llvm -o %t %s &&
+// RUN: clang-cc -g -triple ppc64-apple-darwin9 -emit-llvm -o %t %s &&
+// RUN: clang-cc -g -triple armv6-unknown-unknown -emit-llvm -o %t %s &&
+// RUN: clang-cc -g -triple armv6-apple-darwin9 -emit-llvm -o %t %s &&
+// RUN: clang-cc -g -triple sparc-unknown-unknown -emit-llvm -o %t %s &&
+// RUN: clang-cc -g -triple sparc-unknown-solaris -emit-llvm -o %t %s &&
+// RUN: clang-cc -g -triple pic16-unknown-unknown -emit-llvm -o %t %s &&
+// RUN: true
diff --git a/test/Coverage/verbose.c b/test/Coverage/verbose.c
new file mode 100644
index 0000000..a75557b
--- /dev/null
+++ b/test/Coverage/verbose.c
@@ -0,0 +1 @@
+// RUN: clang-cc -fsyntax-only -v %s
OpenPOWER on IntegriCloud