Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
Option: Propagate flags from groups to options in each group
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rnk committed Jul 12, 2014
1 parent f7d3052 commit e2729b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions include/llvm/Option/OptParser.td
Expand Up @@ -75,6 +75,7 @@ class OptionGroup<string name> {
string Name = name;
string HelpText = ?;
OptionGroup Group = ?;
list<OptionFlag> Flags = [];
}

// Define the option class.
Expand Down
26 changes: 15 additions & 11 deletions utils/TableGen/OptParserEmitter.cpp
Expand Up @@ -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).
Expand All @@ -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");
Expand Down

0 comments on commit e2729b9

Please sign in to comment.