| Douglas Gregor | 1d46a1f | 2009-04-26 03:52:11 +0000 | [diff] [blame^] | 1 | #!/usr/bin/perl -w |
| 2 | |
| 3 | # This tiny little script, which should be run from the clang |
| 4 | # directory (with clang-cc in your patch), tries to take each |
| 5 | # compilable Clang test and build a PCH file from that test, then read |
| 6 | # and dump the contents of the PCH file just created. |
| 7 | use POSIX; |
| 8 | |
| 9 | $exitcode = 0; |
| 10 | |
| 11 | sub testfiles($$) { |
| 12 | my $suffix = shift; |
| 13 | my $language = shift; |
| 14 | |
| 15 | @files = `ls test/*/*.$suffix`; |
| 16 | foreach $file (@files) { |
| 17 | chomp($file); |
| 18 | print("."); |
| 19 | my $code = system("clang-cc -fsyntax-only -x $language $file > /dev/null 2>&1"); |
| 20 | if ($code == 0) { |
| 21 | $code = system("clang-cc -emit-pch -x $language -o $file.pch $file > /dev/null 2>&1"); |
| 22 | if ($code == 0) { |
| 23 | $code = system("clang-cc -include-pch $file.pch -x $language -ast-dump-full /dev/null > /dev/null 2>&1"); |
| 24 | if ($code == 0) { |
| 25 | } elsif (($code & 0xFF) == SIGINT) { |
| 26 | exit($exitcode); |
| 27 | } else { |
| 28 | print("\n---Failed to dump AST file for \"$file\"---\n"); |
| 29 | $exitcode = 1; |
| 30 | } |
| 31 | unlink "$file.pch"; |
| 32 | } elsif (($code & 0xFF) == SIGINT) { |
| 33 | exit($exitcode); |
| 34 | } else { |
| 35 | print("\n---Failed to build PCH file for \"$file\"---\n"); |
| 36 | $exitcode = 1; |
| 37 | } |
| 38 | } elsif (($code & 0xFF) == SIGINT) { |
| 39 | exit($exitcode); |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | printf("-----Testing precompiled headers for C-----\n"); |
| 45 | testfiles("c", "c"); |
| 46 | printf("\n-----Testing precompiled headers for Objective-C-----\n"); |
| 47 | testfiles("m", "objective-c"); |
| 48 | print("\n"); |
| 49 | exit($exitcode); |