[llvm] [llvm][support] Show name of overlapping cl option (PR #70108)

Maksim Levental via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 24 15:07:13 PDT 2023


https://github.com/makslevental updated https://github.com/llvm/llvm-project/pull/70108

>From ef1e56f2b88ddf07170f7560ec36063db55f154d Mon Sep 17 00:00:00 2001
From: max <maksim.levental at gmail.com>
Date: Tue, 24 Oct 2023 14:48:16 -0500
Subject: [PATCH] [llvm][support] show name of overlapping cl opt

---
 llvm/include/llvm/Support/CommandLine.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h
index 49f4a668ae416fe..70e6a0fca268152 100644
--- a/llvm/include/llvm/Support/CommandLine.h
+++ b/llvm/include/llvm/Support/CommandLine.h
@@ -863,7 +863,11 @@ template <class DataType> class parser : public generic_parser_base {
   ///
   template <class DT>
   void addLiteralOption(StringRef Name, const DT &V, StringRef HelpStr) {
-    assert(findOption(Name) == Values.size() && "Option already exists!");
+#ifndef NDEBUG
+    if (findOption(Name) != Values.size()) {
+      report_fatal_error("Option " + Name + " already exists!", false);
+    }
+#endif
     OptionInfo X(Name, static_cast<DataType>(V), HelpStr);
     Values.push_back(X);
     AddLiteralOption(Owner, Name);



More information about the llvm-commits mailing list