[clang][Tooling] Use Windows command lines on all Windows, except Cygwin
authorJeremy Drake <github@jdrake.com>
Wed, 13 Oct 2021 19:49:29 +0000 (22:49 +0300)
committerMartin Storsjö <martin@martin.st>
Wed, 13 Oct 2021 19:55:14 +0000 (22:55 +0300)
Previously it only used Windows command lines for MSVC triples, but this
was causing issues for windows-gnu.  In fact, everything 'native' Windows
(ie, not Cygwin) should use Windows command line parsing.

Reviewed By: mstorsjo

Differential Revision: https://reviews.llvm.org/D111195

clang/lib/Tooling/JSONCompilationDatabase.cpp

index 97ba7e411fbb37d59049525c088729a17ca90734..5e18d7a576c08d4ddaee06c563b9cfcd8a49ac06 100644 (file)
@@ -135,15 +135,12 @@ class CommandLineArgumentParser {
 std::vector<std::string> unescapeCommandLine(JSONCommandLineSyntax Syntax,
                                              StringRef EscapedCommandLine) {
   if (Syntax == JSONCommandLineSyntax::AutoDetect) {
+#ifdef _WIN32
+    // Assume Windows command line parsing on Win32
+    Syntax = JSONCommandLineSyntax::Windows;
+#else
     Syntax = JSONCommandLineSyntax::Gnu;
-    llvm::Triple Triple(llvm::sys::getProcessTriple());
-    if (Triple.getOS() == llvm::Triple::OSType::Win32) {
-      // Assume Windows command line parsing on Win32 unless the triple
-      // explicitly tells us otherwise.
-      if (!Triple.hasEnvironment() ||
-          Triple.getEnvironment() == llvm::Triple::EnvironmentType::MSVC)
-        Syntax = JSONCommandLineSyntax::Windows;
-    }
+#endif
   }
 
   if (Syntax == JSONCommandLineSyntax::Windows) {