1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[clang][cli][docs] Clarify marshalling infrastructure documentation

This commit is contained in:
Jan Svoboda 2021-05-04 15:15:44 +02:00
parent bc6c00e0a4
commit 241cc56fc0

View File

@ -144,56 +144,68 @@ class MetaVarName<string name> { string MetaVarName = name; }
class Values<string value> { string Values = value; }
class ValuesCode<code valuecode> { code ValuesCode = valuecode; }
// Helpers for defining marshalling information.
// Helpers for defining marshalling information (typically used in Clang's -cc1
// frontend).
// The key path to the mapped field and the macro prefix for the resulting
// definition database.
class KeyPathAndMacro<string key_path_prefix, string key_path_base,
string macro_prefix = ""> {
code KeyPath = !strconcat(key_path_prefix, key_path_base);
code MacroPrefix = macro_prefix;
}
// Mixin that implies the specified value for the current option when any of the
// given key paths evaluates to true.
class ImpliedByAnyOf<list<string> key_paths, code value = "true"> {
code ImpliedCheck = !foldl("false", key_paths, accumulator, key_path,
!strconcat(accumulator, " || ", key_path));
code ImpliedValue = value;
}
// Parent class for marshalled options (typically used in Clang's -cc1 frontend).
class MarshallingInfo<KeyPathAndMacro kpm, code defaultvalue> {
code KeyPath = kpm.KeyPath;
code MacroPrefix = kpm.MacroPrefix;
code DefaultValue = defaultvalue;
}
// Marshalled option accepting a string argument.
class MarshallingInfoString<KeyPathAndMacro kpm, code defaultvalue="std::string()">
: MarshallingInfo<kpm, defaultvalue> {
code Normalizer = "normalizeString";
code Denormalizer = "denormalizeString";
}
// Marshalled option accepting an integer argument.
class MarshallingInfoInt<KeyPathAndMacro kpm, code defaultvalue="0", code type="unsigned">
: MarshallingInfo<kpm, defaultvalue> {
code Normalizer = "normalizeStringIntegral<"#type#">";
code Denormalizer = "denormalizeString<"#type#">";
}
// Marshalled option accepting vector of strings.
class MarshallingInfoStringVector<KeyPathAndMacro kpm>
: MarshallingInfo<kpm, "std::vector<std::string>({})"> {
code Normalizer = "normalizeStringVector";
code Denormalizer = "denormalizeStringVector";
}
// Marshalled option - single positive flag.
class MarshallingInfoFlag<KeyPathAndMacro kpm, code defaultvalue = "false">
: MarshallingInfo<kpm, defaultvalue> {
code Normalizer = "normalizeSimpleFlag";
code Denormalizer = "denormalizeSimpleFlag";
}
// Marshalled option - single negative flag.
class MarshallingInfoNegativeFlag<KeyPathAndMacro kpm, code defaultvalue = "true">
: MarshallingInfo<kpm, defaultvalue> {
code Normalizer = "normalizeSimpleNegativeFlag";
code Denormalizer = "denormalizeSimpleFlag";
}
// Marshalled option - single flag contributing to a bitfield.
class MarshallingInfoBitfieldFlag<KeyPathAndMacro kpm, code value>
: MarshallingInfoFlag<kpm, "0u"> {
code Normalizer = "makeFlagToValueNormalizer("#value#")";
@ -201,7 +213,7 @@ class MarshallingInfoBitfieldFlag<KeyPathAndMacro kpm, code value>
code ValueExtractor = "(extractMaskValue<unsigned, decltype("#value#"), "#value#">)";
}
// Marshalling info for booleans. Applied to the flag setting keypath to false.
// Implementation detail of BoolOption.
class MarshallingInfoBooleanFlag<KeyPathAndMacro kpm, code defaultvalue, code value, code name,
code other_value, code other_name>
: MarshallingInfoFlag<kpm, defaultvalue> {
@ -209,8 +221,8 @@ class MarshallingInfoBooleanFlag<KeyPathAndMacro kpm, code defaultvalue, code va
code Denormalizer = "makeBooleanOptionDenormalizer("#value#")";
}
// Marshalling info for enums. Typically used with `Values`, `NormalizedValues`
// and `NormalizedValuesScope` mixins.
// Marshalled option accepting any of the specified enum values.
// Typically used with `Values`, `NormalizedValues` and `NormalizedValuesScope`.
class MarshallingInfoEnum<KeyPathAndMacro kpm, code defaultvalue>
: MarshallingInfo<kpm, defaultvalue> {
code Normalizer = "normalizeSimpleEnum";