summaryrefslogtreecommitdiffstats
path: root/lld
diff options
context:
space:
mode:
Diffstat (limited to 'lld')
-rw-r--r--lld/lib/Driver/CoreDriver.cpp9
-rw-r--r--lld/lib/Driver/DarwinLdDriver.cpp34
-rw-r--r--lld/lib/Driver/Driver.cpp12
-rw-r--r--lld/lib/Driver/GnuLdDriver.cpp23
-rw-r--r--lld/lib/Driver/UniversalDriver.cpp2
-rw-r--r--lld/lib/Driver/WinLinkDriver.cpp32
-rw-r--r--lld/lib/ReaderWriter/CoreLinkingContext.cpp2
-rw-r--r--lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp2
-rw-r--r--lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp10
-rw-r--r--lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp12
-rw-r--r--lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp4
-rw-r--r--lld/tools/lld/lld.cpp5
-rw-r--r--lld/unittests/DriverTests/DarwinLdDriverTest.cpp70
-rw-r--r--lld/unittests/DriverTests/GnuLdDriverTest.cpp8
-rw-r--r--lld/unittests/DriverTests/WinLinkDriverTest.cpp145
15 files changed, 180 insertions, 190 deletions
diff --git a/lld/lib/Driver/CoreDriver.cpp b/lld/lib/Driver/CoreDriver.cpp
index 7a949b70993..074ae981fbb 100644
--- a/lld/lib/Driver/CoreDriver.cpp
+++ b/lld/lib/Driver/CoreDriver.cpp
@@ -68,9 +68,8 @@ namespace lld {
bool CoreDriver::link(int argc, const char *argv[], raw_ostream &diagnostics) {
CoreLinkingContext info;
- if (parse(argc, argv, info))
- return true;
-
+ if (!parse(argc, argv, info))
+ return false;
return Driver::link(info);
}
@@ -87,7 +86,7 @@ bool CoreDriver::parse(int argc, const char *argv[], CoreLinkingContext &ctx,
diagnostics << "error: missing arg value for '"
<< parsedArgs->getArgString(missingIndex) << "' expected "
<< missingCount << " argument(s).\n";
- return true;
+ return false;
}
std::unique_ptr<InputGraph> inputGraph(new InputGraph());
@@ -148,7 +147,7 @@ bool CoreDriver::parse(int argc, const char *argv[], CoreLinkingContext &ctx,
if (!inputGraph->numFiles()) {
diagnostics << "No input files\n";
- return true;
+ return false;
}
ctx.setInputGraph(std::move(inputGraph));
diff --git a/lld/lib/Driver/DarwinLdDriver.cpp b/lld/lib/Driver/DarwinLdDriver.cpp
index eb8bd2aa027..82fc078ac94 100644
--- a/lld/lib/Driver/DarwinLdDriver.cpp
+++ b/lld/lib/Driver/DarwinLdDriver.cpp
@@ -82,11 +82,10 @@ MachOFileNode::createLinkerInput(const LinkingContext &ctx) {
bool DarwinLdDriver::linkMachO(int argc, const char *argv[],
raw_ostream &diagnostics) {
MachOLinkingContext ctx;
- if (parse(argc, argv, ctx, diagnostics))
- return true;
- if (ctx.doNothing())
+ if (!parse(argc, argv, ctx, diagnostics))
return false;
-
+ if (ctx.doNothing())
+ return true;
return link(ctx, diagnostics);
}
@@ -104,7 +103,7 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
diagnostics << "error: missing arg value for '"
<< parsedArgs->getArgString(missingIndex) << "' expected "
<< missingCount << " argument(s).\n";
- return true;
+ return false;
}
for (auto it = parsedArgs->filtered_begin(OPT_UNKNOWN),
@@ -168,12 +167,12 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
if (ctx.outputFileType() != mach_o::MH_DYLIB) {
diagnostics
<< "error: -compatibility_version can only be used with -dylib\n";
- return true;
+ return false;
}
uint32_t parsedVers;
if (MachOLinkingContext::parsePackedVersion(vers->getValue(), parsedVers)) {
diagnostics << "error: -compatibility_version value is malformed\n";
- return true;
+ return false;
}
ctx.setCompatibilityVersion(parsedVers);
}
@@ -181,12 +180,12 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
if (llvm::opt::Arg *vers = parsedArgs->getLastArg(OPT_current_version)) {
if (ctx.outputFileType() != mach_o::MH_DYLIB) {
diagnostics << "-current_version can only be used with -dylib\n";
- return true;
+ return false;
}
uint32_t parsedVers;
if (MachOLinkingContext::parsePackedVersion(vers->getValue(), parsedVers)) {
diagnostics << "error: -current_version value is malformed\n";
- return true;
+ return false;
}
ctx.setCurrentVersion(parsedVers);
}
@@ -201,7 +200,7 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
if (ctx.arch() == MachOLinkingContext::arch_unknown) {
diagnostics << "error: unknown arch named '" << archStr->getValue()
<< "'\n";
- return true;
+ return false;
}
}
@@ -214,20 +213,20 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
case OPT_macosx_version_min:
if (ctx.setOS(MachOLinkingContext::OS::macOSX, minOS->getValue())) {
diagnostics << "error: malformed macosx_version_min value\n";
- return true;
+ return false;
}
break;
case OPT_ios_version_min:
if (ctx.setOS(MachOLinkingContext::OS::iOS, minOS->getValue())) {
diagnostics << "error: malformed ios_version_min value\n";
- return true;
+ return false;
}
break;
case OPT_ios_simulator_version_min:
if (ctx.setOS(MachOLinkingContext::OS::iOS_simulator,
minOS->getValue())) {
diagnostics << "error: malformed ios_simulator_version_min value\n";
- return true;
+ return false;
}
break;
}
@@ -242,7 +241,7 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
// If only -help on command line, don't try to do any linking
if (argc == 2) {
ctx.setDoNothing(true);
- return false;
+ return true;
}
}
@@ -258,16 +257,13 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
if (!inputGraph->numFiles()) {
diagnostics << "No input files\n";
- return true;
+ return false;
}
ctx.setInputGraph(std::move(inputGraph));
// Validate the combination of options used.
- if (ctx.validate(diagnostics))
- return true;
-
- return false;
+ return ctx.validate(diagnostics);
}
} // namespace lld
diff --git a/lld/lib/Driver/Driver.cpp b/lld/lib/Driver/Driver.cpp
index 33917f3b737..8c61ca8686f 100644
--- a/lld/lib/Driver/Driver.cpp
+++ b/lld/lib/Driver/Driver.cpp
@@ -42,7 +42,7 @@ bool Driver::link(const LinkingContext &context, raw_ostream &diagnostics) {
}
InputGraph &inputGraph = context.inputGraph();
if (!inputGraph.numFiles())
- return true;
+ return false;
// Read inputs
ScopedTask readTask(getDefaultDomain(), "Read Args");
@@ -58,7 +58,7 @@ bool Driver::link(const LinkingContext &context, raw_ostream &diagnostics) {
auto linkerInput = fileNode->createLinkerInput(context);
if (!linkerInput) {
llvm::outs() << fileNode->errStr(error_code(linkerInput)) << "\n";
- return true;
+ return false;
}
linkerInputs.push_back(std::move(*linkerInput));
}
@@ -84,7 +84,7 @@ bool Driver::link(const LinkingContext &context, raw_ostream &diagnostics) {
readTask.end();
if (fail)
- return true;
+ return false;
InputFiles inputs;
@@ -105,7 +105,7 @@ bool Driver::link(const LinkingContext &context, raw_ostream &diagnostics) {
Resolver resolver(context, inputs);
if (resolver.resolve()) {
if (!context.allowRemainingUndefines())
- return true;
+ return false;
}
MutableFile &merged = resolver.resultFile();
resolveTask.end();
@@ -122,10 +122,10 @@ bool Driver::link(const LinkingContext &context, raw_ostream &diagnostics) {
if (error_code ec = context.writeFile(merged)) {
diagnostics << "Failed to write file '" << context.outputPath()
<< "': " << ec.message() << "\n";
- return true;
+ return false;
}
- return false;
+ return true;
}
} // namespace
diff --git a/lld/lib/Driver/GnuLdDriver.cpp b/lld/lib/Driver/GnuLdDriver.cpp
index 410b6cb6806..89d000166c6 100644
--- a/lld/lib/Driver/GnuLdDriver.cpp
+++ b/lld/lib/Driver/GnuLdDriver.cpp
@@ -98,11 +98,10 @@ std::string ELFFileNode::errStr(llvm::error_code errc) {
bool GnuLdDriver::linkELF(int argc, const char *argv[],
raw_ostream &diagnostics) {
std::unique_ptr<ELFLinkingContext> options;
- bool error = parse(argc, argv, options, diagnostics);
- if (error)
- return true;
- if (!options)
+ if (!parse(argc, argv, options, diagnostics))
return false;
+ if (!options)
+ return true;
return link(*options, diagnostics);
}
@@ -122,13 +121,13 @@ bool GnuLdDriver::parse(int argc, const char *argv[],
diagnostics << "error: missing arg value for '"
<< parsedArgs->getArgString(missingIndex) << "' expected "
<< missingCount << " argument(s).\n";
- return true;
+ return false;
}
// Handle --help
if (parsedArgs->getLastArg(OPT_help)) {
table.PrintHelp(llvm::outs(), argv[0], "LLVM Linker", false);
- return false;
+ return true;
}
// Use -target or use default target triple to instantiate LinkingContext
@@ -141,7 +140,7 @@ bool GnuLdDriver::parse(int argc, const char *argv[],
if (!ctx) {
diagnostics << "unknown target triple\n";
- return true;
+ return false;
}
std::unique_ptr<InputGraph> inputGraph(new InputGraph());
@@ -276,7 +275,7 @@ bool GnuLdDriver::parse(int argc, const char *argv[],
(llvm::dyn_cast<ControlNode>)(controlNodeStack.top())
->processControlExit();
controlNodeStack.pop();
- return false;
+ return true;
case OPT_INPUT:
case OPT_l: {
@@ -323,7 +322,7 @@ bool GnuLdDriver::parse(int argc, const char *argv[],
if (!inputGraph->numFiles()) {
diagnostics << "No input files\n";
- return true;
+ return false;
}
inputGraph->addInternalFile(ctx->createInternalFiles());
@@ -348,14 +347,14 @@ bool GnuLdDriver::parse(int argc, const char *argv[],
inputGraph->dump(diagnostics);
// Validate the combination of options used.
- if (ctx->validate(diagnostics))
- return true;
+ if (!ctx->validate(diagnostics))
+ return false;
ctx->setInputGraph(std::move(inputGraph));
context.swap(ctx);
- return false;
+ return true;
}
/// Get the default target triple based on either the program name
diff --git a/lld/lib/Driver/UniversalDriver.cpp b/lld/lib/Driver/UniversalDriver.cpp
index fb4d498000f..a26c83503c1 100644
--- a/lld/lib/Driver/UniversalDriver.cpp
+++ b/lld/lib/Driver/UniversalDriver.cpp
@@ -129,7 +129,7 @@ bool UniversalDriver::link(int argc, const char *argv[],
case Flavor::core:
return CoreDriver::link(args.size(), args.data(), diagnostics);
case Flavor::invalid:
- return true;
+ return false;
}
llvm_unreachable("Unrecognised flavor");
}
diff --git a/lld/lib/Driver/WinLinkDriver.cpp b/lld/lib/Driver/WinLinkDriver.cpp
index 758d307e4c9..8c769a70358 100644
--- a/lld/lib/Driver/WinLinkDriver.cpp
+++ b/lld/lib/Driver/WinLinkDriver.cpp
@@ -257,8 +257,8 @@ bool WinLinkDriver::linkPECOFF(int argc, const char *argv[],
PECOFFLinkingContext context;
std::vector<const char *> newargv = processLinkEnv(context, argc, argv);
processLibEnv(context);
- if (parse(newargv.size() - 1, &newargv[0], context, diagnostics))
- return true;
+ if (!parse(newargv.size() - 1, &newargv[0], context, diagnostics))
+ return false;
return link(context, diagnostics);
}
@@ -269,7 +269,7 @@ bool WinLinkDriver::parse(int argc, const char *argv[], PECOFFLinkingContext &ct
std::unique_ptr<llvm::opt::InputArgList> parsedArgs = parseArgs(
argc, argv, diagnostics, isDirective);
if (!parsedArgs)
- return true;
+ return false;
if (!ctx.hasInputGraph())
ctx.setInputGraph(std::unique_ptr<InputGraph>(new InputGraph()));
@@ -280,7 +280,7 @@ bool WinLinkDriver::parse(int argc, const char *argv[], PECOFFLinkingContext &ct
if (parsedArgs->getLastArg(OPT_help)) {
WinLinkOptTable table;
table.PrintHelp(llvm::outs(), argv[0], "LLVM Linker", false);
- return true;
+ return false;
}
// Handle /nodefaultlib:<lib>. The same option without argument is handled in
@@ -316,7 +316,7 @@ bool WinLinkDriver::parse(int argc, const char *argv[], PECOFFLinkingContext &ct
// it's smaller than the actual size, the linker should warn about that.
// Currently we just ignore the value of size parameter.
if (parseMemoryOption(inputArg->getValue(), addr, size))
- return true;
+ return false;
ctx.setBaseAddress(addr);
break;
@@ -325,7 +325,7 @@ bool WinLinkDriver::parse(int argc, const char *argv[], PECOFFLinkingContext &ct
uint64_t reserve;
uint64_t commit = ctx.getStackCommit();
if (parseMemoryOption(inputArg->getValue(), reserve, commit))
- return true;
+ return false;
ctx.setStackReserve(reserve);
ctx.setStackCommit(commit);
break;
@@ -336,7 +336,7 @@ bool WinLinkDriver::parse(int argc, const char *argv[], PECOFFLinkingContext &ct
uint64_t reserve;
uint64_t commit = ctx.getHeapCommit();
if (parseMemoryOption(inputArg->getValue(), reserve, commit))
- return true;
+ return false;
ctx.setHeapReserve(reserve);
ctx.setHeapCommit(commit);
break;
@@ -347,7 +347,7 @@ bool WinLinkDriver::parse(int argc, const char *argv[], PECOFFLinkingContext &ct
StringRef arg = inputArg->getValue();
if (arg.getAsInteger(10, align)) {
diagnostics << "error: invalid value for /align: " << arg << "\n";
- return true;
+ return false;
}
ctx.setSectionAlignment(align);
break;
@@ -358,7 +358,7 @@ bool WinLinkDriver::parse(int argc, const char *argv[], PECOFFLinkingContext &ct
llvm::COFF::MachineTypes type = stringToMachineType(arg);
if (type == llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN) {
diagnostics << "error: unknown machine type: " << arg << "\n";
- return true;
+ return false;
}
ctx.setMachineType(type);
break;
@@ -367,7 +367,7 @@ bool WinLinkDriver::parse(int argc, const char *argv[], PECOFFLinkingContext &ct
case OPT_version: {
uint32_t major, minor;
if (parseVersion(inputArg->getValue(), major, minor))
- return true;
+ return false;
ctx.setImageVersion(PECOFFLinkingContext::Version(major, minor));
break;
}
@@ -381,7 +381,7 @@ bool WinLinkDriver::parse(int argc, const char *argv[], PECOFFLinkingContext &ct
if (!osVersion.empty()) {
uint32_t major, minor;
if (parseVersion(osVersion, major, minor))
- return true;
+ return false;
ctx.setMinOSVersion(PECOFFLinkingContext::Version(major, minor));
}
// Parse subsystem name.
@@ -390,7 +390,7 @@ bool WinLinkDriver::parse(int argc, const char *argv[], PECOFFLinkingContext &ct
if (subsystem == llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN) {
diagnostics << "error: unknown subsystem name: " << subsystemStr
<< "\n";
- return true;
+ return false;
}
ctx.setSubsystem(subsystem);
break;
@@ -399,7 +399,7 @@ bool WinLinkDriver::parse(int argc, const char *argv[], PECOFFLinkingContext &ct
case OPT_failifmismatch:
if (handleFailIfMismatchOption(inputArg->getValue(), failIfMismatchMap,
diagnostics))
- return true;
+ return false;
break;
case OPT_entry:
@@ -427,7 +427,7 @@ bool WinLinkDriver::parse(int argc, const char *argv[], PECOFFLinkingContext &ct
// /fixed is not compatible with /dynamicbase. Check for it.
if (parsedArgs->getLastArg(OPT_dynamicbase)) {
diagnostics << "/dynamicbase must not be specified with /fixed\n";
- return true;
+ return false;
}
ctx.setBaseRelocationEnabled(false);
ctx.setDynamicBaseEnabled(false);
@@ -493,7 +493,7 @@ bool WinLinkDriver::parse(int argc, const char *argv[], PECOFFLinkingContext &ct
// Specifying both /opt:ref and /opt:noref is an error.
if (parsedArgs->getLastArg(OPT_ref) && parsedArgs->getLastArg(OPT_ref_no)) {
diagnostics << "/opt:ref must not be specified with /opt:noref\n";
- return true;
+ return false;
}
// If dead-stripping is enabled, we need to add the entry symbol and
@@ -525,7 +525,7 @@ bool WinLinkDriver::parse(int argc, const char *argv[], PECOFFLinkingContext &ct
if (!inputGraph.numFiles()) {
diagnostics << "No input files\n";
- return true;
+ return false;
}
// A list of undefined symbols will be added to the input
diff --git a/lld/lib/ReaderWriter/CoreLinkingContext.cpp b/lld/lib/ReaderWriter/CoreLinkingContext.cpp
index 8f89f1d4a6a..fdc56ec7588 100644
--- a/lld/lib/ReaderWriter/CoreLinkingContext.cpp
+++ b/lld/lib/ReaderWriter/CoreLinkingContext.cpp
@@ -272,7 +272,7 @@ private:
CoreLinkingContext::CoreLinkingContext() {}
bool CoreLinkingContext::validateImpl(raw_ostream &diagnostics) {
- return false;
+ return true;
}
void CoreLinkingContext::addPasses(PassManager &pm) const {
diff --git a/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp b/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
index 15769971b18..30cdd2b5195 100644
--- a/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
+++ b/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
@@ -91,7 +91,7 @@ bool ELFLinkingContext::validateImpl(raw_ostream &diagnostics) {
_writer = createWriterELF(*this);
break;
}
- return false;
+ return true;
}
bool ELFLinkingContext::isDynamic() const {
diff --git a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
index 39996f47ed4..b8f7b4e55d9 100644
--- a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
@@ -207,28 +207,28 @@ bool MachOLinkingContext::validateImpl(raw_ostream &diagnostics) {
if (_currentVersion && _outputFileType != mach_o::MH_DYLIB) {
diagnostics << "error: -current_version can only be used with dylibs\n";
- return true;
+ return false;
}
if (_compatibilityVersion && _outputFileType != mach_o::MH_DYLIB) {
diagnostics
<< "error: -compatibility_version can only be used with dylibs\n";
- return true;
+ return false;
}
if (_deadStrippableDylib && _outputFileType != mach_o::MH_DYLIB) {
diagnostics
<< "error: -mark_dead_strippable_dylib can only be used with dylibs.\n";
- return true;
+ return false;
}
if (!_bundleLoader.empty() && outputFileType() != mach_o::MH_BUNDLE) {
diagnostics
<< "error: -bundle_loader can only be used with Mach-O bundles\n";
- return true;
+ return false;
}
- return false;
+ return true;
}
bool MachOLinkingContext::setOS(OS os, StringRef minOSVersion) {
diff --git a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
index b10ca4d0484..db6a0ea1f3c 100644
--- a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
+++ b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
@@ -40,39 +40,39 @@ bool PECOFFLinkingContext::validateImpl(raw_ostream &diagnostics) {
diagnostics << "Invalid stack size: reserve size must be equal to or "
<< "greater than commit size, but got " << _stackCommit
<< " and " << _stackReserve << ".\n";
- return true;
+ return false;
}
if (_heapReserve < _heapCommit) {
diagnostics << "Invalid heap size: reserve size must be equal to or "
<< "greater than commit size, but got " << _heapCommit
<< " and " << _heapReserve << ".\n";
- return true;
+ return false;
}
// It's an error if the base address is not multiple of 64K.
if (_baseAddress & 0xffff) {
diagnostics << "Base address have to be multiple of 64K, but got "
<< _baseAddress << "\n";
- return true;
+ return false;
}
std::bitset<64> alignment(_sectionAlignment);
if (alignment.count() != 1) {
diagnostics << "Section alignment must be a power of 2, but got "
<< _sectionAlignment << "\n";
- return true;
+ return false;
}
// Architectures other than i386 is not supported yet.
if (_machineType != llvm::COFF::IMAGE_FILE_MACHINE_I386) {
diagnostics << "Machine type other than x86 is not supported.\n";
- return true;
+ return false;
}
_reader = createReaderPECOFF(*this);
_writer = createWriterPECOFF(*this);
- return false;
+ return true;
}
std::unique_ptr<File> PECOFFLinkingContext::createEntrySymbolFile() {
diff --git a/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp b/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
index 2e1695394af..453c51f1f26 100644
--- a/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
+++ b/lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
@@ -762,8 +762,8 @@ private:
const char **argv = &tokens[0];
std::string errorMessage;
llvm::raw_string_ostream stream(errorMessage);
- bool parseFailed = WinLinkDriver::parse(argc, argv, _PECOFFLinkingContext,
- stream, /*isDirective*/ true);
+ bool parseFailed = !WinLinkDriver::parse(argc, argv, _PECOFFLinkingContext,
+ stream, /*isDirective*/ true);
stream.flush();
// Print error message if error.
diff --git a/lld/tools/lld/lld.cpp b/lld/tools/lld/lld.cpp
index 6f7a9337ed6..171c018a638 100644
--- a/lld/tools/lld/lld.cpp
+++ b/lld/tools/lld/lld.cpp
@@ -33,8 +33,5 @@ int main(int argc, const char *argv[]) {
llvm::PrettyStackTraceProgram stackPrinter(argc, argv);
llvm::llvm_shutdown_obj shutdown;
- if (UniversalDriver::link(argc, argv))
- return 1;
- else
- return 0;
+ return UniversalDriver::link(argc, argv) ? 0 : 1;
}
diff --git a/lld/unittests/DriverTests/DarwinLdDriverTest.cpp b/lld/unittests/DriverTests/DarwinLdDriverTest.cpp
index 494c877b4a5..1af1a34fad5 100644
--- a/lld/unittests/DriverTests/DarwinLdDriverTest.cpp
+++ b/lld/unittests/DriverTests/DarwinLdDriverTest.cpp
@@ -29,7 +29,7 @@ protected:
};
TEST_F(DarwinLdParserTest, Basic) {
- EXPECT_FALSE(parse("ld", "foo.o", "bar.o", nullptr));
+ EXPECT_TRUE(parse("ld", "foo.o", "bar.o", nullptr));
EXPECT_FALSE(_context.allowRemainingUndefines());
EXPECT_FALSE(_context.deadStrip());
EXPECT_EQ(2, inputFileCount());
@@ -38,187 +38,187 @@ TEST_F(DarwinLdParserTest, Basic) {
}
TEST_F(DarwinLdParserTest, Output) {
- EXPECT_FALSE(parse("ld", "-o", "my.out", "foo.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-o", "my.out", "foo.o", nullptr));
EXPECT_EQ("my.out", _context.outputPath());
}
TEST_F(DarwinLdParserTest, Dylib) {
- EXPECT_FALSE(parse("ld", "-dylib", "foo.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-dylib", "foo.o", nullptr));
EXPECT_EQ(mach_o::MH_DYLIB, _context.outputFileType());
}
TEST_F(DarwinLdParserTest, Relocatable) {
- EXPECT_FALSE(parse("ld", "-r", "foo.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-r", "foo.o", nullptr));
EXPECT_EQ(mach_o::MH_OBJECT, _context.outputFileType());
}
TEST_F(DarwinLdParserTest, Bundle) {
- EXPECT_FALSE(parse("ld", "-bundle", "foo.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-bundle", "foo.o", nullptr));
EXPECT_EQ(mach_o::MH_BUNDLE, _context.outputFileType());
}
TEST_F(DarwinLdParserTest, Preload) {
- EXPECT_FALSE(parse("ld", "-preload", "foo.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-preload", "foo.o", nullptr));
EXPECT_EQ(mach_o::MH_PRELOAD, _context.outputFileType());
}
TEST_F(DarwinLdParserTest, Static) {
- EXPECT_FALSE(parse("ld", "-static", "foo.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-static", "foo.o", nullptr));
EXPECT_EQ(mach_o::MH_EXECUTE, _context.outputFileType());
}
TEST_F(DarwinLdParserTest, Entry) {
- EXPECT_FALSE(parse("ld", "-e", "entryFunc", "foo.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-e", "entryFunc", "foo.o", nullptr));
EXPECT_EQ("entryFunc", _context.entrySymbolName());
}
TEST_F(DarwinLdParserTest, OutputPath) {
- EXPECT_FALSE(parse("ld", "-o", "foo", "foo.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-o", "foo", "foo.o", nullptr));
EXPECT_EQ("foo", _context.outputPath());
}
TEST_F(DarwinLdParserTest, DeadStrip) {
- EXPECT_FALSE(parse("ld", "-dead_strip", "foo.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-dead_strip", "foo.o", nullptr));
EXPECT_TRUE(_context.deadStrip());
}
TEST_F(DarwinLdParserTest, DeadStripRootsExe) {
- EXPECT_FALSE(parse("ld", "-dead_strip", "foo.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-dead_strip", "foo.o", nullptr));
EXPECT_FALSE(_context.globalsAreDeadStripRoots());
}
TEST_F(DarwinLdParserTest, DeadStripRootsDylib) {
- EXPECT_FALSE(parse("ld", "-dylib", "-dead_strip", "foo.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-dylib", "-dead_strip", "foo.o", nullptr));
EXPECT_TRUE(_context.globalsAreDeadStripRoots());
}
TEST_F(DarwinLdParserTest, Arch) {
- EXPECT_FALSE(parse("ld", "-arch", "x86_64", "foo.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-arch", "x86_64", "foo.o", nullptr));
EXPECT_EQ(MachOLinkingContext::arch_x86_64, _context.arch());
EXPECT_EQ(mach_o::CPU_TYPE_X86_64, _context.getCPUType());
EXPECT_EQ(mach_o::CPU_SUBTYPE_X86_64_ALL, _context.getCPUSubType());
}
TEST_F(DarwinLdParserTest, Arch_x86) {
- EXPECT_FALSE(parse("ld", "-arch", "i386", "foo.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-arch", "i386", "foo.o", nullptr));
EXPECT_EQ(MachOLinkingContext::arch_x86, _context.arch());
EXPECT_EQ(mach_o::CPU_TYPE_I386, _context.getCPUType());
EXPECT_EQ(mach_o::CPU_SUBTYPE_X86_ALL, _context.getCPUSubType());
}
TEST_F(DarwinLdParserTest, Arch_armv6) {
- EXPECT_FALSE(parse("ld", "-arch", "armv6", "foo.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-arch", "armv6", "foo.o", nullptr));
EXPECT_EQ(MachOLinkingContext::arch_armv6, _context.arch());
EXPECT_EQ(mach_o::CPU_TYPE_ARM, _context.getCPUType());
EXPECT_EQ(mach_o::CPU_SUBTYPE_ARM_V6, _context.getCPUSubType());
}
TEST_F(DarwinLdParserTest, Arch_armv7) {
- EXPECT_FALSE(parse("ld", "-arch", "armv7", "foo.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-arch", "armv7", "foo.o", nullptr));
EXPECT_EQ(MachOLinkingContext::arch_armv7, _context.arch());
EXPECT_EQ(mach_o::CPU_TYPE_ARM, _context.getCPUType());
EXPECT_EQ(mach_o::CPU_SUBTYPE_ARM_V7, _context.getCPUSubType());
}
TEST_F(DarwinLdParserTest, Arch_armv7s) {
- EXPECT_FALSE(parse("ld", "-arch", "armv7s", "foo.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-arch", "armv7s", "foo.o", nullptr));
EXPECT_EQ(MachOLinkingContext::arch_armv7s, _context.arch());
EXPECT_EQ(mach_o::CPU_TYPE_ARM, _context.getCPUType());
EXPECT_EQ(mach_o::CPU_SUBTYPE_ARM_V7S, _context.getCPUSubType());
}
TEST_F(DarwinLdParserTest, MinMacOSX10_7) {
- EXPECT_FALSE(parse("ld", "-macosx_version_min", "10.7", "foo.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-macosx_version_min", "10.7", "foo.o", nullptr));
EXPECT_EQ(MachOLinkingContext::OS::macOSX, _context.os());
EXPECT_TRUE(_context.minOS("10.7", ""));
EXPECT_FALSE(_context.minOS("10.8", ""));
}
TEST_F(DarwinLdParserTest, MinMacOSX10_8) {
- EXPECT_FALSE(parse("ld", "-macosx_version_min", "10.8.3", "foo.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-macosx_version_min", "10.8.3", "foo.o", nullptr));
EXPECT_EQ(MachOLinkingContext::OS::macOSX, _context.os());
EXPECT_TRUE(_context.minOS("10.7", ""));
EXPECT_TRUE(_context.minOS("10.8", ""));
}
TEST_F(DarwinLdParserTest, iOS5) {
- EXPECT_FALSE(parse("ld", "-ios_version_min", "5.0", "foo.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-ios_version_min", "5.0", "foo.o", nullptr));
EXPECT_EQ(MachOLinkingContext::OS::iOS, _context.os());
EXPECT_TRUE(_context.minOS("", "5.0"));
EXPECT_FALSE(_context.minOS("", "6.0"));
}
TEST_F(DarwinLdParserTest, iOS6) {
- EXPECT_FALSE(parse("ld", "-ios_version_min", "6.0", "foo.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-ios_version_min", "6.0", "foo.o", nullptr));
EXPECT_EQ(MachOLinkingContext::OS::iOS, _context.os());
EXPECT_TRUE(_context.minOS("", "5.0"));
EXPECT_TRUE(_context.minOS("", "6.0"));
}
TEST_F(DarwinLdParserTest, iOS_Simulator5) {
- EXPECT_FALSE(parse("ld", "-ios_simulator_version_min", "5.0", "a.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-ios_simulator_version_min", "5.0", "a.o", nullptr));
EXPECT_EQ(MachOLinkingContext::OS::iOS_simulator, _context.os());
EXPECT_TRUE(_context.minOS("", "5.0"));
EXPECT_FALSE(_context.minOS("", "6.0"));
}
TEST_F(DarwinLdParserTest, iOS_Simulator6) {
- EXPECT_FALSE(parse("ld", "-ios_simulator_version_min", "6.0", "a.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-ios_simulator_version_min", "6.0", "a.o", nullptr));
EXPECT_EQ(MachOLinkingContext::OS::iOS_simulator, _context.os());
EXPECT_TRUE(_context.minOS("", "5.0"));
EXPECT_TRUE(_context.minOS("", "6.0"));
}
TEST_F(DarwinLdParserTest, compatibilityVersion) {
- EXPECT_FALSE(
+ EXPECT_TRUE(
parse("ld", "-dylib", "-compatibility_version", "1.2.3", "a.o", nullptr));
EXPECT_EQ(_context.compatibilityVersion(), 0x10203U);
}
TEST_F(DarwinLdParserTest, compatibilityVersionInvalidType) {
- EXPECT_TRUE(parse("ld", "-bundle", "-compatibility_version", "1.2.3", "a.o",
- nullptr));
+ EXPECT_FALSE(parse("ld", "-bundle", "-compatibility_version", "1.2.3", "a.o",
+ nullptr));
}
TEST_F(DarwinLdParserTest, compatibilityVersionInvalidValue) {
- EXPECT_TRUE(parse("ld", "-bundle", "-compatibility_version", "1,2,3", "a.o",
- nullptr));
+ EXPECT_FALSE(parse("ld", "-bundle", "-compatibility_version", "1,2,3", "a.o",
+ nullptr));
}
TEST_F(DarwinLdParserTest, currentVersion) {
- EXPECT_FALSE(
+ EXPECT_TRUE(
parse("ld", "-dylib", "-current_version", "1.2.3", "a.o", nullptr));
EXPECT_EQ(_context.currentVersion(), 0x10203U);
}
TEST_F(DarwinLdParserTest, currentVersionInvalidType) {
- EXPECT_TRUE(
+ EXPECT_FALSE(
parse("ld", "-bundle", "-current_version", "1.2.3", "a.o", nullptr));
}
TEST_F(DarwinLdParserTest, currentVersionInvalidValue) {
- EXPECT_TRUE(
+ EXPECT_FALSE(
parse("ld", "-bundle", "-current_version", "1,2,3", "a.o", nullptr));
}
TEST_F(DarwinLdParserTest, bundleLoader) {
- EXPECT_FALSE(
+ EXPECT_TRUE(
parse("ld", "-bundle", "-bundle_loader", "/bin/ls", "a.o", nullptr));
EXPECT_EQ(_context.bundleLoader(), "/bin/ls");
}
TEST_F(DarwinLdParserTest, bundleLoaderInvalidType) {
- EXPECT_TRUE(parse("ld", "-bundle_loader", "/bin/ls", "a.o", nullptr));
+ EXPECT_FALSE(parse("ld", "-bundle_loader", "/bin/ls", "a.o", nullptr));
}
TEST_F(DarwinLdParserTest, deadStrippableDylib) {
- EXPECT_FALSE(
+ EXPECT_TRUE(
parse("ld", "-dylib", "-mark_dead_strippable_dylib", "a.o", nullptr));
EXPECT_EQ(true, _context.deadStrippableDylib());
}
TEST_F(DarwinLdParserTest, deadStrippableDylibInvalidType) {
- EXPECT_TRUE(parse("ld", "-mark_dead_strippable_dylib", "a.o", nullptr));
+ EXPECT_FALSE(parse("ld", "-mark_dead_strippable_dylib", "a.o", nullptr));
}
} // end anonymous namespace
diff --git a/lld/unittests/DriverTests/GnuLdDriverTest.cpp b/lld/unittests/DriverTests/GnuLdDriverTest.cpp
index 62b5847726a..3313fd9f1bd 100644
--- a/lld/unittests/DriverTests/GnuLdDriverTest.cpp
+++ b/lld/unittests/DriverTests/GnuLdDriverTest.cpp
@@ -28,13 +28,13 @@ protected:
};
TEST_F(GnuLdParserTest, Empty) {
- EXPECT_TRUE(parse("ld", nullptr));
+ EXPECT_FALSE(parse("ld", nullptr));
EXPECT_EQ(linkingContext(), nullptr);
EXPECT_EQ("No input files\n", errorMessage());
}
TEST_F(GnuLdParserTest, Basic) {
- EXPECT_FALSE(parse("ld", "infile.o", nullptr));
+ EXPECT_TRUE(parse("ld", "infile.o", nullptr));
EXPECT_NE(linkingContext(), nullptr);
EXPECT_EQ("a.out", linkingContext()->outputPath());
EXPECT_EQ(1, inputFileCount());
@@ -44,8 +44,8 @@ TEST_F(GnuLdParserTest, Basic) {
}
TEST_F(GnuLdParserTest, ManyOptions) {
- EXPECT_FALSE(parse("ld", "-entry", "_start", "-o", "outfile",
- "--output-filetype=yaml", "infile.o", nullptr));
+ EXPECT_TRUE(parse("ld", "-entry", "_start", "-o", "outfile",
+ "--output-filetype=yaml", "infile.o", nullptr));
EXPECT_NE(linkingContext(), nullptr);
EXPECT_EQ("outfile", linkingContext()->outputPath());
EXPECT_EQ("_start", linkingContext()->entrySymbolName());
diff --git a/lld/unittests/DriverTests/WinLinkDriverTest.cpp b/lld/unittests/DriverTests/WinLinkDriverTest.cpp
index 3dee43889f6..55defc838f8 100644
--- a/lld/unittests/DriverTests/WinLinkDriverTest.cpp
+++ b/lld/unittests/DriverTests/WinLinkDriverTest.cpp
@@ -31,8 +31,8 @@ protected:
};
TEST_F(WinLinkParserTest, Basic) {
- EXPECT_FALSE(parse("link.exe", "/subsystem:console", "/out:a.exe",
- "-entry:start", "a.obj", "b.obj", "c.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/subsystem:console", "/out:a.exe",
+ "-entry:start", "a.obj", "b.obj", "c.obj", nullptr));
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, _context.getSubsystem());
EXPECT_EQ(llvm::COFF::IMAGE_FILE_MACHINE_I386, _context.getMachineType());
EXPECT_EQ("a.exe", _context.outputPath());
@@ -64,8 +64,8 @@ TEST_F(WinLinkParserTest, Basic) {
}
TEST_F(WinLinkParserTest, StartsWithHyphen) {
- EXPECT_FALSE(parse("link.exe", "-subsystem:console", "-out:a.exe",
- "a.obj", nullptr));
+ EXPECT_TRUE(
+ parse("link.exe", "-subsystem:console", "-out:a.exe", "a.obj", nullptr));
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, _context.getSubsystem());
EXPECT_EQ("a.exe", _context.outputPath());
EXPECT_EQ(1, inputFileCount());
@@ -73,8 +73,8 @@ TEST_F(WinLinkParserTest, StartsWithHyphen) {
}
TEST_F(WinLinkParserTest, UppercaseOption) {
- EXPECT_FALSE(parse("link.exe", "/SUBSYSTEM:CONSOLE", "/OUT:a.exe", "a.obj",
- nullptr));
+ EXPECT_TRUE(
+ parse("link.exe", "/SUBSYSTEM:CONSOLE", "/OUT:a.exe", "a.obj", nullptr));
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, _context.getSubsystem());
EXPECT_EQ("a.exe", _context.outputPath());
EXPECT_EQ(1, inputFileCount());
@@ -82,14 +82,14 @@ TEST_F(WinLinkParserTest, UppercaseOption) {
}
TEST_F(WinLinkParserTest, Mllvm) {
- EXPECT_FALSE(parse("link.exe", "/mllvm:-debug", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/mllvm:-debug", "a.obj", nullptr));
const std::vector<const char *> &options = _context.llvmOptions();
EXPECT_EQ(1U, options.size());
EXPECT_STREQ("-debug", options[0]);
}
TEST_F(WinLinkParserTest, NoInputFiles) {
- EXPECT_TRUE(parse("link.exe", nullptr));
+ EXPECT_FALSE(parse("link.exe", nullptr));
EXPECT_EQ("No input files\n", errorMessage());
}
@@ -98,7 +98,7 @@ TEST_F(WinLinkParserTest, NoInputFiles) {
//
TEST_F(WinLinkParserTest, NoFileExtension) {
- EXPECT_FALSE(parse("link.exe", "foo", "bar", nullptr));
+ EXPECT_TRUE(parse("link.exe", "foo", "bar", nullptr));
EXPECT_EQ("foo.exe", _context.outputPath());
EXPECT_EQ(2, inputFileCount());
EXPECT_EQ("foo.obj", inputFile(0));
@@ -106,15 +106,15 @@ TEST_F(WinLinkParserTest, NoFileExtension) {
}
TEST_F(WinLinkParserTest, NonStandardFileExtension) {
- EXPECT_FALSE(parse("link.exe", "foo.o", nullptr));
+ EXPECT_TRUE(parse("link.exe", "foo.o", nullptr));
EXPECT_EQ("foo.exe", _context.outputPath());
EXPECT_EQ(1, inputFileCount());
EXPECT_EQ("foo.o", inputFile(0));
}
TEST_F(WinLinkParserTest, Libpath) {
- EXPECT_FALSE(parse("link.exe", "/libpath:dir1", "/libpath:dir2",
- "a.obj", nullptr));
+ EXPECT_TRUE(
+ parse("link.exe", "/libpath:dir1", "/libpath:dir2", "a.obj", nullptr));
const std::vector<StringRef> &paths = _context.getInputSearchPaths();
EXPECT_EQ(2U, paths.size());
EXPECT_EQ("dir1", paths[0]);
@@ -126,100 +126,100 @@ TEST_F(WinLinkParserTest, Libpath) {
//
TEST_F(WinLinkParserTest, MachineX86) {
- EXPECT_FALSE(parse("link.exe", "/machine:x86", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/machine:x86", "a.obj", nullptr));
EXPECT_EQ(llvm::COFF::IMAGE_FILE_MACHINE_I386, _context.getMachineType());
}
TEST_F(WinLinkParserTest, MachineX64) {
- EXPECT_TRUE(parse("link.exe", "/machine:x64", "a.obj", nullptr));
- EXPECT_TRUE(StringRef(errorMessage()).startswith(
- "Machine type other than x86 is not supported"));
+ EXPECT_FALSE(parse("link.exe", "/machine:x64", "a.obj", nullptr));
+ EXPECT_TRUE(StringRef(errorMessage())
+ .startswith("Machine type other than x86 is not supported"));
}
TEST_F(WinLinkParserTest, MajorImageVersion) {
- EXPECT_FALSE(parse("link.exe", "/version:7", "foo.o", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/version:7", "foo.o", nullptr));
EXPECT_EQ(7, _context.getImageVersion().majorVersion);
EXPECT_EQ(0, _context.getImageVersion().minorVersion);
}
TEST_F(WinLinkParserTest, MajorMinorImageVersion) {
- EXPECT_FALSE(parse("link.exe", "/version:72.35", "foo.o", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/version:72.35", "foo.o", nullptr));
EXPECT_EQ(72, _context.getImageVersion().majorVersion);
EXPECT_EQ(35, _context.getImageVersion().minorVersion);
}
TEST_F(WinLinkParserTest, MinMajorOSVersion) {
- EXPECT_FALSE(parse("link.exe", "/subsystem:windows,3", "foo.o", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/subsystem:windows,3", "foo.o", nullptr));
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_GUI, _context.getSubsystem());
EXPECT_EQ(3, _context.getMinOSVersion().majorVersion);
EXPECT_EQ(0, _context.getMinOSVersion().minorVersion);
}
TEST_F(WinLinkParserTest, MinMajorMinorOSVersion) {
- EXPECT_FALSE(parse("link.exe", "/subsystem:windows,3.1", "foo.o", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/subsystem:windows,3.1", "foo.o", nullptr));
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_GUI, _context.getSubsystem());
EXPECT_EQ(3, _context.getMinOSVersion().majorVersion);
EXPECT_EQ(1, _context.getMinOSVersion().minorVersion);
}
TEST_F(WinLinkParserTest, Base) {
- EXPECT_FALSE(parse("link.exe", "/base:8388608", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/base:8388608", "a.obj", nullptr));
EXPECT_EQ(0x800000U, _context.getBaseAddress());
}
TEST_F(WinLinkParserTest, InvalidBase) {
- EXPECT_TRUE(parse("link.exe", "/base:1234", "a.obj", nullptr));
- EXPECT_TRUE(StringRef(errorMessage()).startswith(
- "Base address have to be multiple of 64K"));
+ EXPECT_FALSE(parse("link.exe", "/base:1234", "a.obj", nullptr));
+ EXPECT_TRUE(StringRef(errorMessage())
+ .startswith("Base address have to be multiple of 64K"));
}
TEST_F(WinLinkParserTest, StackReserve) {
- EXPECT_FALSE(parse("link.exe", "/stack:8192", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/stack:8192", "a.obj", nullptr));
EXPECT_EQ(8192U, _context.getStackReserve());
EXPECT_EQ(4096U, _context.getStackCommit());
}
TEST_F(WinLinkParserTest, StackReserveAndCommit) {
- EXPECT_FALSE(parse("link.exe", "/stack:16384,8192", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/stack:16384,8192", "a.obj", nullptr));
EXPECT_EQ(16384U, _context.getStackReserve());
EXPECT_EQ(8192U, _context.getStackCommit());
}
TEST_F(WinLinkParserTest, InvalidStackSize) {
- EXPECT_TRUE(parse("link.exe", "/stack:8192,16384", "a.obj", nullptr));
+ EXPECT_FALSE(parse("link.exe", "/stack:8192,16384", "a.obj", nullptr));
EXPECT_TRUE(StringRef(errorMessage()).startswith("Invalid stack size"));
}
TEST_F(WinLinkParserTest, HeapReserve) {
- EXPECT_FALSE(parse("link.exe", "/heap:8192", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/heap:8192", "a.obj", nullptr));
EXPECT_EQ(8192U, _context.getHeapReserve());
EXPECT_EQ(4096U, _context.getHeapCommit());
}
TEST_F(WinLinkParserTest, HeapReserveAndCommit) {
- EXPECT_FALSE(parse("link.exe", "/heap:16384,8192", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/heap:16384,8192", "a.obj", nullptr));
EXPECT_EQ(16384U, _context.getHeapReserve());
EXPECT_EQ(8192U, _context.getHeapCommit());
}
TEST_F(WinLinkParserTest, InvalidHeapSize) {
- EXPECT_TRUE(parse("link.exe", "/heap:8192,16384", "a.obj", nullptr));
+ EXPECT_FALSE(parse("link.exe", "/heap:8192,16384", "a.obj", nullptr));
EXPECT_TRUE(StringRef(errorMessage()).startswith("Invalid heap size"));
}
TEST_F(WinLinkParserTest, SectionAlignment) {
- EXPECT_FALSE(parse("link.exe", "/align:8192", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/align:8192", "a.obj", nullptr));
EXPECT_EQ(8192U, _context.getSectionAlignment());
}
TEST_F(WinLinkParserTest, InvalidAlignment) {
- EXPECT_TRUE(parse("link.exe", "/align:1000", "a.obj", nullptr));
+ EXPECT_FALSE(parse("link.exe", "/align:1000", "a.obj", nullptr));
EXPECT_EQ("Section alignment must be a power of 2, but got 1000\n",
errorMessage());
}
TEST_F(WinLinkParserTest, Include) {
- EXPECT_FALSE(parse("link.exe", "/include:foo", "a.out", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/include:foo", "a.out", nullptr));
auto symbols = _context.initialUndefinedSymbols();
EXPECT_FALSE(symbols.empty());
EXPECT_EQ("foo", symbols[0]);
@@ -232,8 +232,8 @@ TEST_F(WinLinkParserTest, Include) {
//
TEST_F(WinLinkParserTest, DefaultLib) {
- EXPECT_FALSE(parse("link.exe", "/defaultlib:user32.lib",
- "/defaultlib:kernel32", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/defaultlib:user32.lib",
+ "/defaultlib:kernel32", "a.obj", nullptr));
EXPECT_EQ(3, inputFileCount());
EXPECT_EQ("a.obj", inputFile(0));
EXPECT_EQ("user32.lib", inputFile(1));
@@ -241,18 +241,17 @@ TEST_F(WinLinkParserTest, DefaultLib) {
}
TEST_F(WinLinkParserTest, NoDefaultLib) {
- EXPECT_FALSE(parse("link.exe", "/defaultlib:user32.lib",
- "/defaultlib:kernel32", "/nodefaultlib:user32.lib",
- "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/defaultlib:user32.lib",
+ "/defaultlib:kernel32", "/nodefaultlib:user32.lib", "a.obj",
+ nullptr));
EXPECT_EQ(2, inputFileCount());
EXPECT_EQ("a.obj", inputFile(0));
EXPECT_EQ("kernel32.lib", inputFile(1));
}
TEST_F(WinLinkParserTest, NoDefaultLibAll) {
- EXPECT_FALSE(parse("link.exe", "/defaultlib:user32.lib",
- "/defaultlib:kernel32", "/nodefaultlib", "a.obj",
- nullptr));
+ EXPECT_TRUE(parse("link.exe", "/defaultlib:user32.lib",
+ "/defaultlib:kernel32", "/nodefaultlib", "a.obj", nullptr));
EXPECT_EQ(1, inputFileCount());
EXPECT_EQ("a.obj", inputFile(0));
}
@@ -262,93 +261,93 @@ TEST_F(WinLinkParserTest, NoDefaultLibAll) {
//
TEST_F(WinLinkParserTest, Force) {
- EXPECT_FALSE(parse("link.exe", "/force", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/force", "a.obj", nullptr));
EXPECT_TRUE(_context.allowRemainingUndefines());
}
TEST_F(WinLinkParserTest, ForceUnresolved) {
- EXPECT_FALSE(parse("link.exe", "/force:unresolved", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/force:unresolved", "a.obj", nullptr));
EXPECT_TRUE(_context.allowRemainingUndefines());
}
TEST_F(WinLinkParserTest, NoNxCompat) {
- EXPECT_FALSE(parse("link.exe", "/nxcompat:no", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/nxcompat:no", "a.obj", nullptr));
EXPECT_FALSE(_context.isNxCompat());
}
TEST_F(WinLinkParserTest, LargeAddressAware) {
- EXPECT_FALSE(parse("link.exe", "/largeaddressaware", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/largeaddressaware", "a.obj", nullptr));
EXPECT_TRUE(_context.getLargeAddressAware());
}
TEST_F(WinLinkParserTest, NoLargeAddressAware) {
- EXPECT_FALSE(parse("link.exe", "/largeaddressaware:no", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/largeaddressaware:no", "a.obj", nullptr));
EXPECT_FALSE(_context.getLargeAddressAware());
}
TEST_F(WinLinkParserTest, AllowBind) {
- EXPECT_FALSE(parse("link.exe", "/allowbind", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/allowbind", "a.obj", nullptr));
EXPECT_TRUE(_context.getAllowBind());
}
TEST_F(WinLinkParserTest, NoAllowBind) {
- EXPECT_FALSE(parse("link.exe", "/allowbind:no", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/allowbind:no", "a.obj", nullptr));
EXPECT_FALSE(_context.getAllowBind());
}
TEST_F(WinLinkParserTest, AllowIsolation) {
- EXPECT_FALSE(parse("link.exe", "/allowisolation", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/allowisolation", "a.obj", nullptr));
EXPECT_TRUE(_context.getAllowIsolation());
}
TEST_F(WinLinkParserTest, NoAllowIsolation) {
- EXPECT_FALSE(parse("link.exe", "/allowisolation:no", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/allowisolation:no", "a.obj", nullptr));
EXPECT_FALSE(_context.getAllowIsolation());
}
TEST_F(WinLinkParserTest, SwapRunFromCD) {
- EXPECT_FALSE(parse("link.exe", "/swaprun:cd", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/swaprun:cd", "a.obj", nullptr));
EXPECT_TRUE(_context.getSwapRunFromCD());
}
TEST_F(WinLinkParserTest, SwapRunFromNet) {
- EXPECT_FALSE(parse("link.exe", "/swaprun:net", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/swaprun:net", "a.obj", nullptr));
EXPECT_TRUE(_context.getSwapRunFromNet());
}
TEST_F(WinLinkParserTest, Debug) {
- EXPECT_FALSE(parse("link.exe", "/debug", "a.out", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/debug", "a.out", nullptr));
EXPECT_FALSE(_context.deadStrip());
}
TEST_F(WinLinkParserTest, Fixed) {
- EXPECT_FALSE(parse("link.exe", "/fixed", "a.out", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/fixed", "a.out", nullptr));
EXPECT_FALSE(_context.getBaseRelocationEnabled());
EXPECT_FALSE(_context.getDynamicBaseEnabled());
}
TEST_F(WinLinkParserTest, NoFixed) {
- EXPECT_FALSE(parse("link.exe", "/fixed:no", "a.out", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/fixed:no", "a.out", nullptr));
EXPECT_TRUE(_context.getBaseRelocationEnabled());
}
TEST_F(WinLinkParserTest, TerminalServerAware) {
- EXPECT_FALSE(parse("link.exe", "/tsaware", "a.out", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/tsaware", "a.out", nullptr));
EXPECT_TRUE(_context.isTerminalServerAware());
}
TEST_F(WinLinkParserTest, NoTerminalServerAware) {
- EXPECT_FALSE(parse("link.exe", "/tsaware:no", "a.out", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/tsaware:no", "a.out", nullptr));
EXPECT_FALSE(_context.isTerminalServerAware());
}
TEST_F(WinLinkParserTest, DynamicBase) {
- EXPECT_FALSE(parse("link.exe", "/dynamicbase", "a.out", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/dynamicbase", "a.out", nullptr));
EXPECT_TRUE(_context.getDynamicBaseEnabled());
}
TEST_F(WinLinkParserTest, NoDynamicBase) {
- EXPECT_FALSE(parse("link.exe", "/dynamicbase:no", "a.out", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/dynamicbase:no", "a.out", nullptr));
EXPECT_FALSE(_context.getDynamicBaseEnabled());
}
@@ -357,14 +356,14 @@ TEST_F(WinLinkParserTest, NoDynamicBase) {
//
TEST_F(WinLinkParserTest, FailIfMismatch_Match) {
- EXPECT_FALSE(parse("link.exe", "/failifmismatch:foo=bar",
- "/failifmismatch:foo=bar", "/failifmismatch:abc=def",
- "a.out", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/failifmismatch:foo=bar",
+ "/failifmismatch:foo=bar", "/failifmismatch:abc=def",
+ "a.out", nullptr));
}
TEST_F(WinLinkParserTest, FailIfMismatch_Mismatch) {
- EXPECT_TRUE(parse("link.exe", "/failifmismatch:foo=bar",
- "/failifmismatch:foo=baz", "a.out", nullptr));
+ EXPECT_FALSE(parse("link.exe", "/failifmismatch:foo=bar",
+ "/failifmismatch:foo=baz", "a.out", nullptr));
}
//
@@ -374,11 +373,11 @@ TEST_F(WinLinkParserTest, FailIfMismatch_Mismatch) {
TEST_F(WinLinkParserTest, Ignore) {
// There are some no-op command line options that are recognized for
// compatibility with link.exe.
- EXPECT_FALSE(parse("link.exe", "/nologo", "/errorreport:prompt",
- "/incremental", "/incremental:no", "/delay:unload",
- "/delayload:user32", "/pdb:foo", "/pdbaltpath:bar",
- "/verbose", "/verbose:icf", "/wx", "/wx:no", "a.obj",
- nullptr));
+ EXPECT_TRUE(parse("link.exe", "/nologo", "/errorreport:prompt",
+ "/incremental", "/incremental:no", "/delay:unload",
+ "/delayload:user32", "/pdb:foo", "/pdbaltpath:bar",
+ "/verbose", "/verbose:icf", "/wx", "/wx:no", "a.obj",
+ nullptr));
EXPECT_EQ("", errorMessage());
EXPECT_EQ(1, inputFileCount());
EXPECT_EQ("a.obj", inputFile(0));
@@ -389,8 +388,8 @@ TEST_F(WinLinkParserTest, Ignore) {
//
TEST_F(WinLinkParserTest, DashDash) {
- EXPECT_FALSE(parse("link.exe", "/subsystem:console", "/out:a.exe",
- "a.obj", "--", "b.obj", "-c.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/subsystem:console", "/out:a.exe", "a.obj",
+ "--", "b.obj", "-c.obj", nullptr));
EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, _context.getSubsystem());
EXPECT_EQ("a.exe", _context.outputPath());
EXPECT_EQ(3, inputFileCount());
@@ -404,12 +403,12 @@ TEST_F(WinLinkParserTest, DashDash) {
//
TEST_F(WinLinkParserTest, DefEntryNameConsole) {
- EXPECT_FALSE(parse("link.exe", "/subsystem:console", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/subsystem:console", "a.obj", nullptr));
EXPECT_EQ("_mainCRTStartup", _context.entrySymbolName());
}
TEST_F(WinLinkParserTest, DefEntryNameWindows) {
- EXPECT_FALSE(parse("link.exe", "/subsystem:windows", "a.obj", nullptr));
+ EXPECT_TRUE(parse("link.exe", "/subsystem:windows", "a.obj", nullptr));
EXPECT_EQ("_WinMainCRTStartup", _context.entrySymbolName());
}
OpenPOWER on IntegriCloud