Fix more functions in Args to use StringRef.
This patch also marks the const char* versions as =delete to prevent
their use. This has the potential to cause build breakages on some
platforms which I can't compile. I have tested on Windows, Linux,
and OSX. Best practices for fixing broken callsites are outlined in
Args.h in a comment above the deleted function declarations.
Eventually we can remove these =delete declarations, but for now they
are important to make sure that all implicit conversions from
const char * are manually audited to make sure that they do not invoke a
conversion from nullptr.
llvm-svn: 281919
diff --git a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
index 5ce7fb8..e594392 100644
--- a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
+++ b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
@@ -85,6 +85,8 @@
const int short_option = g_option_table[option_idx].short_option;
bool success = false;
+ auto option_strref = llvm::StringRef::withNullAsEmpty(option_arg);
+
switch (short_option) {
case 'd': {
int32_t result;
@@ -141,13 +143,13 @@
break;
case 'S':
- use_synth = Args::StringToBoolean(option_arg, true, &success);
+ use_synth = Args::StringToBoolean(option_strref, true, &success);
if (!success)
error.SetErrorStringWithFormat("invalid synthetic-type '%s'", option_arg);
break;
case 'V':
- run_validator = Args::StringToBoolean(option_arg, true, &success);
+ run_validator = Args::StringToBoolean(option_strref, true, &success);
if (!success)
error.SetErrorStringWithFormat("invalid validate '%s'", option_arg);
break;