This is an archive of the discontinued LLVM Phabricator instance.

[clang] Abstract away string allocation in command line generation
ClosedPublic

Authored by jansvoboda11 on Aug 3 2023, 3:35 PM.

Details

Summary

This patch abstracts away the string allocation and vector push-back from command line generation. Instead, all generated arguments are passed into ArgumentConsumer, which may choose to do the string allocation and vector push-back, or something else entirely.

Diff Detail

Event Timeline

jansvoboda11 created this revision.Aug 3 2023, 3:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2023, 3:35 PM
Herald added a subscriber: ributzka. · View Herald Transcript
jansvoboda11 requested review of this revision.Aug 3 2023, 3:35 PM
Herald added a project: Restricted Project. · View Herald Transcript
jansvoboda11 retitled this revision from [clang] Abstract string allocation in command line generation to [clang] Abstract away string allocation in command line generation.Aug 3 2023, 3:36 PM
benlangmuir accepted this revision.Aug 3 2023, 4:14 PM
benlangmuir added inline comments.
clang/lib/Frontend/CompilerInvocation.cpp
4323

Maybe not worth micro optimizing, but I noticed these two are allocating strings unnecessarily if we had an overload for things that can print to a raw_ostream.

This revision is now accepted and ready to land.Aug 3 2023, 4:14 PM
jansvoboda11 added inline comments.Aug 3 2023, 8:39 PM
clang/lib/Frontend/CompilerInvocation.cpp
4323

Interesting, there are a couple of other instances where this might help. I probably won't be spending time on this right now, but good to be aware.