[lld] r228722 - GNU: Use StringRef::empty instead of a boolean flag.

Rui Ueyama ruiu at google.com
Tue Feb 10 10:55:39 PST 2015


Author: ruiu
Date: Tue Feb 10 12:55:39 2015
New Revision: 228722

URL: http://llvm.org/viewvc/llvm-project?rev=228722&view=rev
Log:
GNU: Use StringRef::empty instead of a boolean flag.

This local variable name did not follow the style guide,
and it is not actually needed.

Modified:
    lld/trunk/lib/Driver/GnuLdDriver.cpp
    lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp

Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=228722&r1=228721&r2=228722&view=diff
==============================================================================
--- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/GnuLdDriver.cpp Tue Feb 10 12:55:39 2015
@@ -393,12 +393,8 @@ bool GnuLdDriver::parse(int argc, const
 
   std::stack<int> groupStack;
   int numfiles = 0;
-
   bool asNeeded = false;
   bool wholeArchive = false;
-
-  bool _outputOptionSet = false;
-
   bool hasNoStdLib = false;
 
   // Ignore unknown arguments.
@@ -513,7 +509,6 @@ bool GnuLdDriver::parse(int argc, const
       break;
 
     case OPT_output:
-      _outputOptionSet = true;
       ctx->setOutputPath(inputArg->getValue());
       break;
 
@@ -723,9 +718,8 @@ bool GnuLdDriver::parse(int argc, const
     return false;
   }
 
-  // Set default output file name if the output file was not
-  // specified.
-  if (!_outputOptionSet) {
+  // Set default output file name if the output file was not specified.
+  if (ctx->outputPath().empty()) {
     switch (ctx->outputFileType()) {
     case LinkingContext::OutputFileType::YAML:
       ctx->setOutputPath("-");

Modified: lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp?rev=228722&r1=228721&r2=228722&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp Tue Feb 10 12:55:39 2015
@@ -62,6 +62,11 @@ TEST_F(GnuLdParserTest, Output) {
   EXPECT_EQ("foo", _context->outputPath());
 }
 
+TEST_F(GnuLdParserTest, OutputDefault) {
+  EXPECT_TRUE(parse("ld", "abc.o", nullptr));
+  EXPECT_EQ("a.out", _context->outputPath());
+}
+
 // --noinhibit-exec
 
 TEST_F(GnuLdParserTest, NoinhibitExec) {





More information about the llvm-commits mailing list