From 0eab5e2efa0741b766f71a75626f7598990d5c3d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 11 Aug 2008 23:39:47 +0000 Subject: [PATCH] add a helper method to sys::Path for clang, patch by Kovarththanan Rajaratnam! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54655 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/System/Path.h | 6 ++++++ lib/System/Unix/Path.inc | 6 ++++++ lib/System/Win32/Path.inc | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/include/llvm/System/Path.h b/include/llvm/System/Path.h index ac0c6cbca2e..d28e11e5456 100644 --- a/include/llvm/System/Path.h +++ b/include/llvm/System/Path.h @@ -202,6 +202,12 @@ namespace sys { return *this; } + /// Makes a copy of \p that to \p this. + /// @param \p that A std::string denoting the path + /// @returns \p this + /// @brief Assignment Operator + Path &operator=(const std::string &that); + /// Compares \p this Path with \p that Path for equality. /// @returns true if \p this and \p that refer to the same thing. /// @brief Equality Operator diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc index 73ccbfbbbf6..cdb574fc01a 100644 --- a/lib/System/Unix/Path.inc +++ b/lib/System/Unix/Path.inc @@ -81,6 +81,12 @@ Path::Path(const std::string& p) Path::Path(const char *StrStart, unsigned StrLen) : path(StrStart, StrLen) {} +Path& +Path::operator=(const std::string &that) { + path = that; + return *this; +} + bool Path::isValid() const { // Check some obvious things diff --git a/lib/System/Win32/Path.inc b/lib/System/Win32/Path.inc index bb1252cfdd2..ff96e33dfad 100644 --- a/lib/System/Win32/Path.inc +++ b/lib/System/Win32/Path.inc @@ -56,6 +56,13 @@ Path::Path(const char *StrStart, unsigned StrLen) FlipBackSlashes(path); } +Path& +Path::operator=(const std::string &that) { + path = that; + FlipBackSlashes(path); + return *this; +} + bool Path::isValid() const { if (path.empty())