Skip to content

Commit 28edff3

Browse files
committed
wip
1 parent 807ba74 commit 28edff3

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

src/ccache/argprocessing.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ process_option_arg(const Context& ctx,
386386
size_t& args_index,
387387
ArgumentProcessingState& state)
388388
{
389+
PRINT(stderr, "XXX: process_option_arg {}\n", args[args_index]);
389390
size_t& i = args_index;
390391

391392
if (option_should_be_ignored(args[i], ctx.ignore_options())) {
@@ -438,6 +439,9 @@ process_option_arg(const Context& ctx,
438439
if (argpath[-1] == '-') {
439440
++argpath;
440441
}
442+
PRINT(stderr,
443+
"XXX: config.response_file_format() = {}\n",
444+
int(config.response_file_format()));
441445
auto file_args =
442446
util::Args::from_response_file(argpath, config.response_file_format());
443447
if (!file_args) {
@@ -642,6 +646,7 @@ process_option_arg(const Context& ctx,
642646
if (arg.length() > 3 && arg.starts_with("-T")
643647
&& (arg[2] == 'c' || arg[2] == 'p')) {
644648
args_info.input_file_prefix = arg.substr(0, 3);
649+
PRINT(stderr, "XXX: input file {}\n", arg.substr(3));
645650
state.input_files.emplace_back(arg.substr(3));
646651
return Statistic::none;
647652
}
@@ -1412,6 +1417,10 @@ process_arg(const Context& ctx,
14121417
process_option_arg(ctx, args_info, config, args, args_index, state);
14131418

14141419
if (statistic && *statistic != Statistic::none) {
1420+
PRINT(stderr,
1421+
"XXX: returning error {} for {}\n",
1422+
int(*statistic),
1423+
args[args_index]);
14151424
return *statistic; // error found
14161425
}
14171426

@@ -1420,9 +1429,14 @@ process_arg(const Context& ctx,
14201429
LOG("Creating PCH with MSVC, disabling base directory");
14211430
config.set_base_dirs({});
14221431
restart = true;
1432+
PRINT(stderr, "XXX: found /Yc, restarting\n");
14231433
}
14241434

14251435
if (statistic) {
1436+
PRINT(stderr,
1437+
"XXX: returning non-error {} for {}\n",
1438+
int(*statistic),
1439+
args[args_index]);
14261440
return *statistic; // processed option without error
14271441
}
14281442

@@ -1435,6 +1449,9 @@ process_arg(const Context& ctx,
14351449
// file when code is testing compiler flags.
14361450
if (!util::is_dev_null_path(args[i])) {
14371451
if (!DirEntry(args[i]).is_regular_file()) {
1452+
PRINT(stderr,
1453+
"XXX: {} is not a regular file, not considering as input file\n",
1454+
args[i]);
14381455
LOG("{} is not a regular file, not considering as input file", args[i]);
14391456
state.add_common_arg(args[i]);
14401457
return Statistic::none;
@@ -1443,8 +1460,10 @@ process_arg(const Context& ctx,
14431460

14441461
if (fs::exists(args[i])) {
14451462
LOG("Detected input file: {}", args[i]);
1463+
PRINT(stderr, "XXX: input file {}\n", args[i]);
14461464
state.input_files.emplace_back(args[i]);
14471465
} else {
1466+
PRINT(stderr, "XXX: input file {} does not exist\n", args[i]);
14481467
LOG("Not considering {} an input file since it doesn't exist", args[i]);
14491468
state.add_common_arg(args[i]);
14501469
}
@@ -1515,6 +1534,7 @@ process_args(Context& ctx)
15151534

15161535
if (state.input_files.empty()) {
15171536
LOG("No input file found");
1537+
PRINT(stderr, "XXX: state.input_files.empty()\n");
15181538
return tl::unexpected(Statistic::no_input_file);
15191539
}
15201540
if (state.input_files.size() > 1) {

unittest/test_argprocessing.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,15 +786,21 @@ TEST_CASE("MSVC /Yc in response file disables base_dir rewriting")
786786
source_path)));
787787

788788
ctx.orig_args = Args::from_string("cl.exe @pch.rsp");
789+
PRINT(stderr, "XXX: RUNNING /Yc TEST: process_args\n");
789790
const auto result = process_args(ctx);
791+
PRINT(stderr, "XXX: RUNNING /Yc TEST: process_args done\n");
790792

793+
if (!result) {
794+
FAIL("XXX: error: ", result.error());
795+
}
791796
REQUIRE(result);
792797
CHECK(ctx.args_info.generating_pch);
793798
CHECK(ctx.args_info.output_obj == output_path);
794799
CHECK(result->preprocessor_args.to_string()
795800
== FMT("cl.exe /Yc -Fp{} -FI{}", pch_path, include_path));
796801
}
797802

803+
#if 0 // XXX
798804
TEST_CASE("MSVC /Yc with base_dir preserves later argument errors")
799805
{
800806
TestContext test_context;
@@ -1120,4 +1126,6 @@ TEST_CASE("-Xarch_device with -Xarch_x86_64 is too hard")
11201126
CHECK(result.error() == Statistic::unsupported_compiler_option);
11211127
}
11221128

1129+
#endif
1130+
11231131
TEST_SUITE_END();

0 commit comments

Comments
 (0)