From: Kazu Hirata Date: Mon, 30 Aug 2021 16:05:05 +0000 (-0700) Subject: [llvm] Remove redundant calls to str() and c_str() (NFC) X-Git-Tag: upstream/15.0.7~32719 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c50faffb4eeca004109a1591e56cd7cac2ed1083;p=platform%2Fupstream%2Fllvm.git [llvm] Remove redundant calls to str() and c_str() (NFC) Identified with readability-redundant-string-cstr. --- diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp index 4a93181..a91d97a 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 112c1ce..d41c7d3 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 7b6959b..efa6c71 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 19f7692..4f68cd8 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) {