summaryrefslogtreecommitdiff
path: root/utils/TableGen/OptParserEmitter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/TableGen/OptParserEmitter.cpp')
-rw-r--r--utils/TableGen/OptParserEmitter.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/utils/TableGen/OptParserEmitter.cpp b/utils/TableGen/OptParserEmitter.cpp
index e3777d036a23..0358cf26509b 100644
--- a/utils/TableGen/OptParserEmitter.cpp
+++ b/utils/TableGen/OptParserEmitter.cpp
@@ -298,5 +298,31 @@ void EmitOptParser(RecordKeeper &Records, raw_ostream &OS) {
OS << ")\n";
}
OS << "#endif // OPTION\n";
+
+ OS << "\n";
+ OS << "#ifdef OPTTABLE_ARG_INIT\n";
+ OS << "//////////\n";
+ OS << "// Option Values\n\n";
+ for (unsigned I = 0, E = Opts.size(); I != E; ++I) {
+ const Record &R = *Opts[I];
+ if (isa<UnsetInit>(R.getValueInit("ValuesCode")))
+ continue;
+ OS << "{\n";
+ OS << "bool ValuesWereAdded;\n";
+ OS << R.getValueAsString("ValuesCode");
+ OS << "\n";
+ for (const std::string &Pref : R.getValueAsListOfStrings("Prefixes")) {
+ OS << "ValuesWereAdded = Opt.addValues(";
+ std::string S = (Pref + R.getValueAsString("Name")).str();
+ write_cstring(OS, S);
+ OS << ", Values);\n";
+ OS << "(void)ValuesWereAdded;\n";
+ OS << "assert(ValuesWereAdded && \"Couldn't add values to "
+ "OptTable!\");\n";
+ }
+ OS << "}\n";
+ }
+ OS << "\n";
+ OS << "#endif // OPTTABLE_ARG_INIT\n";
}
} // end namespace llvm