summaryrefslogtreecommitdiff
path: root/clang/test/Coverage
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-10-15 17:10:06 +1100
committerCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-10-15 17:10:06 +1100
commitbe1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch)
tree1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/Coverage
parentc4626a62754862d20b41e8a46a3574264ea80e6d (diff)
parentf1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff)
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/Coverage')
-rw-r--r--clang/test/Coverage/ast-printing.c6
-rw-r--r--clang/test/Coverage/ast-printing.cpp7
-rw-r--r--clang/test/Coverage/ast-printing.m5
-rw-r--r--clang/test/Coverage/c-language-features.inc198
-rw-r--r--clang/test/Coverage/codegen-gnu.m3
-rw-r--r--clang/test/Coverage/codegen-next.m4
-rw-r--r--clang/test/Coverage/codegen.c7
-rw-r--r--clang/test/Coverage/cxx-language-features.inc27
-rw-r--r--clang/test/Coverage/html-diagnostics.c22
-rw-r--r--clang/test/Coverage/html-print.c3
-rw-r--r--clang/test/Coverage/objc-language-features.inc87
-rw-r--r--clang/test/Coverage/targets.c20
-rw-r--r--clang/test/Coverage/verbose.c1
13 files changed, 390 insertions, 0 deletions
diff --git a/clang/test/Coverage/ast-printing.c b/clang/test/Coverage/ast-printing.c
new file mode 100644
index 0000000..ecaf3ab
--- /dev/null
+++ b/clang/test/Coverage/ast-printing.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+// RUN: %clang_cc1 -ast-print %s
+// RUN: %clang_cc1 -ast-dump %s
+// RUN: %clang_cc1 -print-decl-contexts %s
+
+#include "c-language-features.inc"
diff --git a/clang/test/Coverage/ast-printing.cpp b/clang/test/Coverage/ast-printing.cpp
new file mode 100644
index 0000000..3205078
--- /dev/null
+++ b/clang/test/Coverage/ast-printing.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+// RUN: %clang_cc1 -ast-print %s
+// RUN: %clang_cc1 -ast-dump %s
+// RUN: %clang_cc1 -print-decl-contexts %s
+// RUN: %clang_cc1 -fdump-record-layouts %s
+
+#include "cxx-language-features.inc"
diff --git a/clang/test/Coverage/ast-printing.m b/clang/test/Coverage/ast-printing.m
new file mode 100644
index 0000000..81c3a6b
--- /dev/null
+++ b/clang/test/Coverage/ast-printing.m
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-exceptions %s
+// RUN: %clang_cc1 -ast-print -fobjc-exceptions %s
+// RUN: %clang_cc1 -ast-dump -fobjc-exceptions %s
+
+#include "objc-language-features.inc"
diff --git a/clang/test/Coverage/c-language-features.inc b/clang/test/Coverage/c-language-features.inc
new file mode 100644
index 0000000..0ff1237
--- /dev/null
+++ b/clang/test/Coverage/c-language-features.inc
@@ -0,0 +1,198 @@
+//-*- 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[]) { }
+
+// Object literals.
+void f10() {
+ struct f10_s0 {
+ char iv0[10];
+ } x;
+
+ x = (struct f10_s0) { .iv0 = "name" };
+}
+
+// Nested structures.
+struct s11 {
+ struct s11_2 {
+ int f0;
+ } f0;
+ int f1;
+};
diff --git a/clang/test/Coverage/codegen-gnu.m b/clang/test/Coverage/codegen-gnu.m
new file mode 100644
index 0000000..432637c
--- /dev/null
+++ b/clang/test/Coverage/codegen-gnu.m
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-exceptions -fgnu-runtime -emit-llvm -o %t %s
+
+#include "objc-language-features.inc"
diff --git a/clang/test/Coverage/codegen-next.m b/clang/test/Coverage/codegen-next.m
new file mode 100644
index 0000000..8f6645d
--- /dev/null
+++ b/clang/test/Coverage/codegen-next.m
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-llvm -fobjc-exceptions -o %t %s
+// RUN: %clang_cc1 -g -emit-llvm -fobjc-exceptions -o %t %s
+
+#include "objc-language-features.inc"
diff --git a/clang/test/Coverage/codegen.c b/clang/test/Coverage/codegen.c
new file mode 100644
index 0000000..8e5195c
--- /dev/null
+++ b/clang/test/Coverage/codegen.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o %t %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm-bc -o %t %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown -g -emit-llvm-bc -o %t %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm-bc -o %t %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -g -emit-llvm-bc -o %t %s
+
+#include "c-language-features.inc"
diff --git a/clang/test/Coverage/cxx-language-features.inc b/clang/test/Coverage/cxx-language-features.inc
new file mode 100644
index 0000000..31b50be
--- /dev/null
+++ b/clang/test/Coverage/cxx-language-features.inc
@@ -0,0 +1,27 @@
+//-*- 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 { };
+
+/* Template classes, template functions */
+enum E1 { EC1 };
+template <E1 v> class C1 {};
+template <E1 v> C1<v> f1() { return C1<v>(); }
+void f2() { f1<EC1>(); }
diff --git a/clang/test/Coverage/html-diagnostics.c b/clang/test/Coverage/html-diagnostics.c
new file mode 100644
index 0000000..4f1b0e3
--- /dev/null
+++ b/clang/test/Coverage/html-diagnostics.c
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %t %s
+// RUN: cat %t/*.html | FileCheck %s
+
+// CHECK: <h3>Annotated Source Code</h3>
+
+// Without tweaking expr, the expr would hit to the line below
+// emitted to the output as comment.
+// CHECK: {{[D]ereference of null pointer}}
+
+void f0(int x) {
+ int *p = &x;
+
+ if (x > 10) {
+ if (x == 22)
+ p = 0;
+ }
+
+ *p = 10;
+}
+
+
diff --git a/clang/test/Coverage/html-print.c b/clang/test/Coverage/html-print.c
new file mode 100644
index 0000000..a3f29c6
--- /dev/null
+++ b/clang/test/Coverage/html-print.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -emit-html -o %t %s
+
+#include "c-language-features.inc"
diff --git a/clang/test/Coverage/objc-language-features.inc b/clang/test/Coverage/objc-language-features.inc
new file mode 100644
index 0000000..dbbf205
--- /dev/null
+++ b/clang/test/Coverage/objc-language-features.inc
@@ -0,0 +1,87 @@
+//-*- ObjC -*-
+
+@protocol P0;
+
+@protocol P1
+-(void) fm0;
+@end
+
+@class B;
+
+@interface Root
+@end
+
+@interface A : Root <P1> {
+ int iv0;
+ B *iv1;
+ B<P1> *iv2;
+}
+
+@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;
+@property(assign, readwrite) id p5;
+@end
+
+@implementation A
+@dynamic p0;
+@synthesize p1 = iv0;
+
+// Property type can differ from ivar type.
+@synthesize p5 = iv2;
+
++(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/clang/test/Coverage/targets.c b/clang/test/Coverage/targets.c
new file mode 100644
index 0000000..7c05122
--- /dev/null
+++ b/clang/test/Coverage/targets.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -g -triple armv6-apple-darwin9 -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple armv6-unknown-unknown -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple i686-apple-darwin9 -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple i686-pc-linux-gnu -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple i686-unknown-dragonfly -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple i686-unknown-unknown -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple i686-unknown-win32 -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple powerpc-apple-darwin9 -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple powerpc-unknown-unknown -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple powerpc64-apple-darwin9 -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple powerpc64-unknown-unknown -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple sparc-unknown-solaris -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple sparc-unknown-unknown -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple x86_64-apple-darwin9 -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple x86_64-pc-linux-gnu -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple x86_64-unknown-unknown -emit-llvm -o %t %s
+
+// <rdar://problem/7181838> clang 1.0 fails to compile Python 2.6
+// RUN: %clang -target x86_64-apple-darwin9 -### -S %s -mmacosx-version-min=10.4
+
diff --git a/clang/test/Coverage/verbose.c b/clang/test/Coverage/verbose.c
new file mode 100644
index 0000000..72451d4
--- /dev/null
+++ b/clang/test/Coverage/verbose.c
@@ -0,0 +1 @@
+// RUN: %clang_cc1 -fsyntax-only -v %s