diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2020-03-20 18:34:50 -0700 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2020-03-20 18:35:13 -0700 |
commit | 09c8845adfd9e86a227d6413d57b462d8566d399 (patch) | |
tree | a70717b641ca19a161084e76ed0eefb62730c29f /lldb/utils | |
parent | d35a454170da3da9c9bb0b5627f5796113195283 (diff) | |
download | llvm-09c8845adfd9e86a227d6413d57b462d8566d399.tar.gz |
[lldb]/Tablegen] Use ElementType instead of DefaultValueUnsinged
The fourth field in the property struct is the default unsigned or enum
value for all types, except for Array and Dictionary types. For those,
it is the element type. During the tablegen conversion, this was
incorrectly translated to DefaultValueUnsigned with a value
corresponding to the OptionValue: enum type. So for
OptionValue::eTypeString this became DefaultUnsignedValue<16>. This
patch extends the tablegen backend to understand ElementType to express
this as ElementType<"String">.
Differential revision: https://reviews.llvm.org/D76535
Diffstat (limited to 'lldb/utils')
-rw-r--r-- | lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp b/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp index f36deeebf906..e3522f2c7b2d 100644 --- a/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp +++ b/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp @@ -35,8 +35,9 @@ static void emitProperty(Record *Property, raw_ostream &OS) { OS << ", "; // Emit the property type. + llvm::StringRef type = Property->getValueAsString("Type"); OS << "OptionValue::eType"; - OS << Property->getValueAsString("Type"); + OS << type; OS << ", "; // Emit the property's global value. @@ -46,11 +47,12 @@ static void emitProperty(Record *Property, raw_ostream &OS) { bool hasDefaultUnsignedValue = Property->getValue("HasDefaultUnsignedValue"); bool hasDefaultEnumValue = Property->getValue("HasDefaultEnumValue"); bool hasDefaultStringValue = Property->getValue("HasDefaultStringValue"); + bool hasElementType = Property->getValue("HasElementType"); // Guarantee that every property has a default value. assert((hasDefaultUnsignedValue || hasDefaultEnumValue || - hasDefaultStringValue) && - "Property must have a default value"); + hasDefaultStringValue || hasElementType) && + "Property must have a default value or an element type"); // Guarantee that no property has both a default unsigned value and a default // enum value, since they're bothed stored in the same field. @@ -72,11 +74,18 @@ static void emitProperty(Record *Property, raw_ostream &OS) { !(Property->getValueAsString("Type") == "Enum" && !hasDefaultEnumValue) && "Enum property must have a enum default value."); + // Guarantee that only arrays and dictionaries have an element type; + assert(((type != "Array" && type != "Dictionary") || hasElementType) && + "Only dictionaries and arrays can have an element type."); + // Emit the default uint value. if (hasDefaultUnsignedValue) { OS << std::to_string(Property->getValueAsInt("DefaultUnsignedValue")); } else if (hasDefaultEnumValue) { OS << Property->getValueAsString("DefaultEnumValue"); + } else if (hasElementType) { + OS << "OptionValue::eType"; + OS << Property->getValueAsString("ElementType"); } else { OS << "0"; } |