Fix Clang-tidy readability-redundant-string-cstr warnings
Reviewers: zturner, labath
Subscribers: tberghammer, danalbert, lldb-commits
Differential Revision: https://reviews.llvm.org/D26233
llvm-svn: 285855
diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp
index 5eebc78..c07e5ae 100644
--- a/lldb/source/Commands/CommandCompletions.cpp
+++ b/lldb/source/Commands/CommandCompletions.cpp
@@ -414,7 +414,7 @@
match_start_point, max_return_elements,
matches),
m_include_support_files(include_support_files), m_matching_files() {
- FileSpec partial_spec(m_completion_str.c_str(), false);
+ FileSpec partial_spec(m_completion_str, false);
m_file_name = partial_spec.GetFilename().GetCString();
m_dir_name = partial_spec.GetDirectory().GetCString();
}
@@ -560,7 +560,7 @@
: CommandCompletions::Completer(interpreter, completion_str,
match_start_point, max_return_elements,
matches) {
- FileSpec partial_spec(m_completion_str.c_str(), false);
+ FileSpec partial_spec(m_completion_str, false);
m_file_name = partial_spec.GetFilename().GetCString();
m_dir_name = partial_spec.GetDirectory().GetCString();
}
diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index e977698..dcf6fa2 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -2305,8 +2305,7 @@
}
}
Error error = target->SerializeBreakpointsToFile(
- FileSpec(m_options.m_filename.c_str(), true), valid_bp_ids,
- m_options.m_append);
+ FileSpec(m_options.m_filename, true), valid_bp_ids, m_options.m_append);
if (!error.Success()) {
result.AppendErrorWithFormat("error serializing breakpoints: %s.",
error.AsCString());
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp
index 3df7fb7..ee7add9 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -635,7 +635,7 @@
}
// Verify that the command is alias-able.
- if (m_interpreter.CommandExists(alias_command.c_str())) {
+ if (m_interpreter.CommandExists(alias_command)) {
result.AppendErrorWithFormat(
"'%s' is a permanent debugger command and cannot be redefined.\n",
alias_command.c_str());
@@ -728,7 +728,7 @@
// Verify that the command is alias'able, and get the appropriate command
// object.
- if (m_interpreter.CommandExists(alias_command.c_str())) {
+ if (m_interpreter.CommandExists(alias_command)) {
result.AppendErrorWithFormat(
"'%s' is a permanent debugger command and cannot be redefined.\n",
alias_command.c_str());
@@ -780,17 +780,17 @@
args.GetCommandString(args_string);
}
- if (m_interpreter.AliasExists(alias_command.c_str()) ||
- m_interpreter.UserCommandExists(alias_command.c_str())) {
+ if (m_interpreter.AliasExists(alias_command) ||
+ m_interpreter.UserCommandExists(alias_command)) {
result.AppendWarningWithFormat(
"Overwriting existing definition for '%s'.\n",
alias_command.c_str());
}
if (CommandAlias *alias = m_interpreter.AddAlias(
- alias_command.c_str(),
+ alias_command,
use_subcommand ? subcommand_obj_sp : command_obj_sp,
- args_string.c_str())) {
+ args_string)) {
if (m_command_options.m_help.OptionWasSet())
alias->SetHelp(m_command_options.m_help.GetCurrentValue());
if (m_command_options.m_long_help.OptionWasSet())
@@ -1713,7 +1713,7 @@
// everything should be fine now, let's add this alias
CommandObjectSP command_obj_sp(new CommandObjectPythonFunction(
- m_interpreter, m_cmd_name, funct_name_str.c_str(), m_short_help,
+ m_interpreter, m_cmd_name, funct_name_str, m_short_help,
m_synchronicity));
if (!m_interpreter.AddUserCommand(m_cmd_name, command_obj_sp,
diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp
index 1df7052..eae5ddc 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -591,7 +591,7 @@
scope_string = GetScopeString(var_sp).str();
if (!scope_string.empty())
- s.PutCString(scope_string.c_str());
+ s.PutCString(scope_string);
if (m_option_variable.show_decl &&
var_sp->GetDeclaration().GetFile()) {
@@ -637,7 +637,7 @@
scope_string = GetScopeString(var_sp).str();
if (!scope_string.empty())
- s.PutCString(scope_string.c_str());
+ s.PutCString(scope_string);
// if (format != eFormatDefault)
// valobj_sp->SetFormat (format);
@@ -698,7 +698,7 @@
continue;
if (!scope_string.empty())
- s.PutCString(scope_string.c_str());
+ s.PutCString(scope_string);
if (m_option_variable.show_decl &&
var_sp->GetDeclaration().GetFile()) {
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index e4cd5a4..80e21f7 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -550,7 +550,7 @@
perms = lldb::eFilePermissionsUserRW | lldb::eFilePermissionsGroupRW |
lldb::eFilePermissionsWorldRead;
lldb::user_id_t fd = platform_sp->OpenFile(
- FileSpec(cmd_line.c_str(), false),
+ FileSpec(cmd_line, false),
File::eOpenOptionRead | File::eOpenOptionWrite |
File::eOpenOptionAppend | File::eOpenOptionCanCreate,
perms, error);
@@ -957,7 +957,7 @@
if (platform_sp) {
std::string remote_file_path(args.GetArgumentAtIndex(0));
user_id_t size =
- platform_sp->GetFileSize(FileSpec(remote_file_path.c_str(), false));
+ platform_sp->GetFileSize(FileSpec(remote_file_path, false));
if (size != UINT64_MAX) {
result.AppendMessageWithFormat("File size of %s (remote): %" PRIu64
"\n",
@@ -1793,7 +1793,7 @@
error = (platform_sp->RunShellCommand(expr, working_dir, &status, &signo,
&output, m_options.timeout));
if (!output.empty())
- result.GetOutputStream().PutCString(output.c_str());
+ result.GetOutputStream().PutCString(output);
if (status > 0) {
if (signo > 0) {
const char *signo_cstr = Host::GetSignalAsCString(signo);
diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp
index b0231a7..6f1a50d 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -609,7 +609,7 @@
m_module_list.Clear();
if (!m_options.modules.empty()) {
for (size_t i = 0, e = m_options.modules.size(); i < e; ++i) {
- FileSpec module_file_spec(m_options.modules[i].c_str(), false);
+ FileSpec module_file_spec(m_options.modules[i], false);
if (module_file_spec) {
ModuleSpec module_spec(module_file_spec);
if (target->GetImages().FindModules(module_spec, m_module_list) == 0)
@@ -944,7 +944,7 @@
if (num_modules > 0) {
ModuleList matching_modules;
for (size_t i = 0; i < num_modules; ++i) {
- FileSpec module_file_spec(m_options.modules[i].c_str(), false);
+ FileSpec module_file_spec(m_options.modules[i], false);
if (module_file_spec) {
ModuleSpec module_spec(module_file_spec);
matching_modules.Clear();
@@ -969,7 +969,7 @@
if (num_modules > 0) {
ModuleList matching_modules;
for (size_t i = 0; i < num_modules; ++i) {
- FileSpec module_file_spec(m_options.modules[i].c_str(), false);
+ FileSpec module_file_spec(m_options.modules[i], false);
if (module_file_spec) {
ModuleSpec module_spec(module_file_spec);
matching_modules.Clear();
@@ -1228,7 +1228,7 @@
if (!m_options.modules.empty()) {
ModuleList matching_modules;
for (size_t i = 0, e = m_options.modules.size(); i < e; ++i) {
- FileSpec module_file_spec(m_options.modules[i].c_str(), false);
+ FileSpec module_file_spec(m_options.modules[i], false);
if (module_file_spec) {
ModuleSpec module_spec(module_file_spec);
matching_modules.Clear();
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index ba4aeb8..9cd82c2 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -1279,7 +1279,7 @@
if (width)
strm.Printf("%-*s", width, arch_str.c_str());
else
- strm.PutCString(arch_str.c_str());
+ strm.PutCString(arch_str);
}
}