Don't relax org or align. They change size as the relaxation happens, but they
[oota-llvm.git] / lib / Support / Twine.cpp
index 4f6f479a7eae910f13cdd12b80c622b0204b7221..75cea2961a9dc68d8faccbbd4a6e99681c69283f 100644 (file)
@@ -31,10 +31,18 @@ StringRef Twine::toStringRef(SmallVectorImpl<char> &Out) const {
 }
 
 StringRef Twine::toNullTerminatedStringRef(SmallVectorImpl<char> &Out) const {
-  if (isSingleStringRef()) {
-    StringRef sr = getSingleStringRef();
-    if (*(sr.begin() + sr.size()) == 0)
-      return sr;
+  if (isUnary()) {
+    switch (getLHSKind()) {
+    case CStringKind:
+      // Already null terminated, yay!
+      return StringRef(static_cast<const char*>(LHS));
+    case StdStringKind: {
+        const std::string *str = static_cast<const std::string*>(LHS);
+        return StringRef(str->c_str(), str->size());
+      }
+    default:
+      break;
+    }
   }
   toVector(Out);
   Out.push_back(0);