[lld] r191341 - Make Driver::link and LinkingContext::validate return true on success.

Rui Ueyama ruiu at google.com
Tue Sep 24 16:26:35 PDT 2013


Author: ruiu
Date: Tue Sep 24 18:26:34 2013
New Revision: 191341

URL: http://llvm.org/viewvc/llvm-project?rev=191341&view=rev
Log:
Make Driver::link and LinkingContext::validate return true on success.

This patch inverts the return value of these functions, so that they return
"true" on success and "false" on failure. The meaning of boolean return value
was mixed in LLD; for example, InputGraph::validate() returns true on success.
With this patch they'll become consistent.

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1748

Modified:
    lld/trunk/lib/Driver/CoreDriver.cpp
    lld/trunk/lib/Driver/DarwinLdDriver.cpp
    lld/trunk/lib/Driver/Driver.cpp
    lld/trunk/lib/Driver/GnuLdDriver.cpp
    lld/trunk/lib/Driver/UniversalDriver.cpp
    lld/trunk/lib/Driver/WinLinkDriver.cpp
    lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp
    lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
    lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
    lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
    lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
    lld/trunk/tools/lld/lld.cpp
    lld/trunk/unittests/DriverTests/DarwinLdDriverTest.cpp
    lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp
    lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp

Modified: lld/trunk/lib/Driver/CoreDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/CoreDriver.cpp?rev=191341&r1=191340&r2=191341&view=diff
==============================================================================
--- lld/trunk/lib/Driver/CoreDriver.cpp (original)
+++ lld/trunk/lib/Driver/CoreDriver.cpp Tue Sep 24 18:26:34 2013
@@ -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 c
     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 c
 
   if (!inputGraph->numFiles()) {
     diagnostics << "No input files\n";
-    return true;
+    return false;
   }
 
   ctx.setInputGraph(std::move(inputGraph));

Modified: lld/trunk/lib/Driver/DarwinLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=191341&r1=191340&r2=191341&view=diff
==============================================================================
--- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Tue Sep 24 18:26:34 2013
@@ -82,11 +82,10 @@ MachOFileNode::createLinkerInput(const L
 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, con
     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, con
     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, con
   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, con
     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, con
     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, con
     // 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, con
 
   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

Modified: lld/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/Driver.cpp?rev=191341&r1=191340&r2=191341&view=diff
==============================================================================
--- lld/trunk/lib/Driver/Driver.cpp (original)
+++ lld/trunk/lib/Driver/Driver.cpp Tue Sep 24 18:26:34 2013
@@ -42,7 +42,7 @@ bool Driver::link(const LinkingContext &
   }
   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 &
       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 &
   readTask.end();
 
   if (fail)
-    return true;
+    return false;
 
   InputFiles inputs;
 
@@ -105,7 +105,7 @@ bool Driver::link(const LinkingContext &
   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 &
   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

Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=191341&r1=191340&r2=191341&view=diff
==============================================================================
--- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/GnuLdDriver.cpp Tue Sep 24 18:26:34 2013
@@ -98,11 +98,10 @@ std::string ELFFileNode::errStr(llvm::er
 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
     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
 
   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
       (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
 
   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
     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

Modified: lld/trunk/lib/Driver/UniversalDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/UniversalDriver.cpp?rev=191341&r1=191340&r2=191341&view=diff
==============================================================================
--- lld/trunk/lib/Driver/UniversalDriver.cpp (original)
+++ lld/trunk/lib/Driver/UniversalDriver.cpp Tue Sep 24 18:26:34 2013
@@ -129,7 +129,7 @@ bool UniversalDriver::link(int argc, con
   case Flavor::core:
     return CoreDriver::link(args.size(), args.data(), diagnostics);
   case Flavor::invalid:
-    return true;
+    return false;
   }
   llvm_unreachable("Unrecognised flavor");
 }

Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=191341&r1=191340&r2=191341&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Tue Sep 24 18:26:34 2013
@@ -257,8 +257,8 @@ bool WinLinkDriver::linkPECOFF(int argc,
   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, cons
   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, cons
   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, cons
       // 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, cons
       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, cons
       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, cons
       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, cons
       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, cons
     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, cons
       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, cons
       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, cons
     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, cons
       // /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, cons
   // 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, cons
 
   if (!inputGraph.numFiles()) {
     diagnostics << "No input files\n";
-    return true;
+    return false;
   }
 
   // A list of undefined symbols will be added to the input

Modified: lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp?rev=191341&r1=191340&r2=191341&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp Tue Sep 24 18:26:34 2013
@@ -272,7 +272,7 @@ private:
 CoreLinkingContext::CoreLinkingContext() {}
 
 bool CoreLinkingContext::validateImpl(raw_ostream &diagnostics) {
-  return false;
+  return true;
 }
 
 void CoreLinkingContext::addPasses(PassManager &pm) const {

Modified: lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp?rev=191341&r1=191340&r2=191341&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp Tue Sep 24 18:26:34 2013
@@ -91,7 +91,7 @@ bool ELFLinkingContext::validateImpl(raw
     _writer = createWriterELF(*this);
     break;
   }
-  return false;
+  return true;
 }
 
 bool ELFLinkingContext::isDynamic() const {

Modified: lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp?rev=191341&r1=191340&r2=191341&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp Tue Sep 24 18:26:34 2013
@@ -207,28 +207,28 @@ bool MachOLinkingContext::validateImpl(r
 
   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) {

Modified: lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp?rev=191341&r1=191340&r2=191341&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp Tue Sep 24 18:26:34 2013
@@ -40,39 +40,39 @@ bool PECOFFLinkingContext::validateImpl(
     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() {

Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=191341&r1=191340&r2=191341&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp Tue Sep 24 18:26:34 2013
@@ -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.

Modified: lld/trunk/tools/lld/lld.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/tools/lld/lld.cpp?rev=191341&r1=191340&r2=191341&view=diff
==============================================================================
--- lld/trunk/tools/lld/lld.cpp (original)
+++ lld/trunk/tools/lld/lld.cpp Tue Sep 24 18:26:34 2013
@@ -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;
 }

Modified: lld/trunk/unittests/DriverTests/DarwinLdDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/DarwinLdDriverTest.cpp?rev=191341&r1=191340&r2=191341&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/DarwinLdDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/DarwinLdDriverTest.cpp Tue Sep 24 18:26:34 2013
@@ -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

Modified: lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp?rev=191341&r1=191340&r2=191341&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp Tue Sep 24 18:26:34 2013
@@ -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());

Modified: lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=191341&r1=191340&r2=191341&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp Tue Sep 24 18:26:34 2013
@@ -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, StartsWithHyph
 }
 
 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, UppercaseOptio
 }
 
 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, NoFileExtensio
 }
 
 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, NoDefaultLibAl
 //
 
 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
 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());
 }
 





More information about the llvm-commits mailing list