[PATCH] D126796: [clang][driver] adds `-print-diagnostics`

Christopher Di Bella via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 1 10:47:09 PDT 2022


cjdb created this revision.
cjdb added a reviewer: aaron.ballman.
Herald added a project: All.
cjdb requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Prints a list of all the warnings that Clang offers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126796

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp


Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2006,6 +2006,16 @@
     return false;
   }
 
+  if (C.getArgs().hasArg(options::OPT_print_diagnostics)) {
+    std::vector<std::string> DiagnosticFlags =
+        DiagnosticIDs::getDiagnosticFlags();
+    llvm::erase_if(DiagnosticFlags,
+                   [](StringRef Flag) { return Flag.startswith("-Wno"); });
+    for (StringRef Flag : DiagnosticFlags)
+      llvm::outs() << "  " << Flag << '\n';
+    return false;
+  }
+
   // FIXME: The following handlers should use a callback mechanism, we don't
   // know what the client would like to do.
   if (Arg *A = C.getArgs().getLastArg(options::OPT_print_file_name_EQ)) {
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3996,6 +3996,8 @@
   HelpText<"Print the paths used for finding ROCm installation">;
 def print_runtime_dir : Flag<["-", "--"], "print-runtime-dir">,
   HelpText<"Print the directory pathname containing clangs runtime libraries">;
+def print_diagnostics : Flag<["-", "--"], "print-diagnostics">,
+  HelpText<"Print all of Clang's diagnostics">;
 def private__bundle : Flag<["-"], "private_bundle">;
 def pthreads : Flag<["-"], "pthreads">;
 defm pthread : BoolOption<"", "pthread",


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126796.433459.patch
Type: text/x-patch
Size: 1481 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220601/81f6d04e/attachment-0001.bin>


More information about the cfe-commits mailing list