llvm.org GIT mirror llvm / e2729b9
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 Reid Kleckner 5 years ago
2 changed file(s) with 17 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
7474 string Name = name;
7575 string HelpText = ?;
7676 OptionGroup Group = ?;
77 list Flags = [];
7778 }
7879
7980 // Define the option class.
220220
221221 // The containing option group (if any).
222222 OS << ", ";
223 if (const DefInit *DI = dyn_cast(R.getValueInit("Group")))
223 const ListInit *GroupFlags = nullptr;
224 if (const DefInit *DI = dyn_cast(R.getValueInit("Group"))) {
225 GroupFlags = DI->getDef()->getValueAsListInit("Flags");
224226 OS << getOptionName(*DI->getDef());
225 else
227 } else
226228 OS << "INVALID";
227229
228230 // The option alias (if any).
248250 }
249251
250252 // The option flags.
253 OS << ", ";
254 int NumFlags = 0;
251255 const ListInit *LI = R.getValueAsListInit("Flags");
252 if (LI->empty()) {
253 OS << ", 0";
254 } else {
255 OS << ", ";
256 for (unsigned i = 0, e = LI->size(); i != e; ++i) {
257 if (i)
258 OS << " | ";
259 OS << cast(LI->getElement(i))->getDef()->getName();
260 }
261 }
256 for (Init *I : *LI)
257 OS << (NumFlags++ ? " | " : "")
258 << cast(I)->getDef()->getName();
259 if (GroupFlags) {
260 for (Init *I : *GroupFlags)
261 OS << (NumFlags++ ? " | " : "")
262 << cast(I)->getDef()->getName();
263 }
264 if (NumFlags == 0)
265 OS << '0';
262266
263267 // The option parameter field.
264268 OS << ", " << R.getValueAsInt("NumArgs");