Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions llvm/include/llvm/TableGen/Main.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#define LLVM_TABLEGEN_MAIN_H

#include "llvm/Support/CommandLine.h"
#include <functional>
#include <map>

namespace llvm {
Expand All @@ -30,18 +29,17 @@ struct TableGenOutputFiles {
};

/// Returns true on error, false otherwise.
using TableGenMainFn = bool(raw_ostream &OS, const RecordKeeper &Records);
using TableGenMainFn =
function_ref<bool(raw_ostream &OS, const RecordKeeper &Records)>;

/// Perform the action using Records, and store output in OutFiles.
/// Returns true on error, false otherwise.
using MultiFileTableGenMainFn = bool(TableGenOutputFiles &OutFiles,
const RecordKeeper &Records);
using MultiFileTableGenMainFn = function_ref<bool(TableGenOutputFiles &OutFiles,
const RecordKeeper &Records)>;

int TableGenMain(const char *argv0,
std::function<TableGenMainFn> MainFn = nullptr);
int TableGenMain(const char *argv0, TableGenMainFn MainFn = nullptr);

int TableGenMain(const char *argv0,
std::function<MultiFileTableGenMainFn> MainFn = nullptr);
int TableGenMain(const char *argv0, MultiFileTableGenMainFn MainFn = nullptr);

/// Controls emitting large character arrays as strings or character arrays.
/// Typically set to false when building with MSVC.
Expand Down
6 changes: 2 additions & 4 deletions llvm/lib/TableGen/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ static int WriteOutput(const TGParser &Parser, const char *argv0,
return 0;
}

int llvm::TableGenMain(const char *argv0,
std::function<MultiFileTableGenMainFn> MainFn) {
int llvm::TableGenMain(const char *argv0, MultiFileTableGenMainFn MainFn) {
RecordKeeper Records;
TGTimer &Timer = Records.getTimer();

Expand Down Expand Up @@ -209,8 +208,7 @@ int llvm::TableGenMain(const char *argv0,
return 0;
}

int llvm::TableGenMain(const char *argv0,
std::function<TableGenMainFn> MainFn) {
int llvm::TableGenMain(const char *argv0, TableGenMainFn MainFn) {
return TableGenMain(argv0, [&MainFn](TableGenOutputFiles &OutFiles,
const RecordKeeper &Records) {
std::string S;
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/TableGen/Basic/TableGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int tblgen_main(int argc, char **argv) {
InitLLVM X(argc, argv);
cl::ParseCommandLineOptions(argc, argv);

std::function<MultiFileTableGenMainFn> MainFn = nullptr;
MultiFileTableGenMainFn MainFn = nullptr;
return TableGenMain(argv[0], MainFn);
}

Expand Down
Loading