| 35 | } |
| 36 | |
| 37 | StringRef Twine::toNullTerminatedStringRef(SmallVectorImpl<char> &Out) const { |
| 38 | if (isUnary()) { |
| 39 | switch (getLHSKind()) { |
| 40 | case CStringKind: |
| 41 | // Already null terminated, yay! |
| 42 | return StringRef(LHS.cString); |
| 43 | case StdStringKind: { |
| 44 | const std::string *str = LHS.stdString; |
| 45 | return StringRef(str->c_str(), str->size()); |
| 46 | } |
| 47 | default: |
| 48 | break; |
| 49 | } |
| 50 | } |
| 51 | toVector(Out); |
| 52 | Out.push_back(0); |
| 53 | Out.pop_back(); |
| 54 | return StringRef(Out.data(), Out.size()); |
| 55 | } |
| 56 | |
| 57 | void Twine::printOneChild(raw_ostream &OS, Child Ptr, |
| 58 | NodeKind Kind) const { |