Right now, sys::getProcessTriple returns the LLVM_HOST_TRIPLE, whose system version might not be the actual version of the system on which the compiler running. This patch ensures that for macOS, sys::getProcessTriple returns a triple with the system's macOS version.
The function sys::getDefaultTargetTriple does this version adjustment as well. However, it seems wrong to me (the default target OS might not be the host OS). I left it alone in this patch to avoid breaking things, but I think that the version adjustment in sys::getDefaultTargetTriple should check that the host OS is the same as the target OS before making the adjustment.
I'm not sure if it's possible to test this change (Please let me know if I'm wrong though). I do have a commit in Clang r305678 (that I reverted for now) that depends on this change.
This is the function that clang calls to determine its default triple (here: http://llvm-cs.pcc.me.uk/tools/clang/lib/Frontend/CompilerInvocation.cpp#3410)
LLVM_DEFAULT_TARGET_TRIPLE is what we tell people to set when they build cross compilers. It's what we use to make sure our compiler isn't dependent on the host OS version.
Changing this here to rewrite LLVM_DEFAULT_TARGET_TRIPLE to use the host OS version seems like the wrong thing to do, from the perspective of clang's default triple. Do you agree?