summaryrefslogtreecommitdiff
path: root/lldb/utils
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2020-07-26 19:36:28 +0000
committerDimitry Andric <dim@FreeBSD.org>2020-07-26 19:36:28 +0000
commitcfca06d7963fa0909f90483b42a6d7d194d01e08 (patch)
tree209fb2a2d68f8f277793fc8df46c753d31bc853b /lldb/utils
parent706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff)
Notes
Diffstat (limited to 'lldb/utils')
-rw-r--r--lldb/utils/TableGen/LLDBOptionDefEmitter.cpp8
-rw-r--r--lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp15
-rw-r--r--lldb/utils/TableGen/LLDBTableGenBackends.h4
-rw-r--r--lldb/utils/TableGen/LLDBTableGenUtils.h4
4 files changed, 20 insertions, 11 deletions
diff --git a/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp b/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
index 6e73d0c53de3..ccf48275f42c 100644
--- a/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
+++ b/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
@@ -55,18 +55,18 @@ struct CommandOption {
Required = Option->getValue("Required");
// Add the full and short name for this option.
- FullName = Option->getValueAsString("FullName");
- ShortName = Option->getValueAsString("ShortName");
+ FullName = std::string(Option->getValueAsString("FullName"));
+ ShortName = std::string(Option->getValueAsString("ShortName"));
if (auto A = Option->getValue("ArgType"))
ArgType = A->getValue()->getAsUnquotedString();
OptionalArg = Option->getValue("OptionalArg") != nullptr;
if (Option->getValue("Validator"))
- Validator = Option->getValueAsString("Validator");
+ Validator = std::string(Option->getValueAsString("Validator"));
if (Option->getValue("ArgEnum"))
- ArgEnum = Option->getValueAsString("ArgEnum");
+ ArgEnum = std::string(Option->getValueAsString("ArgEnum"));
if (Option->getValue("Completions"))
Completions = Option->getValueAsListOfStrings("Completions");
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";
}
diff --git a/lldb/utils/TableGen/LLDBTableGenBackends.h b/lldb/utils/TableGen/LLDBTableGenBackends.h
index b424abfce9a7..88ae0888c22d 100644
--- a/lldb/utils/TableGen/LLDBTableGenBackends.h
+++ b/lldb/utils/TableGen/LLDBTableGenBackends.h
@@ -13,8 +13,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LLDB_UTILS_TABLEGEN_TABLEGENBACKENDS_H
-#define LLVM_LLDB_UTILS_TABLEGEN_TABLEGENBACKENDS_H
+#ifndef LLDB_UTILS_TABLEGEN_LLDBTABLEGENBACKENDS_H
+#define LLDB_UTILS_TABLEGEN_LLDBTABLEGENBACKENDS_H
#include "llvm/ADT/StringRef.h"
diff --git a/lldb/utils/TableGen/LLDBTableGenUtils.h b/lldb/utils/TableGen/LLDBTableGenUtils.h
index 5553cecafb12..76f0df9a23f6 100644
--- a/lldb/utils/TableGen/LLDBTableGenUtils.h
+++ b/lldb/utils/TableGen/LLDBTableGenUtils.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LLDB_UTILS_TABLEGEN_TABLEGENUTILS_H
-#define LLVM_LLDB_UTILS_TABLEGEN_TABLEGENUTILS_H
+#ifndef LLDB_UTILS_TABLEGEN_LLDBTABLEGENUTILS_H
+#define LLDB_UTILS_TABLEGEN_LLDBTABLEGENUTILS_H
#include "llvm/ADT/StringRef.h"
#include <map>