diff options
author | Reid Kleckner <reid@kleckner.net> | 2014-07-12 00:18:58 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2014-07-12 00:18:58 +0000 |
commit | e2729b9a98306d6fc97ae0f9832a0a850d8f653a (patch) | |
tree | 7870325fecab66685d8a72db73545713c6a3ca62 /utils | |
parent | f7d3052fc76cccf8944cbf53664030f40f21d48f (diff) |
Option: Propagate flags from groups to options in each group
This should make it easy to set a flag for a whole group of clang driver
options.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212865 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/TableGen/OptParserEmitter.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/utils/TableGen/OptParserEmitter.cpp b/utils/TableGen/OptParserEmitter.cpp index c5fd7eecbfe..9262d7c8a02 100644 --- a/utils/TableGen/OptParserEmitter.cpp +++ b/utils/TableGen/OptParserEmitter.cpp @@ -221,9 +221,11 @@ void EmitOptParser(RecordKeeper &Records, raw_ostream &OS) { // The containing option group (if any). OS << ", "; - if (const DefInit *DI = dyn_cast<DefInit>(R.getValueInit("Group"))) + const ListInit *GroupFlags = nullptr; + if (const DefInit *DI = dyn_cast<DefInit>(R.getValueInit("Group"))) { + GroupFlags = DI->getDef()->getValueAsListInit("Flags"); OS << getOptionName(*DI->getDef()); - else + } else OS << "INVALID"; // The option alias (if any). @@ -249,17 +251,19 @@ void EmitOptParser(RecordKeeper &Records, raw_ostream &OS) { } // The option flags. + OS << ", "; + int NumFlags = 0; const ListInit *LI = R.getValueAsListInit("Flags"); - if (LI->empty()) { - OS << ", 0"; - } else { - OS << ", "; - for (unsigned i = 0, e = LI->size(); i != e; ++i) { - if (i) - OS << " | "; - OS << cast<DefInit>(LI->getElement(i))->getDef()->getName(); - } + for (Init *I : *LI) + OS << (NumFlags++ ? " | " : "") + << cast<DefInit>(I)->getDef()->getName(); + if (GroupFlags) { + for (Init *I : *GroupFlags) + OS << (NumFlags++ ? " | " : "") + << cast<DefInit>(I)->getDef()->getName(); } + if (NumFlags == 0) + OS << '0'; // The option parameter field. OS << ", " << R.getValueAsInt("NumArgs"); |