From fb78495376017111d8b5a1f43745d3c17b0d8978 Mon Sep 17 00:00:00 2001 From: Prabhuk Date: Fri, 20 Sep 2024 11:16:36 -0700 Subject: Reland "[Driver] Add toolchain for X86_64 UEFI target" (#109364) Reverts llvm/llvm-project#109340 Addressing the failed MAC Clang Driver test as part of this reland. --- clang/unittests/Driver/ToolChainTest.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'clang/unittests/Driver/ToolChainTest.cpp') diff --git a/clang/unittests/Driver/ToolChainTest.cpp b/clang/unittests/Driver/ToolChainTest.cpp index a9b5f3c..8542a16 100644 --- a/clang/unittests/Driver/ToolChainTest.cpp +++ b/clang/unittests/Driver/ToolChainTest.cpp @@ -14,6 +14,7 @@ #include "clang/Basic/DiagnosticIDs.h" #include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/LLVM.h" +#include "clang/Basic/TargetInfo.h" #include "clang/Basic/TargetOptions.h" #include "clang/Driver/Compilation.h" #include "clang/Driver/Driver.h" @@ -574,6 +575,26 @@ TEST(CompilerInvocation, SplitSwarfSingleCrash) { EXPECT_TRUE(CI); // no-crash } +TEST(ToolChainTest, UEFICallingConventionTest) { + clang::CompilerInstance compiler; + compiler.createDiagnostics(); + + std::string TrStr = "x86_64-unknown-uefi"; + llvm::Triple Tr(TrStr); + Tr.setOS(llvm::Triple::OSType::UEFI); + Tr.setVendor(llvm::Triple::VendorType::UnknownVendor); + Tr.setEnvironment(llvm::Triple::EnvironmentType::UnknownEnvironment); + Tr.setArch(llvm::Triple::ArchType::x86_64); + + compiler.getTargetOpts().Triple = Tr.getTriple(); + compiler.setTarget(clang::TargetInfo::CreateTargetInfo( + compiler.getDiagnostics(), + std::make_shared(compiler.getTargetOpts()))); + + EXPECT_EQ(compiler.getTarget().getCallingConvKind(true), + TargetInfo::CallingConvKind::CCK_MicrosoftWin64); +} + TEST(GetDriverMode, PrefersLastDriverMode) { static constexpr const char *Args[] = {"clang-cl", "--driver-mode=foo", "--driver-mode=bar", "foo.cpp"}; -- cgit v1.1