This is an archive of the discontinued LLVM Phabricator instance.

[lldb] [Utility/UriParser] Replace port==-1 with llvm::None
ClosedPublic

Authored by mgorny on Oct 22 2021, 5:06 AM.

Details

Summary

Use llvm::Optional<uint16_t> instead of int for port number
in UriParser::Parse(), and use llvm::None to indicate missing port
instead of a magic value of -1.

Diff Detail

Event Timeline

mgorny requested review of this revision.Oct 22 2021, 5:06 AM
mgorny created this revision.
labath accepted this revision.Oct 22 2021, 5:16 AM

Seems like a (slight) improvement. You don't have to do this, but what I think would best help here is if we made a struct for these parsed results:

struct URI {
  static Optional<URI> parse(StringRef);
  StringRef scheme;
  ...
}

throw in an operator== and << and even the unit tests would become nicer.

This revision is now accepted and ready to land.Oct 22 2021, 5:16 AM
This revision was landed with ongoing or failed builds.Oct 22 2021, 5:39 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptOct 22 2021, 5:39 AM