diff options
author | ed <ed@FreeBSD.org> | 2009-06-02 17:58:47 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2009-06-02 17:58:47 +0000 |
commit | f27e5a09a0d815b8a4814152954ff87dadfdefc0 (patch) | |
tree | ce7d964cbb5e39695b71481698f10cb099c23d4a /test/Driver | |
download | FreeBSD-src-f27e5a09a0d815b8a4814152954ff87dadfdefc0.zip FreeBSD-src-f27e5a09a0d815b8a4814152954ff87dadfdefc0.tar.gz |
Import Clang, at r72732.
Diffstat (limited to 'test/Driver')
-rw-r--r-- | test/Driver/Xarch.c | 10 | ||||
-rw-r--r-- | test/Driver/analyze.c | 9 | ||||
-rw-r--r-- | test/Driver/bindings.c | 56 | ||||
-rw-r--r-- | test/Driver/ccc-add-args.c | 3 | ||||
-rw-r--r-- | test/Driver/clang-translation.c | 16 | ||||
-rw-r--r-- | test/Driver/clang_cpp.c | 4 | ||||
-rw-r--r-- | test/Driver/clang_f_opts.c | 10 | ||||
-rw-r--r-- | test/Driver/darwin-cc.c | 6 | ||||
-rw-r--r-- | test/Driver/darwin-ld.c | 44 | ||||
-rw-r--r-- | test/Driver/darwin-version.c | 6 | ||||
-rw-r--r-- | test/Driver/dragonfly.c | 6 | ||||
-rw-r--r-- | test/Driver/emit-llvm.c | 3 | ||||
-rw-r--r-- | test/Driver/flags.c | 9 | ||||
-rw-r--r-- | test/Driver/freebsd.c | 7 | ||||
-rw-r--r-- | test/Driver/hello.c | 14 | ||||
-rw-r--r-- | test/Driver/immediate-options.c | 5 | ||||
-rw-r--r-- | test/Driver/lto.c | 25 | ||||
-rw-r--r-- | test/Driver/parsing.c | 24 | ||||
-rw-r--r-- | test/Driver/phases.c | 79 | ||||
-rw-r--r-- | test/Driver/preprocessor.c | 6 | ||||
-rw-r--r-- | test/Driver/pth.c | 8 | ||||
-rw-r--r-- | test/Driver/qa_override.c | 6 | ||||
-rw-r--r-- | test/Driver/std.c | 8 | ||||
-rw-r--r-- | test/Driver/unknown-gcc-arch.c | 8 | ||||
-rw-r--r-- | test/Driver/x86_features.c | 3 |
25 files changed, 375 insertions, 0 deletions
diff --git a/test/Driver/Xarch.c b/test/Driver/Xarch.c new file mode 100644 index 0000000..a2a3fde --- /dev/null +++ b/test/Driver/Xarch.c @@ -0,0 +1,10 @@ +// RUN: clang -ccc-host-triple i386-apple-darwin9 -m32 -Xarch_i386 -O2 %s -S -### 2> %t.log && +// RUN: grep ' "-O2" ' %t.log | count 1 && +// RUN: clang -ccc-host-triple i386-apple-darwin9 -m64 -Xarch_i386 -O2 %s -S -### 2> %t.log && +// RUN: grep ' "-O2" ' %t.log | count 0 && +// RUN: grep "argument unused during compilation: '-Xarch_i386 -O2'" %t.log && +// RUN: not clang -ccc-host-triple i386-apple-darwin9 -m32 -Xarch_i386 -o -Xarch_i386 -S %s -S -Xarch_i386 -o 2> %t.log && +// RUN: grep "error: invalid Xarch argument: '-Xarch_i386 -o'" %t.log | count 2 && +// RUN: grep "error: invalid Xarch argument: '-Xarch_i386 -S'" %t.log && +// RUN: true + diff --git a/test/Driver/analyze.c b/test/Driver/analyze.c new file mode 100644 index 0000000..338c614 --- /dev/null +++ b/test/Driver/analyze.c @@ -0,0 +1,9 @@ +// Verify that the analyzer gets the same flags as normal compilation +// (at least for a few key ones). + +// RUN: clang -ccc-host-triple i386-apple-darwin9 -### --analyze -o /dev/null %s -msse 2> %t.log && +// RUN: grep '"-analyze"' %t.log && +// RUN: grep '"--fmath-errno=0"' %t.log && +// RUN: grep '"-target-feature" "+sse"' %t.log && +// RUN: grep '"-mmacosx-version-min=10.5.0"' %t.log + diff --git a/test/Driver/bindings.c b/test/Driver/bindings.c new file mode 100644 index 0000000..3cac22c --- /dev/null +++ b/test/Driver/bindings.c @@ -0,0 +1,56 @@ +// Basic binding. +// RUN: clang -ccc-host-triple i386-unknown-unknown -ccc-print-bindings %s 2> %t && +// RUN: grep '"clang", inputs: \[".*bindings.c"\], output: ".*\.s"' %t && +// 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 %s 2> %t && +// RUN: grep '"gcc::Compile", inputs: \[".*bindings.c"\], output: ".*\.s"' %t && +// 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 %s 2> %t && +// RUN: grep '"gcc::Preprocess", inputs: \[".*bindings.c"\], output: ".*\.i"' %t && +// RUN: grep '"gcc::Compile", inputs: \[".*\.i"\], output: ".*\.s"' %t && +// 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 && + +// Clang control options + +// RUN: clang -ccc-host-triple i386-unknown-unknown -ccc-print-bindings -fsyntax-only %s 2> %t && +// RUN: grep '"clang", inputs: \[".*bindings.c"\], output: (nothing)' %t && +// RUN: clang -ccc-host-triple i386-unknown-unknown -ccc-print-bindings -ccc-no-clang -fsyntax-only %s 2> %t && +// RUN: grep '"gcc::Compile", inputs: \[".*bindings.c"\], output: (nothing)' %t && +// RUN: clang -ccc-host-triple i386-unknown-unknown -ccc-print-bindings -fsyntax-only -x c++ %s 2> %t && +// RUN: grep '"gcc::Compile", inputs: \[".*bindings.c"\], output: (nothing)' %t && +// RUN: clang -ccc-host-triple i386-unknown-unknown -ccc-print-bindings -ccc-clang-cxx -fsyntax-only -x c++ %s 2> %t && +// RUN: grep '"clang", inputs: \[".*bindings.c"\], output: (nothing)' %t && +// RUN: clang -ccc-host-triple i386-unknown-unknown -ccc-print-bindings -ccc-no-clang-cpp -fsyntax-only -no-integrated-cpp %s 2> %t && +// RUN: grep '"gcc::Preprocess", inputs: \[".*bindings.c"\], output: ".*\.i"' %t && +// RUN: grep '"clang", inputs: \[".*\.i"\], output: (nothing)' %t && +// RUN: clang -ccc-host-triple i386-apple-darwin9 -ccc-print-bindings -ccc-clang-archs i386 %s -S -arch ppc 2> %t && +// RUN: grep '"gcc::Compile", inputs: \[".*bindings.c"\], output: "bindings.s"' %t && +// RUN: clang -ccc-host-triple i386-apple-darwin9 -ccc-print-bindings -ccc-clang-archs ppc %s -S -arch ppc 2> %t && +// RUN: grep '"clang", inputs: \[".*bindings.c"\], output: "bindings.s"' %t && + +// RUN: clang -ccc-host-triple powerpc-unknown-unknown -ccc-print-bindings -ccc-clang-archs "" %s -S 2> %t && +// RUN: grep '"clang", inputs: \[".*bindings.c"\], output: "bindings.s"' %t && +// RUN: clang -ccc-host-triple powerpc-unknown-unknown -ccc-print-bindings %s -S 2> %t && +// RUN: grep '"gcc::Compile", inputs: \[".*bindings.c"\], output: "bindings.s"' %t && + +// Darwin bindings +// RUN: clang -ccc-host-triple i386-apple-darwin9 -ccc-print-bindings %s 2> %t && +// RUN: grep '"clang", inputs: \[".*bindings.c"\], output: ".*\.s"' %t && +// RUN: grep '"darwin::Assemble", inputs: \[".*\.s"\], output: ".*\.o"' %t && +// RUN: grep '"darwin::Link", inputs: \[".*\.o"\], output: "a.out"' %t && + +// RUN: true diff --git a/test/Driver/ccc-add-args.c b/test/Driver/ccc-add-args.c new file mode 100644 index 0000000..b504b0b4 --- /dev/null +++ b/test/Driver/ccc-add-args.c @@ -0,0 +1,3 @@ +// RUN: env CCC_ADD_ARGS="-ccc-echo,-ccc-print-options,,-v" clang -### 2> %t && +// RUN: grep -F 'Option 0 - Name: "-v", Values: {}' %t && +// RUN: grep -F 'Option 1 - Name: "-###", Values: {}' %t diff --git a/test/Driver/clang-translation.c b/test/Driver/clang-translation.c new file mode 100644 index 0000000..ca60a8d --- /dev/null +++ b/test/Driver/clang-translation.c @@ -0,0 +1,16 @@ +// RUN: clang -ccc-host-triple i386-unknown-unknown -### -S -O0 -Os %s -o %t.s -fverbose-asm 2> %t.log +// RUN: grep '"-triple" "i386-unknown-unknown"' %t.log && +// RUN: grep '"-S"' %t.log && +// RUN: grep '"-disable-free"' %t.log && +// RUN: grep '"--relocation-model" "static"' %t.log && +// RUN: grep '"--disable-fp-elim"' %t.log && +// RUN: grep '"--unwind-tables=0"' %t.log && +// RUN: grep '"--fmath-errno=1"' %t.log && +// RUN: grep '"-Os"' %t.log && +// RUN: grep '"-o" .*clang-translation\.c\.out\.tmp\.s' %t.log && +// RUN: grep '"--asm-verbose"' %t.log && +// RUN: clang -ccc-host-triple i386-apple-darwin9 -### -S %s -o %t.s 2> %t.log +// RUN: grep '"--mcpu=yonah"' %t.log && +// RUN: clang -ccc-host-triple x86_64-apple-darwin9 -### -S %s -o %t.s 2> %t.log +// RUN: grep '"--mcpu=core2"' %t.log && +// RUN: true diff --git a/test/Driver/clang_cpp.c b/test/Driver/clang_cpp.c new file mode 100644 index 0000000..fdbb321 --- /dev/null +++ b/test/Driver/clang_cpp.c @@ -0,0 +1,4 @@ +// Verify that -include isn't included twice with -save-temps. +// RUN: clang -S -o - %s -include %t.h -save-temps -### 2> %t.log && +// RUN: grep '"-include' %t.log | count 1 + diff --git a/test/Driver/clang_f_opts.c b/test/Driver/clang_f_opts.c new file mode 100644 index 0000000..9dc8f63 --- /dev/null +++ b/test/Driver/clang_f_opts.c @@ -0,0 +1,10 @@ +// RUN: clang -### -S -x c /dev/null -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fno-math-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings %s 2> %t && +// RUN: grep -F '"-fblocks"' %t && +// RUN: grep -F '"--fmath-errno=1"' %t && +// RUN: grep -F '"-fpascal-strings"' %t && +// RUN: clang -### -S -x c /dev/null -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fno-math-errno -fno-common -fno-pascal-strings %s 2> %t && +// RUN: grep -F '"-fblocks=0"' %t && +// RUN: grep -F '"-fbuiltin=0"' %t && +// RUN: grep -F '"-fno-common"' %t && +// RUN: grep -F '"--fmath-errno=0"' %t && +// RUN: true diff --git a/test/Driver/darwin-cc.c b/test/Driver/darwin-cc.c new file mode 100644 index 0000000..77193cd --- /dev/null +++ b/test/Driver/darwin-cc.c @@ -0,0 +1,6 @@ +// 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" "-F" "ARG1" "-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: true + diff --git a/test/Driver/darwin-ld.c b/test/Driver/darwin-ld.c new file mode 100644 index 0000000..5ac5ae3 --- /dev/null +++ b/test/Driver/darwin-ld.c @@ -0,0 +1,44 @@ +// Check that ld gets arch_multiple. + +// 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 && +// RUN: clang -ccc-host-triple i386-apple-darwin9 -### -g -filelist FOO %s -o BAR 2> %t.log && +// RUN: grep '".*dsymutil" "BAR"' %t.log && + +// Splatter test case. This is gross, but it works for now. For the +// driver, just getting coverage of the tool code and checking the +// output options is nearly good enough. The main thing we are +// protecting against here is unintended changes in the driver +// output. Intended changes should add more reasonable test cases, and +// just update this test to match the expected behavior. +// +// Note that at conception, this exactly matches gcc. + +// RUN: clang -ccc-host-triple i386-apple-darwin9 -### -A ARG0 -F ARG1 -L ARG2 -Mach -T ARG4 -X -Z -all_load -allowable_client ARG8 -bind_at_load -compatibility_version ARG11 -current_version ARG12 -d -dead_strip -dylib_file ARG14 -dylinker -dylinker_install_name ARG16 -dynamic -dynamiclib -e ARG19 -exported_symbols_list ARG20 -fexceptions -flat_namespace -fnested-functions -fopenmp -force_cpusubtype_ALL -fpie -fprofile-arcs -headerpad_max_install_names -image_base ARG29 -init ARG30 -install_name ARG31 -m ARG33 -miphoneos-version-min=2.0 -mmacosx-version-min=10.3.2 -multi_module -multiply_defined ARG37 -multiply_defined_unused ARG38 -no_dead_strip_inits_and_terms -nodefaultlibs -nofixprebinding -nomultidefs -noprebind -noseglinkedit -nostartfiles -nostdlib -object -pagezero_size ARG54 -pg -prebind -prebind_all_twolevel_modules -preload -r -read_only_relocs ARG55 -s -sectalign ARG57_0 ARG57_1 ARG57_2 -sectcreate ARG58_0 ARG58_1 ARG58_2 -sectobjectsymbols ARG59_0 ARG59_1 -sectorder ARG60_0 ARG60_1 ARG60_2 -seg1addr ARG61 -seg_addr_table ARG62 -seg_addr_table_filename ARG63 -segaddr ARG64_0 ARG64_1 -segcreate ARG65_0 ARG65_1 ARG65_2 -seglinkedit -segprot ARG67_0 ARG67_1 ARG67_2 -segs_read_FOO -segs_read_only_addr ARG69 -segs_read_write_addr ARG70 -shared-libgcc -single_module -static -static-libgcc -sub_library ARG77 -sub_umbrella ARG78 -t -twolevel_namespace -twolevel_namespace_hints -u ARG82 -umbrella ARG83 -undefined ARG84 -unexported_symbols_list ARG85 -w -weak_reference_mismatches ARG87 -whatsloaded -whyload -y -filelist FOO 2> %t.log && +// RUN: grep '".*ld" "-static" "-dylib" "-dylib_compatibility_version" "ARG11" "-dylib_current_version" "ARG12" "-arch" "i386" "-dylib_install_name" "ARG31" "-all_load" "-allowable_client" "ARG8" "-bind_at_load" "-dead_strip" "-no_dead_strip_inits_and_terms" "-dylib_file" "ARG14" "-dynamic" "-exported_symbols_list" "ARG20" "-flat_namespace" "-headerpad_max_install_names" "-image_base" "ARG29" "-init" "ARG30" "-macosx_version_min" "10.3.2" "-iphoneos_version_min" "2.0" "-nomultidefs" "-multi_module" "-single_module" "-multiply_defined" "ARG37" "-multiply_defined_unused" "ARG38" "-pie" "-prebind" "-noprebind" "-nofixprebinding" "-prebind_all_twolevel_modules" "-read_only_relocs" "ARG55" "-sectcreate" "ARG58_0" "ARG58_1" "ARG58_2" "-sectorder" "ARG60_0" "ARG60_1" "ARG60_2" "-seg1addr" "ARG61" "-segprot" "ARG67_0" "ARG67_1" "ARG67_2" "-segaddr" "ARG64_0" "ARG64_1" "-segs_read_only_addr" "ARG69" "-segs_read_write_addr" "ARG70" "-seg_addr_table" "ARG62" "-seg_addr_table_filename" "ARG63" "-sub_library" "ARG77" "-sub_umbrella" "ARG78" "-twolevel_namespace" "-twolevel_namespace_hints" "-umbrella" "ARG83" "-undefined" "ARG84" "-unexported_symbols_list" "ARG85" "-weak_reference_mismatches" "ARG87" "-X" "-y" "-w" "-pagezero_size" "ARG54" "-segs_read_FOO" "-seglinkedit" "-noseglinkedit" "-sectalign" "ARG57_0" "ARG57_1" "ARG57_2" "-sectobjectsymbols" "ARG59_0" "ARG59_1" "-segcreate" "ARG65_0" "ARG65_1" "ARG65_2" "-whyload" "-whatsloaded" "-dylinker_install_name" "ARG16" "-dylinker" "-Mach" "-d" "-s" "-t" "-Z" "-u" "ARG82" "-undefined" "ARG84" "-A" "ARG0" "-e" "ARG19" "-m" "ARG33" "-r" "-object" "-o" "a.out" "-L" "ARG2" "-lgomp" "-L/usr/lib/i686-apple-darwin9/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin9/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin9/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin9/4.2.1/../../../i686-apple-darwin9/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin9/4.2.1/../../.." "-filelist" "FOO" "-lgcov" "-allow_stack_execute" "-T" "ARG4" "-F" "ARG1"' %t.log && + +// Don't run dsymutil on a fat build of an executable. +// RUN: clang -ccc-host-triple i386-apple-darwin9 -### -arch i386 -arch x86_64 -g %s 2> %t.log && +// RUN: grep dsymutil %t.log | count 0 && + +// RUN: true + + diff --git a/test/Driver/darwin-version.c b/test/Driver/darwin-version.c new file mode 100644 index 0000000..dd6905a --- /dev/null +++ b/test/Driver/darwin-version.c @@ -0,0 +1,6 @@ +// RUN: env MACOSX_DEPLOYMENT_TARGET=10.1 clang -ccc-host-triple i386-apple-darwin9 -E %s + +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1010 +#error Invalid version +#endif + diff --git a/test/Driver/dragonfly.c b/test/Driver/dragonfly.c new file mode 100644 index 0000000..5d7b0b0 --- /dev/null +++ b/test/Driver/dragonfly.c @@ -0,0 +1,6 @@ +// RUN: clang -ccc-host-triple amd64-pc-dragonfly %s -### 2> %t.log && +// RUN: grep 'clang-cc" "-triple" "x86_64-pc-dragonfly"' %t.log && +// RUN: grep 'as" "-o" ".*\.o" ".*\.s' %t.log && +// RUN: grep 'ld" "-dynamic-linker" ".*ld-elf.*" "-o" "a\.out" ".*crt1.o" ".*crti.o" "crtbegin.o" ".*\.o" "-L.*/gcc.*" .* "-lc" "-lgcc" ".*crtend.o" ".*crtn.o"' %t.log && +// RUN: true + diff --git a/test/Driver/emit-llvm.c b/test/Driver/emit-llvm.c new file mode 100644 index 0000000..a4aabe7 --- /dev/null +++ b/test/Driver/emit-llvm.c @@ -0,0 +1,3 @@ +// RUN: not clang -ccc-host-triple i386-pc-linux-gnu -emit-llvm -o %t %s 2> %t.log && +// RUN: grep 'unable to pass LLVM bit-code files to linker' %t.log + diff --git a/test/Driver/flags.c b/test/Driver/flags.c new file mode 100644 index 0000000..53f3995 --- /dev/null +++ b/test/Driver/flags.c @@ -0,0 +1,9 @@ +// RUN: clang -ccc-host-triple i386-apple-darwin9 -### -S -msoft-float %s 2> %t.log && +// RUN: grep '"--soft-float"' %t.log && + +// RUN: clang -ccc-host-triple i386-apple-darwin9 -### -S -msoft-float -mno-soft-float %s 2> %t.log && +// RUN: grep '"--soft-float"' %t.log | count 0 && + +// RUN: clang -ccc-host-triple i386-apple-darwin9 -### -S -mno-soft-float %s -msoft-float 2> %t.log && +// RUN: grep '"--soft-float"' %t.log + diff --git a/test/Driver/freebsd.c b/test/Driver/freebsd.c new file mode 100644 index 0000000..91258d9 --- /dev/null +++ b/test/Driver/freebsd.c @@ -0,0 +1,7 @@ +// RUN: clang -ccc-clang-archs "" -ccc-host-triple ppc64-pc-freebsd8 %s -### 2> %t.log && +// RUN: cat %t.log && +// RUN: grep 'clang-cc" "-triple" "powerpc64-pc-freebsd8"' %t.log && +// RUN: grep 'as" "-o" ".*\.o" ".*\.s' %t.log && +// RUN: grep '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"' %t.log && +// RUN: true + diff --git a/test/Driver/hello.c b/test/Driver/hello.c new file mode 100644 index 0000000..7dbe9c7 --- /dev/null +++ b/test/Driver/hello.c @@ -0,0 +1,14 @@ +// RUN: clang -ccc-echo -o %t %s 2> %t.log && + +// Make sure we used clang. +// RUN: grep 'clang-cc" .*hello.c' %t.log && + +// RUN: %t > %t.out && +// RUN: grep "I'm a little driver, short and stout." %t.out + +#include <stdio.h> + +int main() { + printf("I'm a little driver, short and stout."); + return 0; +} diff --git a/test/Driver/immediate-options.c b/test/Driver/immediate-options.c new file mode 100644 index 0000000..34af89f --- /dev/null +++ b/test/Driver/immediate-options.c @@ -0,0 +1,5 @@ +// RUN: clang --help && +// RUN: clang --help-hidden && +// RUN: clang -dumpversion && +// RUN: clang -print-search-dirs && +// RUN: true diff --git a/test/Driver/lto.c b/test/Driver/lto.c new file mode 100644 index 0000000..01ef2eb --- /dev/null +++ b/test/Driver/lto.c @@ -0,0 +1,25 @@ +// -emit-llvm, -flto, and -O4 all cause a switch to llvm-bc object +// files. +// RUN: clang -ccc-print-phases -c %s -flto 2> %t.log && +// RUN: grep '2: compiler, {1}, llvm-bc' %t.log && +// RUN: clang -ccc-print-phases -c %s -O4 2> %t.log && +// RUN: grep '2: compiler, {1}, llvm-bc' %t.log && + +// and -emit-llvm doesn't alter pipeline (unfortunately?). +// RUN: clang -ccc-print-phases %s -emit-llvm 2> %t.log && +// RUN: grep '0: input, ".*lto.c", c' %t.log && +// RUN: grep '1: preprocessor, {0}, cpp-output' %t.log && +// RUN: grep '2: compiler, {1}, llvm-bc' %t.log && +// RUN: grep '3: linker, {2}, image' %t.log && + +// llvm-bc and llvm-ll outputs need to match regular suffixes +// (unfortunately). +// RUN: clang %s -emit-llvm -save-temps -### 2> %t.log && +// RUN: grep '"-o" ".*lto\.i" "-x" "c" ".*lto\.c"' %t.log && +// RUN: grep '"-o" ".*lto\.o" .*".*lto\.i"' %t.log && +// RUN: grep '".*a.out" .*".*lto\.o"' %t.log && + +// RUN: clang %s -emit-llvm -S -### 2> %t.log && +// RUN: grep '"-o" ".*lto\.s" "-x" "c" ".*lto\.c"' %t.log && + +// RUN: true diff --git a/test/Driver/parsing.c b/test/Driver/parsing.c new file mode 100644 index 0000000..7b64440 --- /dev/null +++ b/test/Driver/parsing.c @@ -0,0 +1,24 @@ +// RUN: clang -ccc-print-options input -Yunknown -m32 -arch ppc -djoined -A separate -Ajoined -Wp,one,two -Xarch_joined AndSeparate -sectalign 1 2 3 2> %t && +// RUN: grep 'Option 0 - Name: "<input>", Values: {"input"}' %t && +// RUN: grep 'Option 1 - Name: "<unknown>", Values: {"-Yunknown"}' %t && +// RUN: grep 'Option 2 - Name: "-m32", Values: {}' %t && +// RUN: grep 'Option 3 - Name: "-arch", Values: {"ppc"}' %t && +// RUN: grep 'Option 4 - Name: "-d", Values: {"joined"}' %t && +// RUN: grep 'Option 5 - Name: "-A", Values: {"separate"}' %t && +// RUN: grep 'Option 6 - Name: "-A", Values: {"joined"}' %t && +// RUN: grep 'Option 7 - Name: "-Wp,", Values: {"one", "two"}' %t && +// RUN: grep 'Option 8 - Name: "-Xarch_", Values: {"joined", "AndSeparate"}' %t && +// RUN: grep 'Option 9 - Name: "-sectalign", Values: {"1", "2", "3"}' %t && + +// RUN: not clang -V 2> %t && +// RUN: grep "error: argument to '-V' is missing (expected 1 value)" %t && +// RUN: not clang -sectalign 1 2 2> %t && +// RUN: grep "error: argument to '-sectalign' is missing (expected 3 values)" %t && + +// Verify that search continues after find the first option. +// RUN: clang -ccc-print-options -Wally 2> %t && +// RUN: grep 'Option 0 - Name: "-W", Values: {"ally"}' %t && + +// RUN: true + + diff --git a/test/Driver/phases.c b/test/Driver/phases.c new file mode 100644 index 0000000..0967d33 --- /dev/null +++ b/test/Driver/phases.c @@ -0,0 +1,79 @@ +// Basic compilation for various types of files. +// RUN: clang -ccc-host-triple i386-unknown-unknown -ccc-print-phases -x c %s -x objective-c %s -x c++ %s -x objective-c++ -x assembler %s -x assembler-with-cpp %s -x none %s 2> %t && +// RUN: grep '0: input, ".*phases.c", c' %t && +// RUN: grep -F '1: preprocessor, {0}, cpp-output' %t && +// RUN: grep -F '2: compiler, {1}, assembler' %t && +// RUN: grep -F '3: assembler, {2}, object' %t && +// RUN: grep '4: input, ".*phases.c", objective-c' %t && +// RUN: grep -F '5: preprocessor, {4}, objective-c-cpp-output' %t && +// RUN: grep -F '6: compiler, {5}, assembler' %t && +// RUN: grep -F '7: assembler, {6}, object' %t && +// RUN: grep '8: input, ".*phases.c", c++' %t && +// RUN: grep -F '9: preprocessor, {8}, c++-cpp-output' %t && +// RUN: grep -F '10: compiler, {9}, assembler' %t && +// RUN: grep -F '11: assembler, {10}, object' %t && +// RUN: grep '12: input, ".*phases.c", assembler' %t && +// RUN: grep -F '13: assembler, {12}, object' %t && +// RUN: grep '14: input, ".*phases.c", assembler-with-cpp' %t && +// RUN: grep -F '15: preprocessor, {14}, assembler' %t && +// RUN: grep -F '16: assembler, {15}, object' %t && +// RUN: grep '17: input, ".*phases.c", c' %t && +// RUN: grep -F '18: preprocessor, {17}, cpp-output' %t && +// RUN: grep -F '19: compiler, {18}, assembler' %t && +// RUN: grep -F '20: assembler, {19}, object' %t && +// RUN: grep -F '21: linker, {3, 7, 11, 13, 16, 20}, image' %t && + +// Universal linked image. +// RUN: clang -ccc-host-triple i386-apple-darwin9 -ccc-print-phases -x c %s -arch ppc -arch i386 2> %t && +// RUN: grep '0: input, ".*phases.c", c' %t && +// RUN: grep -F '1: preprocessor, {0}, cpp-output' %t && +// RUN: grep -F '2: compiler, {1}, assembler' %t && +// RUN: grep -F '3: assembler, {2}, object' %t && +// RUN: grep -F '4: linker, {3}, image' %t && +// RUN: grep -F '5: bind-arch, "ppc", {4}, image' %t && +// RUN: grep -F '6: bind-arch, "i386", {4}, image' %t && +// RUN: grep -F '7: lipo, {5, 6}, image' %t && + +// Universal object file. +// RUN: clang -ccc-host-triple i386-apple-darwin9 -ccc-print-phases -c -x c %s -arch ppc -arch i386 2> %t && +// RUN: grep '0: input, ".*phases.c", c' %t && +// RUN: grep -F '1: preprocessor, {0}, cpp-output' %t && +// RUN: grep -F '2: compiler, {1}, assembler' %t && +// RUN: grep -F '3: assembler, {2}, object' %t && +// RUN: grep -F '4: bind-arch, "ppc", {3}, object' %t && +// RUN: grep -F '5: bind-arch, "i386", {3}, object' %t && +// RUN: grep -F '6: lipo, {4, 5}, object' %t && + +// Arch defaulting +// RUN: clang -ccc-host-triple i386-apple-darwin9 -ccc-print-phases -c -x assembler %s 2> %t && +// RUN: grep -F '2: bind-arch, "i386", {1}, object' %t && +// RUN: clang -ccc-host-triple i386-apple-darwin9 -ccc-print-phases -c -x assembler %s -m32 -m64 2> %t && +// RUN: grep -F '2: bind-arch, "x86_64", {1}, object' %t && +// RUN: clang -ccc-host-triple x86_64-apple-darwin9 -ccc-print-phases -c -x assembler %s 2> %t && +// RUN: grep -F '2: bind-arch, "x86_64", {1}, object' %t && +// RUN: clang -ccc-host-triple x86_64-apple-darwin9 -ccc-print-phases -c -x assembler %s -m64 -m32 2> %t && +// RUN: grep -F '2: bind-arch, "i386", {1}, object' %t && + +// Analyzer +// RUN: clang -ccc-host-triple i386-unknown-unknown -ccc-print-phases --analyze %s 2> %t && +// RUN: grep '0: input, ".*phases.c", c' %t && +// RUN: grep -F '1: preprocessor, {0}, cpp-output' %t && +// RUN: grep -F '2: analyzer, {1}, plist' %t && + +// Precompiler +// RUN: clang -ccc-host-triple i386-unknown-unknown -ccc-print-phases -x c-header %s 2> %t && +// RUN: grep '0: input, ".*phases.c", c-header' %t && +// RUN: grep -F '1: preprocessor, {0}, c-header-cpp-output' %t && +// RUN: grep -F '2: precompiler, {1}, precompiled-header' %t && + +// Darwin overrides the handling for .s +// RUN: touch %t.s && +// RUN: clang -ccc-host-triple i386-unknown-unknown -ccc-print-phases -c %t.s 2> %t && +// RUN: grep '0: input, ".*\.s", assembler' %t && +// RUN: grep -F '1: assembler, {0}, object' %t && +// RUN: clang -ccc-host-triple i386-apple-darwin9 -ccc-print-phases -c %t.s 2> %t && +// RUN: grep '0: input, ".*\.s", assembler-with-cpp' %t && +// RUN: grep -F '1: preprocessor, {0}, assembler' %t && +// RUN: grep -F '2: assembler, {1}, object' %t && + +// RUN: true diff --git a/test/Driver/preprocessor.c b/test/Driver/preprocessor.c new file mode 100644 index 0000000..ec1f42f --- /dev/null +++ b/test/Driver/preprocessor.c @@ -0,0 +1,6 @@ +// RUN: clang -E -x c-header %s > %t && +// RUN: grep 'B B' %t + +#define A B +A A + diff --git a/test/Driver/pth.c b/test/Driver/pth.c new file mode 100644 index 0000000..7480538 --- /dev/null +++ b/test/Driver/pth.c @@ -0,0 +1,8 @@ +// Test transparent PTH support. + +// RUN: clang -ccc-pch-is-pth -x c-header %s -o %t.h.pth -### 2> %t.log && +// RUN: grep '".*/clang-cc" .* "-o" ".*\.h\.pth" "-x" "c-header" ".*pth\.c"' %t.log && + +// RUN: touch %t.h.pth && +// RUN: clang -ccc-pch-is-pth -E -include %t.h %s -### 2> %t.log && +// RUN: grep '".*/clang-cc" .*"-include-pth" ".*\.h\.pth" .*"-x" "c" ".*pth\.c"' %t.log diff --git a/test/Driver/qa_override.c b/test/Driver/qa_override.c new file mode 100644 index 0000000..0ff578c --- /dev/null +++ b/test/Driver/qa_override.c @@ -0,0 +1,6 @@ +// RUN: env QA_OVERRIDE_GCC3_OPTIONS="+-Os +-Oz +-O +-O3 +-Oignore +a +b +c xb Xa Omagic ^-ccc-print-options " clang x -O2 b -O3 2> %t && +// RUN: grep -F 'Option 0 - Name: "<input>", Values: {"x"}' %t && +// RUN: grep -F 'Option 1 - Name: "-O", Values: {"ignore"}' %t && +// RUN: grep -F 'Option 2 - Name: "-O", Values: {"magic"}' %t && +// RUN: true + diff --git a/test/Driver/std.c b/test/Driver/std.c new file mode 100644 index 0000000..ef6d8f1 --- /dev/null +++ b/test/Driver/std.c @@ -0,0 +1,8 @@ +// RUN: clang -std=c99 -trigraphs -std=gnu99 %s -E -o %t && +// RUN: grep '??(??)' %t && +// RUN: clang -ansi %s -E -o %t && +// RUN: grep -F '[]' %t && +// RUN: clang -std=gnu99 -trigraphs %s -E -o %t && +// RUN: grep -F '[]' %t + +??(??) diff --git a/test/Driver/unknown-gcc-arch.c b/test/Driver/unknown-gcc-arch.c new file mode 100644 index 0000000..de9e8e8 --- /dev/null +++ b/test/Driver/unknown-gcc-arch.c @@ -0,0 +1,8 @@ +// RUN: clang -ccc-host-triple x86_64-unknown-unknown -c -x assembler %s -### 2> %t.log && +// RUN: grep '.*gcc.*"-m64"' %t.log && +// RUN: clang -ccc-host-triple x86_64-unknown-unknown -c -x assembler %s -### -m32 2> %t.log && +// RUN: grep '.*gcc.*"-m32"' %t.log && +// RUN: clang -ccc-host-triple i386-unknown-unknown -c -x assembler %s -### 2> %t.log && +// RUN: grep '.*gcc.*"-m32"' %t.log && +// RUN: clang -ccc-host-triple i386-unknown-unknown -c -x assembler %s -### -m64 2> %t.log && +// RUN: grep '.*gcc.*"-m64"' %t.log diff --git a/test/Driver/x86_features.c b/test/Driver/x86_features.c new file mode 100644 index 0000000..efb3681 --- /dev/null +++ b/test/Driver/x86_features.c @@ -0,0 +1,3 @@ +// RUN: clang -ccc-host-triple i386-unknown-unknown -### -S %s -msse -msse4 -mno-sse -mno-mmx -msse 2> %t && +// RUN: grep '"-target-feature" "+sse" "-target-feature" "+sse4" "-target-feature" "-sse" "-target-feature" "-mmx" "-target-feature" "+sse"' %t + |