This is an archive of the discontinued LLVM Phabricator instance.

[TableGen] Clang changes to support Record::getValueAsString and getValueAsListOfStrings returning StringRef instead of std::string
ClosedPublic

Authored by craig.topper on May 30 2017, 11:49 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.May 30 2017, 11:49 PM
craig.topper added inline comments.
utils/TableGen/ClangOptionDocEmitter.cpp
272 ↗(On Diff #100826)

Had to make a copy into vector std::string because emitOptionWithArgs has another caller that passes a std::string vector.

dblaikie accepted this revision.May 31 2017, 8:28 AM

Few questions, but address them as you see fit.

utils/TableGen/ClangDiagnosticsEmitter.cpp
1280–1281 ↗(On Diff #100826)

Any reason (I'm guessing there is) not to do the str() on the + expression instead of the RHS? (seemed like you'd done that in other changes here, to minimize the string buffering/reallocation/etc by stringifying once at the top level of the expression)

utils/TableGen/ClangOptionDocEmitter.cpp
86 ↗(On Diff #100826)

Does this need to be a std::string here? I'm not spotting any mutation (but I could well be missing it) of the value. Is it that StringREf doesn't support some of these substr - like operations?

Oh, I guess it's that all of these operations want a std::string (for lookup in OptionsByName, for the result of string concatenation, etc).

It'd still be marginally more efficient to not have to create a std::string up-front, I'd think, but syntactically annoying/verbose for all those uses?

272 ↗(On Diff #100826)

Would it be better/OK if the other caller was the one making the copy (it'd be cheaper to make a std::vector<StringRef> from a std::vector<std::string> than the other way around - but maybe the other caller is much hotter than this one?)?

This revision is now accepted and ready to land.May 31 2017, 8:28 AM
MatzeB accepted this revision.May 31 2017, 10:23 AM

I assume you have checked that the tablegen output doesn't change. Apart from that I'm all for more StringRef and SmallStrings or even Twines where possible. So LGTM.

This revision was automatically updated to reflect the committed changes.