diff options
author | Mikhail Glushenkov <foldr@codedgers.com> | 2008-05-30 06:26:08 +0000 |
---|---|---|
committer | Mikhail Glushenkov <foldr@codedgers.com> | 2008-05-30 06:26:08 +0000 |
commit | e43228958ce2d9c0c69c7ccaef8bb0517d085951 (patch) | |
tree | 096fc172c497ac64dcb47e71f8b32b11c15296f1 /utils/TableGen/LLVMCConfigurationEmitter.cpp | |
parent | 270cae3bf818987d3079ba26ef3319960a034d25 (diff) | |
download | llvm-e43228958ce2d9c0c69c7ccaef8bb0517d085951.tar.gz llvm-e43228958ce2d9c0c69c7ccaef8bb0517d085951.tar.bz2 llvm-e43228958ce2d9c0c69c7ccaef8bb0517d085951.tar.xz |
New feature: OptionList.
It can be handy to have all information about options gathered in a single place
to provide an overview of all supported options. This patch allows the following:
def Options : OptionList<[
(switch_option "E", (help "Help string")),
(alias_option "quiet", "q")
...
]>;
Tool-specific option properties (like 'append_cmd') have (obviously) no meaning in
this context, so the only properties that are allowed are 'help' and 'required'.
See usage example in examples/Clang.td.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51754 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/LLVMCConfigurationEmitter.cpp')
-rw-r--r-- | utils/TableGen/LLVMCConfigurationEmitter.cpp | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/utils/TableGen/LLVMCConfigurationEmitter.cpp b/utils/TableGen/LLVMCConfigurationEmitter.cpp index 44a6ff4a40..77daf627a2 100644 --- a/utils/TableGen/LLVMCConfigurationEmitter.cpp +++ b/utils/TableGen/LLVMCConfigurationEmitter.cpp @@ -647,9 +647,9 @@ CollectProperties::optionPropertyHandlers_; bool CollectProperties::staticMembersInitialized_ = false; -/// CollectToolProperties - Gather information from the parsed -/// TableGen data (basically a wrapper for the CollectProperties -/// function object). +/// CollectToolProperties - Gather information about tool properties +/// from the parsed TableGen data (basically a wrapper for the +/// CollectProperties function object). void CollectToolProperties (RecordVector::const_iterator B, RecordVector::const_iterator E, ToolPropertiesList& TPList, @@ -657,7 +657,8 @@ void CollectToolProperties (RecordVector::const_iterator B, { // Iterate over a properties list of every Tool definition for (;B!=E;++B) { - RecordVector::value_type T = *B; + Record* T = *B; + // Throws an exception if the value does not exist. ListInit* PropList = T->getValueAsListInit("properties"); IntrusiveRefCntPtr<ToolProperties> @@ -669,6 +670,28 @@ void CollectToolProperties (RecordVector::const_iterator B, } } +/// CollectToolPropertiesFromOptionList - Gather information about +/// *global* option properties from the OptionList. +// TOFIX - This is kinda hacky, since it allows to use arbitrary tool +// properties in the OptionList. CollectProperties function object +// should be split into two parts that collect tool and option +// properties, respectively. +void CollectPropertiesFromOptionList (RecordVector::const_iterator B, + RecordVector::const_iterator E, + GlobalOptionDescriptions& OptDescs) +{ + // Iterate over a properties list of every Tool definition + ToolProperties ToolProps("dummy"); + for (;B!=E;++B) { + RecordVector::value_type T = *B; + // Throws an exception if the value does not exist. + ListInit* PropList = T->getValueAsListInit("options"); + + std::for_each(PropList->begin(), PropList->end(), + CollectProperties(ToolProps, OptDescs)); + } +} + /// EmitCaseTest1Arg - Helper function used by /// EmitCaseConstructHandler. bool EmitCaseTest1Arg(const std::string& TestName, @@ -1571,6 +1594,10 @@ void LLVMCConfigurationEmitter::run (std::ostream &O) { GlobalOptionDescriptions opt_descs; CollectToolProperties(Tools.begin(), Tools.end(), tool_props, opt_descs); + RecordVector OptionLists = Records.getAllDerivedDefinitions("OptionList"); + CollectPropertiesFromOptionList(OptionLists.begin(), OptionLists.end(), + opt_descs); + // Emit global option registration code. EmitOptionDescriptions(opt_descs, O); |