Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save weliveindetail/29f93a4f14e8ffdebfcb8080d3b359b5 to your computer and use it in GitHub Desktop.
Save weliveindetail/29f93a4f14e8ffdebfcb8080d3b359b5 to your computer and use it in GitHub Desktop.
[llvm][hack] Remove assertions for duplicate option registration
From 73643507109bc6cff9a6582d3902492acbd63793 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <stefan.graenitz@gmail.com>
Date: Wed, 5 Jul 2023 14:09:32 +0200
Subject: [PATCH] [hack] Remove assertions for duplicate option registration
---
llvm/include/llvm/Support/CommandLine.h | 4 +++-
llvm/lib/Support/CommandLine.cpp | 6 +++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h
index 2ee02010ff1d..19b1ed37f8f5 100644
--- a/llvm/include/llvm/Support/CommandLine.h
+++ b/llvm/include/llvm/Support/CommandLine.h
@@ -855,7 +855,9 @@ public:
///
template <class DT>
void addLiteralOption(StringRef Name, const DT &V, StringRef HelpStr) {
- assert(findOption(Name) == Values.size() && "Option already exists!");
+ if (findOption(Name) != Values.size())
+ return;
+ // "Option already exists!"
OptionInfo X(Name, static_cast<DataType>(V), HelpStr);
Values.push_back(X);
AddLiteralOption(Owner, Name);
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index e64934aa90cc..025daa60c53e 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -184,7 +184,7 @@ public:
if (!SC->OptionsMap.insert(std::make_pair(Name, &Opt)).second) {
errs() << ProgramName << ": CommandLine Error: Option '" << Name
<< "' registered more than once!\n";
- report_fatal_error("inconsistency in registered CommandLine options");
+ return;
}
// If we're adding this to all sub-commands, add it to the ones that have
@@ -241,7 +241,7 @@ public:
// incorrectly
// linked LLVM distribution.
if (HadErrors)
- report_fatal_error("inconsistency in registered CommandLine options");
+ return;
// If we're adding this to all sub-commands, add it to the ones that have
// already been registered.
@@ -335,7 +335,7 @@ public:
if (!Sub.OptionsMap.insert(std::make_pair(NewName, O)).second) {
errs() << ProgramName << ": CommandLine Error: Option '" << O->ArgStr
<< "' registered more than once!\n";
- report_fatal_error("inconsistency in registered CommandLine options");
+ return;
}
Sub.OptionsMap.erase(O->ArgStr);
}
--
2.37.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment