[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / utils / TestUtils / pch-test.pl
blobcff8255b85a3d119e94e1ede07a2beb67e6977b4
1 #!/usr/bin/env perl
3 # This tiny little script, which should be run from the clang
4 # directory (with clang 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 use warnings;
10 $exitcode = 0;
11 sub testfiles($$) {
12 my $suffix = shift;
13 my $language = shift;
14 my $passed = 0;
15 my $failed = 0;
16 my $skipped = 0;
18 @files = `ls test/*/*.$suffix`;
19 foreach $file (@files) {
20 chomp($file);
21 my $code = system("clang -fsyntax-only -x $language $file > /dev/null 2>&1");
22 if ($code == 0) {
23 print(".");
24 $code = system("clang -cc1 -emit-pch -x $language -o $file.pch $file > /dev/null 2>&1");
25 if ($code == 0) {
26 $code = system("clang -cc1 -include-pch $file.pch -x $language -ast-dump /dev/null > /dev/null 2>&1");
27 if ($code == 0) {
28 $passed++;
29 } elsif (($code & 0xFF) == SIGINT) {
30 exit($exitcode);
31 } else {
32 print("\n---Failed to dump AST file for \"$file\"---\n");
33 $exitcode = 1;
34 $failed++;
36 unlink "$file.pch";
37 } elsif (($code & 0xFF) == SIGINT) {
38 exit($exitcode);
39 } else {
40 print("\n---Failed to build PCH file for \"$file\"---\n");
41 $exitcode = 1;
42 $failed++;
44 } elsif (($code & 0xFF) == SIGINT) {
45 exit($exitcode);
46 } else {
47 print("x");
48 $skipped++;
52 print("\n\n$passed tests passed\n");
53 print("$failed tests failed\n");
54 print("$skipped tests skipped ('x')\n")
57 printf("-----Testing precompiled headers for C-----\n");
58 testfiles("c", "c");
59 printf("\n-----Testing precompiled headers for Objective-C-----\n");
60 testfiles("m", "objective-c");
61 print("\n");
62 exit($exitcode);