This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Parse Debian version as integer when possible. NFC
ClosedPublic

Authored by mgorny on Oct 17 2016, 1:58 PM.

Details

Summary

Replace the string matching for /etc/debian_version with split
integer/string matching algorithm. When the file contains 'major.minor'
version number, parse the major version as integer and use a switch
clause to match it. Otherwise, attempt 'codename/sid' matching using
a StringSwitch.

Diff Detail

Repository
rL LLVM

Event Timeline

mgorny updated this revision to Diff 74897.Oct 17 2016, 1:58 PM
mgorny retitled this revision from to [Driver] Parse Debian version as integer when possible. NFC .
mgorny updated this object.
mgorny added reviewers: bkramer, bruno, rafael.
mgorny added a subscriber: cfe-commits.
bruno added inline comments.Oct 19 2016, 2:33 PM
lib/Driver/ToolChains.cpp
3903 ↗(On Diff #74897)

clang-format the switch: case's should be aligned with it.

3917 ↗(On Diff #74897)

You can remove the else and just return llvm::StringSwitch...

mgorny updated this revision to Diff 75269.Oct 20 2016, 12:06 AM
mgorny marked an inline comment as done.

Restructured and reformatted as requested.

bruno accepted this revision.Oct 20 2016, 1:19 PM
bruno edited edge metadata.

LGTM!

This revision is now accepted and ready to land.Oct 20 2016, 1:19 PM

Thanks for the review. I'll now look into updating the code for other distros to follow suit.

This revision was automatically updated to reflect the committed changes.