Index: include/lldb/lldb-defines.h =================================================================== --- include/lldb/lldb-defines.h +++ include/lldb/lldb-defines.h @@ -148,6 +148,16 @@ #define __attribute__(X) #endif +// MSVS 2015/2017 suffer from internal compiler error when dealing with a +// `constexpr` keyword. It's a known issue, but we have to declare this macro to +// use 'const' as a workaround for now. +// (https://developercommunity.visualstudio.com/content/problem/18155/msvc-2017-c-fatal-error-c1001-constexpr-initializa.html) +#if defined(_MSC_VER) +#define CONSTEXPR const +#else +#define CONSTEXPR constexpr +#endif + #define UNUSED_IF_ASSERT_DISABLED(x) ((void)(x)) #if defined(__cplusplus) Index: source/Commands/CommandObjectBreakpointCommand.cpp =================================================================== --- source/Commands/CommandObjectBreakpointCommand.cpp +++ source/Commands/CommandObjectBreakpointCommand.cpp @@ -36,18 +36,18 @@ // language to lldb and have it pickable here without having to change this // enumeration by hand and rebuild lldb proper. -static constexpr OptionEnumValueElement g_script_option_enumeration[] = { +static CONSTEXPR OptionEnumValueElement g_script_option_enumeration[] = { {eScriptLanguageNone, "command", "Commands are in the lldb command interpreter language"}, {eScriptLanguagePython, "python", "Commands are in the Python language."}, {eSortOrderByName, "default-script", "Commands are in the default scripting language."} }; -static constexpr OptionEnumValues ScriptOptionEnum() { +static CONSTEXPR OptionEnumValues ScriptOptionEnum() { return OptionEnumValues(g_script_option_enumeration); } -static constexpr OptionDefinition g_breakpoint_add_options[] = { +static CONSTEXPR OptionDefinition g_breakpoint_add_options[] = { // clang-format off { LLDB_OPT_SET_1, false, "one-liner", 'o', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeOneLiner, "Specify a one-line breakpoint command inline. Be sure to surround it with quotes." }, { LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Specify whether breakpoint command execution should terminate on error." }, Index: source/Commands/CommandObjectCommands.cpp =================================================================== --- source/Commands/CommandObjectCommands.cpp +++ source/Commands/CommandObjectCommands.cpp @@ -34,7 +34,7 @@ // CommandObjectCommandsSource //------------------------------------------------------------------------- -static constexpr OptionDefinition g_history_options[] = { +static CONSTEXPR OptionDefinition g_history_options[] = { // clang-format off { LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeUnsignedInteger, "How many history commands to print." }, { LLDB_OPT_SET_1, false, "start-index", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeUnsignedInteger, "Index at which to start printing history commands (or end to mean tail mode)." }, @@ -193,7 +193,7 @@ // CommandObjectCommandsSource //------------------------------------------------------------------------- -static constexpr OptionDefinition g_source_options[] = { +static CONSTEXPR OptionDefinition g_source_options[] = { // clang-format off { LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "If true, stop executing commands on error." }, { LLDB_OPT_SET_ALL, false, "stop-on-continue", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "If true, stop executing commands on continue." }, @@ -344,7 +344,7 @@ // CommandObjectCommandsAlias //------------------------------------------------------------------------- -static constexpr OptionDefinition g_alias_options[] = { +static CONSTEXPR OptionDefinition g_alias_options[] = { // clang-format off { LLDB_OPT_SET_ALL, false, "help", 'h', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeHelpText, "Help text for this command" }, { LLDB_OPT_SET_ALL, false, "long-help", 'H', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeHelpText, "Long help text for this command" }, @@ -918,7 +918,7 @@ // CommandObjectCommandsAddRegex //------------------------------------------------------------------------- -static constexpr OptionDefinition g_regex_options[] = { +static CONSTEXPR OptionDefinition g_regex_options[] = { // clang-format off { LLDB_OPT_SET_1, false, "help" , 'h', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeNone, "The help text to display for this command." }, { LLDB_OPT_SET_1, false, "syntax", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeNone, "A syntax string showing the typical usage syntax." }, @@ -1398,7 +1398,7 @@ // CommandObjectCommandsScriptImport //------------------------------------------------------------------------- -static constexpr OptionDefinition g_script_import_options[] = { +static CONSTEXPR OptionDefinition g_script_import_options[] = { // clang-format off { LLDB_OPT_SET_1, false, "allow-reload", 'r', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Allow the script to be loaded even if it was already loaded before. This argument exists for backwards compatibility, but reloading is always allowed, whether you specify it or not." }, // clang-format on @@ -1523,7 +1523,7 @@ //------------------------------------------------------------------------- // CommandObjectCommandsScriptAdd //------------------------------------------------------------------------- -static constexpr OptionEnumValueElement g_script_synchro_type[] = { +static CONSTEXPR OptionEnumValueElement g_script_synchro_type[] = { {eScriptedCommandSynchronicitySynchronous, "synchronous", "Run synchronous"}, {eScriptedCommandSynchronicityAsynchronous, "asynchronous", @@ -1531,11 +1531,11 @@ {eScriptedCommandSynchronicityCurrentValue, "current", "Do not alter current setting"} }; -static constexpr OptionEnumValues ScriptSynchroType() { +static CONSTEXPR OptionEnumValues ScriptSynchroType() { return OptionEnumValues(g_script_synchro_type); } -static constexpr OptionDefinition g_script_add_options[] = { +static CONSTEXPR OptionDefinition g_script_add_options[] = { // clang-format off { LLDB_OPT_SET_1, false, "function", 'f', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonFunction, "Name of the Python function to bind to this command name." }, { LLDB_OPT_SET_2, false, "class", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonClass, "Name of the Python class to bind to this command name." }, Index: source/Commands/CommandObjectExpression.cpp =================================================================== --- source/Commands/CommandObjectExpression.cpp +++ source/Commands/CommandObjectExpression.cpp @@ -39,17 +39,17 @@ CommandObjectExpression::CommandOptions::~CommandOptions() = default; -static constexpr OptionEnumValueElement g_description_verbosity_type[] = { +static CONSTEXPR OptionEnumValueElement g_description_verbosity_type[] = { {eLanguageRuntimeDescriptionDisplayVerbosityCompact, "compact", "Only show the description string"}, {eLanguageRuntimeDescriptionDisplayVerbosityFull, "full", "Show the full output, including persistent variable's name and type"} }; -static constexpr OptionEnumValues DescriptionVerbosityTypes() { +static CONSTEXPR OptionEnumValues DescriptionVerbosityTypes() { return OptionEnumValues(g_description_verbosity_type); } -static constexpr OptionDefinition g_expression_options[] = { +static CONSTEXPR OptionDefinition g_expression_options[] = { // clang-format off {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "all-threads", 'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Should we run all threads if the execution doesn't complete on one thread."}, {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "ignore-breakpoints", 'i', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Ignore breakpoint hits while running expressions"}, Index: source/Commands/CommandObjectTarget.cpp =================================================================== --- source/Commands/CommandObjectTarget.cpp +++ source/Commands/CommandObjectTarget.cpp @@ -137,7 +137,7 @@ // Note that the negation in the argument name causes a slightly confusing // mapping of the enum values, -static constexpr OptionEnumValueElement g_dependents_enumaration[] = { +static CONSTEXPR OptionEnumValueElement g_dependents_enumaration[] = { {eLoadDependentsDefault, "default", "Only load dependents when the target is an executable."}, {eLoadDependentsNo, "true", @@ -145,7 +145,7 @@ {eLoadDependentsYes, "false", "Load dependents, even if the target is not an executable."}}; -static constexpr OptionDefinition g_dependents_options[] = { +static CONSTEXPR OptionDefinition g_dependents_options[] = { {LLDB_OPT_SET_1, false, "no-dependents", 'd', OptionParser::eOptionalArgument, nullptr, OptionEnumValues(g_dependents_enumaration), 0, eArgTypeValue, @@ -1982,13 +1982,13 @@ #pragma mark CommandObjectTargetModulesDumpSymtab -static constexpr OptionEnumValueElement g_sort_option_enumeration[] = { +static CONSTEXPR OptionEnumValueElement g_sort_option_enumeration[] = { {eSortOrderNone, "none", "No sorting, use the original symbol table order."}, {eSortOrderByAddress, "address", "Sort output by symbol address."}, {eSortOrderByName, "name", "Sort output by symbol name."} }; -static constexpr OptionDefinition g_target_modules_dump_symtab_options[] = { +static CONSTEXPR OptionDefinition g_target_modules_dump_symtab_options[] = { // clang-format off { LLDB_OPT_SET_1, false, "sort", 's', OptionParser::eRequiredArgument, nullptr, OptionEnumValues(g_sort_option_enumeration), 0, eArgTypeSortOrder, "Supply a sort order when dumping the symbol table." } // clang-format on Index: source/Commands/CommandObjectThread.cpp =================================================================== --- source/Commands/CommandObjectThread.cpp +++ source/Commands/CommandObjectThread.cpp @@ -243,7 +243,7 @@ // CommandObjectThreadBacktrace //------------------------------------------------------------------------- -static constexpr OptionDefinition g_thread_backtrace_options[] = { +static CONSTEXPR OptionDefinition g_thread_backtrace_options[] = { // clang-format off { LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeCount, "How many frames to display (-1 for all)" }, { LLDB_OPT_SET_1, false, "start", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeFrameIndex, "Frame in which to start the backtrace" }, @@ -398,17 +398,17 @@ enum StepScope { eStepScopeSource, eStepScopeInstruction }; -static constexpr OptionEnumValueElement g_tri_running_mode[] = { +static CONSTEXPR OptionEnumValueElement g_tri_running_mode[] = { {eOnlyThisThread, "this-thread", "Run only this thread"}, {eAllThreads, "all-threads", "Run all threads"}, {eOnlyDuringStepping, "while-stepping", "Run only this thread while stepping"} }; -static constexpr OptionEnumValues TriRunningModes() { +static CONSTEXPR OptionEnumValues TriRunningModes() { return OptionEnumValues(g_tri_running_mode); } -static constexpr OptionDefinition g_thread_step_scope_options[] = { +static CONSTEXPR OptionDefinition g_thread_step_scope_options[] = { // clang-format off { LLDB_OPT_SET_1, false, "step-in-avoids-no-debug", 'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "A boolean value that sets whether stepping into functions will step over functions with no debug information." }, { LLDB_OPT_SET_1, false, "step-out-avoids-no-debug", 'A', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "A boolean value, if true stepping out of functions will continue to step out till it hits a function with debug information." }, @@ -992,15 +992,15 @@ // CommandObjectThreadUntil //------------------------------------------------------------------------- -static constexpr OptionEnumValueElement g_duo_running_mode[] = { +static CONSTEXPR OptionEnumValueElement g_duo_running_mode[] = { {eOnlyThisThread, "this-thread", "Run only this thread"}, {eAllThreads, "all-threads", "Run all threads"} }; -static constexpr OptionEnumValues DuoRunningModes() { +static CONSTEXPR OptionEnumValues DuoRunningModes() { return OptionEnumValues(g_duo_running_mode); } -static constexpr OptionDefinition g_thread_until_options[] = { +static CONSTEXPR OptionDefinition g_thread_until_options[] = { // clang-format off { LLDB_OPT_SET_1, false, "frame", 'f', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeFrameIndex, "Frame index for until operation - defaults to 0" }, { LLDB_OPT_SET_1, false, "thread", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeThreadIndex, "Thread index for the thread for until operation" }, Index: source/Commands/CommandObjectWatchpointCommand.cpp =================================================================== --- source/Commands/CommandObjectWatchpointCommand.cpp +++ source/Commands/CommandObjectWatchpointCommand.cpp @@ -34,18 +34,18 @@ // language to lldb and have it pickable here without having to change this // enumeration by hand and rebuild lldb proper. -static constexpr OptionEnumValueElement g_script_option_enumeration[] = { +static CONSTEXPR OptionEnumValueElement g_script_option_enumeration[] = { {eScriptLanguageNone, "command", "Commands are in the lldb command interpreter language"}, {eScriptLanguagePython, "python", "Commands are in the Python language."}, {eSortOrderByName, "default-script", "Commands are in the default scripting language."} }; -static constexpr OptionEnumValues ScriptOptionEnum() { +static CONSTEXPR OptionEnumValues ScriptOptionEnum() { return OptionEnumValues(g_script_option_enumeration); } -static constexpr OptionDefinition g_watchpoint_command_add_options[] = { +static CONSTEXPR OptionDefinition g_watchpoint_command_add_options[] = { // clang-format off { LLDB_OPT_SET_1, false, "one-liner", 'o', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeOneLiner, "Specify a one-line watchpoint command inline. Be sure to surround it with quotes." }, { LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Specify whether watchpoint command execution should terminate on error." }, Index: source/Core/Debugger.cpp =================================================================== --- source/Core/Debugger.cpp +++ source/Core/Debugger.cpp @@ -93,7 +93,7 @@ static DebuggerList *g_debugger_list_ptr = nullptr; // NOTE: intentional leak to avoid issues with C++ destructor chain -static constexpr OptionEnumValueElement g_show_disassembly_enum_values[] = { +static CONSTEXPR OptionEnumValueElement g_show_disassembly_enum_values[] = { {Debugger::eStopDisassemblyTypeNever, "never", "Never show disassembly when displaying a stop context."}, {Debugger::eStopDisassemblyTypeNoDebugInfo, "no-debuginfo", @@ -104,7 +104,7 @@ {Debugger::eStopDisassemblyTypeAlways, "always", "Always show disassembly when displaying a stop context."} }; -static constexpr OptionEnumValueElement g_language_enumerators[] = { +static CONSTEXPR OptionEnumValueElement g_language_enumerators[] = { {eScriptLanguageNone, "none", "Disable scripting languages."}, {eScriptLanguagePython, "python", "Select python as the default scripting language."}, @@ -182,7 +182,7 @@ // args}}:\n}{${function.changed}\n{${module.file.basename}`}{${function.name- // without-args}}:\n}{${current-pc-arrow} }{${addr-file-or-load}}: -static constexpr OptionEnumValueElement s_stop_show_column_values[] = { +static CONSTEXPR OptionEnumValueElement s_stop_show_column_values[] = { {eStopShowColumnAnsiOrCaret, "ansi-or-caret", "Highlight the stop column with ANSI terminal codes when color/ANSI mode " "is enabled; otherwise, fall back to using a text-only caret (^) as if " @@ -196,7 +196,7 @@ "display thread stop locations."}, {eStopShowColumnNone, "none", "Do not highlight the stop column."}}; -static constexpr PropertyDefinition g_properties[] = { +static CONSTEXPR PropertyDefinition g_properties[] = { {"auto-confirm", OptionValue::eTypeBoolean, true, false, nullptr, {}, "If true all confirmation prompts will receive their default reply."}, {"disassembly-format", OptionValue::eTypeFormatEntity, true, 0, Index: source/Interpreter/OptionGroupWatchpoint.cpp =================================================================== --- source/Interpreter/OptionGroupWatchpoint.cpp +++ source/Interpreter/OptionGroupWatchpoint.cpp @@ -16,19 +16,19 @@ using namespace lldb; using namespace lldb_private; -static constexpr OptionEnumValueElement g_watch_type[] = { +static CONSTEXPR OptionEnumValueElement g_watch_type[] = { {OptionGroupWatchpoint::eWatchRead, "read", "Watch for read"}, {OptionGroupWatchpoint::eWatchWrite, "write", "Watch for write"}, {OptionGroupWatchpoint::eWatchReadWrite, "read_write", - "Watch for read/write"} }; + "Watch for read/write"}}; -static constexpr OptionEnumValueElement g_watch_size[] = { +static CONSTEXPR OptionEnumValueElement g_watch_size[] = { {1, "1", "Watch for byte size of 1"}, {2, "2", "Watch for byte size of 2"}, {4, "4", "Watch for byte size of 4"}, - {8, "8", "Watch for byte size of 8"} }; + {8, "8", "Watch for byte size of 8"}}; -static constexpr OptionDefinition g_option_table[] = { +static CONSTEXPR OptionDefinition g_option_table[] = { {LLDB_OPT_SET_1, false, "watch", 'w', OptionParser::eRequiredArgument, nullptr, OptionEnumValues(g_watch_type), 0, eArgTypeWatchType, "Specify the type of watching to perform."}, Index: source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp =================================================================== --- source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -58,7 +58,7 @@ // range looking for a kernel }; -static constexpr OptionEnumValueElement g_kaslr_kernel_scan_enum_values[] = { +static CONSTEXPR OptionEnumValueElement g_kaslr_kernel_scan_enum_values[] = { {eKASLRScanNone, "none", "Do not read memory looking for a Darwin kernel when attaching."}, {eKASLRScanLowgloAddresses, "basic", "Check for the Darwin kernel's load " @@ -70,7 +70,7 @@ "Scan through the entire potential address range of Darwin kernel (only " "on 32-bit targets)."}}; -static constexpr PropertyDefinition g_properties[] = { +static CONSTEXPR PropertyDefinition g_properties[] = { {"load-kexts", OptionValue::eTypeBoolean, true, true, NULL, {}, "Automatically loads kext images when attaching to a kernel."}, {"scan-type", OptionValue::eTypeEnum, true, eKASLRScanNearPC, NULL, Index: source/Target/Target.cpp =================================================================== --- source/Target/Target.cpp +++ source/Target/Target.cpp @@ -3130,7 +3130,7 @@ //-------------------------------------------------------------- // clang-format off -static constexpr OptionEnumValueElement g_dynamic_value_types[] = { +static CONSTEXPR OptionEnumValueElement g_dynamic_value_types[] = { {eNoDynamicValues, "no-dynamic-values", "Don't calculate the dynamic type of values"}, {eDynamicCanRunTarget, "run-target", "Calculate the dynamic type of values " @@ -3142,7 +3142,7 @@ return OptionEnumValues(g_dynamic_value_types); } -static constexpr OptionEnumValueElement g_inline_breakpoint_enums[] = { +static CONSTEXPR OptionEnumValueElement g_inline_breakpoint_enums[] = { {eInlineBreakpointsNever, "never", "Never look for inline breakpoint " "locations (fastest). This setting " "should only be used if you know that " @@ -3161,16 +3161,16 @@ eX86DisFlavorATT } x86DisassemblyFlavor; -static constexpr OptionEnumValueElement g_x86_dis_flavor_value_types[] = { +static CONSTEXPR OptionEnumValueElement g_x86_dis_flavor_value_types[] = { {eX86DisFlavorDefault, "default", "Disassembler default (currently att)."}, {eX86DisFlavorIntel, "intel", "Intel disassembler flavor."}, {eX86DisFlavorATT, "att", "AT&T disassembler flavor."} }; -static constexpr OptionEnumValueElement g_hex_immediate_style_values[] = { +static CONSTEXPR OptionEnumValueElement g_hex_immediate_style_values[] = { {Disassembler::eHexStyleC, "c", "C-style (0xffff)."}, {Disassembler::eHexStyleAsm, "asm", "Asm-style (0ffffh)."} }; -static constexpr OptionEnumValueElement g_load_script_from_sym_file_values[] = { +static CONSTEXPR OptionEnumValueElement g_load_script_from_sym_file_values[] = { {eLoadScriptFromSymFileTrue, "true", "Load debug scripts inside symbol files"}, {eLoadScriptFromSymFileFalse, "false", @@ -3178,7 +3178,7 @@ {eLoadScriptFromSymFileWarn, "warn", "Warn about debug scripts inside symbol files but do not load them."} }; -static constexpr +static CONSTEXPR OptionEnumValueElement g_load_current_working_dir_lldbinit_values[] = { {eLoadCWDlldbinitTrue, "true", "Load .lldbinit files from current directory"}, @@ -3187,7 +3187,7 @@ {eLoadCWDlldbinitWarn, "warn", "Warn about loading .lldbinit files from current directory"} }; -static constexpr OptionEnumValueElement g_memory_module_load_level_values[] = { +static CONSTEXPR OptionEnumValueElement g_memory_module_load_level_values[] = { {eMemoryModuleLoadLevelMinimal, "minimal", "Load minimal information when loading modules from memory. Currently " "this setting loads sections only."}, @@ -3198,7 +3198,7 @@ "Load complete information when loading modules from memory. Currently " "this setting loads sections and all symbols."} }; -static constexpr PropertyDefinition g_properties[] = { +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,