[llvm-commits] [llvm] r121381 - in /llvm/trunk: include/llvm/ADT/SmallString.h include/llvm/ADT/SmallVector.h lib/Support/Windows/PathV2.inc lib/Support/Windows/Windows.h

Michael J. Spencer bigcheesegs at gmail.com
Thu Dec 9 09:37:18 PST 2010


Author: mspencer
Date: Thu Dec  9 11:37:18 2010
New Revision: 121381

URL: http://llvm.org/viewvc/llvm-project?rev=121381&view=rev
Log:
Support: Move c_str from SmallVector back to SmallString and add a free standing
templated c_str in Windows.h to replace it.

Modified:
    llvm/trunk/include/llvm/ADT/SmallString.h
    llvm/trunk/include/llvm/ADT/SmallVector.h
    llvm/trunk/lib/Support/Windows/PathV2.inc
    llvm/trunk/lib/Support/Windows/Windows.h

Modified: llvm/trunk/include/llvm/ADT/SmallString.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SmallString.h?rev=121381&r1=121380&r2=121381&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/SmallString.h (original)
+++ llvm/trunk/include/llvm/ADT/SmallString.h Thu Dec  9 11:37:18 2010
@@ -38,6 +38,13 @@
   // Extra methods.
   StringRef str() const { return StringRef(this->begin(), this->size()); }
 
+  // TODO: Make this const, if it's safe...
+  const char* c_str() {
+    this->push_back(0);
+    this->pop_back();
+    return this->data();
+  }
+
   // Implicit conversion to StringRef.
   operator StringRef() const { return str(); }
 

Modified: llvm/trunk/include/llvm/ADT/SmallVector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SmallVector.h?rev=121381&r1=121380&r2=121381&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/SmallVector.h (original)
+++ llvm/trunk/include/llvm/ADT/SmallVector.h Thu Dec  9 11:37:18 2010
@@ -340,13 +340,6 @@
     return Result;
   }
 
-  // TODO: Make this const, if it's safe...
-  typename SuperClass::const_pointer c_str() {
-    push_back(0);
-    pop_back();
-    return this->data();
-  }
-
   void swap(SmallVectorImpl &RHS);
 
   /// append - Add the specified range to the end of the SmallVector.

Modified: llvm/trunk/lib/Support/Windows/PathV2.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/PathV2.inc?rev=121381&r1=121380&r2=121381&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/PathV2.inc (original)
+++ llvm/trunk/lib/Support/Windows/PathV2.inc Thu Dec  9 11:37:18 2010
@@ -623,7 +623,7 @@
 
   //  Get the first directory entry.
   WIN32_FIND_DATAW FirstFind;
-  ScopedFindHandle FindHandle(::FindFirstFileW(path_utf16.c_str(), &FirstFind));
+  ScopedFindHandle FindHandle(::FindFirstFileW(c_str(path_utf16), &FirstFind));
   if (!FindHandle)
     return windows_error(::GetLastError());
 

Modified: llvm/trunk/lib/Support/Windows/Windows.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Windows.h?rev=121381&r1=121380&r2=121381&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/Windows.h (original)
+++ llvm/trunk/lib/Support/Windows/Windows.h Thu Dec  9 11:37:18 2010
@@ -102,3 +102,16 @@
 typedef ScopedHandle<HANDLE, uintptr_t(-1),
                       BOOL (WINAPI*)(HANDLE), ::FindClose>
   ScopedFindHandle;
+
+namespace llvm {
+template <class T>
+class SmallVectorImpl;
+
+template <class T>
+typename SmallVectorImpl<T>::const_pointer
+c_str(SmallVectorImpl<T> &str) {
+  str.push_back(0);
+  str.pop_back();
+  return str.data();
+}
+} // end namespace llvm.





More information about the llvm-commits mailing list