[llvm] [TableGen] Allow emitter callbacks to use `const RecordKeeper &` (PR #104716)
Pierre van Houtryve via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 20 23:47:43 PDT 2024
================
@@ -12,22 +12,76 @@
#include "llvm/TableGen/TableGenBackend.h"
#include "llvm/ADT/Twine.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
+#include <variant>
using namespace llvm;
+using namespace TableGen::Emitter;
const size_t MAX_LINE_LEN = 80U;
-namespace llvm::TableGen::Emitter {
-ManagedStatic<cl::opt<FnT>, OptCreatorT> Action;
-void *OptCreatorT::call() {
- return new cl::opt<FnT>(cl::desc("Action to perform:"));
+using FnT = std::variant<FnNonConstT, FnConstT>;
----------------
Pierre-vh wrote:
nit: I'm not a fan of using variant here, could we simplify this by just storing non-const version all the time ? Cast the const away and always call it with the mutable version. Then this code doesn't care whether the actual target uses a const or non const RK
https://github.com/llvm/llvm-project/pull/104716
More information about the llvm-commits
mailing list