Let tablegen generate property definitions

Property definitions are currently defined in a PropertyDefinition array
and have a corresponding enum to index in this array. Unfortunately this
is quite error prone. Indeed, just today we found an incorrect merge
where a discrepancy between the order of the enum values and their
definition caused the test suite to fail spectacularly.

Tablegen can streamline the process of generating the property
definition table while at the same time guaranteeing that the enums stay
in sync. That's exactly what this patch does. It adds a new tablegen
file for the properties, building on top of the infrastructure that
Raphael added recently for the command options. It also introduces two
new tablegen backends: one for the property definitions and one for
their corresponding enums.

It might be worth mentioning that I generated most of the tablegen
definitions from the existing property definitions, by adding a dump
method to the struct. This seems both more efficient and less error
prone that copying everything over by hand. Only Enum properties needed
manual fixup for the EnumValues and DefaultEnumValue fields.

Differential revision: https://reviews.llvm.org/D65185

llvm-svn: 367058
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 2bdfc30..7f7b548 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -3274,221 +3274,13 @@
      "this setting loads sections and all symbols."} };
 
 static constexpr PropertyDefinition g_properties[] = {
-    {"default-arch", OptionValue::eTypeArch, true, 0, nullptr, {},
-     "Default architecture to choose, when there's a choice."},
-    {"move-to-nearest-code", OptionValue::eTypeBoolean, false, true, nullptr,
-     {}, "Move breakpoints to nearest code."},
-    {"language", OptionValue::eTypeLanguage, false, eLanguageTypeUnknown,
-     nullptr, {},
-     "The language to use when interpreting expressions entered in commands."},
-    {"expr-prefix", OptionValue::eTypeFileSpec, false, 0, nullptr, {},
-     "Path to a file containing expressions to be prepended to all "
-     "expressions."},
-    {"prefer-dynamic-value", OptionValue::eTypeEnum, false,
-     eDynamicDontRunTarget, nullptr, OptionEnumValues(g_dynamic_value_types),
-     "Should printed values be shown as their dynamic value."},
-    {"enable-synthetic-value", OptionValue::eTypeBoolean, false, true, nullptr,
-     {}, "Should synthetic values be used by default whenever available."},
-    {"skip-prologue", OptionValue::eTypeBoolean, false, true, nullptr, {},
-     "Skip function prologues when setting breakpoints by name."},
-    {"source-map", OptionValue::eTypePathMap, false, 0, nullptr, {},
-     "Source path remappings are used to track the change of location between "
-     "a source file when built, and "
-     "where it exists on the current system.  It consists of an array of "
-     "duples, the first element of each duple is "
-     "some part (starting at the root) of the path to the file when it was "
-     "built, "
-     "and the second is where the remainder of the original build hierarchy is "
-     "rooted on the local system.  "
-     "Each element of the array is checked in order and the first one that "
-     "results in a match wins."},
-    {"exec-search-paths", OptionValue::eTypeFileSpecList, false, 0, nullptr,
-     {}, "Executable search paths to use when locating executable files "
-         "whose paths don't match the local file system."},
-    {"debug-file-search-paths", OptionValue::eTypeFileSpecList, false, 0,
-     nullptr, {},
-     "List of directories to be searched when locating debug symbol files. "
-     "See also symbols.enable-external-lookup."},
-    {"clang-module-search-paths", OptionValue::eTypeFileSpecList, false, 0,
-     nullptr, {},
-     "List of directories to be searched when locating modules for Clang."},
-    {"auto-import-clang-modules", OptionValue::eTypeBoolean, false, true,
-     nullptr, {},
-     "Automatically load Clang modules referred to by the program."},
-    {"import-std-module", OptionValue::eTypeBoolean, false, false,
-     nullptr, {},
-     "Import the C++ std module to improve debugging STL containers."},
-    {"auto-apply-fixits", OptionValue::eTypeBoolean, false, true, nullptr,
-     {}, "Automatically apply fix-it hints to expressions."},
-    {"notify-about-fixits", OptionValue::eTypeBoolean, false, true, nullptr,
-     {}, "Print the fixed expression text."},
-    {"save-jit-objects", OptionValue::eTypeBoolean, false, false, nullptr,
-     {}, "Save intermediate object files generated by the LLVM JIT"},
-    {"max-children-count", OptionValue::eTypeSInt64, false, 256, nullptr,
-     {}, "Maximum number of children to expand in any level of depth."},
-    {"max-string-summary-length", OptionValue::eTypeSInt64, false, 1024,
-     nullptr, {},
-     "Maximum number of characters to show when using %s in summary strings."},
-    {"max-memory-read-size", OptionValue::eTypeSInt64, false, 1024, nullptr,
-     {}, "Maximum number of bytes that 'memory read' will fetch before "
-         "--force must be specified."},
-    {"breakpoints-use-platform-avoid-list", OptionValue::eTypeBoolean, false,
-     true, nullptr, {}, "Consult the platform module avoid list when "
-                        "setting non-module specific breakpoints."},
-    {"arg0", OptionValue::eTypeString, false, 0, nullptr, {},
-     "The first argument passed to the program in the argument array which can "
-     "be different from the executable itself."},
-    {"run-args", OptionValue::eTypeArgs, false, 0, nullptr, {},
-     "A list containing all the arguments to be passed to the executable when "
-     "it is run. Note that this does NOT include the argv[0] which is in "
-     "target.arg0."},
-    {"env-vars", OptionValue::eTypeDictionary, false, OptionValue::eTypeString,
-     nullptr, {}, "A list of all the environment variables to be passed "
-                  "to the executable's environment, and their values."},
-    {"inherit-env", OptionValue::eTypeBoolean, false, true, nullptr, {},
-     "Inherit the environment from the process that is running LLDB."},
-    {"input-path", OptionValue::eTypeFileSpec, false, 0, nullptr, {},
-     "The file/path to be used by the executable program for reading its "
-     "standard input."},
-    {"output-path", OptionValue::eTypeFileSpec, false, 0, nullptr, {},
-     "The file/path to be used by the executable program for writing its "
-     "standard output."},
-    {"error-path", OptionValue::eTypeFileSpec, false, 0, nullptr, {},
-     "The file/path to be used by the executable program for writing its "
-     "standard error."},
-    {"detach-on-error", OptionValue::eTypeBoolean, false, true, nullptr,
-     {}, "debugserver will detach (rather than killing) a process if it "
-              "loses connection with lldb."},
-    {"preload-symbols", OptionValue::eTypeBoolean, false, true, nullptr, {},
-     "Enable loading of symbol tables before they are needed."},
-    {"disable-aslr", OptionValue::eTypeBoolean, false, true, nullptr, {},
-     "Disable Address Space Layout Randomization (ASLR)"},
-    {"disable-stdio", OptionValue::eTypeBoolean, false, false, nullptr, {},
-     "Disable stdin/stdout for process (e.g. for a GUI application)"},
-    {"inline-breakpoint-strategy", OptionValue::eTypeEnum, false,
-     eInlineBreakpointsAlways, nullptr,
-     OptionEnumValues(g_inline_breakpoint_enums),
-     "The strategy to use when settings breakpoints by file and line. "
-     "Breakpoint locations can end up being inlined by the compiler, so that a "
-     "compile unit 'a.c' might contain an inlined function from another source "
-     "file. "
-     "Usually this is limited to breakpoint locations from inlined functions "
-     "from header or other include files, or more accurately "
-     "non-implementation source files. "
-     "Sometimes code might #include implementation files and cause inlined "
-     "breakpoint locations in inlined implementation files. "
-     "Always checking for inlined breakpoint locations can be expensive "
-     "(memory and time), so if you have a project with many headers "
-     "and find that setting breakpoints is slow, then you can change this "
-     "setting to headers. "
-     "This setting allows you to control exactly which strategy is used when "
-     "setting "
-     "file and line breakpoints."},
-    // FIXME: This is the wrong way to do per-architecture settings, but we
-    // don't have a general per architecture settings system in place yet.
-    {"x86-disassembly-flavor", OptionValue::eTypeEnum, false,
-     eX86DisFlavorDefault, nullptr,
-     OptionEnumValues(g_x86_dis_flavor_value_types),
-     "The default disassembly flavor to use for x86 or x86-64 targets."},
-    {"use-hex-immediates", OptionValue::eTypeBoolean, false, true, nullptr,
-     {}, "Show immediates in disassembly as hexadecimal."},
-    {"hex-immediate-style", OptionValue::eTypeEnum, false,
-     Disassembler::eHexStyleC, nullptr,
-     OptionEnumValues(g_hex_immediate_style_values),
-     "Which style to use for printing hexadecimal disassembly values."},
-    {"use-fast-stepping", OptionValue::eTypeBoolean, false, true, nullptr,
-     {}, "Use a fast stepping algorithm based on running from branch to "
-         "branch rather than instruction single-stepping."},
-    {"load-script-from-symbol-file", OptionValue::eTypeEnum, false,
-     eLoadScriptFromSymFileWarn, nullptr,
-     OptionEnumValues(g_load_script_from_sym_file_values),
-     "Allow LLDB to load scripting resources embedded in symbol files when "
-     "available."},
-    {"load-cwd-lldbinit", OptionValue::eTypeEnum, false, eLoadCWDlldbinitWarn,
-     nullptr, OptionEnumValues(g_load_current_working_dir_lldbinit_values),
-     "Allow LLDB to .lldbinit files from the current directory automatically."},
-    {"memory-module-load-level", OptionValue::eTypeEnum, false,
-     eMemoryModuleLoadLevelComplete, nullptr,
-     OptionEnumValues(g_memory_module_load_level_values),
-     "Loading modules from memory can be slow as reading the symbol tables and "
-     "other data can take a long time depending on your connection to the "
-     "debug target. "
-     "This setting helps users control how much information gets loaded when "
-     "loading modules from memory."
-     "'complete' is the default value for this setting which will load all "
-     "sections and symbols by reading them from memory (slowest, most "
-     "accurate). "
-     "'partial' will load sections and attempt to find function bounds without "
-     "downloading the symbol table (faster, still accurate, missing symbol "
-     "names). "
-     "'minimal' is the fastest setting and will load section data with no "
-     "symbols, but should rarely be used as stack frames in these memory "
-     "regions will be inaccurate and not provide any context (fastest). "},
-    {"display-expression-in-crashlogs", OptionValue::eTypeBoolean, false, false,
-     nullptr, {}, "Expressions that crash will show up in crash logs if "
-                  "the host system supports executable specific crash log "
-                  "strings and this setting is set to true."},
-    {"trap-handler-names", OptionValue::eTypeArray, true,
-     OptionValue::eTypeString, nullptr, {},
-     "A list of trap handler function names, e.g. a common Unix user process "
-     "one is _sigtramp."},
-    {"display-runtime-support-values", OptionValue::eTypeBoolean, false, false,
-     nullptr, {}, "If true, LLDB will show variables that are meant to "
-                  "support the operation of a language's runtime support."},
-    {"display-recognized-arguments", OptionValue::eTypeBoolean, false, false,
-     nullptr, {}, "Show recognized arguments in variable listings by default."},
-    {"non-stop-mode", OptionValue::eTypeBoolean, false, 0, nullptr, {},
-     "Disable lock-step debugging, instead control threads independently."},
-    {"require-hardware-breakpoint", OptionValue::eTypeBoolean, false, 0,
-     nullptr, {}, "Require all breakpoints to be hardware breakpoints."}};
-// clang-format on
+#define LLDB_PROPERTIES_target
+#include "lldb/Core/Properties.inc"
+};
 
 enum {
-  ePropertyDefaultArch,
-  ePropertyMoveToNearestCode,
-  ePropertyLanguage,
-  ePropertyExprPrefix,
-  ePropertyPreferDynamic,
-  ePropertyEnableSynthetic,
-  ePropertySkipPrologue,
-  ePropertySourceMap,
-  ePropertyExecutableSearchPaths,
-  ePropertyDebugFileSearchPaths,
-  ePropertyClangModuleSearchPaths,
-  ePropertyAutoImportClangModules,
-  ePropertyImportStdModule,
-  ePropertyAutoApplyFixIts,
-  ePropertyNotifyAboutFixIts,
-  ePropertySaveObjects,
-  ePropertyMaxChildrenCount,
-  ePropertyMaxSummaryLength,
-  ePropertyMaxMemReadSize,
-  ePropertyBreakpointUseAvoidList,
-  ePropertyArg0,
-  ePropertyRunArgs,
-  ePropertyEnvVars,
-  ePropertyInheritEnv,
-  ePropertyInputPath,
-  ePropertyOutputPath,
-  ePropertyErrorPath,
-  ePropertyDetachOnError,
-  ePropertyPreloadSymbols,
-  ePropertyDisableASLR,
-  ePropertyDisableSTDIO,
-  ePropertyInlineStrategy,
-  ePropertyDisassemblyFlavor,
-  ePropertyUseHexImmediates,
-  ePropertyHexImmediateStyle,
-  ePropertyUseFastStepping,
-  ePropertyLoadScriptFromSymbolFile,
-  ePropertyLoadCWDlldbinitFile,
-  ePropertyMemoryModuleLoadLevel,
-  ePropertyDisplayExpressionsInCrashlogs,
-  ePropertyTrapHandlerNames,
-  ePropertyDisplayRuntimeSupportValues,
-  ePropertyDisplayRecognizedArguments,
-  ePropertyNonStopModeEnabled,
-  ePropertyRequireHardwareBreakpoints,
+#define LLDB_PROPERTIES_target
+#include "lldb/Core/PropertiesEnum.inc"
   ePropertyExperimental,
 };
 
@@ -3565,25 +3357,14 @@
 
 // TargetProperties
 static constexpr PropertyDefinition g_experimental_properties[]{
-    {"inject-local-vars",
-     OptionValue::eTypeBoolean,
-     true,
-     true,
-     nullptr,
-     {},
-     "If true, inject local variables explicitly into the expression text.  "
-     "This will fix symbol resolution when there are name collisions between "
-     "ivars and local variables.  "
-     "But it can make expressions run much more slowly."},
-    {"use-modern-type-lookup",
-     OptionValue::eTypeBoolean,
-     true,
-     false,
-     nullptr,
-     {},
-     "If true, use Clang's modern type lookup infrastructure."}};
+#define LLDB_PROPERTIES_experimental
+#include "lldb/Core/Properties.inc"
+};
 
-enum { ePropertyInjectLocalVars = 0, ePropertyUseModernTypeLookup };
+enum {
+#define LLDB_PROPERTIES_experimental
+#include "lldb/Core/PropertiesEnum.inc"
+};
 
 class TargetExperimentalOptionValueProperties : public OptionValueProperties {
 public: