[PATCH] D13093: [ELF2] - output of all unknown arguments instead of only one

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 08:30:45 PDT 2015


grimar updated this revision to Diff 35508.
grimar added a comment.

Comment about naming variables addressed.


http://reviews.llvm.org/D13093

Files:
  DriverUtils.cpp
  Error.cpp
  Error.h

Index: Error.h
===================================================================
--- Error.h
+++ Error.h
@@ -15,6 +15,8 @@
 namespace lld {
 namespace elf2 {
 
+void warning(const Twine &Msg);
+
 LLVM_ATTRIBUTE_NORETURN void error(const Twine &Msg);
 void error(std::error_code EC, const Twine &Prefix);
 void error(std::error_code EC);
Index: Error.cpp
===================================================================
--- Error.cpp
+++ Error.cpp
@@ -15,6 +15,10 @@
 namespace lld {
 namespace elf2 {
 
+void warning(const Twine &Msg) {
+  llvm::errs() << Msg << "\n";
+}
+
 void error(const Twine &Msg) {
   llvm::errs() << Msg << "\n";
   exit(1);
Index: DriverUtils.cpp
===================================================================
--- DriverUtils.cpp
+++ DriverUtils.cpp
@@ -58,7 +58,12 @@
     error(Twine("missing arg value for \"") + Args.getArgString(MissingIndex) +
           "\", expected " + Twine(MissingCount) +
           (MissingCount == 1 ? " argument.\n" : " arguments"));
-  for (auto *Arg : Args.filtered(OPT_UNKNOWN))
-    error(Twine("unknown argument: ") + Arg->getSpelling());
+
+  auto Unknowns = Args.filtered(OPT_UNKNOWN);
+  for (auto *Arg : Unknowns)
+    warning(Twine("warning: unknown argument: ") + Arg->getSpelling());
+  if (Unknowns.begin() != Unknowns.end())
+    error(Twine("unknown argument(s) found"));
+
   return Args;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13093.35508.patch
Type: text/x-patch
Size: 1408 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150923/6ca36072/attachment-0001.bin>


More information about the llvm-commits mailing list