This revision was not accepted when it landed; it landed in state "Needs Review". This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG73c00d40bd49: [clang][Driver] Pick the last --driver-mode in case of multiple ones (authored by kadircet).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D109361/new/ https://reviews.llvm.org/D109361 Files: clang/lib/Driver/Driver.cpp clang/unittests/Driver/ToolChainTest.cpp Index: clang/unittests/Driver/ToolChainTest.cpp =================================================================== --- clang/unittests/Driver/ToolChainTest.cpp +++ clang/unittests/Driver/ToolChainTest.cpp @@ -16,6 +16,7 @@ #include "clang/Basic/LLVM.h" #include "clang/Driver/Compilation.h" #include "clang/Driver/Driver.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/Support/TargetRegistry.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/VirtualFileSystem.h" @@ -357,4 +358,10 @@ EXPECT_TRUE(CallbackHasCalled); } +TEST(GetDriverMode, PrefersLastDriverMode) { + static constexpr const char *Args[] = {"clang-cl", "--driver-mode=foo", + "--driver-mode=bar", "foo.cpp"}; + EXPECT_EQ(getDriverMode(Args[0], llvm::makeArrayRef(Args).slice(1)), "bar"); +} + } // end anonymous namespace. Index: clang/lib/Driver/Driver.cpp =================================================================== --- clang/lib/Driver/Driver.cpp +++ clang/lib/Driver/Driver.cpp @@ -5569,7 +5569,6 @@ if (!Arg.startswith(OptName)) continue; Opt = Arg; - break; } if (Opt.empty()) Opt = ToolChain::getTargetAndModeFromProgramName(ProgName).DriverMode;
Index: clang/unittests/Driver/ToolChainTest.cpp =================================================================== --- clang/unittests/Driver/ToolChainTest.cpp +++ clang/unittests/Driver/ToolChainTest.cpp @@ -16,6 +16,7 @@ #include "clang/Basic/LLVM.h" #include "clang/Driver/Compilation.h" #include "clang/Driver/Driver.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/Support/TargetRegistry.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/VirtualFileSystem.h" @@ -357,4 +358,10 @@ EXPECT_TRUE(CallbackHasCalled); } +TEST(GetDriverMode, PrefersLastDriverMode) { + static constexpr const char *Args[] = {"clang-cl", "--driver-mode=foo", + "--driver-mode=bar", "foo.cpp"}; + EXPECT_EQ(getDriverMode(Args[0], llvm::makeArrayRef(Args).slice(1)), "bar"); +} + } // end anonymous namespace. Index: clang/lib/Driver/Driver.cpp =================================================================== --- clang/lib/Driver/Driver.cpp +++ clang/lib/Driver/Driver.cpp @@ -5569,7 +5569,6 @@ if (!Arg.startswith(OptName)) continue; Opt = Arg; - break; } if (Opt.empty()) Opt = ToolChain::getTargetAndModeFromProgramName(ProgName).DriverMode;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits