[llvm] c50faff - [llvm] Remove redundant calls to str() and c_str() (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 30 09:05:17 PDT 2021
Author: Kazu Hirata
Date: 2021-08-30T09:05:05-07:00
New Revision: c50faffb4eeca004109a1591e56cd7cac2ed1083
URL: https://github.com/llvm/llvm-project/commit/c50faffb4eeca004109a1591e56cd7cac2ed1083
DIFF: https://github.com/llvm/llvm-project/commit/c50faffb4eeca004109a1591e56cd7cac2ed1083.diff
LOG: [llvm] Remove redundant calls to str() and c_str() (NFC)
Identified with readability-redundant-string-cstr.
Added:
Modified:
llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
llvm/lib/InterfaceStub/ELFObjHandler.cpp
llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp
llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
index 4a93181f5439d..a91d97ac92db5 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
@@ -540,7 +540,7 @@ void AsmPrinter::emitInlineAsm(const MachineInstr *MI) const {
"preserved across the asm statement, and clobbering them may "
"lead to undefined behaviour.";
MMI->getModule()->getContext().diagnose(DiagnosticInfoInlineAsm(
- LocCookie, Msg.c_str(), DiagnosticSeverity::DS_Warning));
+ LocCookie, Msg, DiagnosticSeverity::DS_Warning));
MMI->getModule()->getContext().diagnose(
DiagnosticInfoInlineAsm(LocCookie, Note, DiagnosticSeverity::DS_Note));
}
diff --git a/llvm/lib/InterfaceStub/ELFObjHandler.cpp b/llvm/lib/InterfaceStub/ELFObjHandler.cpp
index 112c1cea354ac..d41c7d3217d74 100644
--- a/llvm/lib/InterfaceStub/ELFObjHandler.cpp
+++ b/llvm/lib/InterfaceStub/ELFObjHandler.cpp
@@ -367,7 +367,7 @@ Error appendToError(Error Err, StringRef After) {
Stream << Err;
Stream << " " << After;
consumeError(std::move(Err));
- return createError(Stream.str().c_str());
+ return createError(Stream.str());
}
/// This function populates a DynamicEntries struct using an ELFT::DynRange.
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp
index 7b6959b56145b..efa6c71972829 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp
@@ -330,7 +330,7 @@ bool AMDGPUPrintfRuntimeBindingImpl::lowerPrintfForGpu(Module &M) {
M.getOrInsertFunction(StringRef("__printf_alloc"), FTy_alloc, Attr);
LLVM_DEBUG(dbgs() << "Printf metadata = " << Sizes.str() << '\n');
- std::string fmtstr = itostr(++UniqID) + ":" + Sizes.str().c_str();
+ std::string fmtstr = itostr(++UniqID) + ":" + Sizes.str();
MDString *fmtStrArray = MDString::get(Ctx, fmtstr);
// Instead of creating global variables, the
diff --git a/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
index 19f7692705691..4f68cd8a53669 100644
--- a/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
+++ b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
@@ -461,7 +461,7 @@ bool AVRAsmParser::tryParseRelocExpression(OperandVector &Operands) {
return true;
}
StringRef ModifierName = Parser.getTok().getString();
- ModifierKind = AVRMCExpr::getKindByName(ModifierName.str().c_str());
+ ModifierKind = AVRMCExpr::getKindByName(ModifierName);
if (ModifierKind != AVRMCExpr::VK_AVR_None) {
Parser.Lex();
@@ -469,7 +469,7 @@ bool AVRAsmParser::tryParseRelocExpression(OperandVector &Operands) {
if (Parser.getTok().getString() == GENERATE_STUBS &&
Parser.getTok().getKind() == AsmToken::Identifier) {
std::string GSModName = ModifierName.str() + "_" + GENERATE_STUBS;
- ModifierKind = AVRMCExpr::getKindByName(GSModName.c_str());
+ ModifierKind = AVRMCExpr::getKindByName(GSModName);
if (ModifierKind != AVRMCExpr::VK_AVR_None)
Parser.Lex(); // Eat gs modifier name
}
@@ -678,7 +678,7 @@ bool AVRAsmParser::parseLiteralValues(unsigned SizeInBytes, SMLoc L) {
Parser.getLexer().peekTok().getKind() == AsmToken::LParen) {
StringRef ModifierName = Parser.getTok().getString();
AVRMCExpr::VariantKind ModifierKind =
- AVRMCExpr::getKindByName(ModifierName.str().c_str());
+ AVRMCExpr::getKindByName(ModifierName);
if (ModifierKind != AVRMCExpr::VK_AVR_None) {
Parser.Lex();
Parser.Lex(); // Eat the modifier and parenthesis
@@ -722,7 +722,7 @@ unsigned AVRAsmParser::validateTargetOperandClass(MCParsedAsmOperand &AsmOp,
int64_t RegNum = Const->getValue();
std::ostringstream RegName;
RegName << "r" << RegNum;
- RegNum = MatchRegisterName(RegName.str().c_str());
+ RegNum = MatchRegisterName(RegName.str());
if (RegNum != AVR::NoRegister) {
Op.makeReg(RegNum);
if (validateOperandClass(Op, Expected) == Match_Success) {
More information about the llvm-commits
mailing list