Add separate counter "called for preprocessing"

This commit is contained in:
Joel Rosdahl 2011-04-03 14:42:33 +02:00
parent 08526533e1
commit e5d351036c
5 changed files with 26 additions and 1 deletions

View File

@ -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], "@")

View File

@ -47,6 +47,7 @@ enum stats {
STATS_BADEXTRAFILE = 25,
STATS_COMPCHECK = 26,
STATS_CANTUSEPCH = 27,
STATS_PREPROCESSING = 28,
STATS_END
};

View File

@ -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 },

View File

@ -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

View File

@ -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));