[clang-tools-extra] e1bb54b - [clangd, llvm] Remove redundant calls to c_str() (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 2 09:07:22 PDT 2021
Author: Kazu Hirata
Date: 2021-09-02T09:07:13-07:00
New Revision: e1bb54b5930544b48c3a94069c037648a6adfc65
URL: https://github.com/llvm/llvm-project/commit/e1bb54b5930544b48c3a94069c037648a6adfc65
DIFF: https://github.com/llvm/llvm-project/commit/e1bb54b5930544b48c3a94069c037648a6adfc65.diff
LOG: [clangd, llvm] Remove redundant calls to c_str() (NFC)
Identified with readability-redundant-string-cstr.
Added:
Modified:
clang-tools-extra/clangd/PathMapping.cpp
llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
llvm/tools/bugpoint/OptimizerDriver.cpp
llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
llvm/tools/llvm-lto/llvm-lto.cpp
llvm/tools/llvm-readobj/ELFDumper.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/PathMapping.cpp b/clang-tools-extra/clangd/PathMapping.cpp
index 0cd9d22b998ca..cc98025393841 100644
--- a/clang-tools-extra/clangd/PathMapping.cpp
+++ b/clang-tools-extra/clangd/PathMapping.cpp
@@ -40,7 +40,7 @@ llvm::Optional<std::string> doPathMapping(llvm::StringRef S,
llvm::StringRef Body = Uri->body();
if (Body.consume_front(From) && (Body.empty() || Body.front() == '/')) {
std::string MappedBody = (To + Body).str();
- return URI(Uri->scheme(), Uri->authority(), MappedBody.c_str())
+ return URI(Uri->scheme(), Uri->authority(), MappedBody)
.toString();
}
}
diff --git a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
index fe335f154703c..1cbd650bdf064 100644
--- a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
+++ b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
@@ -26,7 +26,7 @@ NVPTXTargetStreamer::~NVPTXTargetStreamer() = default;
void NVPTXTargetStreamer::outputDwarfFileDirectives() {
for (const std::string &S : DwarfFiles)
- getStreamer().emitRawText(S.data());
+ getStreamer().emitRawText(S);
DwarfFiles.clear();
}
diff --git a/llvm/tools/bugpoint/OptimizerDriver.cpp b/llvm/tools/bugpoint/OptimizerDriver.cpp
index ca78735202fcb..848baf90965be 100644
--- a/llvm/tools/bugpoint/OptimizerDriver.cpp
+++ b/llvm/tools/bugpoint/OptimizerDriver.cpp
@@ -223,8 +223,8 @@ bool BugDriver::runPasses(Module &Program,
for (std::vector<std::string>::const_iterator I = pass_args.begin(),
E = pass_args.end();
I != E; ++I)
- Args.push_back(I->c_str());
- Args.push_back(Temp->TmpName.c_str());
+ Args.push_back(*I);
+ Args.push_back(Temp->TmpName);
Args.append(ExtraArgs.begin(), ExtraArgs.end());
LLVM_DEBUG(errs() << "\nAbout to run:\t";
diff --git a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
index fbb882e4d2a8f..83c83197118d5 100644
--- a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
+++ b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
@@ -337,7 +337,7 @@ static llvm::Error handleObjectFile(ObjectFile &Obj,
// Save the GSYM file to disk.
support::endianness Endian =
Obj.makeTriple().isLittleEndian() ? support::little : support::big;
- if (auto Err = Gsym.save(OutFile.c_str(), Endian))
+ if (auto Err = Gsym.save(OutFile, Endian))
return Err;
// Verify the DWARF if requested. This will ensure all the info in the DWARF
@@ -359,7 +359,7 @@ static llvm::Error handleBuffer(StringRef Filename, MemoryBufferRef Buffer,
Triple ObjTriple(Obj->makeTriple());
auto ArchName = ObjTriple.getArchName();
outs() << "Output file (" << ArchName << "): " << OutFile << "\n";
- if (auto Err = handleObjectFile(*Obj, OutFile.c_str()))
+ if (auto Err = handleObjectFile(*Obj, OutFile))
return Err;
} else if (auto *Fat = dyn_cast<MachOUniversalBinary>(BinOrErr->get())) {
// Iterate over all contained architectures and filter out any that were
diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp
index 183798634a8be..5332ef28d94e7 100644
--- a/llvm/tools/llvm-lto/llvm-lto.cpp
+++ b/llvm/tools/llvm-lto/llvm-lto.cpp
@@ -1059,7 +1059,7 @@ int main(int argc, char **argv) {
CodeGen.addMustPreserveSymbol(KeptDSOSyms[i]);
// Set cpu and attrs strings for the default target/subtarget.
- CodeGen.setCpu(codegen::getMCPU().c_str());
+ CodeGen.setCpu(codegen::getMCPU());
CodeGen.setOptLevel(OptLevel - '0');
CodeGen.setAttrs(codegen::getMAttrs());
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 1073f22ddd091..273fa8ae9b439 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -4362,7 +4362,7 @@ template <class ELFT> void GNUELFDumper<ELFT>::printDynamicTable() {
for (auto Entry : Table) {
uintX_t Tag = Entry.getTag();
std::string Type =
- std::string("(") + this->Obj.getDynamicTagAsString(Tag).c_str() + ")";
+ std::string("(") + this->Obj.getDynamicTagAsString(Tag) + ")";
std::string Value = this->getDynamicEntry(Tag, Entry.getVal());
OS << " " << format_hex(Tag, ELFT::Is64Bits ? 18 : 10)
<< format(ValueFmt.c_str(), Type.c_str()) << Value << "\n";
More information about the cfe-commits
mailing list