diff options
-rw-r--r-- | include/llvm/System/Path.h | 3 | ||||
-rw-r--r-- | lib/System/Path.cpp | 15 | ||||
-rw-r--r-- | lib/System/Unix/Path.inc | 12 | ||||
-rw-r--r-- | lib/System/Win32/Path.inc | 12 |
4 files changed, 17 insertions, 25 deletions
diff --git a/include/llvm/System/Path.h b/include/llvm/System/Path.h index c13f2e8..2049528 100644 --- a/include/llvm/System/Path.h +++ b/include/llvm/System/Path.h @@ -454,7 +454,8 @@ namespace sys { /// The precondition for this function is that the Path reference a file /// name (i.e. isFile() returns true). If the Path is not a file, no /// action is taken and the function returns false. If the path would - /// become invalid for the host operating system, false is returned. + /// become invalid for the host operating system, false is returned. When + /// the \p suffix is empty, no action is performed. /// @returns false if the suffix could not be added, true if it was. /// @brief Adds a period and the \p suffix to the end of the pathname. bool appendSuffix(StringRef suffix); diff --git a/lib/System/Path.cpp b/lib/System/Path.cpp index 8fc4153..5d8de65 100644 --- a/lib/System/Path.cpp +++ b/lib/System/Path.cpp @@ -196,6 +196,21 @@ StringRef Path::GetDLLSuffix() { } bool +Path::appendSuffix(StringRef suffix) { + if (!suffix.empty()) { + std::string save(path); + path.append("."); + path.append(suffix); + if (!isValid()) { + path = save; + return false; + } + } + + return true; +} + +bool Path::isBitcodeFile() const { std::string actualMagic; if (!getMagicNumber(actualMagic, 4)) diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc index 1558868..b1d2ad2 100644 --- a/lib/System/Unix/Path.inc +++ b/lib/System/Unix/Path.inc @@ -638,18 +638,6 @@ Path::eraseComponent() { } bool -Path::appendSuffix(StringRef suffix) { - std::string save(path); - path.append("."); - path.append(suffix); - if (!isValid()) { - path = save; - return false; - } - return true; -} - -bool Path::eraseSuffix() { std::string save = path; size_t dotpos = path.rfind('.',path.size()); diff --git a/lib/System/Win32/Path.inc b/lib/System/Win32/Path.inc index ea6d463..2ead801 100644 --- a/lib/System/Win32/Path.inc +++ b/lib/System/Win32/Path.inc @@ -552,18 +552,6 @@ Path::eraseComponent() { } bool -Path::appendSuffix(StringRef suffix) { - std::string save(path); - path.append("."); - path.append(suffix); - if (!isValid()) { - path = save; - return false; - } - return true; -} - -bool Path::eraseSuffix() { size_t dotpos = path.rfind('.',path.size()); size_t slashpos = path.rfind('/',path.size()); |