[PATCH] D14935: Fix rewrite of reserved library name in case of -nodefaultlibs

Nirav Dave via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 24 08:10:19 PST 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL253990: Fix rewrite of reserved library name in case of -nodefaultlibs (authored by niravd).

Changed prior to commit:
  http://reviews.llvm.org/D14935?vs=41040&id=41052#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14935

Files:
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/nodefaultlib.c

Index: cfe/trunk/test/Driver/nodefaultlib.c
===================================================================
--- cfe/trunk/test/Driver/nodefaultlib.c
+++ cfe/trunk/test/Driver/nodefaultlib.c
@@ -1,8 +1,10 @@
-// RUN: %clang -target i686-pc-linux-gnu -### -nodefaultlibs %s 2> %t
-// RUN: FileCheck < %t %s
-//
-// CHECK-NOT: start-group
-// CHECK-NOT: "-lgcc"
-// CHECK-NOT: "-lc"
-// CHECK: crtbegin
-// CHECK: crtend
+// RUN: %clang -target i686-pc-linux-gnu -### -nodefaultlibs %s 2>&1 | FileCheck -check-prefix=TEST1 %s
+// TEST1-NOT: start-group
+// TEST1-NOT: "-lgcc"
+// TEST1-NOT: "-lc"
+// TEST1: crtbegin
+// TEST1: crtend
+
+// RUN: %clang -target i686-pc-linux-gnu -stdlib=libc++ -nodefaultlibs -lstdc++ -### %s 2>&1 | FileCheck -check-prefix=TEST2 %s
+// TEST2-NOT: "-lc++"
+// TEST2: "-lstdc++"
Index: cfe/trunk/lib/Driver/Driver.cpp
===================================================================
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -209,6 +209,7 @@
   DerivedArgList *DAL = new DerivedArgList(Args);
 
   bool HasNostdlib = Args.hasArg(options::OPT_nostdlib);
+  bool HasNodefaultlib = Args.hasArg(options::OPT_nodefaultlibs);
   for (Arg *A : Args) {
     // Unfortunately, we have to parse some forwarding options (-Xassembler,
     // -Xlinker, -Xpreprocessor) because we either integrate their functionality
@@ -252,7 +253,7 @@
       StringRef Value = A->getValue();
 
       // Rewrite unless -nostdlib is present.
-      if (!HasNostdlib && Value == "stdc++") {
+      if (!HasNostdlib && !HasNodefaultlib && Value == "stdc++") {
         DAL->AddFlagArg(A, Opts->getOption(options::OPT_Z_reserved_lib_stdcxx));
         continue;
       }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14935.41052.patch
Type: text/x-patch
Size: 1709 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151124/ceb8d868/attachment.bin>


More information about the cfe-commits mailing list