[PATCH] D14935: Fix nodefaultlibs/nostdlib check

Nirav Dave via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 23 14:09:06 PST 2015


niravd created this revision.
niravd added reviewers: dougk, jyknight.
niravd added subscribers: cfe-commits, rsmith.

Checks for nostdlib should also always check nodefaultlibs or nostartfiles as appropriate. Clang Driver misses a case

http://reviews.llvm.org/D14935

Files:
  lib/Driver/Driver.cpp
  test/Driver/nodefaultlib_stdc.c

Index: test/Driver/nodefaultlib_stdc.c
===================================================================
--- /dev/null
+++ test/Driver/nodefaultlib_stdc.c
@@ -0,0 +1,3 @@
+// RUN: %clang -stdlib=libc++ -nodefaultlibs -lstdc++ -### %s 2>&1 | FileCheck %s
+// CHECK-NOT: "-lc++"
+// CHECK: "-lstdc++"
Index: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp
+++ 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.40976.patch
Type: text/x-patch
Size: 1168 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151123/24348a85/attachment-0001.bin>


More information about the cfe-commits mailing list