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/Plugins/ExpressionParser/Clang/ASTDumper.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp
index 3c20b51..c74f147 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp
@@ -106,6 +106,4 @@
free(alloc);
}
-void ASTDumper::ToStream(lldb::StreamSP &stream) {
- stream->PutCString(m_dump.c_str());
-}
+void ASTDumper::ToStream(lldb::StreamSP &stream) { stream->PutCString(m_dump); }
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp
index 4081bc9..7bb784e 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp
@@ -60,7 +60,7 @@
RecordDecl *struct_decl = NULL;
- StringRef desired_name(m_struct_name.c_str());
+ StringRef desired_name(m_struct_name);
for (CompoundStmt::const_body_iterator bi = body_compound_stmt->body_begin(),
be = body_compound_stmt->body_end();
@@ -125,7 +125,7 @@
if (m_ast_context && function_decl &&
!m_function.m_wrapper_function_name.compare(
- function_decl->getNameAsString().c_str())) {
+ function_decl->getNameAsString())) {
ExtractFromFunctionDecl(function_decl);
}
}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index 7a5f4f7..b55d664 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -922,7 +922,7 @@
std::string decl_name_string_without_colon(decl_name_string.c_str(),
decl_name_string.length() - 1);
IdentifierInfo *ident =
- &original_ctx->Idents.get(decl_name_string_without_colon.c_str());
+ &original_ctx->Idents.get(decl_name_string_without_colon);
original_selector = original_ctx->Selectors.getSelector(1, &ident);
} else {
SmallVector<IdentifierInfo *, 4> idents;
@@ -1293,7 +1293,7 @@
return false;
std::string name_str = context.m_decl_name.getAsString();
- StringRef name(name_str.c_str());
+ StringRef name(name_str);
IdentifierInfo &name_identifier(
origin_iface_decl->getASTContext().Idents.get(name));
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index 3c21de2..c542b36 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -131,7 +131,7 @@
for (IDAndDiagnostic &diag : m_diagnostics) {
switch (diag.first) {
default:
- error_stream.PutCString(diag.second.c_str());
+ error_stream.PutCString(diag.second);
error_stream.PutChar('\n');
break;
case clang::DiagnosticsEngine::Level::Ignored:
@@ -441,7 +441,7 @@
if (macro_info) {
std::string macro_expansion = "#define ";
- macro_expansion.append(mi->first->getName().str().c_str());
+ macro_expansion.append(mi->first->getName().str());
{
if (macro_info->isFunctionLike()) {
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index 0956814..ac6e93c 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -1149,7 +1149,7 @@
GlobalVariable *persistent_global = new GlobalVariable(
(*m_module), alloc->getType(), false, /* not constant */
GlobalValue::ExternalLinkage, NULL, /* no initializer */
- alloc->getName().str().c_str());
+ alloc->getName().str());
// What we're going to do here is make believe this was a regular old external
// variable. That means we need to make the metadata valid.