Re: [PATCH] D14935: Fix nodefaultlibs/nostdlib check

2015-11-24 Thread Nirav Dave via cfe-commits
niravd updated this revision to Diff 41040.
niravd added a comment.

Fix review issues


http://reviews.llvm.org/D14935

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

Index: test/Driver/nodefaultlib.c
===
--- test/Driver/nodefaultlib.c
+++ 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: 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;
   }


Index: test/Driver/nodefaultlib.c
===
--- test/Driver/nodefaultlib.c
+++ 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: 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;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D14935: Fix nodefaultlibs/nostdlib check

2015-11-24 Thread Nirav Dave via cfe-commits
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;
   }


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;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits