[llvm] r205130 - Support: correct Windows normalisation
Saleem Abdulrasool
compnerd at compnerd.org
Sun Mar 30 00:19:32 PDT 2014
Author: compnerd
Date: Sun Mar 30 02:19:31 2014
New Revision: 205130
URL: http://llvm.org/viewvc/llvm-project?rev=205130&view=rev
Log:
Support: correct Windows normalisation
If the environment is unknown and no object file is provided, then assume an
"MSVC" environment, otherwise, set the environment to the object file format.
In the case that we have a known environment but a non-native file format for
Windows (COFF) which is used for MCJIT, then append the custom file format to
the triple as an additional component.
This fixes the MCJIT tests on Windows.
Modified:
llvm/trunk/lib/Support/Triple.cpp
llvm/trunk/unittests/ADT/TripleTest.cpp
Modified: llvm/trunk/lib/Support/Triple.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=205130&r1=205129&r2=205130&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Triple.cpp (original)
+++ llvm/trunk/lib/Support/Triple.cpp Sun Mar 30 02:19:31 2014
@@ -434,6 +434,8 @@ std::string Triple::normalize(StringRef
if (Components.size() > 3)
Environment = parseEnvironment(Components[3]);
ObjectFormatType ObjectFormat = UnknownObjectFormat;
+ if (Components.size() > 4)
+ ObjectFormat = parseFormat(Components[4]);
// Note which components are already in their final position. These will not
// be moved.
@@ -544,8 +546,16 @@ std::string Triple::normalize(StringRef
if (OS == Triple::Win32) {
Components.resize(4);
Components[2] = "windows";
- if (Environment == UnknownEnvironment && ObjectFormat == UnknownObjectFormat)
- Components[3] = "msvc";
+ if (Environment == UnknownEnvironment) {
+ if (ObjectFormat == UnknownObjectFormat)
+ Components[3] = "msvc";
+ else
+ Components[3] = getObjectFormatTypeName(ObjectFormat);
+ } else if (ObjectFormat != UnknownObjectFormat &&
+ ObjectFormat != Triple::COFF) {
+ Components.resize(5);
+ Components[4] = getObjectFormatTypeName(ObjectFormat);
+ }
} else if (OS == Triple::MinGW32) {
Components.resize(4);
Components[2] = "windows";
Modified: llvm/trunk/unittests/ADT/TripleTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/TripleTest.cpp?rev=205130&r1=205129&r2=205130&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/TripleTest.cpp (original)
+++ llvm/trunk/unittests/ADT/TripleTest.cpp Sun Mar 30 02:19:31 2014
@@ -513,6 +513,13 @@ TEST(TripleTest, FileFormat) {
EXPECT_EQ(Triple::COFF, Triple("i686--win32").getObjectFormat());
+ EXPECT_EQ(Triple::ELF, Triple("i686-pc-windows-msvc-elf").getObjectFormat());
+
+ {
+ Triple Normalized(Triple::normalize("i686-pc-windows-msvc-elf"));
+ EXPECT_EQ(Triple::ELF, Normalized.getObjectFormat());
+ }
+
Triple T = Triple("");
T.setObjectFormat(Triple::ELF);
EXPECT_EQ(Triple::ELF, T.getObjectFormat());
@@ -546,5 +553,7 @@ TEST(TripleTest, NormalizeWindows) {
EXPECT_EQ("x86_64--windows-macho", Triple::normalize("x86_64-win32-macho"));
EXPECT_EQ("i686-pc-windows-itanium", Triple::normalize("i686-pc-windows-itanium"));
+
+ EXPECT_EQ("i686-pc-windows-msvc", Triple::normalize("i686-pc-windows-msvc"));
}
}
More information about the llvm-commits
mailing list