File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 1313#ifndef LLVM_TABLEGEN_MAIN_H
1414#define LLVM_TABLEGEN_MAIN_H
1515
16+ #include < functional>
17+
1618namespace llvm {
1719
1820class raw_ostream ;
@@ -22,7 +24,8 @@ class RecordKeeper;
2224// / Returns true on error, false otherwise.
2325using TableGenMainFn = bool (raw_ostream &OS, RecordKeeper &Records);
2426
25- int TableGenMain (const char *argv0, TableGenMainFn *MainFn);
27+ int TableGenMain (const char *argv0,
28+ std::function<TableGenMainFn> MainFn = nullptr );
2629
2730} // end namespace llvm
2831
Original file line number Diff line number Diff line change @@ -95,7 +95,8 @@ static int createDependencyFile(const TGParser &Parser, const char *argv0) {
9595 return 0 ;
9696}
9797
98- int llvm::TableGenMain (const char *argv0, TableGenMainFn *MainFn) {
98+ int llvm::TableGenMain (const char *argv0,
99+ std::function<TableGenMainFn> MainFn) {
99100 RecordKeeper Records;
100101
101102 if (TimePhases)
@@ -129,7 +130,11 @@ int llvm::TableGenMain(const char *argv0, TableGenMainFn *MainFn) {
129130 Records.startBackendTimer (" Backend overall" );
130131 std::string OutString;
131132 raw_string_ostream Out (OutString);
132- unsigned status = MainFn (Out, Records);
133+ unsigned status = 0 ;
134+ if (MainFn)
135+ status = MainFn (Out, Records);
136+ else
137+ return 1 ;
133138 Records.stopBackendTimer ();
134139 if (status)
135140 return 1 ;
You can’t perform that action at this time.
0 commit comments