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

Eric Christopher echristo at gmail.com
Fri Feb 13 14:40:18 PST 2015


Bleh, nice catch.

How about a nice comment of why you're doing it? Maybe a unittest? :)

-eric

On Fri Feb 13 2015 at 2:11:26 PM Reid Kleckner <reid at kleckner.net> wrote:

> 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) {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150213/03b59f99/attachment.html>


More information about the llvm-commits mailing list