Index: lib/Support/CommandLine.cpp =================================================================== --- lib/Support/CommandLine.cpp +++ lib/Support/CommandLine.cpp @@ -439,6 +439,14 @@ Value = Arg.substr(EqualPos + 1); Arg = Arg.substr(0, EqualPos); + + // Windows Cmd Shell will not remove the '' from a --checks='abc' type command + // when passed via argv, unlike Linux or cygwin shells. + if (Triple(sys::getProcessTriple()).isOSWindows()) { + // Pull off the leading and trailing 's. + if (Value.size() > 1 && Value[0] == '\'' && Value[Value.size() - 1] == '\'') + Value = Value.substr(1, Value.size() - 2); + } return I->second; } Index: unittests/Support/CommandLineTest.cpp =================================================================== --- unittests/Support/CommandLineTest.cpp +++ unittests/Support/CommandLineTest.cpp @@ -914,4 +914,30 @@ EXPECT_TRUE(MacroDefs.front().compare("HAVE_FOO") == 0); } +TEST(CommandLineTest, WindowsCmdShellQuotesArg) { + if (!Triple(sys::getProcessTriple()).isOSWindows()) + return; + + StackOption> Checks( + "checks", cl::desc("The checks"), cl::init("")); + + const char *argsCmdShell[] = {"clang-tidy.exe", + "-checks='-*,readability-identifier-naming'"}; + + EXPECT_TRUE(cl::ParseCommandLineOptions(2, argsCmdShell, StringRef(), + &llvm::nulls())); + + EXPECT_TRUE(Checks.compare("-*,readability-identifier-naming") == 0); + + cl::ResetAllOptionOccurrences(); + + const char *argsCmdShell2[] = {"clang-tidy.exe", + "-checks=-*,readability-identifier-naming"}; + + EXPECT_TRUE(cl::ParseCommandLineOptions(2, argsCmdShell2, StringRef(), + &llvm::nulls())); + + EXPECT_TRUE(Checks.compare("-*,readability-identifier-naming") == 0); +} + } // anonymous namespace