diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2021-10-21 18:33:24 -0700 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2021-10-29 12:09:41 -0700 |
commit | 99023627010bbfefb71e25a2b4d056de1cbd354e (patch) | |
tree | a7ad434f3071922aac052bf9eb23c29c577cb885 /llvm/lib/Support/GraphWriter.cpp | |
parent | 51ce567b38ec92163ec05c9bef0bd0e2bd53c667 (diff) | |
download | llvm-99023627010bbfefb71e25a2b4d056de1cbd354e.zip llvm-99023627010bbfefb71e25a2b4d056de1cbd354e.tar.gz llvm-99023627010bbfefb71e25a2b4d056de1cbd354e.tar.bz2 |
Support: Use sys::path::is_style_{posix,windows}() in a few places
Use the new sys::path::is_style_posix() and is_style_windows() in a few
places that need to detect the system's native path style.
In llvm/lib/Support/Path.cpp, this patch removes most uses of the
private `real_style()`, where is_style_posix() and is_style_windows()
are just a little tidier.
Elsewhere, this removes `_WIN32` macro checks. Added a FIXME to a
FileManagerTest that seemed fishy, but maintained the existing
behaviour.
Differential Revision: https://reviews.llvm.org/D112289
Diffstat (limited to 'llvm/lib/Support/GraphWriter.cpp')
-rw-r--r-- | llvm/lib/Support/GraphWriter.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/llvm/lib/Support/GraphWriter.cpp b/llvm/lib/Support/GraphWriter.cpp index b41869a..696e6b7 100644 --- a/llvm/lib/Support/GraphWriter.cpp +++ b/llvm/lib/Support/GraphWriter.cpp @@ -23,11 +23,12 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" #include "llvm/Support/Program.h" #include "llvm/Support/raw_ostream.h" #include <cassert> -#include <system_error> #include <string> +#include <system_error> #include <vector> using namespace llvm; @@ -94,11 +95,8 @@ StringRef llvm::DOT::getColorString(unsigned ColorNumber) { static std::string replaceIllegalFilenameChars(std::string Filename, const char ReplacementChar) { -#ifdef _WIN32 - std::string IllegalChars = "\\/:?\"<>|"; -#else - std::string IllegalChars = "/"; -#endif + std::string IllegalChars = + is_style_windows(sys::path::Style::native) ? "\\/:?\"<>|" : "/"; for (char IllegalChar : IllegalChars) { std::replace(Filename.begin(), Filename.end(), IllegalChar, |