This is an archive of the discontinued LLVM Phabricator instance.

[lldb][NFCI] Platforms should own their SDKBuild and SDKRootDirectory strings
ClosedPublic

Authored by bulbazord on Jun 6 2023, 6:52 PM.

Details

Summary

These don't need to be ConstStrings. They don't really benefit much from
deduplication and comparing them isn't on a hot path, so they don't
really benefit much from quick comparisons.

Diff Detail

Event Timeline

bulbazord created this revision.Jun 6 2023, 6:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 6 2023, 6:52 PM
bulbazord requested review of this revision.Jun 6 2023, 6:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 6 2023, 6:52 PM
JDevlieghere requested changes to this revision.Jun 12 2023, 9:06 PM
JDevlieghere added inline comments.
lldb/include/lldb/Interpreter/OptionGroupPlatform.h
52–53

This should take a std::string by value and move it.

58–60

Same here

This revision now requires changes to proceed.Jun 12 2023, 9:06 PM
bulbazord added inline comments.Jun 13 2023, 10:39 AM
lldb/include/lldb/Interpreter/OptionGroupPlatform.h
52–53

Is there a specific reason you want to do that instead of using llvm::StringRef::str()?

JDevlieghere added inline comments.Jun 13 2023, 12:20 PM
lldb/include/lldb/Interpreter/OptionGroupPlatform.h
52–53

Yes, it saves a copy when calling SetSDKRootDirectory with an rvalue reference or a moved std::string. There's no downside if you're going to store it as a std::string anyway.

bulbazord updated this revision to Diff 531084.Jun 13 2023, 3:05 PM

Implement Jonas's suggestion

bulbazord marked 3 inline comments as done.Jun 13 2023, 3:06 PM
JDevlieghere accepted this revision.Jun 13 2023, 3:54 PM

LGTM with the other two functions updated as well.

lldb/include/lldb/Target/Platform.h
453
457–459

std::string

This revision is now accepted and ready to land.Jun 13 2023, 3:54 PM
bulbazord updated this revision to Diff 531103.Jun 13 2023, 4:00 PM

Update other 2 functions (and one callsite)

bulbazord updated this revision to Diff 531104.Jun 13 2023, 4:01 PM

Avoid construction of temporary std::string

Looks like this actually causes TestDebuggerAPI.py to segfault because SBPlatform::SetSDKRoot can take nullptr for its argument, and the conversion from nullptr -> std::string blows up. I'm fixing that in https://reviews.llvm.org/D152962.