[PATCH] D95915: [clang][driver] Only warn once about invalid -stdlib value

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 3 00:30:37 PST 2021


tbaeder updated this revision to Diff 321022.
tbaeder added a comment.

Noticed similar/worse behavior for -rtlib. Expanded the patch to that and -unwindlib as well.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95915/new/

https://reviews.llvm.org/D95915

Files:
  clang/lib/Driver/ToolChain.cpp


Index: clang/lib/Driver/ToolChain.cpp
===================================================================
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -884,8 +884,14 @@
   else if (LibName == "platform")
     return GetDefaultRuntimeLibType();
 
-  if (A)
-    getDriver().Diag(diag::err_drv_invalid_rtlib_name) << A->getAsString(Args);
+  if (A) {
+    static bool Warned = false;
+    if (!Warned) {
+      getDriver().Diag(diag::err_drv_invalid_rtlib_name)
+          << A->getAsString(Args);
+      Warned = true;
+    }
+  }
 
   return GetDefaultRuntimeLibType();
 }
@@ -910,9 +916,14 @@
   } else if (LibName == "libgcc")
     return ToolChain::UNW_Libgcc;
 
-  if (A)
-    getDriver().Diag(diag::err_drv_invalid_unwindlib_name)
-        << A->getAsString(Args);
+  if (A) {
+    static bool Warned = false;
+    if (!Warned) {
+      getDriver().Diag(diag::err_drv_invalid_unwindlib_name)
+          << A->getAsString(Args);
+      Warned = true;
+    }
+  }
 
   return GetDefaultUnwindLibType();
 }
@@ -929,8 +940,14 @@
   else if (LibName == "platform")
     return GetDefaultCXXStdlibType();
 
-  if (A)
-    getDriver().Diag(diag::err_drv_invalid_stdlib_name) << A->getAsString(Args);
+  if (A) {
+    static bool Warned = false;
+    if (!Warned) {
+      getDriver().Diag(diag::err_drv_invalid_stdlib_name)
+          << A->getAsString(Args);
+      Warned = true;
+    }
+  }
 
   return GetDefaultCXXStdlibType();
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95915.321022.patch
Type: text/x-patch
Size: 1462 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210203/884ed0e9/attachment.bin>


More information about the cfe-commits mailing list