This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Convert misc. StringConvert uses
ClosedPublic

Authored by mgorny on Sep 24 2021, 2:41 PM.

Details

Summary

Replace misc. StringConvert uses with llvm::to_integer()
and llvm::to_float(), except for cases where further refactoring is
planned. The purpose of this change is to eliminate the StringConvert
API that is duplicate to LLVM, and less correct in behavior at the same
time.

Diff Detail

Event Timeline

mgorny requested review of this revision.Sep 24 2021, 2:41 PM
mgorny created this revision.
mgorny updated this revision to Diff 375024.Sep 25 2021, 3:38 AM

Reverting debugserver part, this *beep* doesn't use LLVM.

teemperor accepted this revision.Sep 25 2021, 4:21 AM
teemperor added a subscriber: teemperor.

This patch makes me very happy. I have one comment regarding one small change in behaviour, but otherwise this LGTM.

If you have the time, it would be nice to drop FIXME's above the few places where the return value of to_integer is not checked. Those always make great beginner bugs.

lldb/source/Symbol/SymbolContext.cpp
986

This change and the one above make this return true on a parse failure. LLDB is of course one step ahead of us here and never even checks the return value anywhere (...), but I think it still makes sense to preserve the behaviour in this patch.

This revision is now accepted and ready to land.Sep 25 2021, 4:21 AM

If you have the time, it would be nice to drop FIXME's above the few places where the return value of to_integer is not checked. Those always make great beginner bugs.

Beginner? I'm pretty sure these things are really hard ;-).

That said, in most of the cases 'not checking the return value' is combined with setting a fallback value earlier, i.e. if llvm::to_integer() fails, the variable remains with its default/fallback value. But yeah, I suppose it would be nice to rethink these things and maybe add explicit error handling in place of silent fallbacks.

mgorny added inline comments.Sep 25 2021, 5:07 AM
lldb/source/Symbol/SymbolContext.cpp
986

Ahh, good catch. Will fix in a minute.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 25 2021, 5:55 AM