This is an archive of the discontinued LLVM Phabricator instance.

[lldb] [Host] Refactor XML converting getters
ClosedPublic

Authored by mgorny on Sep 24 2021, 6:05 AM.

Details

Summary

Refactor the XML converting attribute and text getters to use LLVM API.
While at it, remove some redundant error and missing XML support
handling, as the called base functions do that anyway. Add tests
for these methods.

Note that this patch changes the getter behavior to be IMHO more
correct. In particular:

  • negative and overflowing integers are now reported as failures to convert, rather than being wrapped over or capped
  • digits followed by text are now reported as failures to convert to double, rather than their numeric part being converted

Diff Detail

Event Timeline

mgorny requested review of this revision.Sep 24 2021, 6:05 AM
mgorny created this revision.
mgorny updated this revision to Diff 374829.Sep 24 2021, 6:43 AM

Remove obsolete includes.

labath accepted this revision.Sep 27 2021, 3:55 AM
labath added inline comments.
lldb/source/Host/common/XML.cpp
296–300

/me wonders if it would be too weird to rely on the fact that to_integer does not modify the result variable on failure.

It would definitely streamline this code:

value = fail_value;
return GetElementText(text) && llvm::to_integer(text,value, base);
This revision is now accepted and ready to land.Sep 27 2021, 3:55 AM
mgorny added inline comments.Sep 27 2021, 3:57 AM
lldb/source/Host/common/XML.cpp
296–300

Other code in LLDB already does that, so I suppose it's fine.

mgorny marked an inline comment as done.Sep 27 2021, 5:20 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 27 2021, 5:26 AM