From e5d351036c331c137b3cce445321d2b4e01d0dc6 Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Sun, 3 Apr 2011 14:42:33 +0200 Subject: [PATCH] Add separate counter "called for preprocessing" --- ccache.c | 7 +++++++ ccache.h | 1 + stats.c | 1 + test.sh | 4 ++++ test/test_argument_processing.c | 14 +++++++++++++- 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ccache.c b/ccache.c index eabed13..8a03680 100644 --- 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], "@") diff --git a/ccache.h b/ccache.h index 1620b78..c2536f5 100644 --- 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 e458cb1..29dcf5e 100644 --- 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 7bdf39b..aaa2dcb 100755 --- 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 diff --git a/test/test_argument_processing.c b/test/test_argument_processing.c index 7408c4a..df8f920 100644 --- a/test/test_argument_processing.c +++ b/test/test_argument_processing.c @@ -26,11 +26,23 @@ 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));