Extend StringRef's edit-distance algorithm to permit an upper bound on the allowed...
[oota-llvm.git] / include / llvm / ADT / Twine.h
index 29490b95b451bf40e514b769c74f763d931a7d07..b519a3e2ed11c419addbf9485c8a8c40d045d06b 100644 (file)
@@ -99,11 +99,12 @@ namespace llvm {
       /// A pointer to a StringRef instance.
       StringRefKind,
 
-      /// A pointer to an unsigned int value, to render as an unsigned decimal
-      /// integer.
+      /// An unsigned int value reinterpreted as a pointer, to render as an 
+      /// unsigned decimal integer.
       DecUIKind,
 
-      /// A pointer to an int value, to render as a signed decimal integer.
+      /// An int value reinterpreted as a pointer, to render as a signed
+      /// decimal integer.
       DecIKind,
 
       /// A pointer to an unsigned long value, to render as an unsigned decimal
@@ -259,13 +260,13 @@ namespace llvm {
     }
 
     /// Construct a twine to print \arg Val as an unsigned decimal integer.
-    explicit Twine(const unsigned int &Val) 
-      : LHS(&Val), LHSKind(DecUIKind), RHSKind(EmptyKind) {
+    explicit Twine(unsigned Val) 
+      : LHS((void*)(intptr_t)Val), LHSKind(DecUIKind), RHSKind(EmptyKind) {
     }
 
     /// Construct a twine to print \arg Val as a signed decimal integer.
-    explicit Twine(const int &Val) 
-      : LHS(&Val), LHSKind(DecIKind), RHSKind(EmptyKind) {
+    explicit Twine(int Val) 
+      : LHS((void*)(intptr_t)Val), LHSKind(DecIKind), RHSKind(EmptyKind) {
     }
 
     /// Construct a twine to print \arg Val as an unsigned decimal integer.
@@ -375,8 +376,12 @@ namespace llvm {
       case StringRefKind:  return *(const StringRef*)LHS;
       }
     }
-    
-    
+
+    /// toStringRef - This returns the twine as a single StringRef if it can be
+    /// represented as such. Otherwise the twine is written into the given
+    /// SmallVector and a StringRef to the SmallVector's data is returned.
+    StringRef toStringRef(SmallVectorImpl<char> &Out) const;
+
     /// print - Write the concatenated string represented by this twine to the
     /// stream \arg OS.
     void print(raw_ostream &OS) const;