[llvm-commits] [llvm] r120539 - in /llvm/trunk: lib/Support/PathV2.cpp unittests/Support/Path.cpp

Michael J. Spencer bigcheesegs at gmail.com
Tue Nov 30 18:48:27 PST 2010


Author: mspencer
Date: Tue Nov 30 20:48:27 2010
New Revision: 120539

URL: http://llvm.org/viewvc/llvm-project?rev=120539&view=rev
Log:
Support/PathV2: Add native implementation.

Modified:
    llvm/trunk/lib/Support/PathV2.cpp
    llvm/trunk/unittests/Support/Path.cpp

Modified: llvm/trunk/lib/Support/PathV2.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/PathV2.cpp?rev=120539&r1=120538&r2=120539&view=diff
==============================================================================
--- llvm/trunk/lib/Support/PathV2.cpp (original)
+++ llvm/trunk/lib/Support/PathV2.cpp Tue Nov 30 20:48:27 2010
@@ -531,6 +531,28 @@
   return make_error_code(errc::success);
 }
 
+error_code native(const Twine &path, SmallVectorImpl<char> &result) {
+  // Clear result.
+  result.set_size(0);
+#ifdef LLVM_ON_WIN32
+  SmallString<128> path_storage;
+  StringRef p = path.toStringRef(path_storage);
+  result.reserve(p.size());
+  for (StringRef::const_iterator i = p.begin(),
+                                 e = p.end();
+                                 i != e;
+                                 ++i) {
+    if (*i == '/')
+      result.push_back('\\');
+    else
+      result.push_back(*i);
+  }
+#else
+  path.toVector(result);
+#endif
+  return make_error_code(errc::success);
+}
+
 }
 }
 }

Modified: llvm/trunk/unittests/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Path.cpp?rev=120539&r1=120538&r2=120539&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/Path.cpp (original)
+++ llvm/trunk/unittests/Support/Path.cpp Tue Nov 30 20:48:27 2010
@@ -107,6 +107,9 @@
     if (error_code ec = sys::path::replace_extension(temp_store, "ext"))
       ASSERT_FALSE(ec.message().c_str());
     outs() << "    replace_extension: " << temp_store << '\n';
+    if (error_code ec = sys::path::native(*i, temp_store))
+      ASSERT_FALSE(ec.message().c_str());
+    outs() << "    native: " << temp_store << '\n';
 
     outs().flush();
   }





More information about the llvm-commits mailing list