aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-12-13 06:57:15 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-12-13 06:57:15 +0000
commit732f92d56ebca7229bea69fdec6b5609f135ff76 (patch)
tree8a3c6662ab0ab2911ce485df198e4c4658fb2e70
parent3265369ff528e09a71cc8f1ce20f28f65d8e2bcc (diff)
* Add a std::ostream inserter for sys::Path
* Correct the std::string constructor to take a const reference. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18877 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/System/Path.h8
-rw-r--r--lib/System/Unix/Path.cpp2
-rw-r--r--lib/System/Unix/Path.inc2
-rw-r--r--lib/System/Win32/Path.cpp2
-rw-r--r--lib/System/Win32/Path.inc2
5 files changed, 11 insertions, 5 deletions
diff --git a/include/llvm/System/Path.h b/include/llvm/System/Path.h
index 7862e21998..10c8bccef8 100644
--- a/include/llvm/System/Path.h
+++ b/include/llvm/System/Path.h
@@ -18,6 +18,7 @@
#include <set>
#include <string>
#include <vector>
+#include <ostream>
namespace llvm {
namespace sys {
@@ -161,7 +162,7 @@ namespace sys {
/// @throws std::string if the path string is not legal.
/// @param unverified_path The path to verify and assign.
/// @brief Construct a Path from a string.
- explicit Path(std::string unverified_path);
+ explicit Path(const std::string& unverified_path);
/// @}
/// @name Operators
@@ -547,6 +548,11 @@ namespace sys {
LLVMFileType IdentifyFileType(const char*magic, unsigned length);
}
+inline std::ostream& operator<<(std::ostream& strm, const sys::Path& aPath) {
+ strm << aPath.toString();
+ return strm;
+}
+
}
// vim: sw=2
diff --git a/lib/System/Unix/Path.cpp b/lib/System/Unix/Path.cpp
index 63184f6c1c..e655ef40cd 100644
--- a/lib/System/Unix/Path.cpp
+++ b/lib/System/Unix/Path.cpp
@@ -27,7 +27,7 @@
namespace llvm {
using namespace sys;
-Path::Path(std::string unverified_path)
+Path::Path(const std::string& unverified_path)
: path(unverified_path)
{
if (unverified_path.empty())
diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc
index 63184f6c1c..e655ef40cd 100644
--- a/lib/System/Unix/Path.inc
+++ b/lib/System/Unix/Path.inc
@@ -27,7 +27,7 @@
namespace llvm {
using namespace sys;
-Path::Path(std::string unverified_path)
+Path::Path(const std::string& unverified_path)
: path(unverified_path)
{
if (unverified_path.empty())
diff --git a/lib/System/Win32/Path.cpp b/lib/System/Win32/Path.cpp
index 095417f0fe..070ebb3120 100644
--- a/lib/System/Win32/Path.cpp
+++ b/lib/System/Win32/Path.cpp
@@ -97,7 +97,7 @@ Path::GetTemporaryDirectory() {
return *TempDirectory;
}
-Path::Path(std::string unverified_path)
+Path::Path(const std::string& unverified_path)
: path(unverified_path)
{
FlipBackSlashes(path);
diff --git a/lib/System/Win32/Path.inc b/lib/System/Win32/Path.inc
index 095417f0fe..070ebb3120 100644
--- a/lib/System/Win32/Path.inc
+++ b/lib/System/Win32/Path.inc
@@ -97,7 +97,7 @@ Path::GetTemporaryDirectory() {
return *TempDirectory;
}
-Path::Path(std::string unverified_path)
+Path::Path(const std::string& unverified_path)
: path(unverified_path)
{
FlipBackSlashes(path);