diff --git a/llvm/examples/ExceptionDemo/ExceptionDemo.cpp b/llvm/examples/ExceptionDemo/ExceptionDemo.cpp index 0afc3fdf59aa..315f95ad4637 100644 --- a/llvm/examples/ExceptionDemo/ExceptionDemo.cpp +++ b/llvm/examples/ExceptionDemo/ExceptionDemo.cpp @@ -254,7 +254,7 @@ static llvm::AllocaInst *createEntryBlockAlloca(llvm::Function &function, llvm::Constant *initWith = 0) { llvm::BasicBlock &block = function.getEntryBlock(); llvm::IRBuilder<> tmp(&block, block.begin()); - llvm::AllocaInst *ret = tmp.CreateAlloca(type, 0, varName.c_str()); + llvm::AllocaInst *ret = tmp.CreateAlloca(type, 0, varName); if (initWith) tmp.CreateStore(initWith, ret); diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp index 02443ce15cc7..eb8832a92dca 100644 --- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp @@ -1047,7 +1047,7 @@ bool MIParser::parseIRConstant(StringRef::iterator Loc, StringRef StringValue, const Constant *&C) { auto Source = StringValue.str(); // The source has to be null terminated. SMDiagnostic Err; - C = parseConstantValue(Source.c_str(), Err, *MF.getFunction()->getParent(), + C = parseConstantValue(Source, Err, *MF.getFunction()->getParent(), &PFS.IRSlots); if (!C) return error(Loc + Err.getColumnNo(), Err.getMessage()); diff --git a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp index 4eee39cf8728..94aa70ef0326 100644 --- a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp +++ b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp @@ -614,7 +614,7 @@ bool DarwinAsmParser::parseDirectiveSection(StringRef, SMLoc) { TAA, TAAParsed, StubSize); if (!ErrorStr.empty()) - return Error(Loc, ErrorStr.c_str()); + return Error(Loc, ErrorStr); // Issue a warning if the target is not powerpc and Section is a *coal* section. Triple TT = getParser().getContext().getObjectFileInfo()->getTargetTriple(); diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp index ce8e216e9164..c4b35f5db9b4 100644 --- a/llvm/lib/MC/MachObjectWriter.cpp +++ b/llvm/lib/MC/MachObjectWriter.cpp @@ -422,7 +422,7 @@ void MachObjectWriter::writeLinkerOptionsLoadCommand( uint64_t BytesWritten = sizeof(MachO::linker_option_command); for (const std::string &Option : Options) { // Write each string, including the null byte. - writeBytes(Option.c_str(), Option.size() + 1); + writeBytes(Option, Option.size() + 1); BytesWritten += Option.size() + 1; } diff --git a/llvm/lib/ObjectYAML/ObjectYAML.cpp b/llvm/lib/ObjectYAML/ObjectYAML.cpp index 97741b5ec8b7..cbbaac6062a7 100644 --- a/llvm/lib/ObjectYAML/ObjectYAML.cpp +++ b/llvm/lib/ObjectYAML/ObjectYAML.cpp @@ -51,7 +51,7 @@ void MappingTraits::mapping(IO &IO, else IO.setError( llvm::Twine("YAML Object File unsupported document type tag '") + - llvm::Twine(Tag.c_str()) + llvm::Twine("'!")); + llvm::Twine(Tag) + llvm::Twine("'!")); } } } diff --git a/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp b/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp index 64f26a8ed4a1..36b6e7299233 100644 --- a/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp +++ b/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp @@ -1504,7 +1504,7 @@ bool HexagonAsmParser::OutOfRange(SMLoc IDLoc, long long Val, long long Max) { ES << "0-" << Max; else ES << Max << "-" << (-Max - 1); - return Parser.printError(IDLoc, ES.str().c_str()); + return Parser.printError(IDLoc, ES.str()); } int HexagonAsmParser::processInstruction(MCInst &Inst, diff --git a/llvm/lib/Target/Hexagon/HexagonVectorPrint.cpp b/llvm/lib/Target/Hexagon/HexagonVectorPrint.cpp index 5920ef715afc..af6d018d0ec4 100644 --- a/llvm/lib/Target/Hexagon/HexagonVectorPrint.cpp +++ b/llvm/lib/Target/Hexagon/HexagonVectorPrint.cpp @@ -80,7 +80,7 @@ static void addAsmInstr(MachineBasicBlock *MBB, unsigned Reg, MachineFunction &Fn) { std::string VDescStr = ".long 0x1dffe0" + getStringReg(Reg); - const char *cstr = Fn.createExternalSymbolName(VDescStr.c_str()); + const char *cstr = Fn.createExternalSymbolName(VDescStr); unsigned ExtraInfo = InlineAsm::Extra_HasSideEffects; BuildMI(*MBB, I, DL, QII->get(TargetOpcode::INLINEASM)) .addExternalSymbol(cstr) diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp index 86d8f64261a7..0b4dc15708b5 100644 --- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -224,8 +224,7 @@ void NVPTXAsmPrinter::lowerImageHandleSymbol(unsigned Index, MCOperand &MCOp) { const char *Sym = MFI->getImageHandleSymbol(Index); std::string *SymNamePtr = nvTM.getManagedStrPool()->getManagedString(Sym); - MCOp = GetSymbolRef(OutContext.getOrCreateSymbol( - StringRef(SymNamePtr->c_str()))); + MCOp = GetSymbolRef(OutContext.getOrCreateSymbol(StringRef(*SymNamePtr))); } void NVPTXAsmPrinter::lowerToMCInst(const MachineInstr *MI, MCInst &OutMI) { diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp index 532d21fbdbf1..6b6d0b7395a1 100644 --- a/llvm/tools/lli/lli.cpp +++ b/llvm/tools/lli/lli.cpp @@ -271,7 +271,7 @@ public: return nullptr; // Load the object from the cache filename ErrorOr> IRObjectBuffer = - MemoryBuffer::getFile(CacheName.c_str(), -1, false); + MemoryBuffer::getFile(CacheName, -1, false); // If the file isn't there, that's OK. if (!IRObjectBuffer) return nullptr; diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp index 483d50132332..58ae08b822ae 100644 --- a/llvm/tools/llvm-lto/llvm-lto.cpp +++ b/llvm/tools/llvm-lto/llvm-lto.cpp @@ -823,7 +823,7 @@ int main(int argc, char **argv) { for (unsigned i = BaseArg; i < InputFilenames.size(); ++i) { CurrentActivity = "loading file '" + InputFilenames[i] + "'"; ErrorOr> ModuleOrErr = - LTOModule::createFromFile(Context, InputFilenames[i].c_str(), Options); + LTOModule::createFromFile(Context, InputFilenames[i], Options); std::unique_ptr &Module = *ModuleOrErr; CurrentActivity = ""; @@ -851,11 +851,11 @@ int main(int argc, char **argv) { // Add all the exported symbols to the table of symbols to preserve. for (unsigned i = 0; i < ExportedSymbols.size(); ++i) - CodeGen.addMustPreserveSymbol(ExportedSymbols[i].c_str()); + CodeGen.addMustPreserveSymbol(ExportedSymbols[i]); // Add all the dso symbols to the table of symbols to expose. for (unsigned i = 0; i < KeptDSOSyms.size(); ++i) - CodeGen.addMustPreserveSymbol(KeptDSOSyms[i].c_str()); + CodeGen.addMustPreserveSymbol(KeptDSOSyms[i]); // Set cpu and attrs strings for the default target/subtarget. CodeGen.setCpu(MCPU.c_str()); @@ -870,7 +870,7 @@ int main(int argc, char **argv) { } if (!attrs.empty()) - CodeGen.setAttr(attrs.c_str()); + CodeGen.setAttr(attrs); if (FileType.getNumOccurrences()) CodeGen.setFileType(FileType); @@ -887,7 +887,7 @@ int main(int argc, char **argv) { ModuleFilename += ".merged.bc"; std::string ErrMsg; - if (!CodeGen.writeMergedModules(ModuleFilename.c_str())) + if (!CodeGen.writeMergedModules(ModuleFilename)) error("writing merged module failed."); } diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp index 64014e5a8e5d..2a6585fc6069 100644 --- a/llvm/tools/lto/lto.cpp +++ b/llvm/tools/lto/lto.cpp @@ -153,7 +153,7 @@ static void lto_add_attrs(lto_code_gen_t cg) { attrs.append(MAttrs[i]); } - CG->setAttr(attrs.c_str()); + CG->setAttr(attrs); } if (OptLevel < '0' || OptLevel > '3') diff --git a/llvm/tools/opt/PassPrinters.cpp b/llvm/tools/opt/PassPrinters.cpp index 88d2fe997a27..65a53038fc50 100644 --- a/llvm/tools/opt/PassPrinters.cpp +++ b/llvm/tools/opt/PassPrinters.cpp @@ -46,7 +46,7 @@ struct FunctionPassPrinter : public FunctionPass { return false; } - StringRef getPassName() const override { return PassName.c_str(); } + StringRef getPassName() const override { return PassName; } void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequiredID(PassToPrint->getTypeInfo()); @@ -83,7 +83,7 @@ struct CallGraphSCCPassPrinter : public CallGraphSCCPass { return false; } - StringRef getPassName() const override { return PassName.c_str(); } + StringRef getPassName() const override { return PassName; } void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequiredID(PassToPrint->getTypeInfo()); @@ -115,7 +115,7 @@ struct ModulePassPrinter : public ModulePass { return false; } - StringRef getPassName() const override { return PassName.c_str(); } + StringRef getPassName() const override { return PassName; } void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequiredID(PassToPrint->getTypeInfo()); @@ -148,7 +148,7 @@ struct LoopPassPrinter : public LoopPass { return false; } - StringRef getPassName() const override { return PassName.c_str(); } + StringRef getPassName() const override { return PassName; } void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequiredID(PassToPrint->getTypeInfo()); @@ -183,7 +183,7 @@ struct RegionPassPrinter : public RegionPass { return false; } - StringRef getPassName() const override { return PassName.c_str(); } + StringRef getPassName() const override { return PassName; } void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequiredID(PassToPrint->getTypeInfo()); @@ -217,7 +217,7 @@ struct BasicBlockPassPrinter : public BasicBlockPass { return false; } - StringRef getPassName() const override { return PassName.c_str(); } + StringRef getPassName() const override { return PassName; } void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequiredID(PassToPrint->getTypeInfo()); diff --git a/llvm/unittests/ExecutionEngine/MCJIT/MCJITTestAPICommon.h b/llvm/unittests/ExecutionEngine/MCJIT/MCJITTestAPICommon.h index f709f0c04d5e..a3d3d1fffdbe 100644 --- a/llvm/unittests/ExecutionEngine/MCJIT/MCJITTestAPICommon.h +++ b/llvm/unittests/ExecutionEngine/MCJIT/MCJITTestAPICommon.h @@ -67,7 +67,7 @@ protected: // If ARCH has sub-arch support, find it SmallVectorImpl::const_iterator I = SupportedSubArchs.begin(); for(; I != SupportedSubArchs.end(); ++I) - if (Host.getArchName().startswith(I->c_str())) + if (Host.getArchName().startswith(*I)) return true; return false;