[clang] [clang][builtins] Return a `SmallString` from `Builtin::Context::getQuotedName()` (PR #227963)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 30 23:21:55 PDT 2026
================
@@ -96,11 +96,13 @@ std::string Builtin::Context::getName(unsigned ID) const {
return I.getName(Shard);
}
-std::string Builtin::Context::getQuotedName(unsigned ID) const {
+SmallString<64> Builtin::Context::getQuotedName(unsigned ID) const {
const auto &[Shard, I] = getShardAndInfo(ID);
- return (Twine("'") + Shard.NamePrefix + (*Shard.Strings)[I.Offsets.Name] +
- "'")
- .str();
+ SmallString<64> Result("'");
+ Result += Shard.NamePrefix;
+ Result += (*Shard.Strings)[I.Offsets.Name];
+ Result += '\'';
----------------
tbaederr wrote:
You mean the the entire size of the string we return? AFAIK that doesn't work since the strings in the `llvm::StringTable` are null-terminated so we don't know the lenght of the `I.Offsets.Name` part?
https://github.com/llvm/llvm-project/pull/227963
More information about the cfe-commits
mailing list