Triple: Make setEnvironment not override the object format

Discovered by Halide users who had C++ code like this:
  Triple.setArch(Triple::x86);
  Triple.setOS(Triple::Windows);
  Triple.setObjectFormat(Triple::ELF);
  Triple.setEnvironment(Triple::MSVC);

This would produce the stringified triple of x86-windows-msvc, instead
of the x86-windows-msvc-elf string needed to run MCJIT.

With this change, they retain the -elf suffix.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229160 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Kleckner 2015-02-13 22:05:50 +00:00
parent fa1b3ba1f0
commit 86b5c3a844

View File

@ -816,7 +816,11 @@ void Triple::setOS(OSType Kind) {
}
void Triple::setEnvironment(EnvironmentType Kind) {
setEnvironmentName(getEnvironmentTypeName(Kind));
if (ObjectFormat == getDefaultFormat(*this))
return setEnvironmentName(getEnvironmentTypeName(Kind));
setEnvironmentName((getEnvironmentTypeName(Kind) + Twine("-") +
getObjectFormatTypeName(ObjectFormat)).str());
}
void Triple::setObjectFormat(ObjectFormatType Kind) {