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], "@")
STATS_BADEXTRAFILE = 25,
STATS_COMPCHECK = 26,
STATS_CANTUSEPCH = 27,
+ STATS_PREPROCESSING = 28,
STATS_END
};
{ 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 },
$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
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));