[llvm] r229160 - Triple: Make setEnvironment not override the object format

Reid Kleckner reid at kleckner.net
Fri Feb 13 14:05:50 PST 2015


Author: rnk
Date: Fri Feb 13 16:05:50 2015
New Revision: 229160

URL: http://llvm.org/viewvc/llvm-project?rev=229160&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/Support/Triple.cpp

Modified: llvm/trunk/lib/Support/Triple.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=229160&r1=229159&r2=229160&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Triple.cpp (original)
+++ llvm/trunk/lib/Support/Triple.cpp Fri Feb 13 16:05:50 2015
@@ -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) {





More information about the llvm-commits mailing list