constify these methods.
[oota-llvm.git] / include / llvm / ADT / SmallString.h
index d5856ac9f1f17d6ff410ec25f54d6417130d7ed6..05bd8a42c67f650c967e3212298deb3dda111b9a 100644 (file)
@@ -16,8 +16,6 @@
 
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Support/DataTypes.h"
-#include <cstring>
 
 namespace llvm {
 
@@ -40,6 +38,15 @@ public:
   // Extra methods.
   StringRef str() const { return StringRef(this->begin(), this->size()); }
 
+  // Implicit conversion to StringRef.
+  operator StringRef() const { return str(); }
+
+  const char *c_str() {
+    this->push_back(0);
+    this->pop_back();
+    return this->data();
+  }
+
   // Extra operators.
   const SmallString &operator=(StringRef RHS) {
     this->clear();
@@ -56,7 +63,6 @@ public:
   }
 };
 
-
 }
 
 #endif