]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Add separate counter "called for preprocessing"
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 3 Apr 2011 12:42:33 +0000 (14:42 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 3 Apr 2011 12:42:33 +0000 (14:42 +0200)
ccache.c
ccache.h
stats.c
test.sh
test/test_argument_processing.c

index eabed134cd44db5a0d35ae5266fa6741f5720944..8a036805ee98633bfd8fefd269458fbea689b91d 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -1239,6 +1239,13 @@ cc_process_args(struct args *orig_args, struct args **preprocessor_args,
                        continue;
                }
 
+               /* Special case for -E. */
+               if (str_eq(argv[i], "-E")) {
+                       stats_update(STATS_PREPROCESSING);
+                       result = false;
+                       goto out;
+               }
+
                /* These are always too hard. */
                if (compopt_too_hard(argv[i])
                    || str_startswith(argv[i], "@")
index 1620b78f2ae92b4ff5ba1db1e12b08611aac18a9..c2536f5cc4b26f60b302d66373f34c348d0e8956 100644 (file)
--- a/ccache.h
+++ b/ccache.h
@@ -47,6 +47,7 @@ enum stats {
        STATS_BADEXTRAFILE = 25,
        STATS_COMPCHECK = 26,
        STATS_CANTUSEPCH = 27,
+       STATS_PREPROCESSING = 28,
 
        STATS_END
 };
diff --git a/stats.c b/stats.c
index e458cb103ddd3b6df110b0f943df3fad90801ac9..29dcf5e71ae7789d2ee7e0f4c75746725a43fa97 100644 (file)
--- a/stats.c
+++ b/stats.c
@@ -60,6 +60,7 @@ static struct {
        { STATS_CACHEHIT_CPP, "cache hit (preprocessed)       ", NULL, FLAG_ALWAYS },
        { STATS_TOCACHE,      "cache miss                     ", NULL, FLAG_ALWAYS },
        { STATS_LINK,         "called for link                ", NULL, 0 },
+       { STATS_PREPROCESSING, "called for preprocessing      ", NULL, 0 },
        { STATS_MULTIPLE,     "multiple source files          ", NULL, 0 },
        { STATS_STDOUT,       "compiler produced stdout       ", NULL, 0 },
        { STATS_NOOUTPUT,     "compiler produced no output    ", NULL, 0 },
diff --git a/test.sh b/test.sh
index 7bdf39bc3b7bf2b7db141f52c9f0af33aadb8e1b..aaa2dcbcd64ad7118ed8c09a95d5abc2236c21dc 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -176,6 +176,10 @@ base_tests() {
     $CCACHE_COMPILE foo.o -o test 2> /dev/null
     checkstat 'called for link' 2
 
+    testname="preprocessing"
+    $CCACHE_COMPILE -E -c test1.c > /dev/null 2>&1
+    checkstat 'called for preprocessing' 1
+
     testname="multiple"
     $CCACHE_COMPILE -c test1.c test2.c
     checkstat 'multiple source files' 1
index 7408c4aebeb26b65092232b097c1e4047ffc34b7..df8f9207c78e2498875f8b7f7de1dd1c198fabc5 100644 (file)
 
 TEST_SUITE(argument_processing)
 
-TEST(dash_E_should_be_unsupported)
+TEST(dash_E_should_result_in_called_for_preprocessing)
 {
        struct args *orig = args_init_from_string("cc -c foo.c -E");
        struct args *preprocessed, *compiler;
 
+       create_file("foo.c", "");
+       CHECK(!cc_process_args(orig, &preprocessed, &compiler));
+       CHECK_UNS_EQ(1, stats_get_pending(STATS_PREPROCESSING));
+
+       args_free(orig);
+}
+
+TEST(dash_M_should_be_unsupported)
+{
+       struct args *orig = args_init_from_string("cc -c foo.c -M");
+       struct args *preprocessed, *compiler;
+
        create_file("foo.c", "");
        CHECK(!cc_process_args(orig, &preprocessed, &compiler));
        CHECK_UNS_EQ(1, stats_get_pending(STATS_UNSUPPORTED));