InternedString BufferedReader::readAndInternString() { int strlen = readShort(); llvm::SmallString<32> chars; for (int i = 0; i < strlen; i++) { chars.push_back(readByte()); } return intern_pool->get(chars.str()); }
static void mangleNameInPlace(InternedString& id, llvm::StringRef private_name, InternedStringPool& interned_strings) { if (!private_name.size()) return; int len = id.s().size(); if (len < 2 || id.s()[0] != '_' || id.s()[1] != '_') return; if ((id.s()[len - 2] == '_' && id.s()[len - 1] == '_') || id.s().find('.') != std::string::npos) return; assert(private_name.data()[private_name.size()] == '\0'); const char* p = private_name.data(); while (*p == '_') { p++; len--; } if (*p == '\0') return; // TODO add a twine interface to interned strings? id = interned_strings.get("_" + std::string(p) + std::string(id.s())); }