const auto arch = arg.substr(7);
auto it = state.xarch_args.emplace(arch, std::vector<std::string>()).first;
it->second.emplace_back(args[i + 1]);
+ if (arch == "host" || arch == "device") {
+ state.add_common_arg(args[i]);
+ state.add_common_arg(args[i + 1]);
+ }
++i;
return Statistic::none;
}
ctx, util::add_extension(args_info.orig_input_file, ".000i.ipa-clones"));
}
+ if (state.xarch_args.size() > 1) {
+ if (state.xarch_args.find("host") != state.xarch_args.end()) {
+ LOG_RAW("-Xarch_host in combination with other -Xarch_* is too hard");
+ return tl::unexpected(Statistic::unsupported_compiler_option);
+ }
+ if (state.xarch_args.find("device") != state.xarch_args.end()) {
+ LOG_RAW("-Xarch_device in combination with other -Xarch_* is too hard");
+ return tl::unexpected(Statistic::unsupported_compiler_option);
+ }
+ }
+
if (!state.xarch_args.empty()) {
for (const auto& arch : args_info.arch_args) {
auto it = state.xarch_args.find(arch);
}
}
+TEST_CASE("Supports -Xarch_host without other -Xarch_*")
+{
+ TestContext test_context;
+ Context ctx;
+ ctx.orig_args =
+ Args::from_string("clang -Xarch_host -foo -c foo.c -Xarch_host -bar");
+ REQUIRE(util::write_file("foo.c", ""));
+
+ const auto result = process_args(ctx);
+
+ REQUIRE(result);
+ CHECK(result->preprocessor_args.to_string()
+ == "clang -Xarch_host -foo -Xarch_host -bar");
+ CHECK(result->extra_args_to_hash.to_string() == "");
+ CHECK(result->compiler_args.to_string()
+ == "clang -Xarch_host -foo -Xarch_host -bar -c");
+}
+
+TEST_CASE("Supports -Xarch_device without other -Xarch_*")
+{
+ TestContext test_context;
+ Context ctx;
+ ctx.orig_args =
+ Args::from_string("clang -Xarch_device -foo -c foo.c -Xarch_device -bar");
+ REQUIRE(util::write_file("foo.c", ""));
+
+ const auto result = process_args(ctx);
+
+ REQUIRE(result);
+ CHECK(result->preprocessor_args.to_string()
+ == "clang -Xarch_device -foo -Xarch_device -bar");
+ CHECK(result->extra_args_to_hash.to_string() == "");
+ CHECK(result->compiler_args.to_string()
+ == "clang -Xarch_device -foo -Xarch_device -bar -c");
+}
+
+TEST_CASE("-Xarch_host with -Xarch_device is too hard")
+{
+ TestContext test_context;
+ Context ctx;
+ ctx.orig_args =
+ Args::from_string("clang -Xarch_device -foo -c foo.c -Xarch_host -bar");
+ REQUIRE(util::write_file("foo.c", ""));
+
+ const auto result = process_args(ctx);
+
+ REQUIRE(!result);
+ CHECK(result.error() == Statistic::unsupported_compiler_option);
+}
+
+TEST_CASE("-Xarch_host with -Xarch_x86_64 is too hard")
+{
+ TestContext test_context;
+ Context ctx;
+ ctx.orig_args =
+ Args::from_string("clang -Xarch_host -foo -c foo.c -Xarch_x86_64 -bar");
+ REQUIRE(util::write_file("foo.c", ""));
+
+ const auto result = process_args(ctx);
+
+ REQUIRE(!result);
+ CHECK(result.error() == Statistic::unsupported_compiler_option);
+}
+
+TEST_CASE("-Xarch_device with -Xarch_x86_64 is too hard")
+{
+ TestContext test_context;
+ Context ctx;
+ ctx.orig_args =
+ Args::from_string("clang -Xarch_device -foo -c foo.c -Xarch_x86_64 -bar");
+ REQUIRE(util::write_file("foo.c", ""));
+
+ const auto result = process_args(ctx);
+
+ REQUIRE(!result);
+ CHECK(result.error() == Statistic::unsupported_compiler_option);
+}
+
TEST_SUITE_END();