================
@@ -1588,11 +1568,35 @@ static bool parseLangOptionsArgs(CompilerInvocation 
&invoc,
   return success;
 }
 
+// Copied from clang/lib/Frontend/CompilerInvocation.cpp.
+static void addDiagnosticArgs(llvm::opt::ArgList &Args,
+                              llvm::opt::OptSpecifier Group,
+                              llvm::opt::OptSpecifier GroupWithValue,
+                              std::vector<std::string> &Diagnostics) {
+  for (auto *A : Args.filtered(Group)) {
+    if (A->getOption().getKind() == llvm::opt::Option::FlagClass) {
+      // The argument is a pure flag (such as OPT_Wall or OPT_Wdeprecated). Add
+      // its name (minus the "W" or "R" at the beginning) to the diagnostics.
+      Diagnostics.push_back(
+          std::string(A->getOption().getName().drop_front(1)));
+    } else if (A->getOption().matches(GroupWithValue)) {
+      // This is -Wfoo= or -Rfoo=, where foo is the name of the diagnostic
+      // group. Add only the group name to the diagnostics.
+      Diagnostics.push_back(
+          std::string(A->getOption().getName().drop_front(1).rtrim("=-")));
+    } else {
+      // Otherwise, add its value (for OPT_W_Joined and similar).
+      Diagnostics.push_back(A->getValue());
+    }
+  }
+}
+
----------------
kparzysz wrote:

Done

https://github.com/llvm/llvm-project/pull/196354
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to