[lld] r234676 - Revert r234649 "PECOFF: Use C++11 braced init list to make Version objects."
Nico Weber
nicolasweber at gmx.de
Fri Apr 10 18:32:53 PDT 2015
Author: nico
Date: Fri Apr 10 20:32:52 2015
New Revision: 234676
URL: http://llvm.org/viewvc/llvm-project?rev=234676&view=rev
Log:
Revert r234649 "PECOFF: Use C++11 braced init list to make Version objects."
This doesn't compile with MSVC 2013:
include\lld/ReaderWriter/PECOFFLinkingContext.h(356) : error C2797:
'lld::PECOFFLinkingContext::_imageVersion': list initialization
inside member initializer list or non-static data member initializer
is not implemented
include\lld/ReaderWriter/PECOFFLinkingContext.h(357) : error C2797:
'lld::PECOFFLinkingContext::_imageVersion': list initialization
inside member initializer list or non-static data member initializer
is not implemented
Modified:
lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
lld/trunk/lib/Driver/WinLinkDriver.cpp
lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
Modified: lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h?rev=234676&r1=234675&r2=234676&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h Fri Apr 10 20:32:52 2015
@@ -35,8 +35,9 @@ public:
PECOFFLinkingContext() { setDeadStripping(true); }
struct Version {
- int major;
- int minor;
+ Version(int v1, int v2) : majorVersion(v1), minorVersion(v2) {}
+ int majorVersion;
+ int minorVersion;
};
struct ExportDesc {
Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=234676&r1=234675&r2=234676&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Fri Apr 10 20:32:52 2015
@@ -132,7 +132,7 @@ static bool parseMemoryOption(StringRef
// Parse an argument for /version or /subsystem. The expected string is
// "<integer>[.<integer>]".
-static bool parseVersion(StringRef arg, int &major, int &minor) {
+static bool parseVersion(StringRef arg, uint32_t &major, uint32_t &minor) {
StringRef majorVersion, minorVersion;
std::tie(majorVersion, minorVersion) = arg.split('.');
if (minorVersion.empty())
@@ -166,12 +166,12 @@ static llvm::COFF::WindowsSubsystem stri
// "subsystem_name[,majorOSVersion[.minorOSVersion]]".
static bool parseSubsystem(StringRef arg,
llvm::COFF::WindowsSubsystem &subsystem,
- llvm::Optional<int> &major,
- llvm::Optional<int> &minor, raw_ostream &diag) {
+ llvm::Optional<uint32_t> &major,
+ llvm::Optional<uint32_t> &minor, raw_ostream &diag) {
StringRef subsystemStr, osVersion;
std::tie(subsystemStr, osVersion) = arg.split(',');
if (!osVersion.empty()) {
- int v1, v2;
+ uint32_t v1, v2;
if (!parseVersion(osVersion, v1, v2))
return false;
major = v1;
@@ -1005,10 +1005,10 @@ bool WinLinkDriver::parse(int argc, cons
}
if (auto *arg = parsedArgs->getLastArg(OPT_version)) {
- int major, minor;
+ uint32_t major, minor;
if (!parseVersion(arg->getValue(), major, minor))
return false;
- ctx.setImageVersion({major, minor});
+ ctx.setImageVersion(PECOFFLinkingContext::Version(major, minor));
}
// Parse /merge:<from>=<to>.
@@ -1026,12 +1026,12 @@ bool WinLinkDriver::parse(int argc, cons
// Parse /subsystem:<subsystem>[,<majorOSVersion>[.<minorOSVersion>]].
if (auto *arg = parsedArgs->getLastArg(OPT_subsystem)) {
llvm::COFF::WindowsSubsystem subsystem;
- llvm::Optional<int> major, minor;
+ llvm::Optional<uint32_t> major, minor;
if (!parseSubsystem(arg->getValue(), subsystem, major, minor, diag))
return false;
ctx.setSubsystem(subsystem);
if (major.hasValue())
- ctx.setMinOSVersion({*major, *minor});
+ ctx.setMinOSVersion(PECOFFLinkingContext::Version(*major, *minor));
}
// Parse /section:name,[[!]{DEKPRSW}]
@@ -1143,7 +1143,8 @@ bool WinLinkDriver::parse(int argc, cons
if (name->getBaseAddress() && ctx.getBaseAddress())
ctx.setBaseAddress(name->getBaseAddress());
} else if (auto *ver = dyn_cast<moduledef::Version>(dir)) {
- ctx.setImageVersion({ver->getMajorVersion(), ver->getMinorVersion()});
+ ctx.setImageVersion(PECOFFLinkingContext::Version(
+ ver->getMajorVersion(), ver->getMinorVersion()));
} else {
llvm::dbgs() << static_cast<int>(dir->getKind()) << "\n";
llvm_unreachable("Unknown module-definition directive.\n");
Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=234676&r1=234675&r2=234676&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Fri Apr 10 20:32:52 2015
@@ -435,16 +435,18 @@ PEHeaderChunk<PEHeader>::PEHeaderChunk(c
// The version number of the resultant executable/DLL. The number is purely
// informative, and neither the linker nor the loader won't use it. User can
// set the value using /version command line option. Default is 0.0.
- _peHeader.MajorImageVersion = ctx.getImageVersion().major;
- _peHeader.MinorImageVersion = ctx.getImageVersion().minor;
+ PECOFFLinkingContext::Version imageVersion = ctx.getImageVersion();
+ _peHeader.MajorImageVersion = imageVersion.majorVersion;
+ _peHeader.MinorImageVersion = imageVersion.minorVersion;
// The required Windows version number. This is the internal version and
// shouldn't be confused with product name. Windows 7 is version 6.1 and
// Windows 8 is 6.2, for example.
- _peHeader.MajorOperatingSystemVersion = ctx.getMinOSVersion().major;
- _peHeader.MinorOperatingSystemVersion = ctx.getMinOSVersion().minor;
- _peHeader.MajorSubsystemVersion = ctx.getMinOSVersion().major;
- _peHeader.MinorSubsystemVersion = ctx.getMinOSVersion().minor;
+ PECOFFLinkingContext::Version minOSVersion = ctx.getMinOSVersion();
+ _peHeader.MajorOperatingSystemVersion = minOSVersion.majorVersion;
+ _peHeader.MinorOperatingSystemVersion = minOSVersion.minorVersion;
+ _peHeader.MajorSubsystemVersion = minOSVersion.majorVersion;
+ _peHeader.MinorSubsystemVersion = minOSVersion.minorVersion;
_peHeader.Subsystem = ctx.getSubsystem();
Modified: lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=234676&r1=234675&r2=234676&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp Fri Apr 10 20:32:52 2015
@@ -45,8 +45,8 @@ TEST_F(WinLinkParserTest, Basic) {
// Unspecified flags will have default values.
EXPECT_FALSE(_ctx.isDll());
- EXPECT_EQ(6, _ctx.getMinOSVersion().major);
- EXPECT_EQ(0, _ctx.getMinOSVersion().minor);
+ EXPECT_EQ(6, _ctx.getMinOSVersion().majorVersion);
+ EXPECT_EQ(0, _ctx.getMinOSVersion().minorVersion);
EXPECT_EQ(0x400000U, _ctx.getBaseAddress());
EXPECT_EQ(1024 * 1024U, _ctx.getStackReserve());
EXPECT_EQ(4096U, _ctx.getStackCommit());
@@ -230,28 +230,28 @@ TEST_F(WinLinkParserTest, MachineUnknown
TEST_F(WinLinkParserTest, MajorImageVersion) {
EXPECT_TRUE(parse("link.exe", "/version:7", "foo.o", nullptr));
- EXPECT_EQ(7, _ctx.getImageVersion().major);
- EXPECT_EQ(0, _ctx.getImageVersion().minor);
+ EXPECT_EQ(7, _ctx.getImageVersion().majorVersion);
+ EXPECT_EQ(0, _ctx.getImageVersion().minorVersion);
}
TEST_F(WinLinkParserTest, MajorMinorImageVersion) {
EXPECT_TRUE(parse("link.exe", "/version:72.35", "foo.o", nullptr));
- EXPECT_EQ(72, _ctx.getImageVersion().major);
- EXPECT_EQ(35, _ctx.getImageVersion().minor);
+ EXPECT_EQ(72, _ctx.getImageVersion().majorVersion);
+ EXPECT_EQ(35, _ctx.getImageVersion().minorVersion);
}
TEST_F(WinLinkParserTest, MinMajorOSVersion) {
EXPECT_TRUE(parse("link.exe", "/subsystem:windows,3", "foo.o", nullptr));
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_GUI, _ctx.getSubsystem());
- EXPECT_EQ(3, _ctx.getMinOSVersion().major);
- EXPECT_EQ(0, _ctx.getMinOSVersion().minor);
+ EXPECT_EQ(3, _ctx.getMinOSVersion().majorVersion);
+ EXPECT_EQ(0, _ctx.getMinOSVersion().minorVersion);
}
TEST_F(WinLinkParserTest, MinMajorMinorOSVersion) {
EXPECT_TRUE(parse("link.exe", "/subsystem:windows,3.1", "foo.o", nullptr));
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_GUI, _ctx.getSubsystem());
- EXPECT_EQ(3, _ctx.getMinOSVersion().major);
- EXPECT_EQ(1, _ctx.getMinOSVersion().minor);
+ EXPECT_EQ(3, _ctx.getMinOSVersion().majorVersion);
+ EXPECT_EQ(1, _ctx.getMinOSVersion().minorVersion);
}
TEST_F(WinLinkParserTest, Base) {
More information about the llvm-commits
mailing list