This is an archive of the discontinued LLVM Phabricator instance.

[driver][darwin] Refactor the target selection code, NFC
ClosedPublic

Authored by arphaman on Dec 8 2017, 2:47 PM.

Details

Summary

This patch refactors the target selection in Darwin's driver.
Firstly, the simulator variant of Darwin's platforms is removed in favor of a new environment field.
Secondly, the code that selects the platform and the version is split into 4 different functions instead of being all in one function.
This is an NFC patch, although it slightly improves the "invalid version number" diagnostic by displaying the environment variable instead of -m<os>-version-min if the OS version was derived from the environment.

This patch is a preparation for making -target the canonical way of specifying the platform. This will be done in a follow-up patch https://reviews.llvm.org/D40998.

Diff Detail

Repository
rC Clang

Event Timeline

dexonsmith edited edge metadata.Dec 8 2017, 3:01 PM

This seems correct to me. I wouldn't mind having someone else back me up though.

Also, I have a suggestion for a static_assert.

lib/Driver/ToolChains/Darwin.cpp
1362–1367

It would be nice to have a static_assert that EnvVars has the right number of elements. Perhaps something like this would work:

const char *EnvVars[] = { /* etc. */ };
static_assert(std::end(EnvVars) - std::begin(EndVars) == Darwin::LastDarwinPlatform + 1,
              "missing platform");
arphaman updated this revision to Diff 126222.Dec 8 2017, 3:18 PM
arphaman marked an inline comment as done.

Add static_assert

This revision was automatically updated to reflect the committed changes.