[PATCH] D61121: [Windows] Separate elements in -print-search-dirs with semicolons

Martin Storsjö via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 25 02:59:00 PDT 2019

mstorsjo created this revision.
mstorsjo added reviewers: rnk, hans, smeenai, thakis.
Herald added a project: clang.

Path lists on windows should always be separated by semicolons, not colons. Reuse llvm::sys::EnvPathSeparator for this purpose (as that's also a path list that is separated in the same way).

Alternatively, this could just be a local ifdef _WIN32 in this function, or should we generalize the existing EnvPathSeparator to e.g. a llvm::sys::path::PathListSeparator?

Does this change need a test? I guess we could add a separate file with "REQUIRES: system-windows" and check if the output does contain a semicolon, but I'm not sure how meaningful that is, especially as the default list printed only contains one single path element.

This was noted within Qt (and worked around with a creative regex) at https://codereview.qt-project.org/247331.

  rC Clang



Index: lib/Driver/Driver.cpp
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1694,7 +1694,7 @@
     bool separator = false;
     for (const std::string &Path : TC.getProgramPaths()) {
       if (separator)
-        llvm::outs() << ':';
+        llvm::outs() << llvm::sys::EnvPathSeparator;
       llvm::outs() << Path;
       separator = true;
@@ -1705,7 +1705,7 @@
     for (const std::string &Path : TC.getFilePaths()) {
       // Always print a separator. ResourceDir was the first item shown.
-      llvm::outs() << ':';
+      llvm::outs() << llvm::sys::EnvPathSeparator;
       // Interpretation of leading '=' is needed only for NetBSD.
       if (Path[0] == '=')
         llvm::outs() << sysroot << Path.substr(1);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61121.196593.patch
Type: text/x-patch
Size: 808 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190425/6b521908/attachment-0001.bin>

More information about the cfe-commits mailing list