Page MenuHomePhabricator

Pass ConstString by value

Authored by aprantl on Mar 6 2019, 9:29 AM.



My apologies for the large patch. With the exception of ConstString.h itself it was entirely produced by sed.

I technically only need one of these changes to fix a taking-reference-of-local-object bug that Jason discovered on the swift-lldb branch, but while I'm at it I thought I might as well do all at once.

ConstString has exactly one const char * data member, so passing a ConstString by reference is not any more efficient than copying it by value. In both cases a single pointer is passed. But passing it by value makes it harder to accidentally return the address of a local object.

(This fixes rdar://problem/48640859 for the Apple folks)

Diff Detail


Event Timeline

aprantl created this revision.Mar 6 2019, 9:29 AM
Herald added a project: Restricted Project. · View Herald Transcript
aprantl edited the summary of this revision. (Show Details)Mar 6 2019, 9:33 AM
jasonmolenda accepted this revision.Mar 6 2019, 1:14 PM

Looks good to me.

121 ↗(On Diff #189523)

big bug! :)

This revision is now accepted and ready to land.Mar 6 2019, 1:14 PM
Closed by commit rL355553: Pass ConstString by value (NFC) (authored by adrian, committed by ). · Explain WhyMar 6 2019, 1:22 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMar 6 2019, 1:22 PM