From 87d13166c7d204c4a70148c64edd0589fd05415d Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Tue, 28 Jan 2020 20:23:46 +0100 Subject: [PATCH] Make llvm::StringRef to std::string conversions explicit. This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up. --- include/llvm/ADT/StringRef.h | 4 +- .../llvm/Analysis/BlockFrequencyInfoImpl.h | 2 +- include/llvm/Analysis/RegionInfoImpl.h | 4 +- include/llvm/Analysis/TargetLibraryInfo.h | 2 +- include/llvm/CodeGen/CommandFlags.inc | 3 +- .../Orc/CompileOnDemandLayer.h | 15 ++--- .../ExecutionEngine/Orc/LazyEmittingLayer.h | 2 +- .../Orc/RTDyldObjectLinkingLayer.h | 2 +- include/llvm/IR/InstrTypes.h | 2 +- include/llvm/IR/Module.h | 8 +-- include/llvm/IR/ModuleSummaryIndex.h | 8 +-- include/llvm/IR/ModuleSummaryIndexYAML.h | 2 +- include/llvm/LTO/legacy/LTOCodeGenerator.h | 4 +- include/llvm/MC/MCAssembler.h | 2 +- include/llvm/MC/MCContext.h | 2 +- include/llvm/MC/MCDwarf.h | 8 +-- include/llvm/MC/MCSymbolWasm.h | 12 +++- include/llvm/MC/SubtargetFeature.h | 2 +- include/llvm/Object/MachO.h | 2 +- include/llvm/Object/TapiUniversal.h | 2 +- include/llvm/Option/Option.h | 2 +- include/llvm/ProfileData/InstrProf.h | 2 +- include/llvm/Support/DebugCounter.h | 2 +- include/llvm/Support/GraphWriter.h | 2 +- include/llvm/Support/JSON.h | 4 +- .../llvm/Support/SmallVectorMemoryBuffer.h | 2 +- include/llvm/Support/YAMLTraits.h | 2 +- include/llvm/TableGen/Record.h | 10 +++- include/llvm/TableGen/StringToOffsetTable.h | 2 +- include/llvm/TextAPI/MachO/InterfaceFile.h | 6 +- lib/Analysis/CallPrinter.cpp | 2 +- lib/Analysis/LazyCallGraph.cpp | 5 +- lib/Analysis/VFABIDemangling.cpp | 2 +- lib/Analysis/VectorUtils.cpp | 2 +- lib/AsmParser/LLParser.cpp | 4 +- lib/Bitcode/Reader/BitcodeReader.cpp | 2 +- lib/Bitcode/Writer/BitcodeWriter.cpp | 10 ++-- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 4 +- lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 17 +++--- lib/CodeGen/FEntryInserter.cpp | 4 +- lib/CodeGen/GCMetadata.cpp | 2 +- lib/CodeGen/GlobalMerge.cpp | 2 +- lib/CodeGen/MIRParser/MIParser.cpp | 4 +- lib/CodeGen/MIRPrinter.cpp | 4 +- .../MachineOptimizationRemarkEmitter.cpp | 2 +- lib/CodeGen/MachineOutliner.cpp | 2 +- lib/CodeGen/MachineScheduler.cpp | 2 +- lib/CodeGen/ScheduleDAGPrinter.cpp | 2 +- .../SelectionDAG/SelectionDAGDumper.cpp | 2 +- .../SelectionDAG/SelectionDAGPrinter.cpp | 2 +- lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 4 +- lib/DWARFLinker/DWARFLinker.cpp | 4 +- lib/DebugInfo/CodeView/RecordName.cpp | 2 +- lib/DebugInfo/CodeView/TypeRecordMapping.cpp | 39 ++++++------- lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp | 5 +- lib/DebugInfo/DWARF/DWARFDebugLine.cpp | 4 +- lib/DebugInfo/GSYM/LookupResult.cpp | 4 +- .../PDB/Native/DbiModuleDescriptorBuilder.cpp | 6 +- .../PDB/Native/NativeCompilandSymbol.cpp | 4 +- .../PDB/Native/NativeEnumInjectedSources.cpp | 6 +- lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp | 2 +- .../PDB/Native/NativeSymbolEnumerator.cpp | 4 +- lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp | 2 +- .../PDB/Native/NativeTypeTypedef.cpp | 4 +- lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp | 2 +- lib/DebugInfo/PDB/Native/PDBFile.cpp | 3 +- lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp | 2 +- lib/DebugInfo/Symbolize/DIPrinter.cpp | 2 +- lib/DebugInfo/Symbolize/Symbolize.cpp | 20 ++++--- lib/ExecutionEngine/ExecutionEngine.cpp | 26 ++++----- .../JITLink/MachOLinkGraphBuilder.cpp | 4 +- lib/ExecutionEngine/MCJIT/MCJIT.cpp | 4 +- .../Orc/CompileOnDemandLayer.cpp | 2 +- lib/ExecutionEngine/Orc/Core.cpp | 4 +- .../Orc/JITTargetMachineBuilder.cpp | 2 +- lib/ExecutionEngine/Orc/OrcCBindingsStack.h | 4 +- lib/ExecutionEngine/Orc/OrcMCJITReplacement.h | 9 +-- .../RuntimeDyld/RuntimeDyldImpl.h | 2 +- lib/FuzzMutate/FuzzerCLI.cpp | 4 +- lib/IR/AsmWriter.cpp | 2 +- lib/IR/AttributeImpl.h | 3 +- lib/IR/Attributes.cpp | 4 +- lib/IR/AutoUpgrade.cpp | 10 ++-- lib/IR/ConstantsContext.h | 4 +- lib/IR/DataLayout.cpp | 2 +- lib/IR/DiagnosticInfo.cpp | 29 +++++----- lib/IR/Globals.cpp | 2 +- lib/IR/InlineAsm.cpp | 10 ++-- lib/IR/LegacyPassManager.cpp | 5 +- lib/IR/Module.cpp | 3 +- lib/LTO/Caching.cpp | 2 +- lib/LTO/LTO.cpp | 14 ++--- lib/LTO/LTOCodeGenerator.cpp | 2 +- lib/LTO/ThinLTOCodeGenerator.cpp | 6 +- lib/LineEditor/LineEditor.cpp | 4 +- lib/MC/MCContext.cpp | 6 +- lib/MC/MCDwarf.cpp | 4 +- lib/MC/MCParser/AsmParser.cpp | 2 +- lib/MC/MCParser/DarwinAsmParser.cpp | 2 +- lib/MC/MCSubtargetInfo.cpp | 20 ++++--- lib/MC/SubtargetFeature.cpp | 4 +- lib/MC/WinCOFFObjectWriter.cpp | 2 +- lib/MCA/InstrBuilder.cpp | 2 +- lib/Object/Archive.cpp | 4 +- lib/Object/ArchiveWriter.cpp | 2 +- lib/Object/COFFImportFile.cpp | 2 +- lib/Object/COFFModuleDefinition.cpp | 8 +-- lib/Object/IRSymtab.cpp | 2 +- lib/Object/WasmObjectFile.cpp | 2 +- lib/Object/WindowsResource.cpp | 4 +- lib/Option/Arg.cpp | 2 +- lib/Option/ArgList.cpp | 2 +- lib/Option/OptTable.cpp | 6 +- lib/Passes/StandardInstrumentations.cpp | 4 +- lib/ProfileData/GCOV.cpp | 4 +- lib/ProfileData/InstrProf.cpp | 4 +- lib/ProfileData/SampleProfReader.cpp | 8 +-- lib/Remarks/BitstreamRemarkParser.cpp | 2 +- lib/Remarks/RemarkLinker.cpp | 2 +- lib/Remarks/YAMLRemarkParser.h | 2 +- lib/Support/APInt.cpp | 2 +- lib/Support/CommandLine.cpp | 6 +- lib/Support/Debug.cpp | 2 +- lib/Support/DebugCounter.cpp | 6 +- lib/Support/FileCheck.cpp | 4 +- lib/Support/FileCollector.cpp | 2 +- lib/Support/GraphWriter.cpp | 4 +- lib/Support/LockFileManager.cpp | 8 +-- lib/Support/Path.cpp | 7 ++- lib/Support/Process.cpp | 2 +- lib/Support/Regex.cpp | 2 +- lib/Support/Signals.cpp | 2 +- lib/Support/SourceMgr.cpp | 14 ++--- lib/Support/SpecialCaseList.cpp | 4 +- lib/Support/TarWriter.cpp | 3 +- lib/Support/TimeProfiler.cpp | 7 ++- lib/Support/Timer.cpp | 3 +- lib/Support/ToolOutputFile.cpp | 2 +- lib/Support/Unix/Host.inc | 2 +- lib/Support/Unix/Program.inc | 11 ++-- lib/Support/VirtualFileSystem.cpp | 21 +++---- lib/Support/YAMLParser.cpp | 6 +- lib/TableGen/Record.cpp | 15 +++-- lib/TableGen/SetTheory.cpp | 2 +- lib/TableGen/TGParser.cpp | 2 +- lib/Target/AArch64/AArch64SIMDInstrOpt.cpp | 5 +- .../AMDGPU/AMDGPUHSAMetadataStreamer.cpp | 11 ++-- lib/Target/AMDGPU/AMDGPULibCalls.cpp | 2 +- lib/Target/AMDGPU/AMDGPULibFunc.cpp | 4 +- lib/Target/AMDGPU/AMDGPULibFunc.h | 4 +- .../AMDGPU/AMDGPUPropagateAttributes.cpp | 2 +- .../AMDGPU/AsmParser/AMDGPUAsmParser.cpp | 2 +- .../MCTargetDesc/AMDGPUTargetStreamer.cpp | 2 +- lib/Target/ARM/ARMAsmPrinter.cpp | 5 +- lib/Target/ARM/ARMConstantPoolValue.cpp | 2 +- lib/Target/ARM/ARMISelLowering.cpp | 2 +- lib/Target/ARM/ARMSubtarget.cpp | 2 +- .../ARM/MCTargetDesc/ARMELFStreamer.cpp | 28 +++------ .../ARM/MCTargetDesc/ARMMCTargetDesc.cpp | 2 +- lib/Target/BPF/BPFAbstractMemberAccess.cpp | 4 +- lib/Target/BPF/BPFTargetMachine.cpp | 2 +- lib/Target/BPF/BTFDebug.cpp | 20 ++++--- .../Hexagon/AsmParser/HexagonAsmParser.cpp | 4 +- lib/Target/Hexagon/HexagonSubtarget.cpp | 5 +- .../MCTargetDesc/HexagonMCTargetDesc.cpp | 2 +- lib/Target/Lanai/LanaiSubtarget.cpp | 2 +- .../Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp | 2 +- lib/Target/MSP430/MSP430Subtarget.cpp | 2 +- lib/Target/MSP430/MSP430TargetMachine.cpp | 2 +- lib/Target/Mips/Mips16HardFloat.cpp | 4 +- lib/Target/Mips/MipsRegisterBankInfo.cpp | 2 +- lib/Target/Mips/MipsSubtarget.cpp | 2 +- lib/Target/NVPTX/NVPTXAsmPrinter.cpp | 4 +- lib/Target/NVPTX/NVPTXGenericToNVVM.cpp | 2 +- lib/Target/NVPTX/NVPTXReplaceImageHandles.cpp | 2 +- lib/Target/NVPTX/NVPTXSubtarget.cpp | 10 ++-- lib/Target/NVPTX/NVPTXTargetMachine.cpp | 2 +- lib/Target/NVPTX/NVPTXUtilities.cpp | 6 +- lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp | 4 +- lib/Target/PowerPC/PPCSubtarget.cpp | 2 +- lib/Target/PowerPC/PPCTargetMachine.cpp | 2 +- .../RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp | 2 +- lib/Target/RISCV/RISCVSubtarget.cpp | 2 +- lib/Target/Sparc/SparcSubtarget.cpp | 2 +- lib/Target/Sparc/SparcTargetMachine.cpp | 3 +- lib/Target/SystemZ/SystemZSubtarget.cpp | 2 +- lib/Target/SystemZ/SystemZTargetMachine.cpp | 2 +- lib/Target/TargetMachine.cpp | 8 +-- lib/Target/TargetMachineC.cpp | 4 +- .../WebAssemblyAddMissingPrototypes.cpp | 2 +- .../WebAssemblyLowerEmscriptenEHSjLj.cpp | 4 +- .../WebAssembly/WebAssemblyTargetMachine.cpp | 4 +- .../X86/MCTargetDesc/X86MCTargetDesc.cpp | 2 +- lib/Target/X86/X86Subtarget.cpp | 4 +- lib/Target/XCore/XCoreTargetMachine.cpp | 2 +- lib/TextAPI/MachO/ArchitectureSet.cpp | 2 +- lib/TextAPI/MachO/InterfaceFile.cpp | 4 +- lib/TextAPI/MachO/TextStub.cpp | 4 +- lib/TextAPI/MachO/TextStubCommon.cpp | 2 +- .../llvm-dlltool/DlltoolDriver.cpp | 2 +- lib/ToolDrivers/llvm-lib/LibDriver.cpp | 2 +- lib/Transforms/IPO/ArgumentPromotion.cpp | 2 +- lib/Transforms/IPO/BlockExtractor.cpp | 3 +- lib/Transforms/IPO/FunctionImport.cpp | 7 ++- lib/Transforms/IPO/LowerTypeTests.cpp | 11 ++-- lib/Transforms/IPO/SampleProfile.cpp | 2 +- lib/Transforms/IPO/WholeProgramDevirt.cpp | 8 +-- .../Instrumentation/AddressSanitizer.cpp | 2 +- .../Instrumentation/DataFlowSanitizer.cpp | 2 +- .../Instrumentation/GCOVProfiling.cpp | 13 +++-- .../Instrumentation/Instrumentation.cpp | 2 +- .../Instrumentation/PGOInstrumentation.cpp | 6 +- lib/Transforms/Scalar/LoopDeletion.cpp | 2 +- lib/Transforms/Scalar/LoopUnrollPass.cpp | 4 +- .../Scalar/LowerMatrixIntrinsics.cpp | 4 +- lib/Transforms/Scalar/SimpleLoopUnswitch.cpp | 2 +- lib/Transforms/Utils/InjectTLIMappings.cpp | 7 ++- lib/Transforms/Utils/InlineFunction.cpp | 2 +- lib/Transforms/Utils/NameAnonGlobals.cpp | 2 +- lib/Transforms/Utils/SSAUpdater.cpp | 2 +- lib/Transforms/Utils/SymbolRewriter.cpp | 30 +++++----- lib/XRay/FDRTraceExpander.cpp | 6 +- tools/bugpoint/CrashDebugger.cpp | 2 +- tools/bugpoint/ExecutionDriver.cpp | 4 +- tools/bugpoint/Miscompilation.cpp | 21 ++++--- tools/bugpoint/OptimizerDriver.cpp | 2 +- tools/bugpoint/ToolRunner.cpp | 4 +- tools/bugpoint/ToolRunner.h | 2 +- tools/bugpoint/bugpoint.cpp | 4 +- tools/dsymutil/BinaryHolder.cpp | 4 +- tools/dsymutil/DebugMap.cpp | 5 +- tools/dsymutil/DebugMap.h | 6 +- tools/dsymutil/MachODebugMapParser.cpp | 11 ++-- tools/dsymutil/MachOUtils.cpp | 2 +- tools/dsymutil/MachOUtils.h | 2 +- tools/dsymutil/dsymutil.cpp | 15 ++--- tools/gold/gold-plugin.cpp | 30 +++++----- tools/llc/llc.cpp | 8 +-- tools/lli/lli.cpp | 2 +- tools/llvm-ar/llvm-ar.cpp | 6 +- tools/llvm-cfi-verify/lib/FileAnalysis.cpp | 11 ++-- tools/llvm-config/llvm-config.cpp | 7 ++- tools/llvm-cov/CodeCoverage.cpp | 10 ++-- tools/llvm-cov/CoverageSummaryInfo.cpp | 2 +- tools/llvm-cov/SourceCoverageView.cpp | 4 +- tools/llvm-cov/SourceCoverageViewHTML.cpp | 8 +-- tools/llvm-cxxfilt/llvm-cxxfilt.cpp | 4 +- tools/llvm-dwarfdump/Statistics.cpp | 2 +- tools/llvm-elfabi/ELFObjHandler.cpp | 6 +- tools/llvm-exegesis/lib/BenchmarkRunner.cpp | 4 +- .../lib/SerialSnippetGenerator.cpp | 6 +- tools/llvm-exegesis/lib/SnippetGenerator.cpp | 3 +- tools/llvm-ifs/llvm-ifs.cpp | 2 +- tools/llvm-link/llvm-link.cpp | 2 +- tools/llvm-lipo/llvm-lipo.cpp | 7 ++- tools/llvm-lto/llvm-lto.cpp | 4 +- tools/llvm-lto2/llvm-lto2.cpp | 15 +++-- tools/llvm-mc/llvm-mc.cpp | 2 +- tools/llvm-mca/llvm-mca.cpp | 2 +- tools/llvm-ml/llvm-ml.cpp | 2 +- tools/llvm-nm/llvm-nm.cpp | 6 +- tools/llvm-objcopy/ELF/ELFObjcopy.cpp | 4 +- tools/llvm-objcopy/ELF/Object.cpp | 2 +- tools/llvm-objcopy/MachO/MachOObjcopy.cpp | 2 +- tools/llvm-objcopy/MachO/Object.h | 4 +- tools/llvm-objdump/ELFDump.cpp | 2 +- tools/llvm-objdump/MachODump.cpp | 2 +- tools/llvm-objdump/llvm-objdump.cpp | 6 +- tools/llvm-opt-report/OptReport.cpp | 9 ++- tools/llvm-pdbutil/DumpOutputStyle.cpp | 4 +- tools/llvm-pdbutil/FormatUtil.cpp | 12 ++-- tools/llvm-pdbutil/MinimalSymbolDumper.cpp | 4 +- tools/llvm-pdbutil/MinimalTypeDumper.cpp | 5 +- tools/llvm-pdbutil/StreamUtil.cpp | 6 +- tools/llvm-pdbutil/llvm-pdbutil.cpp | 2 +- tools/llvm-profdata/llvm-profdata.cpp | 21 +++---- tools/llvm-rc/llvm-rc.cpp | 2 +- tools/llvm-readobj/COFFDumper.cpp | 2 +- tools/llvm-readobj/ELFDumper.cpp | 30 +++++----- tools/llvm-readobj/ObjDumper.cpp | 2 +- tools/llvm-readobj/llvm-readobj.cpp | 5 +- tools/llvm-reduce/deltas/Delta.cpp | 2 +- tools/llvm-reduce/deltas/ReduceArguments.cpp | 2 +- tools/llvm-rtdyld/llvm-rtdyld.cpp | 6 +- tools/llvm-undname/llvm-undname.cpp | 6 +- tools/llvm-xray/xray-color-helper.cpp | 4 +- tools/llvm-xray/xray-graph-diff.cpp | 12 ++-- tools/llvm-xray/xray-stacks.cpp | 9 +-- tools/obj2yaml/elf2yaml.cpp | 4 +- tools/opt/PassPrinters.cpp | 10 ++-- tools/sancov/sancov.cpp | 8 +-- unittests/ADT/TripleTest.cpp | 4 +- unittests/Analysis/LazyCallGraphTest.cpp | 22 +++---- unittests/DebugInfo/GSYM/GSYMTest.cpp | 10 ++-- .../Orc/LegacyAPIInteropTest.cpp | 2 +- .../LegacyRTDyldObjectLinkingLayerTest.cpp | 2 +- .../Orc/RemoteObjectLayerTest.cpp | 6 +- unittests/IR/PassBuilderCallbacksTest.cpp | 6 +- unittests/Passes/PluginsTest.cpp | 2 +- unittests/ProfileData/SampleProfTest.cpp | 3 +- .../DynamicLibrary/DynamicLibraryTest.cpp | 2 +- unittests/Support/FileCheckTest.cpp | 17 +++--- unittests/Support/FileCollectorTest.cpp | 12 ++-- unittests/Support/FileUtilitiesTest.cpp | 2 +- unittests/Support/FormatVariadicTest.cpp | 4 +- unittests/Support/JSONTest.cpp | 2 +- unittests/Support/Path.cpp | 16 +++--- unittests/Support/SpecialCaseListTest.cpp | 2 +- unittests/Support/VirtualFileSystemTest.cpp | 45 ++++++++------- unittests/Support/raw_ostream_test.cpp | 2 +- unittests/Target/AArch64/InstSizes.cpp | 5 +- unittests/Target/ARM/MachineInstrTest.cpp | 10 ++-- unittests/TextAPI/TextStubV1Tests.cpp | 6 +- unittests/TextAPI/TextStubV2Tests.cpp | 6 +- unittests/TextAPI/TextStubV3Tests.cpp | 6 +- unittests/TextAPI/TextStubV4Tests.cpp | 4 +- .../tools/llvm-exegesis/PerfHelperTest.cpp | 4 +- utils/TableGen/AsmMatcherEmitter.cpp | 35 ++++++------ utils/TableGen/AsmWriterEmitter.cpp | 35 ++++++------ utils/TableGen/CodeEmitterGen.cpp | 4 +- utils/TableGen/CodeGenDAGPatterns.cpp | 15 +++-- utils/TableGen/CodeGenDAGPatterns.h | 7 ++- utils/TableGen/CodeGenHwModes.cpp | 2 +- utils/TableGen/CodeGenInstruction.cpp | 57 +++++++++++-------- utils/TableGen/CodeGenMapTable.cpp | 2 +- utils/TableGen/CodeGenRegisters.cpp | 29 ++++------ utils/TableGen/CodeGenSchedule.cpp | 6 +- utils/TableGen/CodeGenSchedule.h | 2 +- utils/TableGen/CodeGenTarget.cpp | 17 +++--- utils/TableGen/DAGISelMatcherEmitter.cpp | 3 +- utils/TableGen/DAGISelMatcherGen.cpp | 2 +- utils/TableGen/DFAEmitter.cpp | 4 +- utils/TableGen/DFAPacketizerEmitter.cpp | 12 ++-- utils/TableGen/DisassemblerEmitter.cpp | 8 +-- utils/TableGen/ExegesisEmitter.cpp | 2 +- utils/TableGen/FastISelEmitter.cpp | 28 +++++---- utils/TableGen/FixedLenDecoderEmitter.cpp | 37 ++++++------ utils/TableGen/GICombinerEmitter.cpp | 3 +- utils/TableGen/GlobalISelEmitter.cpp | 14 ++--- utils/TableGen/InstrDocsEmitter.cpp | 2 +- utils/TableGen/InstrInfoEmitter.cpp | 6 +- utils/TableGen/OptParserEmitter.cpp | 7 ++- utils/TableGen/RISCVCompressInstEmitter.cpp | 2 +- utils/TableGen/RegisterInfoEmitter.cpp | 10 ++-- utils/TableGen/SearchableTableEmitter.cpp | 25 ++++---- utils/TableGen/SubtargetEmitter.cpp | 9 +-- utils/TableGen/SubtargetFeatureInfo.cpp | 2 +- utils/TableGen/X86RecognizableInstr.cpp | 10 ++-- 348 files changed, 1088 insertions(+), 998 deletions(-) diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h index 4a5d1ae7c5a..9d6e203c82f 100644 --- a/include/llvm/ADT/StringRef.h +++ b/include/llvm/ADT/StringRef.h @@ -272,9 +272,7 @@ namespace llvm { /// @name Type Conversions /// @{ - operator std::string() const { - return str(); - } + operator std::string() const { return str(); } #if __cplusplus > 201402L operator std::string_view() const { diff --git a/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/include/llvm/Analysis/BlockFrequencyInfoImpl.h index bfe4fb14a2b..1b8832a8e1c 100644 --- a/include/llvm/Analysis/BlockFrequencyInfoImpl.h +++ b/include/llvm/Analysis/BlockFrequencyInfoImpl.h @@ -1375,7 +1375,7 @@ struct BFIDOTGraphTraitsBase : public DefaultDOTGraphTraits { explicit BFIDOTGraphTraitsBase(bool isSimple = false) : DefaultDOTGraphTraits(isSimple) {} - static std::string getGraphName(const BlockFrequencyInfoT *G) { + static StringRef getGraphName(const BlockFrequencyInfoT *G) { return G->getFunction()->getName(); } diff --git a/include/llvm/Analysis/RegionInfoImpl.h b/include/llvm/Analysis/RegionInfoImpl.h index 6b5936680c3..539f15d13f2 100644 --- a/include/llvm/Analysis/RegionInfoImpl.h +++ b/include/llvm/Analysis/RegionInfoImpl.h @@ -236,7 +236,7 @@ std::string RegionBase::getNameStr() const { getEntry()->printAsOperand(OS, false); } else - entryName = getEntry()->getName(); + entryName = std::string(getEntry()->getName()); if (getExit()) { if (getExit()->getName().empty()) { @@ -244,7 +244,7 @@ std::string RegionBase::getNameStr() const { getExit()->printAsOperand(OS, false); } else - exitName = getExit()->getName(); + exitName = std::string(getExit()->getName()); } else exitName = ""; diff --git a/include/llvm/Analysis/TargetLibraryInfo.h b/include/llvm/Analysis/TargetLibraryInfo.h index 19efbb7b67b..fdcb44893a8 100644 --- a/include/llvm/Analysis/TargetLibraryInfo.h +++ b/include/llvm/Analysis/TargetLibraryInfo.h @@ -129,7 +129,7 @@ public: void setAvailableWithName(LibFunc F, StringRef Name) { if (StandardNames[F] != Name) { setState(F, CustomName); - CustomNames[F] = Name; + CustomNames[F] = std::string(Name); assert(CustomNames.find(F) != CustomNames.end()); } else { setState(F, StandardName); diff --git a/include/llvm/CodeGen/CommandFlags.inc b/include/llvm/CodeGen/CommandFlags.inc index b65f7bb5b59..e1229346175 100644 --- a/include/llvm/CodeGen/CommandFlags.inc +++ b/include/llvm/CodeGen/CommandFlags.inc @@ -331,8 +331,7 @@ LLVM_ATTRIBUTE_UNUSED static std::string getCPUStr() { // If user asked for the 'native' CPU, autodetect here. If autodection fails, // this will set the CPU to an empty string which tells the target to // pick a basic default. - if (MCPU == "native") - return sys::getHostCPUName(); + if (MCPU == "native") return std::string(sys::getHostCPUName()); return MCPU; } diff --git a/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h b/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h index 7946b5b7b20..7d9dd0482de 100644 --- a/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h +++ b/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h @@ -338,12 +338,13 @@ public: for (auto &KV : LogicalDylibs) { if (auto Sym = KV.second.StubsMgr->findStub(Name, ExportedSymbolsOnly)) return Sym; - if (auto Sym = findSymbolIn(KV.first, Name, ExportedSymbolsOnly)) + if (auto Sym = + findSymbolIn(KV.first, std::string(Name), ExportedSymbolsOnly)) return Sym; else if (auto Err = Sym.takeError()) return std::move(Err); } - return BaseLayer.findSymbol(Name, ExportedSymbolsOnly); + return BaseLayer.findSymbol(std::string(Name), ExportedSymbolsOnly); } /// Get the address of a symbol provided by this layer, or some layer @@ -511,11 +512,11 @@ private: } // Build a resolver for the globals module and add it to the base layer. - auto LegacyLookup = [this, &LD](const std::string &Name) -> JITSymbol { + auto LegacyLookup = [this, &LD](StringRef Name) -> JITSymbol { if (auto Sym = LD.StubsMgr->findStub(Name, false)) return Sym; - if (auto Sym = LD.findSymbol(BaseLayer, Name, false)) + if (auto Sym = LD.findSymbol(BaseLayer, std::string(Name), false)) return Sym; else if (auto Err = Sym.takeError()) return std::move(Err); @@ -631,7 +632,7 @@ private: Module &SrcM = LD.getSourceModule(LMId); // Create the module. - std::string NewName = SrcM.getName(); + std::string NewName(SrcM.getName()); for (auto *F : Part) { NewName += "."; NewName += F->getName(); @@ -688,8 +689,8 @@ private: auto K = ES.allocateVModule(); - auto LegacyLookup = [this, &LD](const std::string &Name) -> JITSymbol { - return LD.findSymbol(BaseLayer, Name, false); + auto LegacyLookup = [this, &LD](StringRef Name) -> JITSymbol { + return LD.findSymbol(BaseLayer, std::string(Name), false); }; // Create memory manager and symbol resolver. diff --git a/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h b/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h index b67a9feed52..84f5e0350c2 100644 --- a/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h +++ b/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h @@ -78,7 +78,7 @@ private: // RuntimeDyld that did the lookup), so just return a nullptr here. return nullptr; case Emitted: - return B.findSymbolIn(K, Name, ExportedSymbolsOnly); + return B.findSymbolIn(K, std::string(Name), ExportedSymbolsOnly); } llvm_unreachable("Invalid emit-state."); } diff --git a/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h b/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h index 091394795c0..435c882d506 100644 --- a/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h +++ b/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h @@ -170,7 +170,7 @@ protected: if (!SymEntry->second.getFlags().isExported() && ExportedSymbolsOnly) return nullptr; if (!Finalized) - return JITSymbol(getSymbolMaterializer(Name), + return JITSymbol(getSymbolMaterializer(std::string(Name)), SymEntry->second.getFlags()); return JITSymbol(SymEntry->second); } diff --git a/include/llvm/IR/InstrTypes.h b/include/llvm/IR/InstrTypes.h index 31c526e8505..2828a7d0d92 100644 --- a/include/llvm/IR/InstrTypes.h +++ b/include/llvm/IR/InstrTypes.h @@ -1066,7 +1066,7 @@ public: : Tag(std::move(Tag)), Inputs(Inputs) {} explicit OperandBundleDefT(const OperandBundleUse &OBU) { - Tag = OBU.getTagName(); + Tag = std::string(OBU.getTagName()); Inputs.insert(Inputs.end(), OBU.Inputs.begin(), OBU.Inputs.end()); } diff --git a/include/llvm/IR/Module.h b/include/llvm/IR/Module.h index bdc1ea93256..71e67b4bedc 100644 --- a/include/llvm/IR/Module.h +++ b/include/llvm/IR/Module.h @@ -273,22 +273,22 @@ public: /// @{ /// Set the module identifier. - void setModuleIdentifier(StringRef ID) { ModuleID = ID; } + void setModuleIdentifier(StringRef ID) { ModuleID = std::string(ID); } /// Set the module's original source file name. - void setSourceFileName(StringRef Name) { SourceFileName = Name; } + void setSourceFileName(StringRef Name) { SourceFileName = std::string(Name); } /// Set the data layout void setDataLayout(StringRef Desc); void setDataLayout(const DataLayout &Other); /// Set the target triple. - void setTargetTriple(StringRef T) { TargetTriple = T; } + void setTargetTriple(StringRef T) { TargetTriple = std::string(T); } /// Set the module-scope inline assembly blocks. /// A trailing newline is added if the input doesn't have one. void setModuleInlineAsm(StringRef Asm) { - GlobalScopeAsm = Asm; + GlobalScopeAsm = std::string(Asm); if (!GlobalScopeAsm.empty() && GlobalScopeAsm.back() != '\n') GlobalScopeAsm += '\n'; } diff --git a/include/llvm/IR/ModuleSummaryIndex.h b/include/llvm/IR/ModuleSummaryIndex.h index 5304071b618..1296de75325 100644 --- a/include/llvm/IR/ModuleSummaryIndex.h +++ b/include/llvm/IR/ModuleSummaryIndex.h @@ -1295,7 +1295,7 @@ public: NewName += ".llvm."; NewName += utostr((uint64_t(ModHash[0]) << 32) | ModHash[1]); // Take the first 64 bits - return NewName.str(); + return std::string(NewName.str()); } /// Helper to obtain the unpromoted name for a global value (or the original @@ -1341,7 +1341,7 @@ public: if (It->second.first == TypeId) return It->second.second; auto It = TypeIdMap.insert( - {GlobalValue::getGUID(TypeId), {TypeId, TypeIdSummary()}}); + {GlobalValue::getGUID(TypeId), {std::string(TypeId), TypeIdSummary()}}); return It->second.second; } @@ -1371,14 +1371,14 @@ public: /// the ThinLTO backends. TypeIdCompatibleVtableInfo & getOrInsertTypeIdCompatibleVtableSummary(StringRef TypeId) { - return TypeIdCompatibleVtableMap[TypeId]; + return TypeIdCompatibleVtableMap[std::string(TypeId)]; } /// For the given \p TypeId, this returns the TypeIdCompatibleVtableMap /// entry if present in the summary map. This may be used when importing. Optional getTypeIdCompatibleVtableSummary(StringRef TypeId) const { - auto I = TypeIdCompatibleVtableMap.find(TypeId); + auto I = TypeIdCompatibleVtableMap.find(std::string(TypeId)); if (I == TypeIdCompatibleVtableMap.end()) return None; return I->second; diff --git a/include/llvm/IR/ModuleSummaryIndexYAML.h b/include/llvm/IR/ModuleSummaryIndexYAML.h index 4d4a67c7517..7dcb455274f 100644 --- a/include/llvm/IR/ModuleSummaryIndexYAML.h +++ b/include/llvm/IR/ModuleSummaryIndexYAML.h @@ -262,7 +262,7 @@ template <> struct CustomMappingTraits { static void inputOne(IO &io, StringRef Key, TypeIdSummaryMapTy &V) { TypeIdSummary TId; io.mapRequired(Key.str().c_str(), TId); - V.insert({GlobalValue::getGUID(Key), {Key, TId}}); + V.insert({GlobalValue::getGUID(Key), {std::string(Key), TId}}); } static void output(IO &io, TypeIdSummaryMapTy &V) { for (auto TidIter = V.begin(); TidIter != V.end(); TidIter++) diff --git a/include/llvm/LTO/legacy/LTOCodeGenerator.h b/include/llvm/LTO/legacy/LTOCodeGenerator.h index 114ba85947a..5bcfaeedfcf 100644 --- a/include/llvm/LTO/legacy/LTOCodeGenerator.h +++ b/include/llvm/LTO/legacy/LTOCodeGenerator.h @@ -92,8 +92,8 @@ struct LTOCodeGenerator { /// The default is CGFT_ObjectFile. void setFileType(CodeGenFileType FT) { FileType = FT; } - void setCpu(StringRef MCpu) { this->MCpu = MCpu; } - void setAttr(StringRef MAttr) { this->MAttr = MAttr; } + void setCpu(StringRef MCpu) { this->MCpu = std::string(MCpu); } + void setAttr(StringRef MAttr) { this->MAttr = std::string(MAttr); } void setOptLevel(unsigned OptLevel); void setShouldInternalize(bool Value) { ShouldInternalize = Value; } diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h index 8c76f30222e..791ebcdde4e 100644 --- a/include/llvm/MC/MCAssembler.h +++ b/include/llvm/MC/MCAssembler.h @@ -440,7 +440,7 @@ public: void addFileName(StringRef FileName) { if (!is_contained(FileNames, FileName)) - FileNames.push_back(FileName); + FileNames.push_back(std::string(FileName)); } /// Write the necessary bundle padding to \p OS. diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h index b925f321888..2f9e477f56e 100644 --- a/include/llvm/MC/MCContext.h +++ b/include/llvm/MC/MCContext.h @@ -541,7 +541,7 @@ namespace llvm { const std::string &getMainFileName() const { return MainFileName; } /// Set the main file name and override the default. - void setMainFileName(StringRef S) { MainFileName = S; } + void setMainFileName(StringRef S) { MainFileName = std::string(S); } /// Creates an entry in the dwarf file and directory tables. Expected getDwarfFile(StringRef Directory, StringRef FileName, diff --git a/include/llvm/MC/MCDwarf.h b/include/llvm/MC/MCDwarf.h index b8ee585bb01..9dead61eb73 100644 --- a/include/llvm/MC/MCDwarf.h +++ b/include/llvm/MC/MCDwarf.h @@ -252,8 +252,8 @@ public: void setRootFile(StringRef Directory, StringRef FileName, Optional Checksum, Optional Source) { - CompilationDir = Directory; - RootFile.Name = FileName; + CompilationDir = std::string(Directory); + RootFile.Name = std::string(FileName); RootFile.DirIndex = 0; RootFile.Checksum = Checksum; RootFile.Source = Source; @@ -325,8 +325,8 @@ public: void setRootFile(StringRef Directory, StringRef FileName, Optional Checksum, Optional Source) { - Header.CompilationDir = Directory; - Header.RootFile.Name = FileName; + Header.CompilationDir = std::string(Directory); + Header.RootFile.Name = std::string(FileName); Header.RootFile.DirIndex = 0; Header.RootFile.Checksum = Checksum; Header.RootFile.Source = Source; diff --git a/include/llvm/MC/MCSymbolWasm.h b/include/llvm/MC/MCSymbolWasm.h index ba2068a4607..a260d5d0a71 100644 --- a/include/llvm/MC/MCSymbolWasm.h +++ b/include/llvm/MC/MCSymbolWasm.h @@ -77,7 +77,9 @@ public: } return "env"; } - void setImportModule(StringRef Name) { ImportModule = Name; } + void setImportModule(StringRef Name) { + ImportModule = std::string(std::string(Name)); + } bool hasImportName() const { return ImportName.hasValue(); } const StringRef getImportName() const { @@ -86,11 +88,15 @@ public: } return getName(); } - void setImportName(StringRef Name) { ImportName = Name; } + void setImportName(StringRef Name) { + ImportName = std::string(std::string(Name)); + } bool hasExportName() const { return ExportName.hasValue(); } const StringRef getExportName() const { return ExportName.getValue(); } - void setExportName(StringRef Name) { ExportName = Name; } + void setExportName(StringRef Name) { + ExportName = std::string(std::string(Name)); + } void setUsedInGOT() const { IsUsedInGOT = true; } bool isUsedInGOT() const { return IsUsedInGOT; } diff --git a/include/llvm/MC/SubtargetFeature.h b/include/llvm/MC/SubtargetFeature.h index defbc3c6472..01ea794a4bc 100644 --- a/include/llvm/MC/SubtargetFeature.h +++ b/include/llvm/MC/SubtargetFeature.h @@ -214,7 +214,7 @@ public: } /// Return string stripped of flag. - static std::string StripFlag(StringRef Feature) { + static StringRef StripFlag(StringRef Feature) { return hasFlag(Feature) ? Feature.substr(1) : Feature; } diff --git a/include/llvm/Object/MachO.h b/include/llvm/Object/MachO.h index c3ecdd93563..8f6e2ff02df 100644 --- a/include/llvm/Object/MachO.h +++ b/include/llvm/Object/MachO.h @@ -644,7 +644,7 @@ public: Version = utostr(major) + "." + utostr(minor); if (update != 0) Version += "." + utostr(update); - return Version.str(); + return std::string(std::string(Version.str())); } private: diff --git a/include/llvm/Object/TapiUniversal.h b/include/llvm/Object/TapiUniversal.h index 4931183852a..923a9a26975 100644 --- a/include/llvm/Object/TapiUniversal.h +++ b/include/llvm/Object/TapiUniversal.h @@ -51,7 +51,7 @@ public: return Result.second; } - std::string getArchFlagName() const { + StringRef getArchFlagName() const { return MachO::getArchitectureName(Parent->Architectures[Index]); } diff --git a/include/llvm/Option/Option.h b/include/llvm/Option/Option.h index 33813d28d27..e598798d9a6 100644 --- a/include/llvm/Option/Option.h +++ b/include/llvm/Option/Option.h @@ -130,7 +130,7 @@ public: /// Get the name of this option with the default prefix. std::string getPrefixedName() const { - std::string Ret = getPrefix(); + std::string Ret(getPrefix()); Ret += getName(); return Ret; } diff --git a/include/llvm/ProfileData/InstrProf.h b/include/llvm/ProfileData/InstrProf.h index c6b605994ef..78ee2cd3c73 100644 --- a/include/llvm/ProfileData/InstrProf.h +++ b/include/llvm/ProfileData/InstrProf.h @@ -562,7 +562,7 @@ StringRef InstrProfSymtab::getFuncName(uint64_t FuncMD5Hash) { finalizeSymtab(); auto Result = std::lower_bound(MD5NameMap.begin(), MD5NameMap.end(), FuncMD5Hash, - [](const std::pair &LHS, + [](const std::pair &LHS, uint64_t RHS) { return LHS.first < RHS; }); if (Result != MD5NameMap.end() && Result->first == FuncMD5Hash) return Result->second; diff --git a/include/llvm/Support/DebugCounter.h b/include/llvm/Support/DebugCounter.h index e7d1fa68f21..2ea050f3001 100644 --- a/include/llvm/Support/DebugCounter.h +++ b/include/llvm/Support/DebugCounter.h @@ -68,7 +68,7 @@ public: // line option parsing. The main reason to register counters is to produce a // nice list of them on the command line, but i'm not sure this is worth it. static unsigned registerCounter(StringRef Name, StringRef Desc) { - return instance().addCounter(Name, Desc); + return instance().addCounter(std::string(Name), std::string(Desc)); } inline static bool shouldExecute(unsigned CounterName) { if (!isCountingEnabled()) diff --git a/include/llvm/Support/GraphWriter.h b/include/llvm/Support/GraphWriter.h index 466a0449e25..0179670456a 100644 --- a/include/llvm/Support/GraphWriter.h +++ b/include/llvm/Support/GraphWriter.h @@ -126,7 +126,7 @@ public: } void writeHeader(const std::string &Title) { - std::string GraphName = DTraits.getGraphName(G); + std::string GraphName(DTraits.getGraphName(G)); if (!Title.empty()) O << "digraph \"" << DOT::EscapeString(Title) << "\" {\n"; diff --git a/include/llvm/Support/JSON.h b/include/llvm/Support/JSON.h index 56d26d2c5a2..f0bab51ad4d 100644 --- a/include/llvm/Support/JSON.h +++ b/include/llvm/Support/JSON.h @@ -565,7 +565,7 @@ inline bool Object::erase(StringRef K) { // See comments on Value. inline bool fromJSON(const Value &E, std::string &Out) { if (auto S = E.getAsString()) { - Out = *S; + Out = std::string(*S); return true; } return false; @@ -632,7 +632,7 @@ bool fromJSON(const Value &E, std::map &Out) { if (auto *O = E.getAsObject()) { Out.clear(); for (const auto &KV : *O) - if (!fromJSON(KV.second, Out[llvm::StringRef(KV.first)])) + if (!fromJSON(KV.second, Out[std::string(llvm::StringRef(KV.first))])) return false; return true; } diff --git a/include/llvm/Support/SmallVectorMemoryBuffer.h b/include/llvm/Support/SmallVectorMemoryBuffer.h index b63b58e3a8b..62900b740b8 100644 --- a/include/llvm/Support/SmallVectorMemoryBuffer.h +++ b/include/llvm/Support/SmallVectorMemoryBuffer.h @@ -44,7 +44,7 @@ public: /// Construct a named SmallVectorMemoryBuffer from the given /// SmallVector r-value and StringRef. SmallVectorMemoryBuffer(SmallVectorImpl &&SV, StringRef Name) - : SV(std::move(SV)), BufferName(Name) { + : SV(std::move(SV)), BufferName(std::string(Name)) { init(this->SV.begin(), this->SV.end(), false); } diff --git a/include/llvm/Support/YAMLTraits.h b/include/llvm/Support/YAMLTraits.h index 8642069ad54..757dc8ea191 100644 --- a/include/llvm/Support/YAMLTraits.h +++ b/include/llvm/Support/YAMLTraits.h @@ -1936,7 +1936,7 @@ template struct StdMapStringCustomMappingTraitsImpl { using map_type = std::map; static void inputOne(IO &io, StringRef key, map_type &v) { - io.mapRequired(key.str().c_str(), v[key]); + io.mapRequired(key.str().c_str(), v[std::string(key)]); } static void output(IO &io, map_type &v) { diff --git a/include/llvm/TableGen/Record.h b/include/llvm/TableGen/Record.h index a553ec99aaa..041156e7149 100644 --- a/include/llvm/TableGen/Record.h +++ b/include/llvm/TableGen/Record.h @@ -614,7 +614,9 @@ public: bool isConcrete() const override { return true; } std::string getAsString() const override { return "\"" + Value.str() + "\""; } - std::string getAsUnquotedString() const override { return Value; } + std::string getAsUnquotedString() const override { + return std::string(Value); + } Init *getBit(unsigned Bit) const override { llvm_unreachable("Illegal bit reference off string"); @@ -649,7 +651,9 @@ public: return "[{" + Value.str() + "}]"; } - std::string getAsUnquotedString() const override { return Value; } + std::string getAsUnquotedString() const override { + return std::string(Value); + } Init *getBit(unsigned Bit) const override { llvm_unreachable("Illegal bit reference off string"); @@ -1098,7 +1102,7 @@ public: Init *getBit(unsigned Bit) const override; - std::string getAsString() const override { return getName(); } + std::string getAsString() const override { return std::string(getName()); } }; /// Opcode{0} - Represent access to one bit of a variable or field. diff --git a/include/llvm/TableGen/StringToOffsetTable.h b/include/llvm/TableGen/StringToOffsetTable.h index 76ce5189390..7fcf20abed6 100644 --- a/include/llvm/TableGen/StringToOffsetTable.h +++ b/include/llvm/TableGen/StringToOffsetTable.h @@ -45,7 +45,7 @@ public: // Escape the string. SmallString<256> Str; raw_svector_ostream(Str).write_escaped(AggregateString); - AggregateString = Str.str(); + AggregateString = std::string(Str.str()); O << " \""; unsigned CharsPrinted = 0; diff --git a/include/llvm/TextAPI/MachO/InterfaceFile.h b/include/llvm/TextAPI/MachO/InterfaceFile.h index bd434e04b69..1a9711cfb40 100644 --- a/include/llvm/TextAPI/MachO/InterfaceFile.h +++ b/include/llvm/TextAPI/MachO/InterfaceFile.h @@ -158,7 +158,7 @@ public: /// Set the path from which this file was generated (if applicable). /// /// \param Path_ The path to the source file. - void setPath(StringRef Path_) { Path = Path_; } + void setPath(StringRef Path_) { Path = std::string(Path_); } /// Get the path from which this file was generated (if applicable). /// @@ -217,7 +217,9 @@ public: const_filtered_target_range targets(ArchitectureSet Archs) const; /// Set the install name of the library. - void setInstallName(StringRef InstallName_) { InstallName = InstallName_; } + void setInstallName(StringRef InstallName_) { + InstallName = std::string(InstallName_); + } /// Get the install name of the library. StringRef getInstallName() const { return InstallName; } diff --git a/lib/Analysis/CallPrinter.cpp b/lib/Analysis/CallPrinter.cpp index 7246b73bfd4..0eac5d4c646 100644 --- a/lib/Analysis/CallPrinter.cpp +++ b/lib/Analysis/CallPrinter.cpp @@ -29,7 +29,7 @@ template <> struct DOTGraphTraits : public DefaultDOTGraphTraits { std::string getNodeLabel(CallGraphNode *Node, CallGraph *Graph) { if (Function *Func = Node->getFunction()) - return Func->getName(); + return std::string(Func->getName()); return "external node"; } diff --git a/lib/Analysis/LazyCallGraph.cpp b/lib/Analysis/LazyCallGraph.cpp index ee1e9a3d792..b54ef3154e1 100644 --- a/lib/Analysis/LazyCallGraph.cpp +++ b/lib/Analysis/LazyCallGraph.cpp @@ -1801,11 +1801,12 @@ LazyCallGraphDOTPrinterPass::LazyCallGraphDOTPrinterPass(raw_ostream &OS) : OS(OS) {} static void printNodeDOT(raw_ostream &OS, LazyCallGraph::Node &N) { - std::string Name = "\"" + DOT::EscapeString(N.getFunction().getName()) + "\""; + std::string Name = + "\"" + DOT::EscapeString(std::string(N.getFunction().getName())) + "\""; for (LazyCallGraph::Edge &E : N.populate()) { OS << " " << Name << " -> \"" - << DOT::EscapeString(E.getFunction().getName()) << "\""; + << DOT::EscapeString(std::string(E.getFunction().getName())) << "\""; if (!E.isCall()) // It is a ref edge. OS << " [style=dashed,label=\"ref\"]"; OS << ";\n"; diff --git a/lib/Analysis/VFABIDemangling.cpp b/lib/Analysis/VFABIDemangling.cpp index a331b95e818..84cad1ad1f1 100644 --- a/lib/Analysis/VFABIDemangling.cpp +++ b/lib/Analysis/VFABIDemangling.cpp @@ -403,7 +403,7 @@ Optional VFABI::tryDemangleForVFABI(StringRef MangledName) { "The global predicate must be the last parameter"); const VFShape Shape({VF, IsScalable, Parameters}); - return VFInfo({Shape, ScalarName, VectorName, ISA}); + return VFInfo({Shape, std::string(ScalarName), std::string(VectorName), ISA}); } VFParamKind VFABI::getVFParamKindFromString(const StringRef Token) { diff --git a/lib/Analysis/VectorUtils.cpp b/lib/Analysis/VectorUtils.cpp index a83dda1fc19..8cee54bec04 100644 --- a/lib/Analysis/VectorUtils.cpp +++ b/lib/Analysis/VectorUtils.cpp @@ -1180,7 +1180,7 @@ void VFABI::getVectorVariantNames( assert(CI.getModule()->getFunction(Info.getValue().VectorName) && "Vector function is missing."); #endif - VariantMappings.push_back(S); + VariantMappings.push_back(std::string(S)); } } diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 4446a9f5e53..708b02fb555 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -3695,7 +3695,7 @@ bool LLParser::parseOptionalComdat(StringRef GlobalName, Comdat *&C) { } else { if (GlobalName.empty()) return TokError("comdat cannot be unnamed"); - C = getComdat(GlobalName, KwLoc); + C = getComdat(std::string(GlobalName), KwLoc); } return false; @@ -5546,7 +5546,7 @@ bool LLParser::PerFunctionState::resolveForwardRefBlockAddresses() { ValID ID; if (FunctionNumber == -1) { ID.Kind = ValID::t_GlobalName; - ID.StrVal = F.getName(); + ID.StrVal = std::string(F.getName()); } else { ID.Kind = ValID::t_GlobalID; ID.UIntVal = FunctionNumber; diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 6baa64a465c..b5476065c36 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -859,7 +859,7 @@ BitcodeReader::BitcodeReader(BitstreamCursor Stream, StringRef Strtab, LLVMContext &Context) : BitcodeReaderBase(std::move(Stream), Strtab), Context(Context), ValueList(Context, Stream.SizeInBytes()) { - this->ProducerIdentification = ProducerIdentification; + this->ProducerIdentification = std::string(ProducerIdentification); } Error BitcodeReader::materializeForwardReferencedFunctions() { diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index 3f45dfe4f84..540a6235e15 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -1174,7 +1174,7 @@ void ModuleBitcodeWriter::writeModuleInfo() { MaxGlobalType = std::max(MaxGlobalType, VE.getTypeID(GV.getValueType())); if (GV.hasSection()) { // Give section names unique ID's. - unsigned &Entry = SectionMap[GV.getSection()]; + unsigned &Entry = SectionMap[std::string(GV.getSection())]; if (!Entry) { writeStringRecord(Stream, bitc::MODULE_CODE_SECTIONNAME, GV.getSection(), 0 /*TODO*/); @@ -1186,7 +1186,7 @@ void ModuleBitcodeWriter::writeModuleInfo() { MaxAlignment = std::max(MaxAlignment, F.getAlignment()); if (F.hasSection()) { // Give section names unique ID's. - unsigned &Entry = SectionMap[F.getSection()]; + unsigned &Entry = SectionMap[std::string(F.getSection())]; if (!Entry) { writeStringRecord(Stream, bitc::MODULE_CODE_SECTIONNAME, F.getSection(), 0 /*TODO*/); @@ -1276,7 +1276,8 @@ void ModuleBitcodeWriter::writeModuleInfo() { (VE.getValueID(GV.getInitializer()) + 1)); Vals.push_back(getEncodedLinkage(GV)); Vals.push_back(Log2_32(GV.getAlignment())+1); - Vals.push_back(GV.hasSection() ? SectionMap[GV.getSection()] : 0); + Vals.push_back(GV.hasSection() ? SectionMap[std::string(GV.getSection())] + : 0); if (GV.isThreadLocal() || GV.getVisibility() != GlobalValue::DefaultVisibility || GV.getUnnamedAddr() != GlobalValue::UnnamedAddr::None || @@ -1321,7 +1322,8 @@ void ModuleBitcodeWriter::writeModuleInfo() { Vals.push_back(getEncodedLinkage(F)); Vals.push_back(VE.getAttributeListID(F.getAttributes())); Vals.push_back(Log2_32(F.getAlignment())+1); - Vals.push_back(F.hasSection() ? SectionMap[F.getSection()] : 0); + Vals.push_back(F.hasSection() ? SectionMap[std::string(F.getSection())] + : 0); Vals.push_back(getEncodedVisibility(F)); Vals.push_back(F.hasGC() ? GCMap[F.getGC()] : 0); Vals.push_back(getEncodedUnnamedAddr(F)); diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index f38c3f3c50a..6793b7a4d8d 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -3152,7 +3152,7 @@ void AsmPrinter::emitXRayTable() { std::string GroupName; if (F.hasComdat()) { Flags |= ELF::SHF_GROUP; - GroupName = F.getComdat()->getName(); + GroupName = std::string(F.getComdat()->getName()); } auto UniqueID = ++XRayFnUniqueID; @@ -3232,7 +3232,7 @@ void AsmPrinter::emitPatchableFunctionEntries() { std::string GroupName; if (F.hasComdat()) { Flags |= ELF::SHF_GROUP; - GroupName = F.getComdat()->getName(); + GroupName = std::string(F.getComdat()->getName()); } MCSection *Section = getObjFileLowering().SectionForGlobal(&F, TM); unsigned UniqueID = diff --git a/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index 62ad356e7f8..60386775368 100644 --- a/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -119,9 +119,9 @@ public: std::string TypeName; if (!TI.isNoneType()) { if (TI.isSimple()) - TypeName = TypeIndex::simpleTypeName(TI); + TypeName = std::string(TypeIndex::simpleTypeName(TI)); else - TypeName = TypeTable.getTypeName(TI); + TypeName = std::string(TypeTable.getTypeName(TI)); } return TypeName; } @@ -183,7 +183,7 @@ StringRef CodeViewDebug::getFullFilepath(const DIFile *File) { if (Dir.startswith("/") || Filename.startswith("/")) { if (llvm::sys::path::is_absolute(Filename, llvm::sys::path::Style::posix)) return Filename; - Filepath = Dir; + Filepath = std::string(Dir); if (Dir.back() != '/') Filepath += '/'; Filepath += Filename; @@ -195,7 +195,7 @@ StringRef CodeViewDebug::getFullFilepath(const DIFile *File) { // that would increase the IR size and probably not needed for other users. // For now, just concatenate and canonicalize the path here. if (Filename.find(':') == 1) - Filepath = Filename; + Filepath = std::string(Filename); else Filepath = (Dir + "\\" + Filename).str(); @@ -322,10 +322,10 @@ static std::string getQualifiedName(ArrayRef QualifiedNameComponents, std::string FullyQualifiedName; for (StringRef QualifiedNameComponent : llvm::reverse(QualifiedNameComponents)) { - FullyQualifiedName.append(QualifiedNameComponent); + FullyQualifiedName.append(std::string(QualifiedNameComponent)); FullyQualifiedName.append("::"); } - FullyQualifiedName.append(TypeName); + FullyQualifiedName.append(std::string(TypeName)); return FullyQualifiedName; } @@ -943,7 +943,8 @@ void CodeViewDebug::switchToDebugSectionForSymbol(const MCSymbol *GVSym) { void CodeViewDebug::emitDebugInfoForThunk(const Function *GV, FunctionInfo &FI, const MCSymbol *Fn) { - std::string FuncName = GlobalValue::dropLLVMManglingEscape(GV->getName()); + std::string FuncName = + std::string(GlobalValue::dropLLVMManglingEscape(GV->getName())); const ThunkOrdinal ordinal = ThunkOrdinal::Standard; // Only supported kind. OS.AddComment("Symbol subsection for " + Twine(FuncName)); @@ -1006,7 +1007,7 @@ void CodeViewDebug::emitDebugInfoForFunction(const Function *GV, // If our DISubprogram name is empty, use the mangled name. if (FuncName.empty()) - FuncName = GlobalValue::dropLLVMManglingEscape(GV->getName()); + FuncName = std::string(GlobalValue::dropLLVMManglingEscape(GV->getName())); // Emit FPO data, but only on 32-bit x86. No other platforms use it. if (Triple(MMI->getModule()->getTargetTriple()).getArch() == Triple::x86) diff --git a/lib/CodeGen/FEntryInserter.cpp b/lib/CodeGen/FEntryInserter.cpp index 4c0f30bce82..c2194929e2e 100644 --- a/lib/CodeGen/FEntryInserter.cpp +++ b/lib/CodeGen/FEntryInserter.cpp @@ -35,8 +35,8 @@ struct FEntryInserter : public MachineFunctionPass { } bool FEntryInserter::runOnMachineFunction(MachineFunction &MF) { - const std::string FEntryName = - MF.getFunction().getFnAttribute("fentry-call").getValueAsString(); + const std::string FEntryName = std::string( + MF.getFunction().getFnAttribute("fentry-call").getValueAsString()); if (FEntryName != "true") return false; diff --git a/lib/CodeGen/GCMetadata.cpp b/lib/CodeGen/GCMetadata.cpp index 600d662e0f9..7c96d838d99 100644 --- a/lib/CodeGen/GCMetadata.cpp +++ b/lib/CodeGen/GCMetadata.cpp @@ -153,7 +153,7 @@ GCStrategy *GCModuleInfo::getGCStrategy(const StringRef Name) { for (auto& Entry : GCRegistry::entries()) { if (Name == Entry.getName()) { std::unique_ptr S = Entry.instantiate(); - S->Name = Name; + S->Name = std::string(Name); GCStrategyMap[Name] = S.get(); GCStrategyList.push_back(std::move(S)); return GCStrategyList.back().get(); diff --git a/lib/CodeGen/GlobalMerge.cpp b/lib/CodeGen/GlobalMerge.cpp index 6e5593abb43..600c717080b 100644 --- a/lib/CodeGen/GlobalMerge.cpp +++ b/lib/CodeGen/GlobalMerge.cpp @@ -523,7 +523,7 @@ bool GlobalMerge::doMerge(const SmallVectorImpl &Globals, const StructLayout *MergedLayout = DL.getStructLayout(MergedTy); for (ssize_t k = i, idx = 0; k != j; k = GlobalSet.find_next(k), ++idx) { GlobalValue::LinkageTypes Linkage = Globals[k]->getLinkage(); - std::string Name = Globals[k]->getName(); + std::string Name(Globals[k]->getName()); GlobalValue::VisibilityTypes Visibility = Globals[k]->getVisibility(); GlobalValue::DLLStorageClassTypes DLLStorage = Globals[k]->getDLLStorageClass(); diff --git a/lib/CodeGen/MIRParser/MIParser.cpp b/lib/CodeGen/MIRParser/MIParser.cpp index 076ca943788..2a220c02613 100644 --- a/lib/CodeGen/MIRParser/MIParser.cpp +++ b/lib/CodeGen/MIRParser/MIParser.cpp @@ -2334,7 +2334,7 @@ bool MIParser::parseIntrinsicOperand(MachineOperand &Dest) { if (Token.isNot(MIToken::NamedGlobalValue)) return error("expected syntax intrinsic(@llvm.whatever)"); - std::string Name = Token.stringValue(); + std::string Name = std::string(Token.stringValue()); lex(); if (expectAndConsume(MIToken::rparen)) @@ -3149,7 +3149,7 @@ MCSymbol *MIParser::getOrCreateMCSymbol(StringRef Name) { bool MIParser::parseStringConstant(std::string &Result) { if (Token.isNot(MIToken::StringConstant)) return error("expected string constant"); - Result = Token.stringValue(); + Result = std::string(Token.stringValue()); lex(); return false; } diff --git a/lib/CodeGen/MIRPrinter.cpp b/lib/CodeGen/MIRPrinter.cpp index 0f8e036db24..284b9045c4a 100644 --- a/lib/CodeGen/MIRPrinter.cpp +++ b/lib/CodeGen/MIRPrinter.cpp @@ -390,8 +390,8 @@ void MIRPrinter::convertStackObjects(yaml::MachineFunction &YMF, yaml::MachineStackObject YamlObject; YamlObject.ID = ID; if (const auto *Alloca = MFI.getObjectAllocation(I)) - YamlObject.Name.Value = - Alloca->hasName() ? Alloca->getName() : ""; + YamlObject.Name.Value = std::string( + Alloca->hasName() ? Alloca->getName() : ""); YamlObject.Type = MFI.isSpillSlotObjectIndex(I) ? yaml::MachineStackObject::SpillSlot : MFI.isVariableSizedObjectIndex(I) diff --git a/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp b/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp index d656953f911..dcb8e4073ea 100644 --- a/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp +++ b/lib/CodeGen/MachineOptimizationRemarkEmitter.cpp @@ -24,7 +24,7 @@ using namespace llvm; DiagnosticInfoMIROptimization::MachineArgument::MachineArgument( StringRef MKey, const MachineInstr &MI) : Argument() { - Key = MKey; + Key = std::string(MKey); raw_string_ostream OS(Val); MI.print(OS, /*IsStandalone=*/true, /*SkipOpers=*/false, diff --git a/lib/CodeGen/MachineOutliner.cpp b/lib/CodeGen/MachineOutliner.cpp index 3a9104bda0d..46a6e862a16 100644 --- a/lib/CodeGen/MachineOutliner.cpp +++ b/lib/CodeGen/MachineOutliner.cpp @@ -1377,7 +1377,7 @@ void MachineOutliner::emitInstrCountChangedRemark( if (!MF) continue; - std::string Fname = F.getName(); + std::string Fname = std::string(F.getName()); unsigned FnCountAfter = MF->getInstructionCount(); unsigned FnCountBefore = 0; diff --git a/lib/CodeGen/MachineScheduler.cpp b/lib/CodeGen/MachineScheduler.cpp index 2bd48ab2a2b..aaa189e4b8e 100644 --- a/lib/CodeGen/MachineScheduler.cpp +++ b/lib/CodeGen/MachineScheduler.cpp @@ -3695,7 +3695,7 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { DOTGraphTraits(bool isSimple = false) : DefaultDOTGraphTraits(isSimple) {} static std::string getGraphName(const ScheduleDAG *G) { - return G->MF.getName(); + return std::string(G->MF.getName()); } static bool renderGraphFromBottomUp() { diff --git a/lib/CodeGen/ScheduleDAGPrinter.cpp b/lib/CodeGen/ScheduleDAGPrinter.cpp index 8d04711f07c..a113c30f851 100644 --- a/lib/CodeGen/ScheduleDAGPrinter.cpp +++ b/lib/CodeGen/ScheduleDAGPrinter.cpp @@ -28,7 +28,7 @@ namespace llvm { DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {} static std::string getGraphName(const ScheduleDAG *G) { - return G->MF.getName(); + return std::string(G->MF.getName()); } static bool renderGraphFromBottomUp() { diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp index 6a46fb41339..8736ee23b8e 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp @@ -65,7 +65,7 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const { if (G) if (const TargetInstrInfo *TII = G->getSubtarget().getInstrInfo()) if (getMachineOpcode() < TII->getNumOpcodes()) - return TII->getName(getMachineOpcode()); + return std::string(TII->getName(getMachineOpcode())); return "<>"; } if (G) { diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp index cdc09d59f6a..038b4ac4783 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp @@ -70,7 +70,7 @@ namespace llvm { } static std::string getGraphName(const SelectionDAG *G) { - return G->getMachineFunction().getName(); + return std::string(G->getMachineFunction().getName()); } static bool renderGraphFromBottomUp() { diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 3b5c917c3d8..3e9e0fca4e1 100644 --- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -888,7 +888,7 @@ void TargetLoweringObjectFileMachO::emitModuleMetadata(MCStreamer &Streamer, for (const auto *Option : LinkerOptions->operands()) { SmallVector StrOptions; for (const auto &Piece : cast(Option)->operands()) - StrOptions.push_back(cast(Piece)->getString()); + StrOptions.push_back(std::string(cast(Piece)->getString())); Streamer.EmitLinkerOptions(StrOptions); } } @@ -1453,7 +1453,7 @@ void TargetLoweringObjectFileCOFF::emitModuleMetadata(MCStreamer &Streamer, for (const auto &Piece : cast(Option)->operands()) { // Lead with a space for consistency with our dllexport implementation. std::string Directive(" "); - Directive.append(cast(Piece)->getString()); + Directive.append(std::string(cast(Piece)->getString())); Streamer.EmitBytes(Directive); } } diff --git a/lib/DWARFLinker/DWARFLinker.cpp b/lib/DWARFLinker/DWARFLinker.cpp index 92e785d33c6..0fa83b32bd6 100644 --- a/lib/DWARFLinker/DWARFLinker.cpp +++ b/lib/DWARFLinker/DWARFLinker.cpp @@ -185,7 +185,7 @@ static void analyzeImportedModule( Twine("Conflicting parseable interfaces for Swift Module ") + *Name + ": " + Entry + " and " + Path, DIE); - Entry = ResolvedPath.str(); + Entry = std::string(ResolvedPath.str()); } } @@ -1180,7 +1180,7 @@ void DWARFLinker::DIECloner::addObjCAccelerator(CompileUnit &Unit, std::string MethodNameNoCategory(Name.getString().data(), OpenParens + 2); // FIXME: The missing space here may be a bug, but // dsymutil-classic also does it this way. - MethodNameNoCategory.append(SelectorStart); + MethodNameNoCategory.append(std::string(SelectorStart)); Unit.addNameAccelerator(Die, StringPool.getEntry(MethodNameNoCategory), SkipPubSection); } diff --git a/lib/DebugInfo/CodeView/RecordName.cpp b/lib/DebugInfo/CodeView/RecordName.cpp index cfaad158115..47b5498181b 100644 --- a/lib/DebugInfo/CodeView/RecordName.cpp +++ b/lib/DebugInfo/CodeView/RecordName.cpp @@ -253,7 +253,7 @@ std::string llvm::codeview::computeTypeName(TypeCollection &Types, consumeError(std::move(EC)); return ""; } - return Computer.name(); + return std::string(Computer.name()); } static int getSymbolNameOffset(CVSymbol Sym) { diff --git a/lib/DebugInfo/CodeView/TypeRecordMapping.cpp b/lib/DebugInfo/CodeView/TypeRecordMapping.cpp index 1aded589e56..bb71c86a060 100644 --- a/lib/DebugInfo/CodeView/TypeRecordMapping.cpp +++ b/lib/DebugInfo/CodeView/TypeRecordMapping.cpp @@ -99,12 +99,12 @@ static std::string getMemberAttributes(CodeViewRecordIO &IO, MethodOptions Options) { if (!IO.isStreaming()) return ""; - std::string AccessSpecifier = - getEnumName(IO, uint8_t(Access), makeArrayRef(getMemberAccessNames())); + std::string AccessSpecifier = std::string( + getEnumName(IO, uint8_t(Access), makeArrayRef(getMemberAccessNames()))); std::string MemberAttrs(AccessSpecifier); if (Kind != MethodKind::Vanilla) { - std::string MethodKind = - getEnumName(IO, unsigned(Kind), makeArrayRef(getMemberKindNames())); + std::string MethodKind = std::string( + getEnumName(IO, unsigned(Kind), makeArrayRef(getMemberKindNames()))); MemberAttrs += ", " + MethodKind; } if (Options != MethodOptions::None) { @@ -201,8 +201,8 @@ Error TypeRecordMapping::visitTypeBegin(CVType &CVR) { if (IO.isStreaming()) { auto RecordKind = CVR.kind(); uint16_t RecordLen = CVR.length() - 2; - std::string RecordKindName = - getEnumName(IO, unsigned(RecordKind), makeArrayRef(LeafTypeNames)); + std::string RecordKindName = std::string( + getEnumName(IO, unsigned(RecordKind), makeArrayRef(LeafTypeNames))); error(IO.mapInteger(RecordLen, "Record length")); error(IO.mapEnum(RecordKind, "Record kind: " + RecordKindName)); } @@ -241,7 +241,7 @@ Error TypeRecordMapping::visitMemberBegin(CVMemberRecord &Record) { MemberKind = Record.Kind; if (IO.isStreaming()) { - std::string MemberKindName = getLeafTypeName(Record.Kind); + std::string MemberKindName = std::string(getLeafTypeName(Record.Kind)); MemberKindName += " ( " + (getEnumName(IO, unsigned(Record.Kind), makeArrayRef(LeafTypeNames))) @@ -277,8 +277,8 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, ModifierRecord &Record) { Error TypeRecordMapping::visitKnownRecord(CVType &CVR, ProcedureRecord &Record) { - std::string CallingConvName = getEnumName( - IO, uint8_t(Record.CallConv), makeArrayRef(getCallingConventions())); + std::string CallingConvName = std::string(getEnumName( + IO, uint8_t(Record.CallConv), makeArrayRef(getCallingConventions()))); std::string FuncOptionNames = getFlagNames(IO, static_cast(Record.Options), makeArrayRef(getFunctionOptionEnum())); @@ -293,8 +293,8 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, Error TypeRecordMapping::visitKnownRecord(CVType &CVR, MemberFunctionRecord &Record) { - std::string CallingConvName = getEnumName( - IO, uint8_t(Record.CallConv), makeArrayRef(getCallingConventions())); + std::string CallingConvName = std::string(getEnumName( + IO, uint8_t(Record.CallConv), makeArrayRef(getCallingConventions()))); std::string FuncOptionNames = getFlagNames(IO, static_cast(Record.Options), makeArrayRef(getFunctionOptionEnum())); @@ -337,12 +337,13 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, PointerRecord &Record) { SmallString<128> Attr("Attrs: "); if (IO.isStreaming()) { - std::string PtrType = getEnumName(IO, unsigned(Record.getPointerKind()), - makeArrayRef(getPtrKindNames())); + std::string PtrType = + std::string(getEnumName(IO, unsigned(Record.getPointerKind()), + makeArrayRef(getPtrKindNames()))); Attr += "[ Type: " + PtrType; - std::string PtrMode = getEnumName(IO, unsigned(Record.getMode()), - makeArrayRef(getPtrModeNames())); + std::string PtrMode = std::string(getEnumName( + IO, unsigned(Record.getMode()), makeArrayRef(getPtrModeNames()))); Attr += ", Mode: " + PtrMode; auto PtrSizeOf = Record.getSize(); @@ -374,8 +375,8 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, PointerRecord &Record) { MemberPointerInfo &M = *Record.MemberInfo; error(IO.mapInteger(M.ContainingType, "ClassType")); - std::string PtrMemberGetRepresentation = getEnumName( - IO, uint16_t(M.Representation), makeArrayRef(getPtrMemberRepNames())); + std::string PtrMemberGetRepresentation = std::string(getEnumName( + IO, uint16_t(M.Representation), makeArrayRef(getPtrMemberRepNames()))); error(IO.mapEnum(M.Representation, "Representation: " + PtrMemberGetRepresentation)); } @@ -581,8 +582,8 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, LabelRecord &Record) { - std::string ModeName = - getEnumName(IO, uint16_t(Record.Mode), makeArrayRef(getLabelTypeEnum())); + std::string ModeName = std::string( + getEnumName(IO, uint16_t(Record.Mode), makeArrayRef(getLabelTypeEnum()))); error(IO.mapEnum(Record.Mode, "Mode: " + ModeName)); return Error::success(); } diff --git a/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp b/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp index afd519013d8..a5f257fe9cc 100644 --- a/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp +++ b/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp @@ -871,13 +871,14 @@ void DWARFDebugNames::ValueIterator::next() { DWARFDebugNames::ValueIterator::ValueIterator(const DWARFDebugNames &AccelTable, StringRef Key) - : CurrentIndex(AccelTable.NameIndices.begin()), IsLocal(false), Key(Key) { + : CurrentIndex(AccelTable.NameIndices.begin()), IsLocal(false), + Key(std::string(Key)) { searchFromStartOfCurrentIndex(); } DWARFDebugNames::ValueIterator::ValueIterator( const DWARFDebugNames::NameIndex &NI, StringRef Key) - : CurrentIndex(&NI), IsLocal(true), Key(Key) { + : CurrentIndex(&NI), IsLocal(true), Key(std::string(Key)) { if (!findInCurrentIndex()) setEnd(); } diff --git a/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/lib/DebugInfo/DWARF/DWARFDebugLine.cpp index b97753eb9dd..84803c80be0 100644 --- a/lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ b/lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -1063,7 +1063,7 @@ bool DWARFDebugLine::Prologue::getFileNameByIndex( StringRef FileName = *Name; if (Kind != FileLineInfoKind::AbsoluteFilePath || isPathAbsoluteOnWindowsOrPosix(FileName)) { - Result = FileName; + Result = std::string(FileName); return true; } @@ -1087,7 +1087,7 @@ bool DWARFDebugLine::Prologue::getFileNameByIndex( // sys::path::append skips empty strings. sys::path::append(FilePath, Style, IncludeDir, FileName); - Result = FilePath.str(); + Result = std::string(FilePath.str()); return true; } diff --git a/lib/DebugInfo/GSYM/LookupResult.cpp b/lib/DebugInfo/GSYM/LookupResult.cpp index c54b166b288..0d9ad8b2272 100644 --- a/lib/DebugInfo/GSYM/LookupResult.cpp +++ b/lib/DebugInfo/GSYM/LookupResult.cpp @@ -21,7 +21,7 @@ std::string LookupResult::getSourceFile(uint32_t Index) const { if (Index < Locations.size()) { if (!Locations[Index].Dir.empty()) { if (Locations[Index].Base.empty()) { - Fullpath = Locations[Index].Dir; + Fullpath = std::string(Locations[Index].Dir); } else { llvm::SmallString<64> Storage; llvm::sys::path::append(Storage, Locations[Index].Dir, @@ -29,7 +29,7 @@ std::string LookupResult::getSourceFile(uint32_t Index) const { Fullpath.assign(Storage.begin(), Storage.end()); } } else if (!Locations[Index].Base.empty()) - Fullpath = Locations[Index].Base; + Fullpath = std::string(Locations[Index].Base); } return Fullpath; } diff --git a/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp b/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp index 419734771cc..06bbbdefe21 100644 --- a/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp +++ b/lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp @@ -39,7 +39,7 @@ static uint32_t calculateDiSymbolStreamSize(uint32_t SymbolByteSize, DbiModuleDescriptorBuilder::DbiModuleDescriptorBuilder(StringRef ModuleName, uint32_t ModIndex, msf::MSFBuilder &Msf) - : MSF(Msf), ModuleName(ModuleName) { + : MSF(Msf), ModuleName(std::string(ModuleName)) { ::memset(&Layout, 0, sizeof(Layout)); Layout.Mod = ModIndex; } @@ -51,7 +51,7 @@ uint16_t DbiModuleDescriptorBuilder::getStreamIndex() const { } void DbiModuleDescriptorBuilder::setObjFileName(StringRef Name) { - ObjFileName = Name; + ObjFileName = std::string(Name); } void DbiModuleDescriptorBuilder::setPdbFilePathNI(uint32_t NI) { @@ -83,7 +83,7 @@ void DbiModuleDescriptorBuilder::addSymbolsInBulk( } void DbiModuleDescriptorBuilder::addSourceFile(StringRef Path) { - SourceFiles.push_back(Path); + SourceFiles.push_back(std::string(Path)); } uint32_t DbiModuleDescriptorBuilder::calculateC13DebugInfoSize() const { diff --git a/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp b/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp index 39ae84acba2..7717f062eac 100644 --- a/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp +++ b/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp @@ -49,11 +49,11 @@ SymIndexId NativeCompilandSymbol::getLexicalParentId() const { return 0; } // this potential confusion. std::string NativeCompilandSymbol::getLibraryName() const { - return Module.getObjFileName(); + return std::string(Module.getObjFileName()); } std::string NativeCompilandSymbol::getName() const { - return Module.getModuleName(); + return std::string(Module.getModuleName()); } } // namespace pdb diff --git a/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp b/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp index 2f6a5bc3d57..7a258acbd7c 100644 --- a/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp +++ b/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp @@ -48,19 +48,19 @@ public: std::string getFileName() const override { StringRef Ret = cantFail(Strings.getStringForID(Entry.FileNI), "InjectedSourceStream should have rejected this"); - return Ret; + return std::string(Ret); } std::string getObjectFileName() const override { StringRef Ret = cantFail(Strings.getStringForID(Entry.ObjNI), "InjectedSourceStream should have rejected this"); - return Ret; + return std::string(Ret); } std::string getVirtualFileName() const override { StringRef Ret = cantFail(Strings.getStringForID(Entry.VFileNI), "InjectedSourceStream should have rejected this"); - return Ret; + return std::string(Ret); } uint32_t getCompression() const override { return Entry.Compression; } diff --git a/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp b/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp index 3f393409129..895f8943157 100644 --- a/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp +++ b/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp @@ -73,7 +73,7 @@ uint32_t NativeExeSymbol::getAge() const { } std::string NativeExeSymbol::getSymbolsFileName() const { - return Session.getPDBFile().getFilePath(); + return std::string(Session.getPDBFile().getFilePath()); } codeview::GUID NativeExeSymbol::getGuid() const { diff --git a/lib/DebugInfo/PDB/Native/NativeSymbolEnumerator.cpp b/lib/DebugInfo/PDB/Native/NativeSymbolEnumerator.cpp index 704c1254afb..e5f1dcaf801 100644 --- a/lib/DebugInfo/PDB/Native/NativeSymbolEnumerator.cpp +++ b/lib/DebugInfo/PDB/Native/NativeSymbolEnumerator.cpp @@ -51,7 +51,9 @@ SymIndexId NativeSymbolEnumerator::getClassParentId() const { SymIndexId NativeSymbolEnumerator::getLexicalParentId() const { return 0; } -std::string NativeSymbolEnumerator::getName() const { return Record.Name; } +std::string NativeSymbolEnumerator::getName() const { + return std::string(Record.Name); +} SymIndexId NativeSymbolEnumerator::getTypeId() const { return Parent.getTypeId(); diff --git a/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp b/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp index 26ccb7daece..aaec3a5e7c6 100644 --- a/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp +++ b/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp @@ -305,7 +305,7 @@ std::string NativeTypeEnum::getName() const { if (UnmodifiedType) return UnmodifiedType->getName(); - return Record->getName(); + return std::string(Record->getName()); } bool NativeTypeEnum::isNested() const { diff --git a/lib/DebugInfo/PDB/Native/NativeTypeTypedef.cpp b/lib/DebugInfo/PDB/Native/NativeTypeTypedef.cpp index 60b37328226..72964a9e0d4 100644 --- a/lib/DebugInfo/PDB/Native/NativeTypeTypedef.cpp +++ b/lib/DebugInfo/PDB/Native/NativeTypeTypedef.cpp @@ -20,7 +20,9 @@ void NativeTypeTypedef::dump(raw_ostream &OS, int Indent, PdbSymbolIdField::Type, ShowIdFields, RecurseIdFields); } -std::string NativeTypeTypedef::getName() const { return Record.Name; } +std::string NativeTypeTypedef::getName() const { + return std::string(Record.Name); +} SymIndexId NativeTypeTypedef::getTypeId() const { return Session.getSymbolCache().findSymbolByTypeIndex(Record.Type); diff --git a/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp b/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp index be67846c0b2..b0be7f76e86 100644 --- a/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp +++ b/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp @@ -74,7 +74,7 @@ std::string NativeTypeUDT::getName() const { if (UnmodifiedType) return UnmodifiedType->getName(); - return Tag->getName(); + return std::string(Tag->getName()); } SymIndexId NativeTypeUDT::getLexicalParentId() const { return 0; } diff --git a/lib/DebugInfo/PDB/Native/PDBFile.cpp b/lib/DebugInfo/PDB/Native/PDBFile.cpp index 9ac226b8913..cde64523685 100644 --- a/lib/DebugInfo/PDB/Native/PDBFile.cpp +++ b/lib/DebugInfo/PDB/Native/PDBFile.cpp @@ -41,7 +41,8 @@ typedef FixedStreamArray ulittle_array; PDBFile::PDBFile(StringRef Path, std::unique_ptr PdbFileBuffer, BumpPtrAllocator &Allocator) - : FilePath(Path), Allocator(Allocator), Buffer(std::move(PdbFileBuffer)) {} + : FilePath(std::string(Path)), Allocator(Allocator), + Buffer(std::move(PdbFileBuffer)) {} PDBFile::~PDBFile() = default; diff --git a/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp b/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp index aa328872439..d6f7e28b839 100644 --- a/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp +++ b/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp @@ -95,7 +95,7 @@ Error PDBFileBuilder::addNamedStream(StringRef Name, StringRef Data) { if (!ExpectedIndex) return ExpectedIndex.takeError(); assert(NamedStreamData.count(*ExpectedIndex) == 0); - NamedStreamData[*ExpectedIndex] = Data; + NamedStreamData[*ExpectedIndex] = std::string(Data); return Error::success(); } diff --git a/lib/DebugInfo/Symbolize/DIPrinter.cpp b/lib/DebugInfo/Symbolize/DIPrinter.cpp index 2f3a2500c29..c5b71ba0645 100644 --- a/lib/DebugInfo/Symbolize/DIPrinter.cpp +++ b/lib/DebugInfo/Symbolize/DIPrinter.cpp @@ -74,7 +74,7 @@ void DIPrinter::print(const DILineInfo &Info, bool Inlined) { if (Filename == DILineInfo::BadString) Filename = DILineInfo::Addr2LineBadString; else if (Basenames) - Filename = llvm::sys::path::filename(Filename); + Filename = std::string(llvm::sys::path::filename(Filename)); if (!Verbose) { OS << Filename << ":" << Info.Line; if (Style == OutputStyle::LLVM) diff --git a/lib/DebugInfo/Symbolize/Symbolize.cpp b/lib/DebugInfo/Symbolize/Symbolize.cpp index ebb4a0c297d..ed6f9088bb4 100644 --- a/lib/DebugInfo/Symbolize/Symbolize.cpp +++ b/lib/DebugInfo/Symbolize/Symbolize.cpp @@ -62,7 +62,7 @@ Expected LLVMSymbolizer::symbolizeCode(const ObjectFile &Obj, object::SectionedAddress ModuleOffset) { StringRef ModuleName = Obj.getFileName(); - auto I = Modules.find(ModuleName); + auto I = Modules.find(std::string(ModuleName)); if (I != Modules.end()) return symbolizeCodeCommon(I->second.get(), ModuleOffset); @@ -184,7 +184,7 @@ std::string getDarwinDWARFResourceForPath( } sys::path::append(ResourceName, "Contents", "Resources", "DWARF"); sys::path::append(ResourceName, Basename); - return ResourceName.str(); + return std::string(ResourceName.str()); } bool checkFileCRC(StringRef Path, uint32_t CRCHash) { @@ -205,14 +205,14 @@ bool findDebugBinary(const std::string &OrigPath, // Try relative/path/to/original_binary/debuglink_name llvm::sys::path::append(DebugPath, DebuglinkName); if (checkFileCRC(DebugPath, CRCHash)) { - Result = DebugPath.str(); + Result = std::string(DebugPath.str()); return true; } // Try relative/path/to/original_binary/.debug/debuglink_name DebugPath = OrigDir; llvm::sys::path::append(DebugPath, ".debug", DebuglinkName); if (checkFileCRC(DebugPath, CRCHash)) { - Result = DebugPath.str(); + Result = std::string(DebugPath.str()); return true; } // Make the path absolute so that lookups will go to @@ -234,7 +234,7 @@ bool findDebugBinary(const std::string &OrigPath, llvm::sys::path::append(DebugPath, llvm::sys::path::relative_path(OrigDir), DebuglinkName); if (checkFileCRC(DebugPath, CRCHash)) { - Result = DebugPath.str(); + Result = std::string(DebugPath.str()); return true; } return false; @@ -342,7 +342,7 @@ bool findDebugBinary(const std::vector &DebugFileDirectory, #endif ); if (llvm::sys::fs::exists(Path)) { - Result = Path.str(); + Result = std::string(Path.str()); return true; } } else { @@ -350,7 +350,7 @@ bool findDebugBinary(const std::vector &DebugFileDirectory, // Try /.build-id/../... SmallString<128> Path = getDebugPath(Directory); if (llvm::sys::fs::exists(Path)) { - Result = Path.str(); + Result = std::string(Path.str()); return true; } } @@ -366,9 +366,11 @@ ObjectFile *LLVMSymbolizer::lookUpDsymFile(const std::string &ExePath, // resource directory. std::vector DsymPaths; StringRef Filename = sys::path::filename(ExePath); - DsymPaths.push_back(getDarwinDWARFResourceForPath(ExePath, Filename)); + DsymPaths.push_back( + getDarwinDWARFResourceForPath(ExePath, std::string(Filename))); for (const auto &Path : Opts.DsymHints) { - DsymPaths.push_back(getDarwinDWARFResourceForPath(Path, Filename)); + DsymPaths.push_back( + getDarwinDWARFResourceForPath(Path, std::string(Filename))); } for (const auto &Path : DsymPaths) { auto DbgObjOrErr = getOrCreateObject(Path, ArchName); diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index ee7a7cb60bc..77f9d70eb54 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -200,7 +200,7 @@ std::string ExecutionEngine::getMangledName(const GlobalValue *GV) { : GV->getParent()->getDataLayout(); Mangler::getNameWithPrefix(FullName, GV->getName(), DL); - return FullName.str(); + return std::string(FullName.str()); } void ExecutionEngine::addGlobalMapping(const GlobalValue *GV, void *Addr) { @@ -223,7 +223,7 @@ void ExecutionEngine::addGlobalMapping(StringRef Name, uint64_t Addr) { std::string &V = EEState.getGlobalAddressReverseMap()[CurVal]; assert((!V.empty() || !Name.empty()) && "GlobalMapping already established!"); - V = Name; + V = std::string(Name); } } @@ -269,7 +269,7 @@ uint64_t ExecutionEngine::updateGlobalMapping(StringRef Name, uint64_t Addr) { std::string &V = EEState.getGlobalAddressReverseMap()[CurVal]; assert((!V.empty() || !Name.empty()) && "GlobalMapping already established!"); - V = Name; + V = std::string(Name); } return OldVal; } @@ -1200,8 +1200,8 @@ void ExecutionEngine::emitGlobals() { GV.hasAppendingLinkage() || !GV.hasName()) continue;// Ignore external globals and globals with internal linkage. - const GlobalValue *&GVEntry = - LinkedGlobalsMap[std::make_pair(GV.getName(), GV.getType())]; + const GlobalValue *&GVEntry = LinkedGlobalsMap[std::make_pair( + std::string(GV.getName()), GV.getType())]; // If this is the first time we've seen this global, it is the canonical // version. @@ -1228,8 +1228,8 @@ void ExecutionEngine::emitGlobals() { for (const auto &GV : M.globals()) { // In the multi-module case, see what this global maps to. if (!LinkedGlobalsMap.empty()) { - if (const GlobalValue *GVEntry = - LinkedGlobalsMap[std::make_pair(GV.getName(), GV.getType())]) { + if (const GlobalValue *GVEntry = LinkedGlobalsMap[std::make_pair( + std::string(GV.getName()), GV.getType())]) { // If something else is the canonical global, ignore this one. if (GVEntry != &GV) { NonCanonicalGlobals.push_back(&GV); @@ -1243,8 +1243,8 @@ void ExecutionEngine::emitGlobals() { } else { // External variable reference. Try to use the dynamic loader to // get a pointer to it. - if (void *SymAddr = - sys::DynamicLibrary::SearchForAddressOfSymbol(GV.getName())) + if (void *SymAddr = sys::DynamicLibrary::SearchForAddressOfSymbol( + std::string(GV.getName()))) addGlobalMapping(&GV, SymAddr); else { report_fatal_error("Could not resolve external global address: " @@ -1258,8 +1258,8 @@ void ExecutionEngine::emitGlobals() { if (!NonCanonicalGlobals.empty()) { for (unsigned i = 0, e = NonCanonicalGlobals.size(); i != e; ++i) { const GlobalValue *GV = NonCanonicalGlobals[i]; - const GlobalValue *CGV = - LinkedGlobalsMap[std::make_pair(GV->getName(), GV->getType())]; + const GlobalValue *CGV = LinkedGlobalsMap[std::make_pair( + std::string(GV->getName()), GV->getType())]; void *Ptr = getPointerToGlobalIfAvailable(CGV); assert(Ptr && "Canonical global wasn't codegen'd!"); addGlobalMapping(GV, Ptr); @@ -1271,8 +1271,8 @@ void ExecutionEngine::emitGlobals() { for (const auto &GV : M.globals()) { if (!GV.isDeclaration()) { if (!LinkedGlobalsMap.empty()) { - if (const GlobalValue *GVEntry = - LinkedGlobalsMap[std::make_pair(GV.getName(), GV.getType())]) + if (const GlobalValue *GVEntry = LinkedGlobalsMap[std::make_pair( + std::string(GV.getName()), GV.getType())]) if (GVEntry != &GV) // Not the canonical variable. continue; } diff --git a/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp b/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp index 701f108a9a2..89eef5783df 100644 --- a/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp +++ b/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp @@ -47,8 +47,8 @@ Expected> MachOLinkGraphBuilder::buildGraph() { MachOLinkGraphBuilder::MachOLinkGraphBuilder(const object::MachOObjectFile &Obj) : Obj(Obj), - G(std::make_unique(Obj.getFileName(), getPointerSize(Obj), - getEndianness(Obj))) {} + G(std::make_unique(std::string(Obj.getFileName()), + getPointerSize(Obj), getEndianness(Obj))) {} void MachOLinkGraphBuilder::addCustomSectionParser( StringRef SectionName, SectionParserFunction Parser) { diff --git a/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/lib/ExecutionEngine/MCJIT/MCJIT.cpp index 94741f5f01d..9c3d0d53984 100644 --- a/lib/ExecutionEngine/MCJIT/MCJIT.cpp +++ b/lib/ExecutionEngine/MCJIT/MCJIT.cpp @@ -609,7 +609,7 @@ GenericValue MCJIT::runFunction(Function *F, ArrayRef ArgValues) { void *MCJIT::getPointerToNamedFunction(StringRef Name, bool AbortOnFailure) { if (!isSymbolSearchingDisabled()) { - if (auto Sym = Resolver.findSymbol(Name)) { + if (auto Sym = Resolver.findSymbol(std::string(Name))) { if (auto AddrOrErr = Sym.getAddress()) return reinterpret_cast( static_cast(*AddrOrErr)); @@ -619,7 +619,7 @@ void *MCJIT::getPointerToNamedFunction(StringRef Name, bool AbortOnFailure) { /// If a LazyFunctionCreator is installed, use it to get/create the function. if (LazyFunctionCreator) - if (void *RP = LazyFunctionCreator(Name)) + if (void *RP = LazyFunctionCreator(std::string(Name))) return RP; if (AbortOnFailure) { diff --git a/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp b/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp index 9c504da611e..29d18b6e4d7 100644 --- a/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp +++ b/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp @@ -35,7 +35,7 @@ static ThreadSafeModule extractSubModule(ThreadSafeModule &TSM, Constant *Aliasee = A.getAliasee(); assert(A.hasName() && "Anonymous alias?"); assert(Aliasee->hasName() && "Anonymous aliasee"); - std::string AliasName = A.getName(); + std::string AliasName = std::string(A.getName()); if (isa(Aliasee)) { auto *F = cloneFunctionDecl(*A.getParent(), *cast(Aliasee)); diff --git a/lib/ExecutionEngine/Orc/Core.cpp b/lib/ExecutionEngine/Orc/Core.cpp index ec706cf63d3..f2b161cc9fc 100644 --- a/lib/ExecutionEngine/Orc/Core.cpp +++ b/lib/ExecutionEngine/Orc/Core.cpp @@ -838,7 +838,7 @@ JITDylib::defineMaterializing(SymbolFlagsMap SymbolFlags) { Symbols.erase(SI); // FIXME: Return all duplicates. - return make_error(*Name); + return make_error(std::string(*Name)); } // Otherwise just make a note to discard this symbol after the loop. @@ -1815,7 +1815,7 @@ Error JITDylib::defineImpl(MaterializationUnit &MU) { // If there were any duplicate definitions then bail out. if (!Duplicates.empty()) - return make_error(**Duplicates.begin()); + return make_error(std::string(**Duplicates.begin())); // Discard any overridden defs in this MU. for (auto &S : MUDefsOverridden) diff --git a/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp b/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp index 114e81e4177..3eda0fa1360 100644 --- a/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp +++ b/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp @@ -33,7 +33,7 @@ Expected JITTargetMachineBuilder::detectHost() { for (auto &Feature : FeatureMap) TMBuilder.getFeatures().AddFeature(Feature.first(), Feature.second); - TMBuilder.setCPU(llvm::sys::getHostCPUName()); + TMBuilder.setCPU(std::string(llvm::sys::getHostCPUName())); return TMBuilder; } diff --git a/lib/ExecutionEngine/Orc/OrcCBindingsStack.h b/lib/ExecutionEngine/Orc/OrcCBindingsStack.h index e0af3df9d01..87bb4398765 100644 --- a/lib/ExecutionEngine/Orc/OrcCBindingsStack.h +++ b/lib/ExecutionEngine/Orc/OrcCBindingsStack.h @@ -133,7 +133,7 @@ private: orc::SymbolNameSet Result; for (auto &S : Symbols) { - if (auto Sym = findSymbol(*S)) { + if (auto Sym = findSymbol(std::string(*S))) { if (!Sym.getFlags().isStrong()) Result.insert(S); } else if (auto Err = Sym.takeError()) { @@ -151,7 +151,7 @@ private: orc::SymbolNameSet UnresolvedSymbols; for (auto &S : Symbols) { - if (auto Sym = findSymbol(*S)) { + if (auto Sym = findSymbol(std::string(*S))) { if (auto Addr = Sym.getAddress()) { Query->notifySymbolMetRequiredState( S, JITEvaluatedSymbol(*Addr, Sym.getFlags())); diff --git a/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h b/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h index 169dc8f1d02..139572bd697 100644 --- a/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h +++ b/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h @@ -154,7 +154,8 @@ class OrcMCJITReplacement : public ExecutionEngine { M.reportError(std::move(Err)); return SymbolNameSet(); } else { - if (auto Sym2 = M.ClientResolver->findSymbolInLogicalDylib(*S)) { + if (auto Sym2 = + M.ClientResolver->findSymbolInLogicalDylib(std::string(*S))) { if (!Sym2.getFlags().isStrong()) Result.insert(S); } else if (auto Err = Sym2.takeError()) { @@ -187,7 +188,7 @@ class OrcMCJITReplacement : public ExecutionEngine { M.ES.legacyFailQuery(*Query, std::move(Err)); return SymbolNameSet(); } else { - if (auto Sym2 = M.ClientResolver->findSymbol(*S)) { + if (auto Sym2 = M.ClientResolver->findSymbol(std::string(*S))) { if (auto Addr = Sym2.getAddress()) { Query->notifySymbolMetRequiredState( S, JITEvaluatedSymbol(*Addr, Sym2.getFlags())); @@ -378,9 +379,9 @@ public: private: JITSymbol findMangledSymbol(StringRef Name) { - if (auto Sym = LazyEmitLayer.findSymbol(Name, false)) + if (auto Sym = LazyEmitLayer.findSymbol(std::string(Name), false)) return Sym; - if (auto Sym = ClientResolver->findSymbol(Name)) + if (auto Sym = ClientResolver->findSymbol(std::string(Name))) return Sym; if (auto Sym = scanArchives(Name)) return Sym; diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h index cec7b92b8c4..a2f6df32de0 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h @@ -74,7 +74,7 @@ class SectionEntry { public: SectionEntry(StringRef name, uint8_t *address, size_t size, size_t allocationSize, uintptr_t objAddress) - : Name(name), Address(address), Size(size), + : Name(std::string(name)), Address(address), Size(size), LoadAddress(reinterpret_cast(address)), StubOffset(size), AllocationSize(allocationSize), ObjAddress(objAddress) { // AllocationSize is used only in asserts, prevent an "unused private field" diff --git a/lib/FuzzMutate/FuzzerCLI.cpp b/lib/FuzzMutate/FuzzerCLI.cpp index f2368ea7f26..b77a0e09184 100644 --- a/lib/FuzzMutate/FuzzerCLI.cpp +++ b/lib/FuzzMutate/FuzzerCLI.cpp @@ -36,7 +36,7 @@ void llvm::parseFuzzerCLOpts(int ArgC, char *ArgV[]) { } void llvm::handleExecNameEncodedBEOpts(StringRef ExecName) { - std::vector Args{ExecName}; + std::vector Args{std::string(ExecName)}; auto NameAndArgs = ExecName.split("--"); if (NameAndArgs.second.empty()) @@ -73,7 +73,7 @@ void llvm::handleExecNameEncodedBEOpts(StringRef ExecName) { void llvm::handleExecNameEncodedOptimizerOpts(StringRef ExecName) { // TODO: Refactor parts common with the 'handleExecNameEncodedBEOpts' - std::vector Args{ExecName}; + std::vector Args{std::string(ExecName)}; auto NameAndArgs = ExecName.split("--"); if (NameAndArgs.second.empty()) diff --git a/lib/IR/AsmWriter.cpp b/lib/IR/AsmWriter.cpp index 86bb7ba72d4..953d7ae49ff 100644 --- a/lib/IR/AsmWriter.cpp +++ b/lib/IR/AsmWriter.cpp @@ -2693,7 +2693,7 @@ void AssemblyWriter::printModuleSummaryIndex() { // A module id of -1 is a special entry for a regular LTO module created // during the thin link. ModPath.second.first == -1u ? RegularLTOModuleName - : (std::string)ModPath.first(), + : (std::string)std::string(ModPath.first()), ModPath.second.second); unsigned i = 0; diff --git a/lib/IR/AttributeImpl.h b/lib/IR/AttributeImpl.h index 15e488bbb13..da6e993e2e5 100644 --- a/lib/IR/AttributeImpl.h +++ b/lib/IR/AttributeImpl.h @@ -152,7 +152,8 @@ class StringAttributeImpl : public AttributeImpl { public: StringAttributeImpl(StringRef Kind, StringRef Val = StringRef()) - : AttributeImpl(StringAttrEntry), Kind(Kind), Val(Val) {} + : AttributeImpl(StringAttrEntry), Kind(std::string(Kind)), + Val(std::string(Val)) {} StringRef getStringKind() const { return Kind; } StringRef getStringValue() const { return Val; } diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp index 10b6828560a..efc7168bb8e 100644 --- a/lib/IR/Attributes.cpp +++ b/lib/IR/Attributes.cpp @@ -466,7 +466,7 @@ std::string Attribute::getAsString(bool InAttrGrp) const { std::string Result; Result += (Twine('"') + getKindAsString() + Twine('"')).str(); - std::string AttrVal = pImpl->getValueAsString(); + std::string AttrVal = std::string(pImpl->getValueAsString()); if (AttrVal.empty()) return Result; // Since some attribute strings contain special characters that cannot be @@ -1481,7 +1481,7 @@ AttrBuilder &AttrBuilder::addAttribute(Attribute Attr) { } AttrBuilder &AttrBuilder::addAttribute(StringRef A, StringRef V) { - TargetDepAttrs[A] = V; + TargetDepAttrs[std::string(A)] = std::string(V); return *this; } diff --git a/lib/IR/AutoUpgrade.cpp b/lib/IR/AutoUpgrade.cpp index 857e2641233..a14bcef9b37 100644 --- a/lib/IR/AutoUpgrade.cpp +++ b/lib/IR/AutoUpgrade.cpp @@ -3663,7 +3663,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { // Replace the original call result with the first result of the new call. Value *TSC = Builder.CreateExtractValue(NewCall, 0); - std::string Name = CI->getName(); + std::string Name = std::string(CI->getName()); if (!Name.empty()) { CI->setName(Name + ".old"); NewCall->setName(Name); @@ -3738,7 +3738,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { } assert(NewCall && "Should have either set this variable or returned through " "the default case"); - std::string Name = CI->getName(); + std::string Name = std::string(CI->getName()); if (!Name.empty()) { CI->setName(Name + ".old"); NewCall->setName(Name); @@ -4080,7 +4080,7 @@ void llvm::UpgradeSectionAttributes(Module &M) { for (auto Component : Components) OS << ',' << Component.trim(); - return OS.str().substr(1); + return std::string(OS.str().substr(1)); }; for (auto &GV : M.globals()) { @@ -4166,12 +4166,12 @@ std::string llvm::UpgradeDataLayoutString(StringRef DL, StringRef TT) { // If X86, and the datalayout matches the expected format, add pointer size // address spaces to the datalayout. if (!Triple(TT).isX86() || DL.contains(AddrSpaces)) - return DL; + return std::string(DL); SmallVector Groups; Regex R("(e-m:[a-z](-p:32:32)?)(-[if]64:.*$)"); if (!R.match(DL, &Groups)) - return DL; + return std::string(DL); SmallString<1024> Buf; std::string Res = (Groups[1] + AddrSpaces + Groups[3]).toStringRef(Buf).str(); diff --git a/lib/IR/ConstantsContext.h b/lib/IR/ConstantsContext.h index f5e2481f390..9ecbb613783 100644 --- a/lib/IR/ConstantsContext.h +++ b/lib/IR/ConstantsContext.h @@ -454,8 +454,8 @@ struct InlineAsmKeyType { InlineAsm *create(TypeClass *Ty) const { assert(PointerType::getUnqual(FTy) == Ty); - return new InlineAsm(FTy, AsmString, Constraints, HasSideEffects, - IsAlignStack, AsmDialect); + return new InlineAsm(FTy, std::string(AsmString), std::string(Constraints), + HasSideEffects, IsAlignStack, AsmDialect); } }; diff --git a/lib/IR/DataLayout.cpp b/lib/IR/DataLayout.cpp index 26ec6db63c0..c2ac1c3fa02 100644 --- a/lib/IR/DataLayout.cpp +++ b/lib/IR/DataLayout.cpp @@ -229,7 +229,7 @@ static unsigned getAddrSpace(StringRef R) { } void DataLayout::parseSpecifier(StringRef Desc) { - StringRepresentation = Desc; + StringRepresentation = std::string(Desc); while (!Desc.empty()) { // Split at '-'. std::pair Split = split(Desc, '-'); diff --git a/lib/IR/DiagnosticInfo.cpp b/lib/IR/DiagnosticInfo.cpp index 99d5aec3f04..1a4957d886d 100644 --- a/lib/IR/DiagnosticInfo.cpp +++ b/lib/IR/DiagnosticInfo.cpp @@ -132,7 +132,7 @@ StringRef DiagnosticLocation::getRelativePath() const { std::string DiagnosticLocation::getAbsolutePath() const { StringRef Name = File->getFilename(); if (sys::path::is_absolute(Name)) - return Name; + return std::string(Name); SmallString<128> Path; sys::path::append(Path, File->getDirectory(), Name); @@ -160,8 +160,9 @@ const std::string DiagnosticInfoWithLocationBase::getLocationStr() const { return (Filename + ":" + Twine(Line) + ":" + Twine(Column)).str(); } -DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, const Value *V) - : Key(Key) { +DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, + const Value *V) + : Key(std::string(Key)) { if (auto *F = dyn_cast(V)) { if (DISubprogram *SP = F->getSubprogram()) Loc = SP; @@ -172,7 +173,7 @@ DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, const Value *V // Only include names that correspond to user variables. FIXME: We should use // debug info if available to get the name of the user variable. if (isa(V) || isa(V)) - Val = GlobalValue::dropLLVMManglingEscape(V->getName()); + Val = std::string(GlobalValue::dropLLVMManglingEscape(V->getName())); else if (isa(V)) { raw_string_ostream OS(Val); V->printAsOperand(OS, /*PrintType=*/false); @@ -181,39 +182,39 @@ DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, const Value *V } DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, const Type *T) - : Key(Key) { + : Key(std::string(Key)) { raw_string_ostream OS(Val); OS << *T; } DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, StringRef S) - : Key(Key), Val(S.str()) {} + : Key(std::string(Key)), Val(S.str()) {} DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, int N) - : Key(Key), Val(itostr(N)) {} + : Key(std::string(Key)), Val(itostr(N)) {} DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, float N) - : Key(Key), Val(llvm::to_string(N)) {} + : Key(std::string(Key)), Val(llvm::to_string(N)) {} DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, long N) - : Key(Key), Val(itostr(N)) {} + : Key(std::string(Key)), Val(itostr(N)) {} DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, long long N) - : Key(Key), Val(itostr(N)) {} + : Key(std::string(Key)), Val(itostr(N)) {} DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, unsigned N) - : Key(Key), Val(utostr(N)) {} + : Key(std::string(Key)), Val(utostr(N)) {} DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, unsigned long N) - : Key(Key), Val(utostr(N)) {} + : Key(std::string(Key)), Val(utostr(N)) {} DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, unsigned long long N) - : Key(Key), Val(utostr(N)) {} + : Key(std::string(Key)), Val(utostr(N)) {} DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key, DebugLoc Loc) - : Key(Key), Loc(Loc) { + : Key(std::string(Key)), Loc(Loc) { if (Loc) { Val = (Loc->getFilename() + ":" + Twine(Loc.getLine()) + ":" + Twine(Loc.getCol())).str(); diff --git a/lib/IR/Globals.cpp b/lib/IR/Globals.cpp index 46a9696b294..9a07a689e88 100644 --- a/lib/IR/Globals.cpp +++ b/lib/IR/Globals.cpp @@ -143,7 +143,7 @@ std::string GlobalValue::getGlobalIdentifier(StringRef Name, if (Name[0] == '\1') Name = Name.substr(1); - std::string NewName = Name; + std::string NewName = std::string(Name); if (llvm::GlobalValue::isLocalLinkage(Linkage)) { // For local symbols, prepend the main file name to distinguish them. // Do not include the full path in the file name since there's no guarantee diff --git a/lib/IR/InlineAsm.cpp b/lib/IR/InlineAsm.cpp index fd732f9eda8..ee30b92522d 100644 --- a/lib/IR/InlineAsm.cpp +++ b/lib/IR/InlineAsm.cpp @@ -136,14 +136,14 @@ bool InlineAsm::ConstraintInfo::Parse(StringRef Str, // Find the end of the register name. StringRef::iterator ConstraintEnd = std::find(I+1, E, '}'); if (ConstraintEnd == E) return true; // "{foo" - pCodes->push_back(StringRef(I, ConstraintEnd+1 - I)); + pCodes->push_back(std::string(StringRef(I, ConstraintEnd + 1 - I))); I = ConstraintEnd+1; } else if (isdigit(static_cast(*I))) { // Matching Constraint // Maximal munch numbers. StringRef::iterator NumStart = I; while (I != E && isdigit(static_cast(*I))) ++I; - pCodes->push_back(StringRef(NumStart, I - NumStart)); + pCodes->push_back(std::string(StringRef(NumStart, I - NumStart))); unsigned N = atoi(pCodes->back().c_str()); // Check that this is a valid matching constraint! if (N >= ConstraintsSoFar.size() || ConstraintsSoFar[N].Type != isOutput|| @@ -179,7 +179,7 @@ bool InlineAsm::ConstraintInfo::Parse(StringRef Str, } else if (*I == '^') { // Multi-letter constraint // FIXME: For now assuming these are 2-character constraints. - pCodes->push_back(StringRef(I+1, 2)); + pCodes->push_back(std::string(StringRef(I + 1, 2))); I += 3; } else if (*I == '@') { // Multi-letter constraint @@ -189,11 +189,11 @@ bool InlineAsm::ConstraintInfo::Parse(StringRef Str, int N = C - '0'; assert(N > 0 && "Found a zero letter constraint!"); ++I; - pCodes->push_back(StringRef(I, N)); + pCodes->push_back(std::string(StringRef(I, N))); I += N; } else { // Single letter constraint. - pCodes->push_back(StringRef(I, 1)); + pCodes->push_back(std::string(StringRef(I, 1))); ++I; } } diff --git a/lib/IR/LegacyPassManager.cpp b/lib/IR/LegacyPassManager.cpp index 90239bb7629..d5c7e287482 100644 --- a/lib/IR/LegacyPassManager.cpp +++ b/lib/IR/LegacyPassManager.cpp @@ -132,7 +132,8 @@ bool llvm::forcePrintModuleIR() { return PrintModuleScope; } bool llvm::isFunctionInPrintList(StringRef FunctionName) { static std::unordered_set PrintFuncNames(PrintFuncsList.begin(), PrintFuncsList.end()); - return PrintFuncNames.empty() || PrintFuncNames.count(FunctionName); + return PrintFuncNames.empty() || + PrintFuncNames.count(std::string(FunctionName)); } /// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions /// or higher is specified. @@ -239,7 +240,7 @@ void PMDataManager::emitInstrCountChangedRemark( // Helper lambda that emits a remark when the size of a function has changed. auto EmitFunctionSizeChangedRemark = [&FunctionToInstrCount, &F, &BB, - &PassName](const std::string &Fname) { + &PassName](StringRef Fname) { unsigned FnCountBefore, FnCountAfter; std::pair &Change = FunctionToInstrCount[Fname]; std::tie(FnCountBefore, FnCountAfter) = Change; diff --git a/lib/IR/Module.cpp b/lib/IR/Module.cpp index eb23b125a65..3b351763900 100644 --- a/lib/IR/Module.cpp +++ b/lib/IR/Module.cpp @@ -72,7 +72,8 @@ template class llvm::SymbolTableListTraits; Module::Module(StringRef MID, LLVMContext &C) : Context(C), ValSymTab(std::make_unique()), - Materializer(), ModuleID(MID), SourceFileName(MID), DL("") { + Materializer(), ModuleID(std::string(MID)), + SourceFileName(std::string(MID)), DL("") { Context.addModule(this); } diff --git a/lib/LTO/Caching.cpp b/lib/LTO/Caching.cpp index 12dcd182de2..46cac3fb183 100644 --- a/lib/LTO/Caching.cpp +++ b/lib/LTO/Caching.cpp @@ -144,7 +144,7 @@ Expected lto::localCache(StringRef CacheDirectoryPath, // This CacheStream will move the temporary file into the cache when done. return std::make_unique( std::make_unique(Temp->FD, /* ShouldClose */ false), - AddBuffer, std::move(*Temp), EntryPath.str(), Task); + AddBuffer, std::move(*Temp), std::string(EntryPath.str()), Task); }; }; } diff --git a/lib/LTO/LTO.cpp b/lib/LTO/LTO.cpp index e8f0fd6866d..5d03be1db2a 100644 --- a/lib/LTO/LTO.cpp +++ b/lib/LTO/LTO.cpp @@ -513,7 +513,7 @@ void LTO::addModuleToGlobalRes(ArrayRef Syms, assert(!GlobalRes.Prevailing && "Multiple prevailing defs are not allowed"); GlobalRes.Prevailing = true; - GlobalRes.IRName = Sym.getIRName(); + GlobalRes.IRName = std::string(Sym.getIRName()); } else if (!GlobalRes.Prevailing && GlobalRes.IRName.empty()) { // Sometimes it can be two copies of symbol in a module and prevailing // symbol can have no IR name. That might happen if symbol is defined in @@ -521,7 +521,7 @@ void LTO::addModuleToGlobalRes(ArrayRef Syms, // the same symbol we want to use IR name of the prevailing symbol. // Otherwise, if we haven't seen a prevailing symbol, set the name so that // we can later use it to check if there is any prevailing copy in IR. - GlobalRes.IRName = Sym.getIRName(); + GlobalRes.IRName = std::string(Sym.getIRName()); } // Set the partition to external if we know it is re-defined by the linker @@ -762,7 +762,7 @@ LTO::addRegularLTO(BitcodeModule BM, ArrayRef Syms, if (Sym.isCommon()) { // FIXME: We should figure out what to do about commons defined by asm. // For now they aren't reported correctly by ModuleSymbolTable. - auto &CommonRes = RegularLTO.Commons[Sym.getIRName()]; + auto &CommonRes = RegularLTO.Commons[std::string(Sym.getIRName())]; CommonRes.Size = std::max(CommonRes.Size, Sym.getCommonSize()); CommonRes.Align = std::max(CommonRes.Align, MaybeAlign(Sym.getCommonAlignment())); @@ -1191,7 +1191,7 @@ std::string lto::getThinLTOOutputFile(const std::string &Path, llvm::errs() << "warning: could not create directory '" << ParentPath << "': " << EC.message() << '\n'; } - return NewPath.str(); + return std::string(NewPath.str()); } namespace { @@ -1220,7 +1220,7 @@ public: MapVector &ModuleMap) override { StringRef ModulePath = BM.getModuleIdentifier(); std::string NewModulePath = - getThinLTOOutputFile(ModulePath, OldPrefix, NewPrefix); + getThinLTOOutputFile(std::string(ModulePath), OldPrefix, NewPrefix); if (LinkedObjectsFile) *LinkedObjectsFile << NewModulePath << '\n'; @@ -1244,7 +1244,7 @@ public: } if (OnWrite) - OnWrite(ModulePath); + OnWrite(std::string(ModulePath)); return Error::success(); } @@ -1391,7 +1391,7 @@ Expected> lto::setupOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename, StringRef RemarksPasses, StringRef RemarksFormat, bool RemarksWithHotness, int Count) { - std::string Filename = RemarksFilename; + std::string Filename = std::string(RemarksFilename); // For ThinLTO, file.opt. becomes // file.opt..thin... if (!Filename.empty() && Count != -1) diff --git a/lib/LTO/LTOCodeGenerator.cpp b/lib/LTO/LTOCodeGenerator.cpp index b3bc727e50a..bbc1f4040e9 100644 --- a/lib/LTO/LTOCodeGenerator.cpp +++ b/lib/LTO/LTOCodeGenerator.cpp @@ -632,7 +632,7 @@ bool LTOCodeGenerator::compileOptimized(ArrayRef Out) { void LTOCodeGenerator::setCodeGenDebugOptions(ArrayRef Options) { for (StringRef Option : Options) - CodegenOptions.push_back(Option); + CodegenOptions.push_back(std::string(Option)); } void LTOCodeGenerator::parseCodeGenDebugOptions() { diff --git a/lib/LTO/ThinLTOCodeGenerator.cpp b/lib/LTO/ThinLTOCodeGenerator.cpp index f4099e68315..2fa1cddad59 100644 --- a/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/lib/LTO/ThinLTOCodeGenerator.cpp @@ -870,11 +870,11 @@ ThinLTOCodeGenerator::writeGeneratedObject(int count, StringRef CacheEntryPath, // Cache is enabled, hard-link the entry (or copy if hard-link fails). auto Err = sys::fs::create_hard_link(CacheEntryPath, OutputPath); if (!Err) - return OutputPath.str(); + return std::string(OutputPath.str()); // Hard linking failed, try to copy. Err = sys::fs::copy_file(CacheEntryPath, OutputPath); if (!Err) - return OutputPath.str(); + return std::string(OutputPath.str()); // Copy failed (could be because the CacheEntry was removed from the cache // in the meantime by another process), fall back and try to write down the // buffer to the output. @@ -887,7 +887,7 @@ ThinLTOCodeGenerator::writeGeneratedObject(int count, StringRef CacheEntryPath, if (Err) report_fatal_error("Can't open output '" + OutputPath + "'\n"); OS << OutputBuffer.getBuffer(); - return OutputPath.str(); + return std::string(OutputPath.str()); } // Main entry point for the ThinLTO processing diff --git a/lib/LineEditor/LineEditor.cpp b/lib/LineEditor/LineEditor.cpp index 57e62bd6487..1aa3476eb35 100644 --- a/lib/LineEditor/LineEditor.cpp +++ b/lib/LineEditor/LineEditor.cpp @@ -24,7 +24,7 @@ std::string LineEditor::getDefaultHistoryPath(StringRef ProgName) { SmallString<32> Path; if (sys::path::home_directory(Path)) { sys::path::append(Path, "." + ProgName + "-history"); - return Path.str(); + return std::string(Path.str()); } return std::string(); } @@ -197,7 +197,7 @@ unsigned char ElCompletionFn(EditLine *EL, int ch) { LineEditor::LineEditor(StringRef ProgName, StringRef HistoryPath, FILE *In, FILE *Out, FILE *Err) - : Prompt((ProgName + "> ").str()), HistoryPath(HistoryPath), + : Prompt((ProgName + "> ").str()), HistoryPath(std::string(HistoryPath)), Data(new InternalData) { if (HistoryPath.empty()) this->HistoryPath = getDefaultHistoryPath(ProgName); diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp index a6417113fd3..ff4f636f846 100644 --- a/lib/MC/MCContext.cpp +++ b/lib/MC/MCContext.cpp @@ -68,8 +68,8 @@ MCContext::MCContext(const MCAsmInfo *mai, const MCRegisterInfo *mri, SecureLogFile = AsSecureLogFileName; if (SrcMgr && SrcMgr->getNumBuffers()) - MainFileName = - SrcMgr->getMemoryBuffer(SrcMgr->getMainFileID())->getBufferIdentifier(); + MainFileName = std::string(SrcMgr->getMemoryBuffer(SrcMgr->getMainFileID()) + ->getBufferIdentifier()); } MCContext::~MCContext() { @@ -593,7 +593,7 @@ void MCContext::RemapDebugPaths() { }; // Remap compilation directory. - std::string CompDir = CompilationDir.str(); + std::string CompDir = std::string(CompilationDir.str()); RemapDebugPath(CompDir); CompilationDir = CompDir; diff --git a/lib/MC/MCDwarf.cpp b/lib/MC/MCDwarf.cpp index b4b3c9956cc..1a328222916 100644 --- a/lib/MC/MCDwarf.cpp +++ b/lib/MC/MCDwarf.cpp @@ -620,7 +620,7 @@ MCDwarfLineTableHeader::tryGetFile(StringRef &Directory, } else { DirIndex = llvm::find(MCDwarfDirs, Directory) - MCDwarfDirs.begin(); if (DirIndex >= MCDwarfDirs.size()) - MCDwarfDirs.push_back(Directory); + MCDwarfDirs.push_back(std::string(Directory)); // The DirIndex is one based, as DirIndex of 0 is used for FileNames with // no directories. MCDwarfDirs[] is unlike MCDwarfFiles[] in that the // directory names are stored at MCDwarfDirs[DirIndex-1] where FileNames @@ -628,7 +628,7 @@ MCDwarfLineTableHeader::tryGetFile(StringRef &Directory, DirIndex++; } - File.Name = FileName; + File.Name = std::string(FileName); File.DirIndex = DirIndex; File.Checksum = Checksum; trackMD5Usage(Checksum.hasValue()); diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index c5938b813f4..30f1147fb6c 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -2358,7 +2358,7 @@ void AsmParser::DiagHandler(const SMDiagnostic &Diag, void *Context) { // Use the CppHashFilename and calculate a line number based on the // CppHashInfo.Loc and CppHashInfo.LineNumber relative to this Diag's SMLoc // for the diagnostic. - const std::string &Filename = Parser->CppHashInfo.Filename; + const std::string &Filename = std::string(Parser->CppHashInfo.Filename); int DiagLocLineNo = DiagSrcMgr.FindLineNumber(DiagLoc, DiagBuf); int CppHashLocLineNo = diff --git a/lib/MC/MCParser/DarwinAsmParser.cpp b/lib/MC/MCParser/DarwinAsmParser.cpp index bd66e5f39c0..1d1feaa2fbe 100644 --- a/lib/MC/MCParser/DarwinAsmParser.cpp +++ b/lib/MC/MCParser/DarwinAsmParser.cpp @@ -672,7 +672,7 @@ bool DarwinAsmParser::parseDirectiveSection(StringRef, SMLoc) { if (!getLexer().is(AsmToken::Comma)) return TokError("unexpected token in '.section' directive"); - std::string SectionSpec = SectionName; + std::string SectionSpec = std::string(SectionName); SectionSpec += ","; // Add all the tokens until the end of the line, ParseSectionSpecifier will diff --git a/lib/MC/MCSubtargetInfo.cpp b/lib/MC/MCSubtargetInfo.cpp index c8678df02bf..7d38cd0f729 100644 --- a/lib/MC/MCSubtargetInfo.cpp +++ b/lib/MC/MCSubtargetInfo.cpp @@ -206,15 +206,17 @@ void MCSubtargetInfo::setDefaultFeatures(StringRef CPU, StringRef FS) { FeatureBits = getFeatures(CPU, FS, ProcDesc, ProcFeatures); } -MCSubtargetInfo::MCSubtargetInfo( - const Triple &TT, StringRef C, StringRef FS, - ArrayRef PF, ArrayRef PD, - const MCWriteProcResEntry *WPR, - const MCWriteLatencyEntry *WL, const MCReadAdvanceEntry *RA, - const InstrStage *IS, const unsigned *OC, const unsigned *FP) - : TargetTriple(TT), CPU(C), ProcFeatures(PF), ProcDesc(PD), - WriteProcResTable(WPR), WriteLatencyTable(WL), - ReadAdvanceTable(RA), Stages(IS), OperandCycles(OC), ForwardingPaths(FP) { +MCSubtargetInfo::MCSubtargetInfo(const Triple &TT, StringRef C, StringRef FS, + ArrayRef PF, + ArrayRef PD, + const MCWriteProcResEntry *WPR, + const MCWriteLatencyEntry *WL, + const MCReadAdvanceEntry *RA, + const InstrStage *IS, const unsigned *OC, + const unsigned *FP) + : TargetTriple(TT), CPU(std::string(C)), ProcFeatures(PF), ProcDesc(PD), + WriteProcResTable(WPR), WriteLatencyTable(WL), ReadAdvanceTable(RA), + Stages(IS), OperandCycles(OC), ForwardingPaths(FP) { InitMCProcessorInfo(CPU, FS); } diff --git a/lib/MC/SubtargetFeature.cpp b/lib/MC/SubtargetFeature.cpp index c4dd77359b2..3155adcf267 100644 --- a/lib/MC/SubtargetFeature.cpp +++ b/lib/MC/SubtargetFeature.cpp @@ -33,7 +33,9 @@ using namespace llvm; void SubtargetFeatures::Split(std::vector &V, StringRef S) { SmallVector Tmp; S.split(Tmp, ',', -1, false /* KeepEmpty */); - V.assign(Tmp.begin(), Tmp.end()); + V.reserve(Tmp.size()); + for (StringRef T : Tmp) + V.push_back(std::string(T)); } void SubtargetFeatures::AddFeature(StringRef String, bool Enable) { diff --git a/lib/MC/WinCOFFObjectWriter.cpp b/lib/MC/WinCOFFObjectWriter.cpp index 749ed8badfa..cf755dcb288 100644 --- a/lib/MC/WinCOFFObjectWriter.cpp +++ b/lib/MC/WinCOFFObjectWriter.cpp @@ -118,7 +118,7 @@ public: COFFSymbol *Symbol = nullptr; relocations Relocations; - COFFSection(StringRef Name) : Name(Name) {} + COFFSection(StringRef Name) : Name(std::string(Name)) {} }; class WinCOFFObjectWriter : public MCObjectWriter { diff --git a/lib/MCA/InstrBuilder.cpp b/lib/MCA/InstrBuilder.cpp index c137f1da8a4..f3c71340201 100644 --- a/lib/MCA/InstrBuilder.cpp +++ b/lib/MCA/InstrBuilder.cpp @@ -502,7 +502,7 @@ Error InstrBuilder::verifyInstrDesc(const InstrDesc &ID, "resources."; } - return make_error>(Message, MCI); + return make_error>(std::string(Message), MCI); } Expected diff --git a/lib/Object/Archive.cpp b/lib/Object/Archive.cpp index 148c011d9cd..17d5eec9156 100644 --- a/lib/Object/Archive.cpp +++ b/lib/Object/Archive.cpp @@ -423,12 +423,12 @@ Expected Archive::Child::getFullName() const { return NameOrErr.takeError(); StringRef Name = *NameOrErr; if (sys::path::is_absolute(Name)) - return Name; + return std::string(Name); SmallString<128> FullName = sys::path::parent_path( Parent->getMemoryBufferRef().getBufferIdentifier()); sys::path::append(FullName, Name); - return StringRef(FullName); + return std::string(FullName.str()); } Expected Archive::Child::getBuffer() const { diff --git a/lib/Object/ArchiveWriter.cpp b/lib/Object/ArchiveWriter.cpp index 5234b0e1823..13dafb58f47 100644 --- a/lib/Object/ArchiveWriter.cpp +++ b/lib/Object/ArchiveWriter.cpp @@ -545,7 +545,7 @@ Expected computeArchiveRelativePath(StringRef From, StringRef To) { for (auto ToE = sys::path::end(PathTo); ToI != ToE; ++ToI) sys::path::append(Relative, sys::path::Style::posix, *ToI); - return Relative.str(); + return std::string(Relative.str()); } Error writeArchive(StringRef ArcName, ArrayRef NewMembers, diff --git a/lib/Object/COFFImportFile.cpp b/lib/Object/COFFImportFile.cpp index ff4a799be60..69bbf70b43a 100644 --- a/lib/Object/COFFImportFile.cpp +++ b/lib/Object/COFFImportFile.cpp @@ -600,7 +600,7 @@ Error writeImportLibrary(StringRef ImportName, StringRef Path, : getNameType(SymbolName, E.Name, Machine, MinGW); Expected Name = E.ExtName.empty() - ? SymbolName + ? std::string(SymbolName) : replace(SymbolName, E.Name, E.ExtName); if (!Name) diff --git a/lib/Object/COFFModuleDefinition.cpp b/lib/Object/COFFModuleDefinition.cpp index 64d4cf0efda..8f29f7a658f 100644 --- a/lib/Object/COFFModuleDefinition.cpp +++ b/lib/Object/COFFModuleDefinition.cpp @@ -229,14 +229,14 @@ private: Error parseExport() { COFFShortExport E; - E.Name = Tok.Value; + E.Name = std::string(Tok.Value); read(); if (Tok.K == Equal) { read(); if (Tok.K != Identifier) return createError("identifier expected, but got " + Tok.Value); E.ExtName = E.Name; - E.Name = Tok.Value; + E.Name = std::string(Tok.Value); } else { unget(); } @@ -285,7 +285,7 @@ private: } if (Tok.K == EqualEqual) { read(); - E.AliasTarget = Tok.Value; + E.AliasTarget = std::string(Tok.Value); if (Machine == IMAGE_FILE_MACHINE_I386 && !isDecorated(E.AliasTarget, MingwDef)) E.AliasTarget = std::string("_").append(E.AliasTarget); continue; @@ -315,7 +315,7 @@ private: Error parseName(std::string *Out, uint64_t *Baseaddr) { read(); if (Tok.K == Identifier) { - *Out = Tok.Value; + *Out = std::string(Tok.Value); } else { *Out = ""; unget(); diff --git a/lib/Object/IRSymtab.cpp b/lib/Object/IRSymtab.cpp index e4282b9d6bd..a92cb02ed29 100644 --- a/lib/Object/IRSymtab.cpp +++ b/lib/Object/IRSymtab.cpp @@ -181,7 +181,7 @@ Expected Builder::getComdatIndex(const Comdat *C, const Module *M) { llvm::raw_string_ostream OS(Name); Mang.getNameWithPrefix(OS, GV, false); } else { - Name = C->getName(); + Name = std::string(C->getName()); } storage::Comdat Comdat; diff --git a/lib/Object/WasmObjectFile.cpp b/lib/Object/WasmObjectFile.cpp index 813ced1ce21..1a692588e4e 100644 --- a/lib/Object/WasmObjectFile.cpp +++ b/lib/Object/WasmObjectFile.cpp @@ -732,7 +732,7 @@ Error WasmObjectFile::parseTargetFeaturesSection(ReadContext &Ctx) { return make_error("Unknown feature policy prefix", object_error::parse_failed); } - Feature.Name = readString(Ctx); + Feature.Name = std::string(readString(Ctx)); if (!FeaturesSeen.insert(Feature.Name).second) return make_error( "Target features section contains repeated feature \"" + diff --git a/lib/Object/WindowsResource.cpp b/lib/Object/WindowsResource.cpp index 10717718b20..0cf9da43ae2 100644 --- a/lib/Object/WindowsResource.cpp +++ b/lib/Object/WindowsResource.cpp @@ -346,7 +346,7 @@ Error WindowsResourceParser::parse(WindowsResource *WR, ResourceEntryRef Entry = EntryOrErr.get(); uint32_t Origin = InputFilenames.size(); - InputFilenames.push_back(WR->getFileName()); + InputFilenames.push_back(std::string(WR->getFileName())); bool End = false; while (!End) { @@ -368,7 +368,7 @@ Error WindowsResourceParser::parse(ResourceSectionRef &RSR, StringRef Filename, std::vector &Duplicates) { UNWRAP_REF_OR_RETURN(BaseTable, RSR.getBaseTable()); uint32_t Origin = InputFilenames.size(); - InputFilenames.push_back(Filename); + InputFilenames.push_back(std::string(Filename)); std::vector Context; return addChildren(Root, RSR, BaseTable, Origin, Context, Duplicates); } diff --git a/lib/Option/Arg.cpp b/lib/Option/Arg.cpp index ea382b34734..2da32bfacf3 100644 --- a/lib/Option/Arg.cpp +++ b/lib/Option/Arg.cpp @@ -81,7 +81,7 @@ std::string Arg::getAsString(const ArgList &Args) const { OS << *it; } - return OS.str(); + return std::string(OS.str()); } void Arg::renderAsInput(const ArgList &Args, ArgStringList &Output) const { diff --git a/lib/Option/ArgList.cpp b/lib/Option/ArgList.cpp index 09e921502eb..ad7be5fbec1 100644 --- a/lib/Option/ArgList.cpp +++ b/lib/Option/ArgList.cpp @@ -209,7 +209,7 @@ unsigned InputArgList::MakeIndex(StringRef String0) const { unsigned Index = ArgStrings.size(); // Tuck away so we have a reliable const char *. - SynthesizedStrings.push_back(String0); + SynthesizedStrings.push_back(std::string(String0)); ArgStrings.push_back(SynthesizedStrings.back().c_str()); return Index; diff --git a/lib/Option/OptTable.cpp b/lib/Option/OptTable.cpp index 5833d03069f..926eb8e0437 100644 --- a/lib/Option/OptTable.cpp +++ b/lib/Option/OptTable.cpp @@ -219,7 +219,7 @@ OptTable::suggestValueCompletions(StringRef Option, StringRef Arg) const { std::vector Result; for (StringRef Val : Candidates) if (Val.startswith(Arg) && Arg.compare(Val)) - Result.push_back(Val); + Result.push_back(std::string(Val)); return Result; } return {}; @@ -283,10 +283,10 @@ unsigned OptTable::findNearest(StringRef Option, std::string &NearestString, StringRef LHS, RHS; char Last = CandidateName.back(); bool CandidateHasDelimiter = Last == '=' || Last == ':'; - std::string NormalizedName = Option; + std::string NormalizedName = std::string(Option); if (CandidateHasDelimiter) { std::tie(LHS, RHS) = Option.split(Last); - NormalizedName = LHS; + NormalizedName = std::string(LHS); if (Option.find(Last) == LHS.size()) NormalizedName += Last; } diff --git a/lib/Passes/StandardInstrumentations.cpp b/lib/Passes/StandardInstrumentations.cpp index 5cf0ca8e28f..2d3440c1e87 100644 --- a/lib/Passes/StandardInstrumentations.cpp +++ b/lib/Passes/StandardInstrumentations.cpp @@ -98,7 +98,7 @@ void printIR(const Loop *L, StringRef Banner) { const Function *F = L->getHeader()->getParent(); if (!llvm::isFunctionInPrintList(F->getName())) return; - llvm::printLoop(const_cast(*L), dbgs(), Banner); + llvm::printLoop(const_cast(*L), dbgs(), std::string(Banner)); } /// Generic IR-printing helper that unpacks a pointer to IRUnit wrapped into @@ -127,7 +127,7 @@ void unwrapAndPrint(Any IR, StringRef Banner, bool ForceModule = false) { if (any_isa(IR)) { const LazyCallGraph::SCC *C = any_cast(IR); assert(C && "scc should be valid for printing"); - std::string Extra = formatv(" (scc: {0})", C->getName()); + std::string Extra = std::string(formatv(" (scc: {0})", C->getName())); printIR(C, Banner, Extra); return; } diff --git a/lib/ProfileData/GCOV.cpp b/lib/ProfileData/GCOV.cpp index 228c1b3b442..e0f33fbbdb3 100644 --- a/lib/ProfileData/GCOV.cpp +++ b/lib/ProfileData/GCOV.cpp @@ -672,7 +672,7 @@ static std::string mangleCoveragePath(StringRef Filename, bool PreservePaths) { if (S < I) Result.append(S, I); - return Result.str(); + return std::string(Result.str()); } std::string FileInfo::getCoveragePath(StringRef Filename, @@ -681,7 +681,7 @@ std::string FileInfo::getCoveragePath(StringRef Filename, // This is probably a bug in gcov, but when -n is specified, paths aren't // mangled at all, and the -l and -p options are ignored. Here, we do the // same. - return Filename; + return std::string(Filename); std::string CoveragePath; if (Options.LongFileNames && !Filename.equals(MainFilename)) diff --git a/lib/ProfileData/InstrProf.cpp b/lib/ProfileData/InstrProf.cpp index 57d4fbc59f8..1859127b4a2 100644 --- a/lib/ProfileData/InstrProf.cpp +++ b/lib/ProfileData/InstrProf.cpp @@ -286,7 +286,7 @@ StringRef getFuncNameWithoutPrefix(StringRef PGOFuncName, StringRef FileName) { // symbol is created to hold the name. Return the legalized symbol name. std::string getPGOFuncNameVarName(StringRef FuncName, GlobalValue::LinkageTypes Linkage) { - std::string VarName = getInstrProfNameVarPrefix(); + std::string VarName = std::string(getInstrProfNameVarPrefix()); VarName += FuncName; if (!GlobalValue::isLocalLinkage(Linkage)) @@ -427,7 +427,7 @@ Error collectPGOFuncNameStrings(ArrayRef NameVars, std::string &Result, bool doCompression) { std::vector NameStrs; for (auto *NameVar : NameVars) { - NameStrs.push_back(getPGOFuncNameVarInitializer(NameVar)); + NameStrs.push_back(std::string(getPGOFuncNameVarInitializer(NameVar))); } return collectPGOFuncNameStrings( NameStrs, zlib::isAvailable() && doCompression, Result); diff --git a/lib/ProfileData/SampleProfReader.cpp b/lib/ProfileData/SampleProfReader.cpp index 001aafce7bf..6f74cec07b9 100644 --- a/lib/ProfileData/SampleProfReader.cpp +++ b/lib/ProfileData/SampleProfReader.cpp @@ -245,7 +245,7 @@ std::error_code SampleProfileReaderText::readImpl() { InlineStack.pop_back(); } FunctionSamples &FSamples = InlineStack.back()->functionSamplesAt( - LineLocation(LineOffset, Discriminator))[FName]; + LineLocation(LineOffset, Discriminator))[std::string(FName)]; FSamples.setName(FName); MergeResult(Result, FSamples.addTotalSamples(NumSamples)); InlineStack.push_back(&FSamples); @@ -430,7 +430,7 @@ SampleProfileReaderBinary::readProfile(FunctionSamples &FProfile) { return EC; FunctionSamples &CalleeProfile = FProfile.functionSamplesAt( - LineLocation(*LineOffset, *Discriminator))[*FName]; + LineLocation(*LineOffset, *Discriminator))[std::string(*FName)]; CalleeProfile.setName(*FName); if (std::error_code EC = readProfile(CalleeProfile)) return EC; @@ -1043,7 +1043,7 @@ std::error_code SampleProfileReaderGCC::readNameTable() { StringRef Str; if (!GcovBuffer.readString(Str)) return sampleprof_error::truncated; - Names.push_back(Str); + Names.push_back(std::string(Str)); } return sampleprof_error::success; @@ -1107,7 +1107,7 @@ std::error_code SampleProfileReaderGCC::readOneFunctionProfile( uint32_t LineOffset = Offset >> 16; uint32_t Discriminator = Offset & 0xffff; FProfile = &CallerProfile->functionSamplesAt( - LineLocation(LineOffset, Discriminator))[Name]; + LineLocation(LineOffset, Discriminator))[std::string(Name)]; } FProfile->setName(Name); diff --git a/lib/Remarks/BitstreamRemarkParser.cpp b/lib/Remarks/BitstreamRemarkParser.cpp index 4c450887911..25fbea7d31c 100644 --- a/lib/Remarks/BitstreamRemarkParser.cpp +++ b/lib/Remarks/BitstreamRemarkParser.cpp @@ -323,7 +323,7 @@ remarks::createBitstreamParserFromMeta( : std::make_unique(Buf); if (ExternalFilePrependPath) - Parser->ExternalFilePrependPath = *ExternalFilePrependPath; + Parser->ExternalFilePrependPath = std::string(*ExternalFilePrependPath); return std::move(Parser); } diff --git a/lib/Remarks/RemarkLinker.cpp b/lib/Remarks/RemarkLinker.cpp index 617ce770af6..dd1bba3d176 100644 --- a/lib/Remarks/RemarkLinker.cpp +++ b/lib/Remarks/RemarkLinker.cpp @@ -57,7 +57,7 @@ Remark &RemarkLinker::keep(std::unique_ptr Remark) { } void RemarkLinker::setExternalFilePrependPath(StringRef PrependPathIn) { - PrependPath = PrependPathIn; + PrependPath = std::string(PrependPathIn); } // Discard remarks with no source location. diff --git a/lib/Remarks/YAMLRemarkParser.h b/lib/Remarks/YAMLRemarkParser.h index 03707433bc0..df3b908f477 100644 --- a/lib/Remarks/YAMLRemarkParser.h +++ b/lib/Remarks/YAMLRemarkParser.h @@ -35,7 +35,7 @@ public: YAMLParseError(StringRef Message, SourceMgr &SM, yaml::Stream &Stream, yaml::Node &Node); - YAMLParseError(StringRef Message) : Message(Message) {} + YAMLParseError(StringRef Message) : Message(std::string(Message)) {} void log(raw_ostream &OS) const override { OS << Message; } std::error_code convertToErrorCode() const override { diff --git a/lib/Support/APInt.cpp b/lib/Support/APInt.cpp index 9b9cd70078b..c07fc6d2279 100644 --- a/lib/Support/APInt.cpp +++ b/lib/Support/APInt.cpp @@ -2283,7 +2283,7 @@ void APInt::toString(SmallVectorImpl &Str, unsigned Radix, std::string APInt::toString(unsigned Radix = 10, bool Signed = true) const { SmallString<40> S; toString(S, Radix, Signed, /* formatAsCLiteral = */false); - return S.str(); + return std::string(S.str()); } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index cb73380ba38..f78c4bfbb31 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -606,7 +606,7 @@ static Option *LookupNearestOption(StringRef Arg, Best = O; BestDistance = Distance; if (RHS.empty() || !PermitValue) - NearestString = Name; + NearestString = std::string(Name); else NearestString = (Twine(Name) + "=" + RHS).str(); } @@ -1324,7 +1324,7 @@ bool CommandLineParser::ParseCommandLineOptions(int argc, argc = static_cast(newArgv.size()); // Copy the program name into ProgName, making sure not to overflow it. - ProgramName = sys::path::filename(StringRef(argv[0])); + ProgramName = std::string(sys::path::filename(StringRef(argv[0]))); ProgramOverview = Overview; bool IgnoreErrors = Errs; @@ -2482,7 +2482,7 @@ public: OS << " with assertions"; #endif #if LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO - std::string CPU = sys::getHostCPUName(); + std::string CPU = std::string(sys::getHostCPUName()); if (CPU == "generic") CPU = "(unknown)"; OS << ".\n" diff --git a/lib/Support/Debug.cpp b/lib/Support/Debug.cpp index 737cd576ed8..73b25d55237 100644 --- a/lib/Support/Debug.cpp +++ b/lib/Support/Debug.cpp @@ -105,7 +105,7 @@ struct DebugOnlyOpt { SmallVector dbgTypes; StringRef(Val).split(dbgTypes, ',', -1, false); for (auto dbgType : dbgTypes) - CurrentDebugType->push_back(dbgType); + CurrentDebugType->push_back(std::string(dbgType)); } }; diff --git a/lib/Support/DebugCounter.cpp b/lib/Support/DebugCounter.cpp index 1e3ec300964..713b4196981 100644 --- a/lib/Support/DebugCounter.cpp +++ b/lib/Support/DebugCounter.cpp @@ -85,7 +85,7 @@ void DebugCounter::push_back(const std::string &Val) { // add it to the counter values. if (CounterPair.first.endswith("-skip")) { auto CounterName = CounterPair.first.drop_back(5); - unsigned CounterID = getCounterId(CounterName); + unsigned CounterID = getCounterId(std::string(CounterName)); if (!CounterID) { errs() << "DebugCounter Error: " << CounterName << " is not a registered counter\n"; @@ -98,7 +98,7 @@ void DebugCounter::push_back(const std::string &Val) { Counter.IsSet = true; } else if (CounterPair.first.endswith("-count")) { auto CounterName = CounterPair.first.drop_back(6); - unsigned CounterID = getCounterId(CounterName); + unsigned CounterID = getCounterId(std::string(CounterName)); if (!CounterID) { errs() << "DebugCounter Error: " << CounterName << " is not a registered counter\n"; @@ -123,7 +123,7 @@ void DebugCounter::print(raw_ostream &OS) const { auto &Us = instance(); OS << "Counters and values:\n"; for (auto &CounterName : CounterNames) { - unsigned CounterID = getCounterId(CounterName); + unsigned CounterID = getCounterId(std::string(CounterName)); OS << left_justify(RegisteredCounters[CounterID], 32) << ": {" << Us.Counters[CounterID].Count << "," << Us.Counters[CounterID].Skip << "," << Us.Counters[CounterID].StopAfter << "}\n"; diff --git a/lib/Support/FileCheck.cpp b/lib/Support/FileCheck.cpp index d6351e82763..23e1ece2113 100644 --- a/lib/Support/FileCheck.cpp +++ b/lib/Support/FileCheck.cpp @@ -1069,7 +1069,7 @@ std::string Check::FileCheckType::getDescription(StringRef Prefix) const { case Check::CheckPlain: if (Count > 1) return Prefix.str() + "-COUNT"; - return Prefix; + return std::string(Prefix); case Check::CheckNext: return Prefix.str() + "-NEXT"; case Check::CheckSame: @@ -1901,7 +1901,7 @@ Error FileCheckPatternContext::defineCmdlineVariables( // format as in the input file to be able to reuse // parseNumericSubstitutionBlock. CmdlineDefsDiag += (DefPrefix + CmdlineDef + " (parsed as: [[").str(); - std::string SubstitutionStr = CmdlineDef; + std::string SubstitutionStr = std::string(CmdlineDef); SubstitutionStr[EqIdx] = ':'; CmdlineDefsIndices.push_back( std::make_pair(CmdlineDefsDiag.size(), SubstitutionStr.size())); diff --git a/lib/Support/FileCollector.cpp b/lib/Support/FileCollector.cpp index 47fca641372..3a8bc99327b 100644 --- a/lib/Support/FileCollector.cpp +++ b/lib/Support/FileCollector.cpp @@ -51,7 +51,7 @@ bool FileCollector::getRealPath(StringRef SrcPath, auto EC = sys::fs::real_path(Directory, RealPath); if (EC) return false; - SymlinkMap[Directory] = RealPath.str(); + SymlinkMap[Directory] = std::string(RealPath.str()); } else { RealPath = DirWithSymlink->second; } diff --git a/lib/Support/GraphWriter.cpp b/lib/Support/GraphWriter.cpp index c689a81925d..214a9032af7 100644 --- a/lib/Support/GraphWriter.cpp +++ b/lib/Support/GraphWriter.cpp @@ -86,7 +86,7 @@ std::string llvm::createGraphFilename(const Twine &Name, int &FD) { } errs() << "Writing '" << Filename << "'... "; - return Filename.str(); + return std::string(Filename.str()); } // Execute the graph viewer. Return true if there were errors. @@ -147,7 +147,7 @@ static const char *getProgramName(GraphProgram::Name program) { bool llvm::DisplayGraph(StringRef FilenameRef, bool wait, GraphProgram::Name program) { - std::string Filename = FilenameRef; + std::string Filename = std::string(FilenameRef); std::string ErrMsg; std::string ViewerPath; GraphSession S; diff --git a/lib/Support/LockFileManager.cpp b/lib/Support/LockFileManager.cpp index 5c6508c3b00..a4793aa7c04 100644 --- a/lib/Support/LockFileManager.cpp +++ b/lib/Support/LockFileManager.cpp @@ -158,7 +158,7 @@ LockFileManager::LockFileManager(StringRef FileName) this->FileName = FileName; if (std::error_code EC = sys::fs::make_absolute(this->FileName)) { std::string S("failed to obtain absolute path for "); - S.append(this->FileName.str()); + S.append(std::string(this->FileName.str())); setError(EC, S); return; } @@ -177,7 +177,7 @@ LockFileManager::LockFileManager(StringRef FileName) if (std::error_code EC = sys::fs::createUniqueFile( UniqueLockFileName, UniqueLockFileID, UniqueLockFileName)) { std::string S("failed to create unique file "); - S.append(UniqueLockFileName.str()); + S.append(std::string(UniqueLockFileName.str())); setError(EC, S); return; } @@ -203,7 +203,7 @@ LockFileManager::LockFileManager(StringRef FileName) // We failed to write out PID, so report the error, remove the // unique lock file, and fail. std::string S("failed to write to "); - S.append(UniqueLockFileName.str()); + S.append(std::string(UniqueLockFileName.str())); setError(Out.error(), S); sys::fs::remove(UniqueLockFileName); return; @@ -249,7 +249,7 @@ LockFileManager::LockFileManager(StringRef FileName) // ownership. if ((EC = sys::fs::remove(LockFileName))) { std::string S("failed to remove lockfile "); - S.append(UniqueLockFileName.str()); + S.append(std::string(UniqueLockFileName.str())); setError(EC, S); return; } diff --git a/lib/Support/Path.cpp b/lib/Support/Path.cpp index 3c9a08cb407..fa3bf47569e 100644 --- a/lib/Support/Path.cpp +++ b/lib/Support/Path.cpp @@ -578,7 +578,7 @@ void native(SmallVectorImpl &Path, Style style) { std::string convert_to_slash(StringRef path, Style style) { if (real_style(style) != Style::windows) - return path; + return std::string(path); std::string s = path.str(); std::replace(s.begin(), s.end(), '\\', '/'); @@ -1114,7 +1114,7 @@ void directory_entry::replace_filename(const Twine &Filename, file_type Type, basic_file_status Status) { SmallString<128> PathStr = path::parent_path(Path); path::append(PathStr, Filename); - this->Path = PathStr.str(); + this->Path = std::string(PathStr.str()); this->Type = Type; this->Status = Status; } @@ -1142,7 +1142,8 @@ ErrorOr getPermissions(const Twine &Path) { namespace llvm { namespace sys { namespace fs { -TempFile::TempFile(StringRef Name, int FD) : TmpName(Name), FD(FD) {} +TempFile::TempFile(StringRef Name, int FD) + : TmpName(std::string(Name)), FD(FD) {} TempFile::TempFile(TempFile &&Other) { *this = std::move(Other); } TempFile &TempFile::operator=(TempFile &&Other) { TmpName = std::move(Other.TmpName); diff --git a/lib/Support/Process.cpp b/lib/Support/Process.cpp index 5b647100815..0b2d41bcdec 100644 --- a/lib/Support/Process.cpp +++ b/lib/Support/Process.cpp @@ -55,7 +55,7 @@ Optional Process::FindInEnvPath(StringRef EnvName, SmallString<128> FilePath(Dir); path::append(FilePath, FileName); if (fs::exists(Twine(FilePath))) { - FoundPath = FilePath.str(); + FoundPath = std::string(FilePath.str()); break; } } diff --git a/lib/Support/Regex.cpp b/lib/Support/Regex.cpp index 8da345d4f14..615e48a5df7 100644 --- a/lib/Support/Regex.cpp +++ b/lib/Support/Regex.cpp @@ -135,7 +135,7 @@ std::string Regex::sub(StringRef Repl, StringRef String, // Return the input if there was no match. if (!match(String, &Matches, Error)) - return String; + return std::string(String); // Otherwise splice in the replacement string, starting with the prefix before // the match. diff --git a/lib/Support/Signals.cpp b/lib/Support/Signals.cpp index add6fde0eb5..2cfdf2d42a4 100644 --- a/lib/Support/Signals.cpp +++ b/lib/Support/Signals.cpp @@ -131,7 +131,7 @@ static bool printSymbolizedStackTrace(StringRef Argv0, void **StackTrace, // If we don't know argv0 or the address of main() at this point, try // to guess it anyway (it's possible on some platforms). std::string MainExecutableName = - sys::fs::exists(Argv0) ? (std::string)Argv0 + sys::fs::exists(Argv0) ? (std::string)std::string(Argv0) : sys::fs::getMainExecutable(nullptr, nullptr); BumpPtrAllocator Allocator; StringSaver StrPool(Allocator); diff --git a/lib/Support/SourceMgr.cpp b/lib/Support/SourceMgr.cpp index 2a241f18c36..acb7101ba02 100644 --- a/lib/Support/SourceMgr.cpp +++ b/lib/Support/SourceMgr.cpp @@ -256,14 +256,14 @@ void SourceMgr::PrintMessage(SMLoc Loc, SourceMgr::DiagKind Kind, // SMDiagnostic Implementation //===----------------------------------------------------------------------===// -SMDiagnostic::SMDiagnostic(const SourceMgr &sm, SMLoc L, StringRef FN, - int Line, int Col, SourceMgr::DiagKind Kind, - StringRef Msg, StringRef LineStr, - ArrayRef> Ranges, +SMDiagnostic::SMDiagnostic(const SourceMgr &sm, SMLoc L, StringRef FN, int Line, + int Col, SourceMgr::DiagKind Kind, StringRef Msg, + StringRef LineStr, + ArrayRef> Ranges, ArrayRef Hints) - : SM(&sm), Loc(L), Filename(FN), LineNo(Line), ColumnNo(Col), Kind(Kind), - Message(Msg), LineContents(LineStr), Ranges(Ranges.vec()), - FixIts(Hints.begin(), Hints.end()) { + : SM(&sm), Loc(L), Filename(std::string(FN)), LineNo(Line), ColumnNo(Col), + Kind(Kind), Message(std::string(Msg)), LineContents(std::string(LineStr)), + Ranges(Ranges.vec()), FixIts(Hints.begin(), Hints.end()) { llvm::sort(FixIts); } diff --git a/lib/Support/SpecialCaseList.cpp b/lib/Support/SpecialCaseList.cpp index d1ff44cefb0..e465451924a 100644 --- a/lib/Support/SpecialCaseList.cpp +++ b/lib/Support/SpecialCaseList.cpp @@ -172,14 +172,14 @@ bool SpecialCaseList::parse(const MemoryBuffer *MB, } std::pair SplitRegexp = SplitLine.second.split("="); - std::string Regexp = SplitRegexp.first; + std::string Regexp = std::string(SplitRegexp.first); StringRef Category = SplitRegexp.second; // Create this section if it has not been seen before. if (SectionsMap.find(Section) == SectionsMap.end()) { std::unique_ptr M = std::make_unique(); std::string REError; - if (!M->insert(Section, LineNo, REError)) { + if (!M->insert(std::string(Section), LineNo, REError)) { Error = (Twine("malformed section ") + Section + ": '" + REError).str(); return false; } diff --git a/lib/Support/TarWriter.cpp b/lib/Support/TarWriter.cpp index 6136e921976..6c62f8861af 100644 --- a/lib/Support/TarWriter.cpp +++ b/lib/Support/TarWriter.cpp @@ -167,7 +167,8 @@ Expected> TarWriter::create(StringRef OutputPath, } TarWriter::TarWriter(int FD, StringRef BaseDir) - : OS(FD, /*shouldClose=*/true, /*unbuffered=*/false), BaseDir(BaseDir) {} + : OS(FD, /*shouldClose=*/true, /*unbuffered=*/false), + BaseDir(std::string(BaseDir)) {} // Append a given file to an archive. void TarWriter::append(StringRef Path, StringRef Data) { diff --git a/lib/Support/TimeProfiler.cpp b/lib/Support/TimeProfiler.cpp index 24da35ceafb..4e48477f19a 100644 --- a/lib/Support/TimeProfiler.cpp +++ b/lib/Support/TimeProfiler.cpp @@ -166,7 +166,7 @@ struct TimeTraceProfiler { // Combine all CountAndTotalPerName from threads into one. StringMap AllCountAndTotalPerName; auto combineStat = [&](const auto &Stat) { - std::string Key = Stat.getKey(); + StringRef Key = Stat.getKey(); auto Value = Stat.getValue(); auto &CountAndTotal = AllCountAndTotalPerName[Key]; CountAndTotal.first += Value.first; @@ -275,13 +275,14 @@ void timeTraceProfilerWrite(raw_pwrite_stream &OS) { void timeTraceProfilerBegin(StringRef Name, StringRef Detail) { if (TimeTraceProfilerInstance != nullptr) - TimeTraceProfilerInstance->begin(Name, [&]() { return Detail; }); + TimeTraceProfilerInstance->begin(std::string(Name), + [&]() { return std::string(Detail); }); } void timeTraceProfilerBegin(StringRef Name, llvm::function_ref Detail) { if (TimeTraceProfilerInstance != nullptr) - TimeTraceProfilerInstance->begin(Name, Detail); + TimeTraceProfilerInstance->begin(std::string(Name), Detail); } void timeTraceProfilerEnd() { diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp index 613d2eaae6d..dcb96d18c47 100644 --- a/lib/Support/Timer.cpp +++ b/lib/Support/Timer.cpp @@ -247,7 +247,8 @@ TimerGroup::TimerGroup(StringRef Name, StringRef Description, : TimerGroup(Name, Description) { TimersToPrint.reserve(Records.size()); for (const auto &P : Records) - TimersToPrint.emplace_back(P.getValue(), P.getKey(), P.getKey()); + TimersToPrint.emplace_back(P.getValue(), std::string(P.getKey()), + std::string(P.getKey())); assert(TimersToPrint.size() == Records.size() && "Size mismatch"); } diff --git a/lib/Support/ToolOutputFile.cpp b/lib/Support/ToolOutputFile.cpp index ed3a247f011..1051af3eb45 100644 --- a/lib/Support/ToolOutputFile.cpp +++ b/lib/Support/ToolOutputFile.cpp @@ -16,7 +16,7 @@ using namespace llvm; ToolOutputFile::CleanupInstaller::CleanupInstaller(StringRef Filename) - : Filename(Filename), Keep(false) { + : Filename(std::string(Filename)), Keep(false) { // Arrange for the file to be deleted if the process is killed. if (Filename != "-") sys::RemoveFileOnSignal(Filename); diff --git a/lib/Support/Unix/Host.inc b/lib/Support/Unix/Host.inc index 17d78dc18be..dfcfdd0dee6 100644 --- a/lib/Support/Unix/Host.inc +++ b/lib/Support/Unix/Host.inc @@ -56,7 +56,7 @@ static std::string updateTripleOSVersion(std::string TargetTripleString) { if (TT.getOS() == Triple::AIX && !TT.getOSMajorVersion()) { struct utsname name; if (uname(&name) != -1) { - std::string NewOSName = Triple::getOSTypeName(Triple::AIX); + std::string NewOSName = std::string(Triple::getOSTypeName(Triple::AIX)); NewOSName += name.version; NewOSName += '.'; NewOSName += name.release; diff --git a/lib/Support/Unix/Program.inc b/lib/Support/Unix/Program.inc index 520685a0e98..c1b5d0c9a33 100644 --- a/lib/Support/Unix/Program.inc +++ b/lib/Support/Unix/Program.inc @@ -70,8 +70,7 @@ ErrorOr sys::findProgramByName(StringRef Name, assert(!Name.empty() && "Must have a name!"); // Use the given path verbatim if it contains any slashes; this matches // the behavior of sh(1) and friends. - if (Name.find('/') != StringRef::npos) - return std::string(Name); + if (Name.find('/') != StringRef::npos) return std::string(Name); SmallVector EnvironmentPaths; if (Paths.empty()) @@ -88,7 +87,7 @@ ErrorOr sys::findProgramByName(StringRef Name, SmallString<128> FilePath(Path); sys::path::append(FilePath, Name); if (sys::fs::can_execute(FilePath.c_str())) - return std::string(FilePath.str()); // Found the executable! + return std::string(FilePath.str()); // Found the executable! } return errc::no_such_file_or_directory; } @@ -101,7 +100,7 @@ static bool RedirectIO(Optional Path, int FD, std::string* ErrMsg) { // Redirect empty paths to /dev/null File = "/dev/null"; else - File = *Path; + File = std::string(*Path); // Open the file int InFD = open(File.c_str(), FD == 0 ? O_RDONLY : O_WRONLY|O_CREAT, 0666); @@ -213,7 +212,7 @@ static bool Execute(ProcessInfo &PI, StringRef Program, std::string *RedirectsStr[3] = {nullptr, nullptr, nullptr}; for (int I = 0; I < 3; ++I) { if (Redirects[I]) { - RedirectsStorage[I] = *Redirects[I]; + RedirectsStorage[I] = std::string(*Redirects[I]); RedirectsStr[I] = &RedirectsStorage[I]; } } @@ -304,7 +303,7 @@ static bool Execute(ProcessInfo &PI, StringRef Program, } // Execute! - std::string PathStr = Program; + std::string PathStr = std::string(Program); if (Envp != nullptr) execve(PathStr.c_str(), const_cast(Argv), const_cast(Envp)); diff --git a/lib/Support/VirtualFileSystem.cpp b/lib/Support/VirtualFileSystem.cpp index edd4234fe50..321ce144b67 100644 --- a/lib/Support/VirtualFileSystem.cpp +++ b/lib/Support/VirtualFileSystem.cpp @@ -306,12 +306,12 @@ RealFileSystem::openFileForRead(const Twine &Name) { llvm::ErrorOr RealFileSystem::getCurrentWorkingDirectory() const { if (WD) - return WD->Specified.str(); + return std::string(WD->Specified.str()); SmallString<128> Dir; if (std::error_code EC = llvm::sys::fs::current_path(Dir)) return EC; - return Dir.str(); + return std::string(Dir.str()); } std::error_code RealFileSystem::setCurrentWorkingDirectory(const Twine &Path) { @@ -535,7 +535,8 @@ class InMemoryNode { public: InMemoryNode(llvm::StringRef FileName, InMemoryNodeKind Kind) - : Kind(Kind), FileName(llvm::sys::path::filename(FileName)) {} + : Kind(Kind), FileName(std::string(llvm::sys::path::filename(FileName))) { + } virtual ~InMemoryNode() = default; /// Get the filename of this node (the name without the directory part). @@ -904,7 +905,7 @@ class InMemoryDirIterator : public llvm::vfs::detail::DirIterImpl { Type = sys::fs::file_type::directory_file; break; } - CurrentEntry = directory_entry(Path.str(), Type); + CurrentEntry = directory_entry(std::string(Path.str()), Type); } else { // When we're at the end, make CurrentEntry invalid and DirIterImpl will // do the rest. @@ -960,7 +961,7 @@ std::error_code InMemoryFileSystem::setCurrentWorkingDirectory(const Twine &P) { llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true); if (!Path.empty()) - WorkingDirectory = Path.str(); + WorkingDirectory = std::string(Path.str()); return {}; } @@ -1064,7 +1065,7 @@ RedirectingFileSystem::setCurrentWorkingDirectory(const Twine &Path) { Path.toVector(AbsolutePath); if (std::error_code EC = makeAbsolute(AbsolutePath)) return EC; - WorkingDirectory = AbsolutePath.str(); + WorkingDirectory = std::string(AbsolutePath.str()); return {}; } @@ -1347,9 +1348,9 @@ class llvm::vfs::RedirectingFileSystemParser { // are properly canonicalized before read into the VFS. Path = sys::path::remove_leading_dotslash(Path); sys::path::remove_dots(Path, /*remove_dot_dot=*/true); - Name = Path.str(); + Name = std::string(Path.str()); } else { - Name = Value; + Name = std::string(Value); } } else if (Key == "type") { if (!parseScalarString(I.getValue(), Value, Buffer)) @@ -1409,7 +1410,7 @@ class llvm::vfs::RedirectingFileSystemParser { FullPath = sys::path::remove_leading_dotslash(FullPath); sys::path::remove_dots(FullPath, /*remove_dot_dot=*/true); } - ExternalContentsPath = FullPath.str(); + ExternalContentsPath = std::string(FullPath.str()); } else if (Key == "use-external-name") { bool Val; if (!parseScalarBool(I.getValue(), Val)) @@ -2104,7 +2105,7 @@ std::error_code VFSFromYamlDirIterImpl::incrementContent(bool IsFirstTime) { Type = sys::fs::file_type::regular_file; break; } - CurrentEntry = directory_entry(PathStr.str(), Type); + CurrentEntry = directory_entry(std::string(PathStr.str()), Type); return {}; } return incrementExternal(); diff --git a/lib/Support/YAMLParser.cpp b/lib/Support/YAMLParser.cpp index d17e7b227f4..db1eb66ca26 100644 --- a/lib/Support/YAMLParser.cpp +++ b/lib/Support/YAMLParser.cpp @@ -1819,11 +1819,11 @@ std::string Node::getVerbatimTag() const { if (!Raw.empty() && Raw != "!") { std::string Ret; if (Raw.find_last_of('!') == 0) { - Ret = Doc->getTagMap().find("!")->second; + Ret = std::string(Doc->getTagMap().find("!")->second); Ret += Raw.substr(1); return Ret; } else if (Raw.startswith("!!")) { - Ret = Doc->getTagMap().find("!!")->second; + Ret = std::string(Doc->getTagMap().find("!!")->second); Ret += Raw.substr(2); return Ret; } else { @@ -1831,7 +1831,7 @@ std::string Node::getVerbatimTag() const { std::map::const_iterator It = Doc->getTagMap().find(TagHandle); if (It != Doc->getTagMap().end()) - Ret = It->second; + Ret = std::string(It->second); else { Token T; T.Kind = Token::TK_Tag; diff --git a/lib/TableGen/Record.cpp b/lib/TableGen/Record.cpp index 9db842dc678..54ff9ae3067 100644 --- a/lib/TableGen/Record.cpp +++ b/lib/TableGen/Record.cpp @@ -1183,21 +1183,22 @@ Init *TernOpInit::Fold(Record *CurRec) const { return DefInit::get(Val); } if (LHSv && MHSv && RHSv) { - std::string Val = RHSv->getName(); + std::string Val = std::string(RHSv->getName()); if (LHSv->getAsString() == RHSv->getAsString()) - Val = MHSv->getName(); + Val = std::string(MHSv->getName()); return VarInit::get(Val, getType()); } if (LHSs && MHSs && RHSs) { - std::string Val = RHSs->getValue(); + std::string Val = std::string(RHSs->getValue()); std::string::size_type found; std::string::size_type idx = 0; while (true) { - found = Val.find(LHSs->getValue(), idx); + found = Val.find(std::string(LHSs->getValue()), idx); if (found == std::string::npos) break; - Val.replace(found, LHSs->getValue().size(), MHSs->getValue()); + Val.replace(found, LHSs->getValue().size(), + std::string(MHSs->getValue())); idx = found + MHSs->getValue().size(); } @@ -1612,9 +1613,7 @@ RecTy *DefInit::getFieldType(StringInit *FieldName) const { return nullptr; } -std::string DefInit::getAsString() const { - return Def->getName(); -} +std::string DefInit::getAsString() const { return std::string(Def->getName()); } static void ProfileVarDefInit(FoldingSetNodeID &ID, Record *Class, diff --git a/lib/TableGen/SetTheory.cpp b/lib/TableGen/SetTheory.cpp index 5a30ee98cce..0389bd3ac83 100644 --- a/lib/TableGen/SetTheory.cpp +++ b/lib/TableGen/SetTheory.cpp @@ -191,7 +191,7 @@ struct SequenceOp : public SetTheory::Operator { std::string Format; if (StringInit *SI = dyn_cast(Expr->arg_begin()[0])) - Format = SI->getValue(); + Format = std::string(SI->getValue()); else PrintFatalError(Loc, "Format must be a string: " + Expr->getAsString()); diff --git a/lib/TableGen/TGParser.cpp b/lib/TableGen/TGParser.cpp index 01cc1af34ab..1b2809a519e 100644 --- a/lib/TableGen/TGParser.cpp +++ b/lib/TableGen/TGParser.cpp @@ -3294,7 +3294,7 @@ bool TGParser::ParseDefm(MultiClass *CurMultiClass) { // To instantiate a multiclass, we need to first get the multiclass, then // instantiate each def contained in the multiclass with the SubClassRef // template parameters. - MultiClass *MC = MultiClasses[Ref.Rec->getName()].get(); + MultiClass *MC = MultiClasses[std::string(Ref.Rec->getName())].get(); assert(MC && "Didn't lookup multiclass correctly?"); ArrayRef TemplateVals = Ref.TemplateArgs; diff --git a/lib/Target/AArch64/AArch64SIMDInstrOpt.cpp b/lib/Target/AArch64/AArch64SIMDInstrOpt.cpp index 28a7e680849..fc31e701d3a 100644 --- a/lib/Target/AArch64/AArch64SIMDInstrOpt.cpp +++ b/lib/Target/AArch64/AArch64SIMDInstrOpt.cpp @@ -219,7 +219,7 @@ shouldReplaceInst(MachineFunction *MF, const MCInstrDesc *InstDesc, SmallVectorImpl &InstDescRepl) { // Check if replacement decision is already available in the cached table. // if so, return it. - std::string Subtarget = SchedModel.getSubtargetInfo()->getCPU(); + std::string Subtarget = std::string(SchedModel.getSubtargetInfo()->getCPU()); auto InstID = std::make_pair(InstDesc->getOpcode(), Subtarget); if (SIMDInstrTable.find(InstID) != SIMDInstrTable.end()) return SIMDInstrTable[InstID]; @@ -288,7 +288,8 @@ bool AArch64SIMDInstrOpt::shouldExitEarly(MachineFunction *MF, Subpass SP) { // For this optimization, check for all concerned instructions. case Interleave: - std::string Subtarget = SchedModel.getSubtargetInfo()->getCPU(); + std::string Subtarget = + std::string(SchedModel.getSubtargetInfo()->getCPU()); if (InterlEarlyExit.find(Subtarget) != InterlEarlyExit.end()) return InterlEarlyExit[Subtarget]; diff --git a/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp b/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp index 511d6294318..4a39d9e4481 100644 --- a/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp +++ b/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp @@ -47,7 +47,7 @@ void MetadataStreamerV2::verify(StringRef HSAMetadataString) const { errs() << "AMDGPU HSA Metadata Parser Test: "; HSAMD::Metadata FromHSAMetadataString; - if (fromString(HSAMetadataString, FromHSAMetadataString)) { + if (fromString(std::string(HSAMetadataString), FromHSAMetadataString)) { errs() << "FAIL\n"; return; } @@ -259,7 +259,8 @@ void MetadataStreamerV2::emitPrintf(const Module &Mod) { for (auto Op : Node->operands()) if (Op->getNumOperands()) - Printf.push_back(cast(Op->getOperand(0))->getString()); + Printf.push_back( + std::string(cast(Op->getOperand(0))->getString())); } void MetadataStreamerV2::emitKernelLanguage(const Function &Func) { @@ -367,8 +368,8 @@ void MetadataStreamerV2::emitKernelArg(const DataLayout &DL, Type *Ty, HSAMetadata.mKernels.back().mArgs.push_back(Kernel::Arg::Metadata()); auto &Arg = HSAMetadata.mKernels.back().mArgs.back(); - Arg.mName = Name; - Arg.mTypeName = TypeName; + Arg.mName = std::string(Name); + Arg.mTypeName = std::string(TypeName); Arg.mSize = DL.getTypeAllocSize(Ty); Arg.mAlign = DL.getABITypeAlignment(Ty); Arg.mValueKind = ValueKind; @@ -479,7 +480,7 @@ void MetadataStreamerV2::emitKernel(const MachineFunction &MF, HSAMetadata.mKernels.push_back(Kernel::Metadata()); auto &Kernel = HSAMetadata.mKernels.back(); - Kernel.mName = Func.getName(); + Kernel.mName = std::string(Func.getName()); Kernel.mSymbolName = (Twine(Func.getName()) + Twine("@kd")).str(); emitKernelLanguage(Func); emitKernelAttrs(Func); diff --git a/lib/Target/AMDGPU/AMDGPULibCalls.cpp b/lib/Target/AMDGPU/AMDGPULibCalls.cpp index 0c56927dea0..98931c72bc6 100644 --- a/lib/Target/AMDGPU/AMDGPULibCalls.cpp +++ b/lib/Target/AMDGPU/AMDGPULibCalls.cpp @@ -585,7 +585,7 @@ bool AMDGPULibCalls::fold_read_write_pipe(CallInst *CI, IRBuilder<> &B, assert(Callee->hasName() && "Invalid read_pipe/write_pipe function"); auto *M = Callee->getParent(); auto &Ctx = M->getContext(); - std::string Name = Callee->getName(); + std::string Name = std::string(Callee->getName()); auto NumArg = CI->getNumArgOperands(); if (NumArg != 4 && NumArg != 6) return false; diff --git a/lib/Target/AMDGPU/AMDGPULibFunc.cpp b/lib/Target/AMDGPU/AMDGPULibFunc.cpp index e1ae496d9cb..1f14eb3a6fa 100644 --- a/lib/Target/AMDGPU/AMDGPULibFunc.cpp +++ b/lib/Target/AMDGPU/AMDGPULibFunc.cpp @@ -863,7 +863,7 @@ std::string AMDGPUMangledLibFunc::mangleNameItanium() const { Param P; while ((P = I.getNextParam()).ArgType != 0) Mangler(S, P); - return S.str(); + return std::string(S.str()); } /////////////////////////////////////////////////////////////////////////////// @@ -936,7 +936,7 @@ std::string AMDGPUMangledLibFunc::getName() const { SmallString<128> Buf; raw_svector_ostream OS(Buf); writeName(OS); - return OS.str(); + return std::string(OS.str()); } Function *AMDGPULibFunc::getFunction(Module *M, const AMDGPULibFunc &fInfo) { diff --git a/lib/Target/AMDGPU/AMDGPULibFunc.h b/lib/Target/AMDGPU/AMDGPULibFunc.h index 2354ed7df20..f43b88f4ed5 100644 --- a/lib/Target/AMDGPU/AMDGPULibFunc.h +++ b/lib/Target/AMDGPU/AMDGPULibFunc.h @@ -341,7 +341,7 @@ public: /// and unmangled function name for unmangled library functions. virtual std::string mangle() const = 0; - void setName(StringRef N) { Name = N; } + void setName(StringRef N) { Name = std::string(N); } void setPrefix(ENamePrefix pfx) { FKind = pfx; } virtual FunctionType *getFunctionType(Module &M) const = 0; @@ -438,7 +438,7 @@ class AMDGPUUnmangledLibFunc : public AMDGPULibFuncImpl { public: explicit AMDGPUUnmangledLibFunc(); explicit AMDGPUUnmangledLibFunc(StringRef FName, FunctionType *FT) { - Name = FName; + Name = std::string(FName); FuncTy = FT; } std::string getName() const override { return Name; } diff --git a/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp b/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp index 7a7addd0f5c..68fa5bafa97 100644 --- a/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp +++ b/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp @@ -273,7 +273,7 @@ AMDGPUPropagateAttributes::cloneWithFeatures(Function &F, // Swap names. If that is the only clone it will retain the name of now // dead value. if (F.hasName()) { - std::string NewName = NewF->getName(); + std::string NewName = std::string(NewF->getName()); NewF->takeName(&F); F.setName(NewName); diff --git a/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp index f3aa1a58236..ea70307df49 100644 --- a/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp +++ b/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp @@ -6499,7 +6499,7 @@ OperandMatchResultTy AMDGPUAsmParser::parseDim(OperandVector &Operands) { std::string Token; if (getLexer().is(AsmToken::Integer)) { SMLoc Loc = getLexer().getTok().getEndLoc(); - Token = getLexer().getTok().getString(); + Token = std::string(getLexer().getTok().getString()); Parser.Lex(); if (getLexer().getTok().getLoc() != Loc) return MatchOperand_ParseFail; diff --git a/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp b/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp index fef665c2900..31a9b4be2d3 100644 --- a/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp +++ b/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp @@ -43,7 +43,7 @@ using namespace llvm::AMDGPU::HSAMD; bool AMDGPUTargetStreamer::EmitHSAMetadataV2(StringRef HSAMetadataString) { HSAMD::Metadata HSAMetadata; - if (HSAMD::fromString(HSAMetadataString, HSAMetadata)) + if (HSAMD::fromString(std::string(HSAMetadataString), HSAMetadata)) return false; return EmitHSAMetadata(HSAMetadata); diff --git a/lib/Target/ARM/ARMAsmPrinter.cpp b/lib/Target/ARM/ARMAsmPrinter.cpp index 6f26ca127f9..14d40188f1d 100644 --- a/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/ARMAsmPrinter.cpp @@ -606,11 +606,12 @@ void ARMAsmPrinter::emitAttributes() { if (!ArchFS.empty()) ArchFS = (Twine(ArchFS) + "," + FS).str(); else - ArchFS = FS; + ArchFS = std::string(FS); } const ARMBaseTargetMachine &ATM = static_cast(TM); - const ARMSubtarget STI(TT, CPU, ArchFS, ATM, ATM.isLittleEndian()); + const ARMSubtarget STI(TT, std::string(CPU), ArchFS, ATM, + ATM.isLittleEndian()); // Emit build attributes for the available hardware. ATS.emitTargetAttributes(STI); diff --git a/lib/Target/ARM/ARMConstantPoolValue.cpp b/lib/Target/ARM/ARMConstantPoolValue.cpp index 72c95f44126..a7706a18156 100644 --- a/lib/Target/ARM/ARMConstantPoolValue.cpp +++ b/lib/Target/ARM/ARMConstantPoolValue.cpp @@ -228,7 +228,7 @@ ARMConstantPoolSymbol::ARMConstantPoolSymbol(LLVMContext &C, StringRef s, bool AddCurrentAddress) : ARMConstantPoolValue(C, id, ARMCP::CPExtSymbol, PCAdj, Modifier, AddCurrentAddress), - S(s) {} + S(std::string(s)) {} ARMConstantPoolSymbol *ARMConstantPoolSymbol::Create(LLVMContext &C, StringRef s, unsigned ID, diff --git a/lib/Target/ARM/ARMISelLowering.cpp b/lib/Target/ARM/ARMISelLowering.cpp index b6e631edbef..24bb764f120 100644 --- a/lib/Target/ARM/ARMISelLowering.cpp +++ b/lib/Target/ARM/ARMISelLowering.cpp @@ -15958,7 +15958,7 @@ bool ARMTargetLowering::ExpandInlineAsm(CallInst *CI) const { switch (AsmPieces.size()) { default: return false; case 1: - AsmStr = AsmPieces[0]; + AsmStr = std::string(AsmPieces[0]); AsmPieces.clear(); SplitString(AsmStr, AsmPieces, " \t,"); diff --git a/lib/Target/ARM/ARMSubtarget.cpp b/lib/Target/ARM/ARMSubtarget.cpp index eb4d39b01cb..e87b248123f 100644 --- a/lib/Target/ARM/ARMSubtarget.cpp +++ b/lib/Target/ARM/ARMSubtarget.cpp @@ -183,7 +183,7 @@ void ARMSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) { if (!ArchFS.empty()) ArchFS = (Twine(ArchFS) + "," + FS).str(); else - ArchFS = FS; + ArchFS = std::string(FS); } ParseSubtargetFeatures(CPUString, ArchFS); diff --git a/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp b/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp index f558ca8d2d9..276ff26cd86 100644 --- a/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp +++ b/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp @@ -328,12 +328,8 @@ private: } // Create new attribute item - AttributeItem Item = { - AttributeItem::NumericAttribute, - Attribute, - Value, - StringRef("") - }; + AttributeItem Item = {AttributeItem::NumericAttribute, Attribute, Value, + std::string(StringRef(""))}; Contents.push_back(Item); } @@ -344,17 +340,13 @@ private: if (!OverwriteExisting) return; Item->Type = AttributeItem::TextAttribute; - Item->StringValue = Value; + Item->StringValue = std::string(Value); return; } // Create new attribute item - AttributeItem Item = { - AttributeItem::TextAttribute, - Attribute, - 0, - Value - }; + AttributeItem Item = {AttributeItem::TextAttribute, Attribute, 0, + std::string(Value)}; Contents.push_back(Item); } @@ -366,17 +358,13 @@ private: return; Item->Type = AttributeItem::NumericAndTextAttributes; Item->IntValue = IntValue; - Item->StringValue = StringValue; + Item->StringValue = std::string(StringValue); return; } // Create new attribute item - AttributeItem Item = { - AttributeItem::NumericAndTextAttributes, - Attribute, - IntValue, - StringValue - }; + AttributeItem Item = {AttributeItem::NumericAndTextAttributes, Attribute, + IntValue, std::string(StringValue)}; Contents.push_back(Item); } diff --git a/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp b/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp index 9f60e70e0e0..1540796cd43 100644 --- a/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp +++ b/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp @@ -168,7 +168,7 @@ MCSubtargetInfo *ARM_MC::createARMMCSubtargetInfo(const Triple &TT, if (!ArchFS.empty()) ArchFS = (Twine(ArchFS) + "," + FS).str(); else - ArchFS = FS; + ArchFS = std::string(FS); } return createARMMCSubtargetInfoImpl(TT, CPU, ArchFS); diff --git a/lib/Target/BPF/BPFAbstractMemberAccess.cpp b/lib/Target/BPF/BPFAbstractMemberAccess.cpp index a28816cc87b..4379d49008a 100644 --- a/lib/Target/BPF/BPFAbstractMemberAccess.cpp +++ b/lib/Target/BPF/BPFAbstractMemberAccess.cpp @@ -731,7 +731,7 @@ Value *BPFAbstractMemberAccess::computeBaseAndAccessKey(CallInst *Call, if (CInfo.Kind == BPFPreserveUnionAI || CInfo.Kind == BPFPreserveStructAI) { // struct or union type - TypeName = Ty->getName(); + TypeName = std::string(Ty->getName()); TypeMeta = Ty; PatchImm += FirstIndex * (Ty->getSizeInBits() >> 3); break; @@ -782,7 +782,7 @@ Value *BPFAbstractMemberAccess::computeBaseAndAccessKey(CallInst *Call, unsigned CTag = CTy->getTag(); if (CTag == dwarf::DW_TAG_structure_type || CTag == dwarf::DW_TAG_union_type) { - TypeName = CTy->getName(); + TypeName = std::string(CTy->getName()); } else { if (HasPreserveFieldInfoCall(CallStack)) report_fatal_error("Invalid field access for llvm.preserve.field.info intrinsic"); diff --git a/lib/Target/BPF/BPFTargetMachine.cpp b/lib/Target/BPF/BPFTargetMachine.cpp index 40375bc88bf..d2a332c78aa 100644 --- a/lib/Target/BPF/BPFTargetMachine.cpp +++ b/lib/Target/BPF/BPFTargetMachine.cpp @@ -63,7 +63,7 @@ BPFTargetMachine::BPFTargetMachine(const Target &T, const Triple &TT, getEffectiveRelocModel(RM), getEffectiveCodeModel(CM, CodeModel::Small), OL), TLOF(std::make_unique()), - Subtarget(TT, CPU, FS, *this) { + Subtarget(TT, std::string(CPU), std::string(FS), *this) { initAsmInfo(); BPFMCAsmInfo *MAI = diff --git a/lib/Target/BPF/BTFDebug.cpp b/lib/Target/BPF/BTFDebug.cpp index a9fb04f20d1..e868ccad4b1 100644 --- a/lib/Target/BPF/BTFDebug.cpp +++ b/lib/Target/BPF/BTFDebug.cpp @@ -259,7 +259,7 @@ void BTFTypeStruct::emitType(MCStreamer &OS) { } } -std::string BTFTypeStruct::getName() { return STy->getName(); } +std::string BTFTypeStruct::getName() { return std::string(STy->getName()); } /// The Func kind represents both subprogram and pointee of function /// pointers. If the FuncName is empty, it represents a pointee of function @@ -374,7 +374,7 @@ uint32_t BTFStringTable::addString(StringRef S) { // Not find, add to the string table. uint32_t Offset = Size; OffsetToIdMap[Offset] = Table.size(); - Table.push_back(S); + Table.push_back(std::string(S)); Size += S.size() + 1; return Offset; } @@ -667,7 +667,7 @@ std::string BTFDebug::populateFileContent(const DISubprogram *SP) { if (!File->getFilename().startswith("/") && File->getDirectory().size()) FileName = File->getDirectory().str() + "/" + File->getFilename().str(); else - FileName = File->getFilename(); + FileName = std::string(File->getFilename()); // No need to populate the contends if it has been populated! if (FileContent.find(FileName) != FileContent.end()) @@ -686,7 +686,7 @@ std::string BTFDebug::populateFileContent(const DISubprogram *SP) { Buf = std::move(*BufOrErr); if (Buf) for (line_iterator I(*Buf, false), E; I != E; ++I) - Content.push_back(*I); + Content.push_back(std::string(*I)); FileContent[FileName] = Content; return FileName; @@ -955,8 +955,8 @@ void BTFDebug::generateFieldReloc(const MCSymbol *ORSym, DIType *RootTy, FieldReloc.Label = ORSym; FieldReloc.OffsetNameOff = addString(IndexPattern); FieldReloc.TypeID = RootId; - FieldReloc.RelocKind = std::stoull(RelocKindStr); - PatchImms[AccessPattern.str()] = std::stoul(PatchImmStr); + FieldReloc.RelocKind = std::stoull(std::string(RelocKindStr)); + PatchImms[AccessPattern.str()] = std::stoul(std::string(PatchImmStr)); FieldRelocTable[SecNameOff].push_back(FieldReloc); } @@ -1119,15 +1119,17 @@ void BTFDebug::processGlobals(bool ProcessingMapDef) { assert(!SecName.empty()); // Find or create a DataSec - if (DataSecEntries.find(SecName) == DataSecEntries.end()) { - DataSecEntries[SecName] = std::make_unique(Asm, SecName); + if (DataSecEntries.find(std::string(SecName)) == DataSecEntries.end()) { + DataSecEntries[std::string(SecName)] = + std::make_unique(Asm, std::string(SecName)); } // Calculate symbol size const DataLayout &DL = Global.getParent()->getDataLayout(); uint32_t Size = DL.getTypeAllocSize(Global.getType()->getElementType()); - DataSecEntries[SecName]->addVar(VarId, Asm->getSymbol(&Global), Size); + DataSecEntries[std::string(SecName)]->addVar(VarId, Asm->getSymbol(&Global), + Size); } } diff --git a/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp b/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp index 2f12ea6a016..5976a811c97 100644 --- a/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp +++ b/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp @@ -942,7 +942,7 @@ bool HexagonAsmParser::isLabel(AsmToken &Token) { assert(Second.is(AsmToken::Colon)); StringRef Raw(String.data(), Third.getString().data() - String.data() + Third.getString().size()); - std::string Collapsed = Raw; + std::string Collapsed = std::string(Raw); Collapsed.erase(llvm::remove_if(Collapsed, isspace), Collapsed.end()); StringRef Whole = Collapsed; std::pair DotSplit = Whole.split('.'); @@ -988,7 +988,7 @@ bool HexagonAsmParser::ParseRegister(unsigned &RegNo, SMLoc &StartLoc, Again = (Contigious && Type) || (Workaround && Type); NeededWorkaround = NeededWorkaround || (Again && !(Contigious && Type)); } - std::string Collapsed = RawString; + std::string Collapsed = std::string(RawString); Collapsed.erase(llvm::remove_if(Collapsed, isspace), Collapsed.end()); StringRef FullString = Collapsed; std::pair DotSplit = FullString.split('.'); diff --git a/lib/Target/Hexagon/HexagonSubtarget.cpp b/lib/Target/Hexagon/HexagonSubtarget.cpp index adeb3e0c8de..7bcc9560657 100644 --- a/lib/Target/Hexagon/HexagonSubtarget.cpp +++ b/lib/Target/Hexagon/HexagonSubtarget.cpp @@ -75,12 +75,11 @@ static cl::opt EnableCheckBankConflict("hexagon-check-bank-conflict", cl::Hidden, cl::ZeroOrMore, cl::init(true), cl::desc("Enable checking for cache bank conflicts")); - HexagonSubtarget::HexagonSubtarget(const Triple &TT, StringRef CPU, StringRef FS, const TargetMachine &TM) : HexagonGenSubtargetInfo(TT, CPU, FS), OptLevel(TM.getOptLevel()), - CPUString(Hexagon_MC::selectHexagonCPU(CPU)), TargetTriple(TT), - InstrInfo(initializeSubtargetDependencies(CPU, FS)), + CPUString(std::string(Hexagon_MC::selectHexagonCPU(CPU))), + TargetTriple(TT), InstrInfo(initializeSubtargetDependencies(CPU, FS)), RegInfo(getHwMode()), TLInfo(TM, *this), InstrItins(getInstrItineraryForCPU(CPUString)) { Hexagon_MC::addArchSubtarget(this, FS); diff --git a/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp b/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp index aa038572adc..ac5ba87c798 100644 --- a/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp +++ b/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp @@ -390,7 +390,7 @@ namespace { std::pair selectCPUAndFS(StringRef CPU, StringRef FS) { std::pair Result; - Result.first = Hexagon_MC::selectHexagonCPU(CPU); + Result.first = std::string(Hexagon_MC::selectHexagonCPU(CPU)); Result.second = selectHexagonFS(Result.first, FS); return Result; } diff --git a/lib/Target/Lanai/LanaiSubtarget.cpp b/lib/Target/Lanai/LanaiSubtarget.cpp index 9a872c789bc..ebf91e08fbc 100644 --- a/lib/Target/Lanai/LanaiSubtarget.cpp +++ b/lib/Target/Lanai/LanaiSubtarget.cpp @@ -23,7 +23,7 @@ using namespace llvm; void LanaiSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) { - std::string CPUName = CPU; + std::string CPUName = std::string(CPU); if (CPUName.empty()) CPUName = "generic"; diff --git a/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp b/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp index 9de15bf61c8..2ff893273c9 100644 --- a/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp +++ b/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp @@ -52,7 +52,7 @@ static MCRegisterInfo *createLanaiMCRegisterInfo(const Triple & /*TT*/) { static MCSubtargetInfo * createLanaiMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) { - std::string CPUName = CPU; + std::string CPUName = std::string(CPU); if (CPUName.empty()) CPUName = "generic"; diff --git a/lib/Target/MSP430/MSP430Subtarget.cpp b/lib/Target/MSP430/MSP430Subtarget.cpp index 20168773cd5..1f3c1d34f76 100644 --- a/lib/Target/MSP430/MSP430Subtarget.cpp +++ b/lib/Target/MSP430/MSP430Subtarget.cpp @@ -43,7 +43,7 @@ MSP430Subtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) { ExtendedInsts = false; HWMultMode = NoHWMult; - std::string CPUName = CPU; + StringRef CPUName = CPU; if (CPUName.empty()) CPUName = "msp430"; diff --git a/lib/Target/MSP430/MSP430TargetMachine.cpp b/lib/Target/MSP430/MSP430TargetMachine.cpp index 81851427c0e..827f24daad1 100644 --- a/lib/Target/MSP430/MSP430TargetMachine.cpp +++ b/lib/Target/MSP430/MSP430TargetMachine.cpp @@ -47,7 +47,7 @@ MSP430TargetMachine::MSP430TargetMachine(const Target &T, const Triple &TT, Options, getEffectiveRelocModel(RM), getEffectiveCodeModel(CM, CodeModel::Small), OL), TLOF(std::make_unique()), - Subtarget(TT, CPU, FS, *this) { + Subtarget(TT, std::string(CPU), std::string(FS), *this) { initAsmInfo(); } diff --git a/lib/Target/Mips/Mips16HardFloat.cpp b/lib/Target/Mips/Mips16HardFloat.cpp index e9a3c7ec4b1..10a7451f1bb 100644 --- a/lib/Target/Mips/Mips16HardFloat.cpp +++ b/lib/Target/Mips/Mips16HardFloat.cpp @@ -260,7 +260,7 @@ static void assureFPCallStub(Function &F, Module *M, return; LLVMContext &Context = M->getContext(); bool LE = TM.isLittleEndian(); - std::string Name = F.getName(); + std::string Name(F.getName()); std::string SectionName = ".mips16.call.fp." + Name; std::string StubName = "__call_stub_fp_" + Name; // @@ -448,7 +448,7 @@ static void createFPFnStub(Function *F, Module *M, FPParamVariant PV, bool PicMode = TM.isPositionIndependent(); bool LE = TM.isLittleEndian(); LLVMContext &Context = M->getContext(); - std::string Name = F->getName(); + std::string Name(F->getName()); std::string SectionName = ".mips16.fn." + Name; std::string StubName = "__fn_stub_" + Name; std::string LocalName = "$$__fn_local_" + Name; diff --git a/lib/Target/Mips/MipsRegisterBankInfo.cpp b/lib/Target/Mips/MipsRegisterBankInfo.cpp index 3b96738d814..225cfa0cc4e 100644 --- a/lib/Target/Mips/MipsRegisterBankInfo.cpp +++ b/lib/Target/Mips/MipsRegisterBankInfo.cpp @@ -362,7 +362,7 @@ MipsRegisterBankInfo::TypeInfoForMF::determineInstType(const MachineInstr *MI) { void MipsRegisterBankInfo::TypeInfoForMF::cleanupIfNewFunction( llvm::StringRef FunctionName) { if (MFName != FunctionName) { - MFName = FunctionName; + MFName = std::string(FunctionName); WaitingQueues.clear(); Types.clear(); } diff --git a/lib/Target/Mips/MipsSubtarget.cpp b/lib/Target/Mips/MipsSubtarget.cpp index 133b818114c..ef4191cec3d 100644 --- a/lib/Target/Mips/MipsSubtarget.cpp +++ b/lib/Target/Mips/MipsSubtarget.cpp @@ -237,7 +237,7 @@ CodeGenOpt::Level MipsSubtarget::getOptLevelToEnablePostRAScheduler() const { MipsSubtarget & MipsSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS, const TargetMachine &TM) { - std::string CPUName = MIPS_MC::selectMipsCPU(TM.getTargetTriple(), CPU); + StringRef CPUName = MIPS_MC::selectMipsCPU(TM.getTargetTriple(), CPU); // Parse features string. ParseSubtargetFeatures(CPUName, FS); diff --git a/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/lib/Target/NVPTX/NVPTXAsmPrinter.cpp index 7117438dc50..4bb3ef81420 100644 --- a/lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ b/lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -982,7 +982,7 @@ void NVPTXAsmPrinter::emitLinkageDirective(const GlobalValue *V, msg.append("Error: "); msg.append("Symbol "); if (V->hasName()) - msg.append(V->getName()); + msg.append(std::string(V->getName())); msg.append("has unsupported appending linkage type"); llvm_unreachable(msg.c_str()); } else if (!V->hasInternalLinkage() && @@ -1439,7 +1439,7 @@ void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) { if (isKernelFunction(*F)) { if (isSampler(*I) || isImage(*I)) { if (isImage(*I)) { - std::string sname = I->getName(); + std::string sname = std::string(I->getName()); if (isImageWriteOnly(*I) || isImageReadWrite(*I)) { if (hasImageHandles) O << "\t.param .u64 .ptr .surfref "; diff --git a/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp b/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp index b36d9b2e240..9078ff8cfb9 100644 --- a/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp +++ b/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp @@ -144,7 +144,7 @@ bool GenericToNVVM::runOnModule(Module &M) { // variable initializers, as other uses have been already been removed // while walking through the instructions in function definitions. GV->replaceAllUsesWith(BitCastNewGV); - std::string Name = GV->getName(); + std::string Name = std::string(GV->getName()); GV->eraseFromParent(); NewGV->setName(Name); } diff --git a/lib/Target/NVPTX/NVPTXReplaceImageHandles.cpp b/lib/Target/NVPTX/NVPTXReplaceImageHandles.cpp index e213089e408..8ae542130a1 100644 --- a/lib/Target/NVPTX/NVPTXReplaceImageHandles.cpp +++ b/lib/Target/NVPTX/NVPTXReplaceImageHandles.cpp @@ -152,7 +152,7 @@ findIndexForHandle(MachineOperand &Op, MachineFunction &MF, unsigned &Idx) { assert(TexHandleDef.getOperand(6).isSymbol() && "Load is not a symbol!"); StringRef Sym = TexHandleDef.getOperand(6).getSymbolName(); - std::string ParamBaseName = MF.getName(); + std::string ParamBaseName = std::string(MF.getName()); ParamBaseName += "_param_"; assert(Sym.startswith(ParamBaseName) && "Invalid symbol reference"); unsigned Param = atoi(Sym.data()+ParamBaseName.size()); diff --git a/lib/Target/NVPTX/NVPTXSubtarget.cpp b/lib/Target/NVPTX/NVPTXSubtarget.cpp index 357826c2d19..f1fa6416f15 100644 --- a/lib/Target/NVPTX/NVPTXSubtarget.cpp +++ b/lib/Target/NVPTX/NVPTXSubtarget.cpp @@ -33,13 +33,13 @@ void NVPTXSubtarget::anchor() {} NVPTXSubtarget &NVPTXSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) { // Provide the default CPU if we don't have one. - TargetName = CPU.empty() ? "sm_20" : CPU; + TargetName = std::string(CPU.empty() ? "sm_20" : CPU); - ParseSubtargetFeatures(TargetName, FS); + ParseSubtargetFeatures(TargetName, FS); - // Set default to PTX 3.2 (CUDA 5.5) - if (PTXVersion == 0) { - PTXVersion = 32; + // Set default to PTX 3.2 (CUDA 5.5) + if (PTXVersion == 0) { + PTXVersion = 32; } return *this; diff --git a/lib/Target/NVPTX/NVPTXTargetMachine.cpp b/lib/Target/NVPTX/NVPTXTargetMachine.cpp index 0778706d936..77487d1c99a 100644 --- a/lib/Target/NVPTX/NVPTXTargetMachine.cpp +++ b/lib/Target/NVPTX/NVPTXTargetMachine.cpp @@ -117,7 +117,7 @@ NVPTXTargetMachine::NVPTXTargetMachine(const Target &T, const Triple &TT, getEffectiveCodeModel(CM, CodeModel::Small), OL), is64bit(is64bit), UseShortPointers(UseShortPointersOpt), TLOF(std::make_unique()), - Subtarget(TT, CPU, FS, *this) { + Subtarget(TT, std::string(CPU), std::string(FS), *this) { if (TT.getOS() == Triple::NVCL) drvInterface = NVPTX::NVCL; else diff --git a/lib/Target/NVPTX/NVPTXUtilities.cpp b/lib/Target/NVPTX/NVPTXUtilities.cpp index 43c2e992040..74d129d330f 100644 --- a/lib/Target/NVPTX/NVPTXUtilities.cpp +++ b/lib/Target/NVPTX/NVPTXUtilities.cpp @@ -226,17 +226,17 @@ bool isManaged(const Value &val) { std::string getTextureName(const Value &val) { assert(val.hasName() && "Found texture variable with no name"); - return val.getName(); + return std::string(val.getName()); } std::string getSurfaceName(const Value &val) { assert(val.hasName() && "Found surface variable with no name"); - return val.getName(); + return std::string(val.getName()); } std::string getSamplerName(const Value &val) { assert(val.hasName() && "Found sampler variable with no name"); - return val.getName(); + return std::string(val.getName()); } bool getMaxNTIDx(const Function &F, unsigned &x) { diff --git a/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp b/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp index 2d9ba02b35b..343c0eb3038 100644 --- a/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp +++ b/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp @@ -1570,12 +1570,12 @@ bool PPCAsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name, // instruction name, to match what TableGen is doing. std::string NewOpcode; if (parseOptionalToken(AsmToken::Plus)) { - NewOpcode = Name; + NewOpcode = std::string(Name); NewOpcode += '+'; Name = NewOpcode; } if (parseOptionalToken(AsmToken::Minus)) { - NewOpcode = Name; + NewOpcode = std::string(Name); NewOpcode += '-'; Name = NewOpcode; } diff --git a/lib/Target/PowerPC/PPCSubtarget.cpp b/lib/Target/PowerPC/PPCSubtarget.cpp index 1d0ed7e5357..0549df1ec5c 100644 --- a/lib/Target/PowerPC/PPCSubtarget.cpp +++ b/lib/Target/PowerPC/PPCSubtarget.cpp @@ -123,7 +123,7 @@ void PPCSubtarget::initializeEnvironment() { void PPCSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) { // Determine default and user specified characteristics - std::string CPUName = CPU; + std::string CPUName = std::string(CPU); if (CPUName.empty() || CPU == "generic") { // If cross-compiling with -march=ppc64le without -mcpu if (TargetTriple.getArch() == Triple::ppc64le) diff --git a/lib/Target/PowerPC/PPCTargetMachine.cpp b/lib/Target/PowerPC/PPCTargetMachine.cpp index 71bad1a5550..8aa1f1bcaef 100644 --- a/lib/Target/PowerPC/PPCTargetMachine.cpp +++ b/lib/Target/PowerPC/PPCTargetMachine.cpp @@ -158,7 +158,7 @@ static std::string getDataLayoutString(const Triple &T) { static std::string computeFSAdditions(StringRef FS, CodeGenOpt::Level OL, const Triple &TT) { - std::string FullFS = FS; + std::string FullFS = std::string(FS); // Make sure 64-bit features are available when CPUname is generic if (TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le) { diff --git a/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp b/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp index c37482be3c2..d231280cc1a 100644 --- a/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp +++ b/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp @@ -64,7 +64,7 @@ static MCAsmInfo *createRISCVMCAsmInfo(const MCRegisterInfo &MRI, static MCSubtargetInfo *createRISCVMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) { - std::string CPUName = CPU; + std::string CPUName = std::string(CPU); if (CPUName.empty()) CPUName = TT.isArch64Bit() ? "generic-rv64" : "generic-rv32"; return createRISCVMCSubtargetInfoImpl(TT, CPUName, FS); diff --git a/lib/Target/RISCV/RISCVSubtarget.cpp b/lib/Target/RISCV/RISCVSubtarget.cpp index 83e7e2d52cc..47a48c820a2 100644 --- a/lib/Target/RISCV/RISCVSubtarget.cpp +++ b/lib/Target/RISCV/RISCVSubtarget.cpp @@ -33,7 +33,7 @@ RISCVSubtarget &RISCVSubtarget::initializeSubtargetDependencies( const Triple &TT, StringRef CPU, StringRef FS, StringRef ABIName) { // Determine default and user-specified characteristics bool Is64Bit = TT.isArch64Bit(); - std::string CPUName = CPU; + std::string CPUName = std::string(CPU); if (CPUName.empty()) CPUName = Is64Bit ? "generic-rv64" : "generic-rv32"; ParseSubtargetFeatures(CPUName, FS); diff --git a/lib/Target/Sparc/SparcSubtarget.cpp b/lib/Target/Sparc/SparcSubtarget.cpp index 075a002a358..dbc6cf8e5b8 100644 --- a/lib/Target/Sparc/SparcSubtarget.cpp +++ b/lib/Target/Sparc/SparcSubtarget.cpp @@ -50,7 +50,7 @@ SparcSubtarget &SparcSubtarget::initializeSubtargetDependencies(StringRef CPU, HasLeonCycleCounter = false; // Determine default and user specified characteristics - std::string CPUName = CPU; + std::string CPUName = std::string(CPU); if (CPUName.empty()) CPUName = (Is64Bit) ? "v9" : "v8"; diff --git a/lib/Target/Sparc/SparcTargetMachine.cpp b/lib/Target/Sparc/SparcTargetMachine.cpp index 76f387842f7..d48d94e2faf 100644 --- a/lib/Target/Sparc/SparcTargetMachine.cpp +++ b/lib/Target/Sparc/SparcTargetMachine.cpp @@ -99,7 +99,8 @@ SparcTargetMachine::SparcTargetMachine( CM, getEffectiveRelocModel(RM), is64bit, JIT), OL), TLOF(std::make_unique()), - Subtarget(TT, CPU, FS, *this, is64bit), is64Bit(is64bit) { + Subtarget(TT, std::string(CPU), std::string(FS), *this, is64bit), + is64Bit(is64bit) { initAsmInfo(); } diff --git a/lib/Target/SystemZ/SystemZSubtarget.cpp b/lib/Target/SystemZ/SystemZSubtarget.cpp index 5e8af81842c..a4fdc008555 100644 --- a/lib/Target/SystemZ/SystemZSubtarget.cpp +++ b/lib/Target/SystemZ/SystemZSubtarget.cpp @@ -28,7 +28,7 @@ void SystemZSubtarget::anchor() {} SystemZSubtarget & SystemZSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) { - std::string CPUName = CPU; + StringRef CPUName = CPU; if (CPUName.empty()) CPUName = "generic"; // Parse features string. diff --git a/lib/Target/SystemZ/SystemZTargetMachine.cpp b/lib/Target/SystemZ/SystemZTargetMachine.cpp index dfcdb535648..3e0a9f8ea46 100644 --- a/lib/Target/SystemZ/SystemZTargetMachine.cpp +++ b/lib/Target/SystemZ/SystemZTargetMachine.cpp @@ -155,7 +155,7 @@ SystemZTargetMachine::SystemZTargetMachine(const Target &T, const Triple &TT, getEffectiveSystemZCodeModel(CM, getEffectiveRelocModel(RM), JIT), OL), TLOF(std::make_unique()), - Subtarget(TT, CPU, FS, *this) { + Subtarget(TT, std::string(CPU), std::string(FS), *this) { initAsmInfo(); } diff --git a/lib/Target/TargetMachine.cpp b/lib/Target/TargetMachine.cpp index 88ed6a72103..4844a959bb4 100644 --- a/lib/Target/TargetMachine.cpp +++ b/lib/Target/TargetMachine.cpp @@ -34,10 +34,10 @@ using namespace llvm; TargetMachine::TargetMachine(const Target &T, StringRef DataLayoutString, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options) - : TheTarget(T), DL(DataLayoutString), TargetTriple(TT), TargetCPU(CPU), - TargetFS(FS), AsmInfo(nullptr), MRI(nullptr), MII(nullptr), STI(nullptr), - RequireStructuredCFG(false), O0WantsFastISel(false), - DefaultOptions(Options), Options(Options) {} + : TheTarget(T), DL(DataLayoutString), TargetTriple(TT), + TargetCPU(std::string(CPU)), TargetFS(std::string(FS)), AsmInfo(nullptr), + MRI(nullptr), MII(nullptr), STI(nullptr), RequireStructuredCFG(false), + O0WantsFastISel(false), DefaultOptions(Options), Options(Options) {} TargetMachine::~TargetMachine() = default; diff --git a/lib/Target/TargetMachineC.cpp b/lib/Target/TargetMachineC.cpp index a38633e1f27..60fe84cadac 100644 --- a/lib/Target/TargetMachineC.cpp +++ b/lib/Target/TargetMachineC.cpp @@ -164,12 +164,12 @@ char* LLVMGetTargetMachineTriple(LLVMTargetMachineRef T) { } char* LLVMGetTargetMachineCPU(LLVMTargetMachineRef T) { - std::string StringRep = unwrap(T)->getTargetCPU(); + std::string StringRep = std::string(unwrap(T)->getTargetCPU()); return strdup(StringRep.c_str()); } char* LLVMGetTargetMachineFeatureString(LLVMTargetMachineRef T) { - std::string StringRep = unwrap(T)->getTargetFeatureString(); + std::string StringRep = std::string(unwrap(T)->getTargetFeatureString()); return strdup(StringRep.c_str()); } diff --git a/lib/Target/WebAssembly/WebAssemblyAddMissingPrototypes.cpp b/lib/Target/WebAssembly/WebAssemblyAddMissingPrototypes.cpp index b7a701f1578..530a55cda0e 100644 --- a/lib/Target/WebAssembly/WebAssemblyAddMissingPrototypes.cpp +++ b/lib/Target/WebAssembly/WebAssemblyAddMissingPrototypes.cpp @@ -132,7 +132,7 @@ bool WebAssemblyAddMissingPrototypes::runOnModule(Module &M) { for (auto &Pair : Replacements) { Function *OldF = Pair.first; Function *NewF = Pair.second; - std::string Name = OldF->getName(); + std::string Name = std::string(OldF->getName()); M.getFunctionList().push_back(NewF); OldF->replaceAllUsesWith( ConstantExpr::getPointerBitCastOrAddrSpaceCast(NewF, OldF->getType())); diff --git a/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp b/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp index 3e905c18fa3..8072770406a 100644 --- a/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp +++ b/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp @@ -744,8 +744,8 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runEHOnFunction(Function &F) { bool Changed = false; SmallVector ToErase; SmallPtrSet LandingPads; - bool AllowExceptions = - areAllExceptionsAllowed() || EHWhitelistSet.count(F.getName()); + bool AllowExceptions = areAllExceptionsAllowed() || + EHWhitelistSet.count(std::string(F.getName())); for (BasicBlock &BB : F) { auto *II = dyn_cast(BB.getTerminator()); diff --git a/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp index 4291b48c16b..07b00b6df41 100644 --- a/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ b/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -210,8 +210,8 @@ private: FeatureBitset coalesceFeatures(const Module &M) { FeatureBitset Features = WasmTM - ->getSubtargetImpl(WasmTM->getTargetCPU(), - WasmTM->getTargetFeatureString()) + ->getSubtargetImpl(std::string(WasmTM->getTargetCPU()), + std::string(WasmTM->getTargetFeatureString())) ->getFeatureBits(); for (auto &F : M) Features |= WasmTM->getSubtargetImpl(F)->getFeatureBits(); diff --git a/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp b/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp index 049a3a81598..5594f342bfa 100644 --- a/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp +++ b/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp @@ -294,7 +294,7 @@ MCSubtargetInfo *X86_MC::createX86MCSubtargetInfo(const Triple &TT, if (!FS.empty()) ArchFS = (Twine(ArchFS) + "," + FS).str(); - std::string CPUName = CPU; + std::string CPUName = std::string(CPU); if (CPUName.empty()) CPUName = "generic"; diff --git a/lib/Target/X86/X86Subtarget.cpp b/lib/Target/X86/X86Subtarget.cpp index 75c3a70b430..82687de8289 100644 --- a/lib/Target/X86/X86Subtarget.cpp +++ b/lib/Target/X86/X86Subtarget.cpp @@ -227,11 +227,11 @@ bool X86Subtarget::isLegalToCallImmediateAddr() const { } void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) { - std::string CPUName = CPU; + std::string CPUName = std::string(CPU); if (CPUName.empty()) CPUName = "generic"; - std::string FullFS = FS; + std::string FullFS = std::string(FS); if (In64BitMode) { // SSE2 should default to enabled in 64-bit mode, but can be turned off // explicitly. diff --git a/lib/Target/XCore/XCoreTargetMachine.cpp b/lib/Target/XCore/XCoreTargetMachine.cpp index 736bc4148a1..1eea1e37c25 100644 --- a/lib/Target/XCore/XCoreTargetMachine.cpp +++ b/lib/Target/XCore/XCoreTargetMachine.cpp @@ -54,7 +54,7 @@ XCoreTargetMachine::XCoreTargetMachine(const Target &T, const Triple &TT, TT, CPU, FS, Options, getEffectiveRelocModel(RM), getEffectiveXCoreCodeModel(CM), OL), TLOF(std::make_unique()), - Subtarget(TT, CPU, FS, *this) { + Subtarget(TT, std::string(CPU), std::string(FS), *this) { initAsmInfo(); } diff --git a/lib/TextAPI/MachO/ArchitectureSet.cpp b/lib/TextAPI/MachO/ArchitectureSet.cpp index c589671199b..a05d3ebd67b 100644 --- a/lib/TextAPI/MachO/ArchitectureSet.cpp +++ b/lib/TextAPI/MachO/ArchitectureSet.cpp @@ -40,7 +40,7 @@ ArchitectureSet::operator std::string() const { std::string result; auto size = count(); for (auto arch : *this) { - result.append(getArchitectureName(arch)); + result.append(std::string(getArchitectureName(arch))); size -= 1; if (size) result.append(" "); diff --git a/lib/TextAPI/MachO/InterfaceFile.cpp b/lib/TextAPI/MachO/InterfaceFile.cpp index c40a952a6a8..9f084560d5f 100644 --- a/lib/TextAPI/MachO/InterfaceFile.cpp +++ b/lib/TextAPI/MachO/InterfaceFile.cpp @@ -63,7 +63,7 @@ void InterfaceFile::addParentUmbrella(const Target &Target_, StringRef Parent) { Target RHS) { return LHS.first < RHS; }); if ((Iter != ParentUmbrellas.end()) && !(Target_ < Iter->first)) { - Iter->second = Parent; + Iter->second = std::string(Parent); return; } @@ -77,7 +77,7 @@ void InterfaceFile::addUUID(const Target &Target_, StringRef UUID) { Target RHS) { return LHS.first < RHS; }); if ((Iter != UUIDs.end()) && !(Target_ < Iter->first)) { - Iter->second = UUID; + Iter->second = std::string(UUID); return; } diff --git a/lib/TextAPI/MachO/TextStub.cpp b/lib/TextAPI/MachO/TextStub.cpp index 0584e43d589..cdfe7f47ee6 100644 --- a/lib/TextAPI/MachO/TextStub.cpp +++ b/lib/TextAPI/MachO/TextStub.cpp @@ -1107,7 +1107,7 @@ static void DiagHandler(const SMDiagnostic &Diag, void *Context) { Expected> TextAPIReader::get(MemoryBufferRef InputBuffer) { TextAPIContext Ctx; - Ctx.Path = InputBuffer.getBufferIdentifier(); + Ctx.Path = std::string(InputBuffer.getBufferIdentifier()); yaml::Input YAMLIn(InputBuffer.getBuffer(), &Ctx, DiagHandler, &Ctx); // Fill vector with interface file objects created by parsing the YAML file. @@ -1127,7 +1127,7 @@ TextAPIReader::get(MemoryBufferRef InputBuffer) { Error TextAPIWriter::writeToStream(raw_ostream &OS, const InterfaceFile &File) { TextAPIContext Ctx; - Ctx.Path = File.getPath(); + Ctx.Path = std::string(File.getPath()); Ctx.FileKind = File.getFileType(); llvm::yaml::Output YAMLOut(OS, &Ctx, /*WrapColumn=*/80); diff --git a/lib/TextAPI/MachO/TextStubCommon.cpp b/lib/TextAPI/MachO/TextStubCommon.cpp index a7fd58fba5f..e4e58cd66f3 100644 --- a/lib/TextAPI/MachO/TextStubCommon.cpp +++ b/lib/TextAPI/MachO/TextStubCommon.cpp @@ -215,7 +215,7 @@ StringRef ScalarTraits::input(StringRef Scalar, void *, UUID &Value) { auto UUID = Split.second.trim(); if (UUID.empty()) return "invalid uuid string pair"; - Value.second = UUID; + Value.second = std::string(UUID); Value.first = Target{getArchitectureFromName(Arch), PlatformKind::unknown}; return {}; } diff --git a/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp b/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp index 19f253be795..a4fd62e5557 100644 --- a/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp +++ b/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp @@ -146,7 +146,7 @@ int llvm::dlltoolDriverMain(llvm::ArrayRef ArgsArr) { return 1; } - std::string Path = Args.getLastArgValue(OPT_l); + std::string Path = std::string(Args.getLastArgValue(OPT_l)); // If ExtName is set (if the "ExtName = Name" syntax was used), overwrite // Name with ExtName and clear ExtName. When only creating an import diff --git a/lib/ToolDrivers/llvm-lib/LibDriver.cpp b/lib/ToolDrivers/llvm-lib/LibDriver.cpp index 286191abff2..16b231f977a 100644 --- a/lib/ToolDrivers/llvm-lib/LibDriver.cpp +++ b/lib/ToolDrivers/llvm-lib/LibDriver.cpp @@ -65,7 +65,7 @@ static std::string getOutputPath(opt::InputArgList *Args, return Arg->getValue(); SmallString<128> Val = StringRef(FirstMember.Buf->getBufferIdentifier()); sys::path::replace_extension(Val, ".lib"); - return Val.str(); + return std::string(Val.str()); } static std::vector getSearchPaths(opt::InputArgList *Args, diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index cdf8a2eb598..c9c8d0a749a 100644 --- a/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -453,7 +453,7 @@ doPromotion(Function *F, SmallPtrSetImpl &ArgsToPromote, assert(It != ArgIndices.end() && "GEP not handled??"); } - std::string NewName = I->getName(); + std::string NewName = std::string(I->getName()); for (unsigned i = 0, e = Operands.size(); i != e; ++i) { NewName += "." + utostr(Operands[i]); } diff --git a/lib/Transforms/IPO/BlockExtractor.cpp b/lib/Transforms/IPO/BlockExtractor.cpp index aec470ffadc..1d1300c6cd1 100644 --- a/lib/Transforms/IPO/BlockExtractor.cpp +++ b/lib/Transforms/IPO/BlockExtractor.cpp @@ -127,7 +127,8 @@ void BlockExtractor::loadFile() { /*KeepEmpty=*/false); if (BBNames.empty()) report_fatal_error("Missing bbs name"); - BlocksByName.push_back({LineSplit[0], {BBNames.begin(), BBNames.end()}}); + BlocksByName.push_back( + {std::string(LineSplit[0]), {BBNames.begin(), BBNames.end()}}); } } diff --git a/lib/Transforms/IPO/FunctionImport.cpp b/lib/Transforms/IPO/FunctionImport.cpp index be0446a946e..abaacb9438d 100644 --- a/lib/Transforms/IPO/FunctionImport.cpp +++ b/lib/Transforms/IPO/FunctionImport.cpp @@ -913,11 +913,12 @@ void llvm::gatherImportedSummariesForModule( const FunctionImporter::ImportMapTy &ImportList, std::map &ModuleToSummariesForIndex) { // Include all summaries from the importing module. - ModuleToSummariesForIndex[ModulePath] = + ModuleToSummariesForIndex[std::string(ModulePath)] = ModuleToDefinedGVSummaries.lookup(ModulePath); // Include summaries for imports. for (auto &ILI : ImportList) { - auto &SummariesForIndex = ModuleToSummariesForIndex[ILI.first()]; + auto &SummariesForIndex = + ModuleToSummariesForIndex[std::string(ILI.first())]; const auto &DefinedGVSummaries = ModuleToDefinedGVSummaries.lookup(ILI.first()); for (auto &GI : ILI.second) { @@ -1291,7 +1292,7 @@ static bool doImportingForModule(Module &M) { // Perform the import now. auto ModuleLoader = [&M](StringRef Identifier) { - return loadFile(Identifier, M.getContext()); + return loadFile(std::string(Identifier), M.getContext()); }; FunctionImporter Importer(*Index, ModuleLoader); Expected Result = Importer.importFunctions(M, ImportList); diff --git a/lib/Transforms/IPO/LowerTypeTests.cpp b/lib/Transforms/IPO/LowerTypeTests.cpp index 6eba35aaa4e..6f38a312393 100644 --- a/lib/Transforms/IPO/LowerTypeTests.cpp +++ b/lib/Transforms/IPO/LowerTypeTests.cpp @@ -1055,7 +1055,7 @@ void LowerTypeTestsModule::importFunction( assert(F->getType()->getAddressSpace() == 0); GlobalValue::VisibilityTypes Visibility = F->getVisibility(); - std::string Name = F->getName(); + std::string Name = std::string(F->getName()); if (F->isDeclarationForLinker() && isJumpTableCanonical) { // Non-dso_local functions may be overriden at run time, @@ -1523,13 +1523,13 @@ void LowerTypeTestsModule::buildBitSetsFromFunctionsNative( F->getType()); if (Functions[I]->isExported()) { if (IsJumpTableCanonical) { - ExportSummary->cfiFunctionDefs().insert(F->getName()); + ExportSummary->cfiFunctionDefs().insert(std::string(F->getName())); } else { GlobalAlias *JtAlias = GlobalAlias::create( F->getValueType(), 0, GlobalValue::ExternalLinkage, F->getName() + ".cfi_jt", CombinedGlobalElemPtr, &M); JtAlias->setVisibility(GlobalValue::HiddenVisibility); - ExportSummary->cfiFunctionDecls().insert(F->getName()); + ExportSummary->cfiFunctionDecls().insert(std::string(F->getName())); } } if (!IsJumpTableCanonical) { @@ -1821,9 +1821,10 @@ bool LowerTypeTestsModule::lower() { // have the same name, but it's not the one we are looking for. if (F.hasLocalLinkage()) continue; - if (ImportSummary->cfiFunctionDefs().count(F.getName())) + if (ImportSummary->cfiFunctionDefs().count(std::string(F.getName()))) Defs.push_back(&F); - else if (ImportSummary->cfiFunctionDecls().count(F.getName())) + else if (ImportSummary->cfiFunctionDecls().count( + std::string(F.getName()))) Decls.push_back(&F); } diff --git a/lib/Transforms/IPO/SampleProfile.cpp b/lib/Transforms/IPO/SampleProfile.cpp index 8bfb2fd1aaa..719b18cbb28 100644 --- a/lib/Transforms/IPO/SampleProfile.cpp +++ b/lib/Transforms/IPO/SampleProfile.cpp @@ -310,7 +310,7 @@ public: std::function GetTargetTransformInfo) : GetAC(std::move(GetAssumptionCache)), GetTTI(std::move(GetTargetTransformInfo)), CoverageTracker(*this), - Filename(Name), RemappingFilename(RemapName), + Filename(std::string(Name)), RemappingFilename(std::string(RemapName)), IsThinLTOPreLink(IsThinLTOPreLink) {} bool doInitialization(Module &M); diff --git a/lib/Transforms/IPO/WholeProgramDevirt.cpp b/lib/Transforms/IPO/WholeProgramDevirt.cpp index 5c5ddf4a38c..bbc1433a22e 100644 --- a/lib/Transforms/IPO/WholeProgramDevirt.cpp +++ b/lib/Transforms/IPO/WholeProgramDevirt.cpp @@ -1083,7 +1083,7 @@ bool DevirtModule::trySingleImplDevirt( AddCalls(SlotInfo, TheFnVI); Res->TheKind = WholeProgramDevirtResolution::SingleImpl; - Res->SingleImplName = TheFn->getName(); + Res->SingleImplName = std::string(TheFn->getName()); return true; } @@ -1132,10 +1132,10 @@ bool DevirtIndex::trySingleImplDevirt(MutableArrayRef TargetsForSlot, TheFn.name(), ExportSummary.getModuleHash(S->modulePath())); else { LocalWPDTargetsMap[TheFn].push_back(SlotSummary); - Res->SingleImplName = TheFn.name(); + Res->SingleImplName = std::string(TheFn.name()); } } else - Res->SingleImplName = TheFn.name(); + Res->SingleImplName = std::string(TheFn.name()); // Name will be empty if this thin link driven off of serialized combined // index (e.g. llvm-lto). However, WPD is not supported/invoked for the @@ -2003,7 +2003,7 @@ bool DevirtModule::run() { if (RemarksEnabled) for (const auto &T : TargetsForSlot) if (T.WasDevirt) - DevirtTargets[T.Fn->getName()] = T.Fn; + DevirtTargets[std::string(T.Fn->getName())] = T.Fn; } // CFI-specific: if we are exporting and any llvm.type.checked.load diff --git a/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 73a0e10c4f2..75b4c8bffc8 100644 --- a/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1993,7 +1993,7 @@ void ModuleAddressSanitizer::SetComdatForGlobalMetadata( } if (!InternalSuffix.empty() && G->hasLocalLinkage()) { - std::string Name = G->getName(); + std::string Name = std::string(G->getName()); Name += InternalSuffix; C = M.getOrInsertComdat(Name); } else { diff --git a/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp index 8053474d40e..388a7d44d03 100644 --- a/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp +++ b/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp @@ -628,7 +628,7 @@ DataFlowSanitizer::WrapperKind DataFlowSanitizer::getWrapperKind(Function *F) { } void DataFlowSanitizer::addGlobalNamePrefix(GlobalValue *GV) { - std::string GVName = GV->getName(), Prefix = "dfs$"; + std::string GVName = std::string(GV->getName()), Prefix = "dfs$"; GV->setName(Prefix + GVName); // Try to change the name of the function in module inline asm. We only do diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index bf3e4ed3e31..2a302b547dc 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -268,8 +268,7 @@ namespace { write(Lines[i]); } - GCOVLines(StringRef F, raw_ostream *os) - : Filename(F) { + GCOVLines(StringRef F, raw_ostream *os) : Filename(std::string(F)) { this->os = os; } @@ -537,7 +536,8 @@ std::string GCOVProfiler::mangleName(const DICompileUnit *CU, MDString *DataFile = dyn_cast(N->getOperand(1)); if (!NotesFile || !DataFile) continue; - return Notes ? NotesFile->getString() : DataFile->getString(); + return std::string(Notes ? NotesFile->getString() + : DataFile->getString()); } MDString *GCovFile = dyn_cast(N->getOperand(0)); @@ -546,7 +546,7 @@ std::string GCOVProfiler::mangleName(const DICompileUnit *CU, SmallString<128> Filename = GCovFile->getString(); sys::path::replace_extension(Filename, Notes ? "gcno" : "gcda"); - return Filename.str(); + return std::string(Filename.str()); } } @@ -554,9 +554,10 @@ std::string GCOVProfiler::mangleName(const DICompileUnit *CU, sys::path::replace_extension(Filename, Notes ? "gcno" : "gcda"); StringRef FName = sys::path::filename(Filename); SmallString<128> CurPath; - if (sys::fs::current_path(CurPath)) return FName; + if (sys::fs::current_path(CurPath)) + return std::string(FName); sys::path::append(CurPath, FName); - return CurPath.str(); + return std::string(CurPath.str()); } bool GCOVProfiler::runOnModule( diff --git a/lib/Transforms/Instrumentation/Instrumentation.cpp b/lib/Transforms/Instrumentation/Instrumentation.cpp index f675e2661ea..64626225f23 100644 --- a/lib/Transforms/Instrumentation/Instrumentation.cpp +++ b/lib/Transforms/Instrumentation/Instrumentation.cpp @@ -78,7 +78,7 @@ Comdat *llvm::GetOrCreateFunctionComdat(Function &F, Triple &T, if (auto Comdat = F.getComdat()) return Comdat; assert(F.hasName()); Module *M = F.getParent(); - std::string Name = F.getName(); + std::string Name = std::string(F.getName()); // Make a unique comdat name for internal linkage things on ELF. On COFF, the // name of the comdat group identifies the leader symbol of the comdat group. diff --git a/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/lib/Transforms/Instrumentation/PGOInstrumentation.cpp index 8ef6908234c..b5f0a366d7f 100644 --- a/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -469,7 +469,7 @@ INITIALIZE_PASS(PGOInstrumentationGenCreateVarLegacyPass, ModulePass * llvm::createPGOInstrumentationGenCreateVarLegacyPass(StringRef CSInstrName) { - return new PGOInstrumentationGenCreateVarLegacyPass(CSInstrName); + return new PGOInstrumentationGenCreateVarLegacyPass(std::string(CSInstrName)); } namespace { @@ -1731,7 +1731,7 @@ bool PGOInstrumentationUseLegacyPass::runOnModule(Module &M) { static std::string getSimpleNodeName(const BasicBlock *Node) { if (!Node->getName().empty()) - return Node->getName(); + return std::string(Node->getName()); std::string SimpleNodeName; raw_string_ostream OS(SimpleNodeName); @@ -1822,7 +1822,7 @@ template <> struct DOTGraphTraits : DefaultDOTGraphTraits { : DefaultDOTGraphTraits(isSimple) {} static std::string getGraphName(const PGOUseFunc *G) { - return G->getFunc().getName(); + return std::string(G->getFunc().getName()); } std::string getNodeLabel(const BasicBlock *Node, const PGOUseFunc *Graph) { diff --git a/lib/Transforms/Scalar/LoopDeletion.cpp b/lib/Transforms/Scalar/LoopDeletion.cpp index cca7c2407e6..19493405c41 100644 --- a/lib/Transforms/Scalar/LoopDeletion.cpp +++ b/lib/Transforms/Scalar/LoopDeletion.cpp @@ -214,7 +214,7 @@ PreservedAnalyses LoopDeletionPass::run(Loop &L, LoopAnalysisManager &AM, LLVM_DEBUG(dbgs() << "Analyzing Loop for deletion: "); LLVM_DEBUG(L.dump()); - std::string LoopName = L.getName(); + std::string LoopName = std::string(L.getName()); auto Result = deleteLoopIfDead(&L, AR.DT, AR.SE, AR.LI, AR.MSSA); if (Result == LoopDeletionResult::Unmodified) return PreservedAnalyses::all(); diff --git a/lib/Transforms/Scalar/LoopUnrollPass.cpp b/lib/Transforms/Scalar/LoopUnrollPass.cpp index 75310fc11be..da1a8180ba3 100644 --- a/lib/Transforms/Scalar/LoopUnrollPass.cpp +++ b/lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -1327,7 +1327,7 @@ PreservedAnalyses LoopFullUnrollPass::run(Loop &L, LoopAnalysisManager &AM, else OldLoops.insert(AR.LI.begin(), AR.LI.end()); - std::string LoopName = L.getName(); + std::string LoopName = std::string(L.getName()); bool Changed = tryToUnrollLoop(&L, AR.DT, &AR.LI, AR.SE, AR.TTI, AR.AC, *ORE, /*BFI*/ nullptr, /*PSI*/ nullptr, @@ -1470,7 +1470,7 @@ PreservedAnalyses LoopUnrollPass::run(Function &F, Optional LocalAllowPeeling = UnrollOpts.AllowPeeling; if (PSI && PSI->hasHugeWorkingSetSize()) LocalAllowPeeling = false; - std::string LoopName = L.getName(); + std::string LoopName = std::string(L.getName()); // The API here is quite complex to call and we allow to select some // flavors of unrolling during construction time (by setting UnrollOpts). LoopUnrollResult Result = tryToUnrollLoop( diff --git a/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp b/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp index efef2865c94..4047de13d0e 100644 --- a/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp +++ b/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp @@ -983,7 +983,7 @@ public: indent(Indent); } - void write(const std::string &S) { + void write(StringRef S) { LineLength += S.size(); Stream << S; } @@ -1110,7 +1110,7 @@ public: TmpStream << "scalar"; } TmpStream.flush(); - Tmp = StringRef(Tmp).trim(); + Tmp = std::string(StringRef(Tmp).trim()); LineLength += Tmp.size(); Stream << Tmp; } diff --git a/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp index 79e99d02052..b184f0f5cda 100644 --- a/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp +++ b/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp @@ -2868,7 +2868,7 @@ PreservedAnalyses SimpleLoopUnswitchPass::run(Loop &L, LoopAnalysisManager &AM, // Save the current loop name in a variable so that we can report it even // after it has been deleted. - std::string LoopName = L.getName(); + std::string LoopName = std::string(L.getName()); auto UnswitchCB = [&L, &U, &LoopName](bool CurrentLoopValid, ArrayRef NewLoops) { diff --git a/lib/Transforms/Utils/InjectTLIMappings.cpp b/lib/Transforms/Utils/InjectTLIMappings.cpp index 360ed1c76d4..c8407ef6959 100644 --- a/lib/Transforms/Utils/InjectTLIMappings.cpp +++ b/lib/Transforms/Utils/InjectTLIMappings.cpp @@ -55,7 +55,7 @@ static std::string mangleTLIName(StringRef VectorName, const CallInst &CI, for (unsigned I = 0; I < CI.getNumArgOperands(); ++I) Out << "v"; Out << "_" << CI.getCalledFunction()->getName() << "(" << VectorName << ")"; - return Out.str(); + return std::string(Out.str()); } /// A helper function for converting Scalar types to vector types. @@ -110,7 +110,7 @@ static void addMappingsFromTLI(const TargetLibraryInfo &TLI, CallInst &CI) { if (CI.isNoBuiltin() || !CI.getCalledFunction()) return; - const std::string ScalarName = CI.getCalledFunction()->getName(); + const std::string ScalarName = std::string(CI.getCalledFunction()->getName()); // Nothing to be done if the TLI thinks the function is not // vectorizable. if (!TLI.isFunctionVectorizable(ScalarName)) @@ -123,7 +123,8 @@ static void addMappingsFromTLI(const TargetLibraryInfo &TLI, CallInst &CI) { // All VFs in the TLI are powers of 2. for (unsigned VF = 2, WidestVF = TLI.getWidestVF(ScalarName); VF <= WidestVF; VF *= 2) { - const std::string TLIName = TLI.getVectorizedFunction(ScalarName, VF); + const std::string TLIName = + std::string(TLI.getVectorizedFunction(ScalarName, VF)); if (!TLIName.empty()) { std::string MangledName = mangleTLIName(TLIName, CI, VF); if (!OriginalSetOfMappings.count(MangledName)) { diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index b7080672f17..35ce5ba69f2 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/lib/Transforms/Utils/InlineFunction.cpp @@ -951,7 +951,7 @@ static void AddAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap, for (unsigned i = 0, e = NoAliasArgs.size(); i != e; ++i) { const Argument *A = NoAliasArgs[i]; - std::string Name = CalledFunc->getName(); + std::string Name = std::string(CalledFunc->getName()); if (A->hasName()) { Name += ": %"; Name += A->getName(); diff --git a/lib/Transforms/Utils/NameAnonGlobals.cpp b/lib/Transforms/Utils/NameAnonGlobals.cpp index 1c5c41abc68..7083789267d 100644 --- a/lib/Transforms/Utils/NameAnonGlobals.cpp +++ b/lib/Transforms/Utils/NameAnonGlobals.cpp @@ -55,7 +55,7 @@ public: Hasher.final(Hash); SmallString<32> Result; MD5::stringifyResult(Hash, Result); - TheHash = Result.str(); + TheHash = std::string(Result.str()); return TheHash; } }; diff --git a/lib/Transforms/Utils/SSAUpdater.cpp b/lib/Transforms/Utils/SSAUpdater.cpp index 36a17ce7619..57df2334c75 100644 --- a/lib/Transforms/Utils/SSAUpdater.cpp +++ b/lib/Transforms/Utils/SSAUpdater.cpp @@ -56,7 +56,7 @@ void SSAUpdater::Initialize(Type *Ty, StringRef Name) { else getAvailableVals(AV).clear(); ProtoType = Ty; - ProtoName = Name; + ProtoName = std::string(Name); } bool SSAUpdater::HasValueForBlock(BasicBlock *BB) const { diff --git a/lib/Transforms/Utils/SymbolRewriter.cpp b/lib/Transforms/Utils/SymbolRewriter.cpp index aacf81d8351..ec4ea848a5d 100644 --- a/lib/Transforms/Utils/SymbolRewriter.cpp +++ b/lib/Transforms/Utils/SymbolRewriter.cpp @@ -117,8 +117,9 @@ public: const std::string Target; ExplicitRewriteDescriptor(StringRef S, StringRef T, const bool Naked) - : RewriteDescriptor(DT), Source(Naked ? StringRef("\01" + S.str()) : S), - Target(T) {} + : RewriteDescriptor(DT), + Source(std::string(Naked ? StringRef("\01" + S.str()) : S)), + Target(std::string(T)) {} bool performOnModule(Module &M) override; @@ -159,7 +160,8 @@ public: const std::string Transform; PatternRewriteDescriptor(StringRef P, StringRef T) - : RewriteDescriptor(DT), Pattern(P), Transform(T) { } + : RewriteDescriptor(DT), Pattern(std::string(P)), + Transform(std::string(T)) {} bool performOnModule(Module &M) override; @@ -189,7 +191,7 @@ performOnModule(Module &M) { continue; if (GlobalObject *GO = dyn_cast(&C)) - rewriteComdat(M, GO, C.getName(), Name); + rewriteComdat(M, GO, std::string(C.getName()), Name); if (Value *V = (M.*Get)(Name)) C.setValueName(V->getValueName()); @@ -352,19 +354,19 @@ parseRewriteFunctionDescriptor(yaml::Stream &YS, yaml::ScalarNode *K, if (KeyValue.equals("source")) { std::string Error; - Source = Value->getValue(ValueStorage); + Source = std::string(Value->getValue(ValueStorage)); if (!Regex(Source).isValid(Error)) { YS.printError(Field.getKey(), "invalid regex: " + Error); return false; } } else if (KeyValue.equals("target")) { - Target = Value->getValue(ValueStorage); + Target = std::string(Value->getValue(ValueStorage)); } else if (KeyValue.equals("transform")) { - Transform = Value->getValue(ValueStorage); + Transform = std::string(Value->getValue(ValueStorage)); } else if (KeyValue.equals("naked")) { std::string Undecorated; - Undecorated = Value->getValue(ValueStorage); + Undecorated = std::string(Value->getValue(ValueStorage)); Naked = StringRef(Undecorated).lower() == "true" || Undecorated == "1"; } else { YS.printError(Field.getKey(), "unknown key for function"); @@ -421,15 +423,15 @@ parseRewriteGlobalVariableDescriptor(yaml::Stream &YS, yaml::ScalarNode *K, if (KeyValue.equals("source")) { std::string Error; - Source = Value->getValue(ValueStorage); + Source = std::string(Value->getValue(ValueStorage)); if (!Regex(Source).isValid(Error)) { YS.printError(Field.getKey(), "invalid regex: " + Error); return false; } } else if (KeyValue.equals("target")) { - Target = Value->getValue(ValueStorage); + Target = std::string(Value->getValue(ValueStorage)); } else if (KeyValue.equals("transform")) { - Transform = Value->getValue(ValueStorage); + Transform = std::string(Value->getValue(ValueStorage)); } else { YS.printError(Field.getKey(), "unknown Key for Global Variable"); return false; @@ -484,15 +486,15 @@ parseRewriteGlobalAliasDescriptor(yaml::Stream &YS, yaml::ScalarNode *K, if (KeyValue.equals("source")) { std::string Error; - Source = Value->getValue(ValueStorage); + Source = std::string(Value->getValue(ValueStorage)); if (!Regex(Source).isValid(Error)) { YS.printError(Field.getKey(), "invalid regex: " + Error); return false; } } else if (KeyValue.equals("target")) { - Target = Value->getValue(ValueStorage); + Target = std::string(Value->getValue(ValueStorage)); } else if (KeyValue.equals("transform")) { - Transform = Value->getValue(ValueStorage); + Transform = std::string(Value->getValue(ValueStorage)); } else { YS.printError(Field.getKey(), "unknown key for Global Alias"); return false; diff --git a/lib/XRay/FDRTraceExpander.cpp b/lib/XRay/FDRTraceExpander.cpp index cb7f66bccd7..b68e997fe70 100644 --- a/lib/XRay/FDRTraceExpander.cpp +++ b/lib/XRay/FDRTraceExpander.cpp @@ -44,7 +44,7 @@ Error TraceExpander::visit(CustomEventRecord &R) { CurrentRecord.PId = PID; CurrentRecord.TId = TID; CurrentRecord.Type = RecordTypes::CUSTOM_EVENT; - CurrentRecord.Data = R.data(); + CurrentRecord.Data = std::string(R.data()); BuildingRecord = true; } return Error::success(); @@ -59,7 +59,7 @@ Error TraceExpander::visit(CustomEventRecordV5 &R) { CurrentRecord.PId = PID; CurrentRecord.TId = TID; CurrentRecord.Type = RecordTypes::CUSTOM_EVENT; - CurrentRecord.Data = R.data(); + CurrentRecord.Data = std::string(R.data()); BuildingRecord = true; } return Error::success(); @@ -75,7 +75,7 @@ Error TraceExpander::visit(TypedEventRecord &R) { CurrentRecord.TId = TID; CurrentRecord.RecordType = R.eventType(); CurrentRecord.Type = RecordTypes::TYPED_EVENT; - CurrentRecord.Data = R.data(); + CurrentRecord.Data = std::string(R.data()); BuildingRecord = true; } return Error::success(); diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp index aa88a06a6df..73ff1dc11a0 100644 --- a/tools/bugpoint/CrashDebugger.cpp +++ b/tools/bugpoint/CrashDebugger.cpp @@ -1216,7 +1216,7 @@ static Error DebugACrash(BugDriver &BD, BugTester TestFn) { // For each remaining function, try to reduce that function's attributes. std::vector FunctionNames; for (Function &F : BD.getProgram()) - FunctionNames.push_back(F.getName()); + FunctionNames.push_back(std::string(F.getName())); if (!FunctionNames.empty() && !BugpointIsInterrupted) { outs() << "\n*** Attempting to reduce the number of function attributes" diff --git a/tools/bugpoint/ExecutionDriver.cpp b/tools/bugpoint/ExecutionDriver.cpp index 40f198b88d1..4c83a959897 100644 --- a/tools/bugpoint/ExecutionDriver.cpp +++ b/tools/bugpoint/ExecutionDriver.cpp @@ -311,7 +311,7 @@ Expected BugDriver::executeProgram(const Module &Program, << "!\n"; exit(1); } - BitcodeFile = UniqueFilename.str(); + BitcodeFile = std::string(UniqueFilename.str()); if (writeProgramToFile(BitcodeFile, UniqueFD, Program)) { errs() << ToolName << ": Error emitting bitcode to file '" << BitcodeFile @@ -336,7 +336,7 @@ Expected BugDriver::executeProgram(const Module &Program, << "\n"; exit(1); } - OutputFile = UniqueFile.str(); + OutputFile = std::string(UniqueFile.str()); // Figure out which shared objects to run, if any. std::vector SharedObjs(AdditionalSOs); diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp index 1621a51c91d..c5c51c86945 100644 --- a/tools/bugpoint/Miscompilation.cpp +++ b/tools/bugpoint/Miscompilation.cpp @@ -953,7 +953,8 @@ static Expected TestCodeGenerator(BugDriver &BD, << "Error making unique filename: " << EC.message() << "\n"; exit(1); } - if (BD.writeProgramToFile(TestModuleBC.str(), TestModuleFD, *Test)) { + if (BD.writeProgramToFile(std::string(TestModuleBC.str()), TestModuleFD, + *Test)) { errs() << "Error writing bitcode to `" << TestModuleBC.str() << "'\nExiting."; exit(1); @@ -972,7 +973,8 @@ static Expected TestCodeGenerator(BugDriver &BD, exit(1); } - if (BD.writeProgramToFile(SafeModuleBC.str(), SafeModuleFD, *Safe)) { + if (BD.writeProgramToFile(std::string(SafeModuleBC.str()), SafeModuleFD, + *Safe)) { errs() << "Error writing bitcode to `" << SafeModuleBC << "'\nExiting."; exit(1); } @@ -980,7 +982,7 @@ static Expected TestCodeGenerator(BugDriver &BD, FileRemover SafeModuleBCRemover(SafeModuleBC.str(), !SaveTemps); Expected SharedObject = - BD.compileSharedObject(SafeModuleBC.str()); + BD.compileSharedObject(std::string(SafeModuleBC.str())); if (Error E = SharedObject.takeError()) return std::move(E); @@ -988,8 +990,8 @@ static Expected TestCodeGenerator(BugDriver &BD, // Run the code generator on the `Test' code, loading the shared library. // The function returns whether or not the new output differs from reference. - Expected Result = - BD.diffProgram(BD.getProgram(), TestModuleBC.str(), *SharedObject, false); + Expected Result = BD.diffProgram( + BD.getProgram(), std::string(TestModuleBC.str()), *SharedObject, false); if (Error E = Result.takeError()) return std::move(E); @@ -1046,7 +1048,8 @@ Error BugDriver::debugCodeGenerator() { exit(1); } - if (writeProgramToFile(TestModuleBC.str(), TestModuleFD, *ToCodeGen)) { + if (writeProgramToFile(std::string(TestModuleBC.str()), TestModuleFD, + *ToCodeGen)) { errs() << "Error writing bitcode to `" << TestModuleBC << "'\nExiting."; exit(1); } @@ -1062,11 +1065,13 @@ Error BugDriver::debugCodeGenerator() { exit(1); } - if (writeProgramToFile(SafeModuleBC.str(), SafeModuleFD, *ToNotCodeGen)) { + if (writeProgramToFile(std::string(SafeModuleBC.str()), SafeModuleFD, + *ToNotCodeGen)) { errs() << "Error writing bitcode to `" << SafeModuleBC << "'\nExiting."; exit(1); } - Expected SharedObject = compileSharedObject(SafeModuleBC.str()); + Expected SharedObject = + compileSharedObject(std::string(SafeModuleBC.str())); if (Error E = SharedObject.takeError()) return E; diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp index 64af81fcc8a..25a970bd687 100644 --- a/tools/bugpoint/OptimizerDriver.cpp +++ b/tools/bugpoint/OptimizerDriver.cpp @@ -141,7 +141,7 @@ bool BugDriver::runPasses(Module &Program, << ": Error making unique filename: " << EC.message() << "\n"; return 1; } - OutputFilename = UniqueFilename.str(); + OutputFilename = std::string(UniqueFilename.str()); // set up the input file name Expected Temp = diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp index 19b2ea2c018..d880aca044d 100644 --- a/tools/bugpoint/ToolRunner.cpp +++ b/tools/bugpoint/ToolRunner.cpp @@ -442,7 +442,7 @@ Expected LLC::OutputCode(const std::string &Bitcode, errs() << "Error making unique filename: " << EC.message() << "\n"; exit(1); } - OutputAsmFile = UniqueFile.str(); + OutputAsmFile = std::string(UniqueFile.str()); std::vector LLCArgs; LLCArgs.push_back(LLCPath); @@ -772,7 +772,7 @@ Error CC::MakeSharedObject(const std::string &InputFile, FileType fileType, errs() << "Error making unique filename: " << EC.message() << "\n"; exit(1); } - OutputFile = UniqueFilename.str(); + OutputFile = std::string(UniqueFilename.str()); std::vector CCArgs; diff --git a/tools/bugpoint/ToolRunner.h b/tools/bugpoint/ToolRunner.h index dde4ec539cf..f6b5f26c7a6 100644 --- a/tools/bugpoint/ToolRunner.h +++ b/tools/bugpoint/ToolRunner.h @@ -40,7 +40,7 @@ class CC { std::vector ccArgs; // CC-specific arguments. CC(StringRef ccPath, StringRef RemotePath, const std::vector *CCArgs) - : CCPath(ccPath), RemoteClientPath(RemotePath) { + : CCPath(std::string(ccPath)), RemoteClientPath(std::string(RemotePath)) { if (CCArgs) ccArgs = *CCArgs; } diff --git a/tools/bugpoint/bugpoint.cpp b/tools/bugpoint/bugpoint.cpp index d29a79ee3e1..937ec23231b 100644 --- a/tools/bugpoint/bugpoint.cpp +++ b/tools/bugpoint/bugpoint.cpp @@ -110,7 +110,7 @@ public: void add(Pass *P) override { const void *ID = P->getPassID(); const PassInfo *PI = PassRegistry::getPassRegistry()->getPassInfo(ID); - D.addPass(PI->getPassArgument()); + D.addPass(std::string(PI->getPassArgument())); } }; } @@ -221,7 +221,7 @@ int main(int argc, char **argv) { AddOptimizationPasses(PM, 2, 2); for (const PassInfo *PI : PassList) - D.addPass(PI->getPassArgument()); + D.addPass(std::string(PI->getPassArgument())); // Bugpoint has the ability of generating a plethora of core files, so to // avoid filling up the disk, we prevent it diff --git a/tools/dsymutil/BinaryHolder.cpp b/tools/dsymutil/BinaryHolder.cpp index da4ed8abc12..31d32d8d8e8 100644 --- a/tools/dsymutil/BinaryHolder.cpp +++ b/tools/dsymutil/BinaryHolder.cpp @@ -66,7 +66,7 @@ Error BinaryHolder::ArchiveEntry::load(StringRef Filename, ArchiveBuffers.push_back(MemBuffer->getMemBufferRef()); } else { FatBinary = std::move(*ErrOrFat); - FatBinaryName = ArchiveFilename; + FatBinaryName = std::string(ArchiveFilename); ArchiveBuffers = getMachOFatMemoryBuffers(FatBinaryName, *MemBuffer, *FatBinary); } @@ -105,7 +105,7 @@ Error BinaryHolder::ObjectEntry::load(StringRef Filename, bool Verbose) { ObjectBuffers.push_back(MemBuffer->getMemBufferRef()); } else { FatBinary = std::move(*ErrOrFat); - FatBinaryName = Filename; + FatBinaryName = std::string(Filename); ObjectBuffers = getMachOFatMemoryBuffers(FatBinaryName, *MemBuffer, *FatBinary); } diff --git a/tools/dsymutil/DebugMap.cpp b/tools/dsymutil/DebugMap.cpp index 83dddfe9e52..41067106e02 100644 --- a/tools/dsymutil/DebugMap.cpp +++ b/tools/dsymutil/DebugMap.cpp @@ -41,7 +41,7 @@ using namespace llvm::object; DebugMapObject::DebugMapObject(StringRef ObjectFilename, sys::TimePoint Timestamp, uint8_t Type) - : Filename(ObjectFilename), Timestamp(Timestamp), Type(Type) {} + : Filename(std::string(ObjectFilename)), Timestamp(Timestamp), Type(Type) {} bool DebugMapObject::addSymbol(StringRef Name, Optional ObjectAddress, uint64_t LinkedAddress, uint32_t Size) { @@ -228,7 +228,8 @@ MappingTraits::YamlDMO::YamlDMO( Timestamp = sys::toTimeT(Obj.getTimestamp()); Entries.reserve(Obj.Symbols.size()); for (auto &Entry : Obj.Symbols) - Entries.push_back(std::make_pair(Entry.getKey(), Entry.getValue())); + Entries.push_back( + std::make_pair(std::string(Entry.getKey()), Entry.getValue())); } dsymutil::DebugMapObject diff --git a/tools/dsymutil/DebugMap.h b/tools/dsymutil/DebugMap.h index 6c0cb8baff6..ee552ed9837 100644 --- a/tools/dsymutil/DebugMap.h +++ b/tools/dsymutil/DebugMap.h @@ -90,7 +90,7 @@ class DebugMap { public: DebugMap(const Triple &BinaryTriple, StringRef BinaryPath, ArrayRef BinaryUUID = ArrayRef()) - : BinaryTriple(BinaryTriple), BinaryPath(BinaryPath), + : BinaryTriple(BinaryTriple), BinaryPath(std::string(BinaryPath)), BinaryUUID(BinaryUUID.begin(), BinaryUUID.end()) {} using const_iterator = ObjectContainer::const_iterator; @@ -183,7 +183,9 @@ public: bool empty() const { return Symbols.empty(); } - void addWarning(StringRef Warning) { Warnings.push_back(Warning); } + void addWarning(StringRef Warning) { + Warnings.push_back(std::string(Warning)); + } const std::vector &getWarnings() const { return Warnings; } void print(raw_ostream &OS) const; diff --git a/tools/dsymutil/MachODebugMapParser.cpp b/tools/dsymutil/MachODebugMapParser.cpp index 3292e948572..83703fb13f0 100644 --- a/tools/dsymutil/MachODebugMapParser.cpp +++ b/tools/dsymutil/MachODebugMapParser.cpp @@ -26,9 +26,10 @@ public: MachODebugMapParser(StringRef BinaryPath, ArrayRef Archs, StringRef PathPrefix = "", bool PaperTrailWarnings = false, bool Verbose = false) - : BinaryPath(BinaryPath), Archs(Archs.begin(), Archs.end()), - PathPrefix(PathPrefix), PaperTrailWarnings(PaperTrailWarnings), - BinHolder(Verbose), CurrentDebugMapObject(nullptr) {} + : BinaryPath(std::string(BinaryPath)), Archs(Archs.begin(), Archs.end()), + PathPrefix(std::string(PathPrefix)), + PaperTrailWarnings(PaperTrailWarnings), BinHolder(Verbose), + CurrentDebugMapObject(nullptr) {} /// Parses and returns the DebugMaps of the input binary. The binary contains /// multiple maps in case it is a universal binary. @@ -181,7 +182,7 @@ void MachODebugMapParser::switchToNewDebugMapObject( static std::string getArchName(const object::MachOObjectFile &Obj) { Triple T = Obj.getArchTriple(); - return T.getArchName(); + return std::string(T.getArchName()); } std::unique_ptr @@ -497,7 +498,7 @@ void MachODebugMapParser::loadCurrentObjectFileSymbols( CurrentObjectAddresses[*Name] = None; } else if (Flags & SymbolRef::SF_Common) { CurrentObjectAddresses[*Name] = None; - CommonSymbols.push_back(*Name); + CommonSymbols.push_back(std::string(*Name)); } else { CurrentObjectAddresses[*Name] = Addr; } diff --git a/tools/dsymutil/MachOUtils.cpp b/tools/dsymutil/MachOUtils.cpp index 149905fb5bf..f9219dc9cbb 100644 --- a/tools/dsymutil/MachOUtils.cpp +++ b/tools/dsymutil/MachOUtils.cpp @@ -50,7 +50,7 @@ ArchAndFile::~ArchAndFile() { std::string getArchName(StringRef Arch) { if (Arch.startswith("thumb")) return (llvm::Twine("arm") + Arch.drop_front(5)).str(); - return Arch; + return std::string(Arch); } static bool runLipo(StringRef SDKPath, SmallVectorImpl &Args) { diff --git a/tools/dsymutil/MachOUtils.h b/tools/dsymutil/MachOUtils.h index 3dda747dc0f..f64fc68e1b4 100644 --- a/tools/dsymutil/MachOUtils.h +++ b/tools/dsymutil/MachOUtils.h @@ -30,7 +30,7 @@ struct ArchAndFile { llvm::Error createTempFile(); llvm::StringRef path() const; - ArchAndFile(StringRef Arch) : Arch(Arch) {} + ArchAndFile(StringRef Arch) : Arch(std::string(Arch)) {} ArchAndFile(ArchAndFile &&A) = default; ArchAndFile &operator=(ArchAndFile &&A) = default; ~ArchAndFile(); diff --git a/tools/dsymutil/dsymutil.cpp b/tools/dsymutil/dsymutil.cpp index 2801178c605..6b2608160ae 100644 --- a/tools/dsymutil/dsymutil.cpp +++ b/tools/dsymutil/dsymutil.cpp @@ -299,9 +299,9 @@ static Error createPlistFile(StringRef Bin, StringRef BundleRoot, if (BI.IDStr.empty()) { StringRef BundleID = *sys::path::rbegin(BundleRoot); if (sys::path::extension(BundleRoot) == ".dSYM") - BI.IDStr = sys::path::stem(BundleID); + BI.IDStr = std::string(sys::path::stem(BundleID)); else - BI.IDStr = BundleID; + BI.IDStr = std::string(BundleID); } // Print out information to the plist file. @@ -405,7 +405,7 @@ getOutputFileName(StringRef InputFile, const DsymutilOptions &Options) { // When updating, do in place replacement. if (Options.OutputFile.empty() && (Options.LinkOpts.Update || !Options.SymbolMap.empty())) - return OutputLocation(InputFile); + return OutputLocation(std::string(InputFile)); // If a flat dSYM has been requested, things are pretty simple. if (Options.Flat) { @@ -426,7 +426,8 @@ getOutputFileName(StringRef InputFile, const DsymutilOptions &Options) { // Resources/ // DWARF/ // - std::string DwarfFile = InputFile == "-" ? StringRef("a.out") : InputFile; + std::string DwarfFile = + std::string(InputFile == "-" ? StringRef("a.out") : InputFile); SmallString<128> Path(Options.OutputFile); if (Path.empty()) Path = DwarfFile + ".dSYM"; @@ -438,9 +439,9 @@ getOutputFileName(StringRef InputFile, const DsymutilOptions &Options) { } sys::path::append(Path, "Contents", "Resources"); - std::string ResourceDir = Path.str(); + std::string ResourceDir = std::string(Path.str()); sys::path::append(Path, "DWARF", sys::path::filename(DwarfFile)); - return OutputLocation(Path.str(), ResourceDir); + return OutputLocation(std::string(Path.str()), ResourceDir); } int main(int argc, char **argv) { @@ -455,7 +456,7 @@ int main(int argc, char **argv) { void *P = (void *)(intptr_t)getOutputFileName; std::string SDKPath = sys::fs::getMainExecutable(argv[0], P); - SDKPath = sys::path::parent_path(SDKPath); + SDKPath = std::string(sys::path::parent_path(SDKPath)); for (auto *Arg : Args.filtered(OPT_UNKNOWN)) { WithColor::warning() << "ignoring unknown option: " << Arg->getSpelling() diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp index 93e9b60873e..f5d47d68a51 100644 --- a/tools/gold/gold-plugin.cpp +++ b/tools/gold/gold-plugin.cpp @@ -224,13 +224,14 @@ namespace options { llvm::StringRef opt = opt_; if (opt.startswith("mcpu=")) { - mcpu = opt.substr(strlen("mcpu=")); + mcpu = std::string(opt.substr(strlen("mcpu="))); } else if (opt.startswith("extra-library-path=")) { - extra_library_path = opt.substr(strlen("extra_library_path=")); + extra_library_path = + std::string(opt.substr(strlen("extra_library_path="))); } else if (opt.startswith("mtriple=")) { - triple = opt.substr(strlen("mtriple=")); + triple = std::string(opt.substr(strlen("mtriple="))); } else if (opt.startswith("obj-path=")) { - obj_path = opt.substr(strlen("obj-path=")); + obj_path = std::string(opt.substr(strlen("obj-path="))); } else if (opt == "emit-llvm") { TheOutputType = OT_BC_ONLY; } else if (opt == "save-temps") { @@ -245,23 +246,25 @@ namespace options { thinlto_index_only = true; } else if (opt.startswith("thinlto-index-only=")) { thinlto_index_only = true; - thinlto_linked_objects_file = opt.substr(strlen("thinlto-index-only=")); + thinlto_linked_objects_file = + std::string(opt.substr(strlen("thinlto-index-only="))); } else if (opt == "thinlto-emit-imports-files") { thinlto_emit_imports_files = true; } else if (opt.startswith("thinlto-prefix-replace=")) { - thinlto_prefix_replace = opt.substr(strlen("thinlto-prefix-replace=")); + thinlto_prefix_replace = + std::string(opt.substr(strlen("thinlto-prefix-replace="))); if (thinlto_prefix_replace.find(';') == std::string::npos) message(LDPL_FATAL, "thinlto-prefix-replace expects 'old;new' format"); } else if (opt.startswith("thinlto-object-suffix-replace=")) { thinlto_object_suffix_replace = - opt.substr(strlen("thinlto-object-suffix-replace=")); + std::string(opt.substr(strlen("thinlto-object-suffix-replace="))); if (thinlto_object_suffix_replace.find(';') == std::string::npos) message(LDPL_FATAL, "thinlto-object-suffix-replace expects 'old;new' format"); } else if (opt.startswith("cache-dir=")) { - cache_dir = opt.substr(strlen("cache-dir=")); + cache_dir = std::string(opt.substr(strlen("cache-dir="))); } else if (opt.startswith("cache-policy=")) { - cache_policy = opt.substr(strlen("cache-policy=")); + cache_policy = std::string(opt.substr(strlen("cache-policy="))); } else if (opt.size() == 2 && opt[0] == 'O') { if (opt[1] < '0' || opt[1] > '3') message(LDPL_FATAL, "Optimization level must be between 0 and 3"); @@ -689,7 +692,7 @@ static std::string getThinLTOObjectFileName(StringRef Path, StringRef OldSuffix, StringRef NewSuffix) { if (Path.consume_back(OldSuffix)) return (Path + NewSuffix).str(); - return Path; + return std::string(Path); } // Returns true if S is valid as a C language identifier. @@ -1074,8 +1077,9 @@ static std::vector, bool>> runLTO() { if (options::thinlto_index_only) for (auto &Identifier : ObjectToIndexFileState) if (!Identifier.getValue()) - writeEmptyDistributedBuildOutputs(Identifier.getKey(), OldPrefix, - NewPrefix, /* SkipModule */ false); + writeEmptyDistributedBuildOutputs(std::string(Identifier.getKey()), + OldPrefix, NewPrefix, + /* SkipModule */ false); return Files; } @@ -1105,7 +1109,7 @@ static ld_plugin_status allSymbolsReadHook() { for (const auto &F : Files) if (!F.first.empty()) - recordFile(F.first.str(), F.second); + recordFile(std::string(F.first.str()), F.second); if (!options::extra_library_path.empty() && set_extra_library_path(options::extra_library_path.c_str()) != LDPS_OK) diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index 0cf65139d5a..50942df302c 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -171,7 +171,7 @@ struct RunPassOption { SmallVector PassNames; StringRef(Val).split(PassNames, ',', -1, false); for (auto PassName : PassNames) - RunPassNames->push_back(PassName); + RunPassNames->push_back(std::string(PassName)); } }; } @@ -196,11 +196,11 @@ static std::unique_ptr GetOutputStream(const char *TargetName, // If InputFilename ends in .bc or .ll, remove it. StringRef IFN = InputFilename; if (IFN.endswith(".bc") || IFN.endswith(".ll")) - OutputFilename = IFN.drop_back(3); + OutputFilename = std::string(IFN.drop_back(3)); else if (IFN.endswith(".mir")) - OutputFilename = IFN.drop_back(4); + OutputFilename = std::string(IFN.drop_back(4)); else - OutputFilename = IFN; + OutputFilename = std::string(IFN); switch (FileType) { case CGFT_AssemblyFile: diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp index 3bf694aba17..a0d7a8c1d06 100644 --- a/tools/lli/lli.cpp +++ b/tools/lli/lli.cpp @@ -714,7 +714,7 @@ static std::function createDebugDumper() { continue; if (F.hasName()) { - std::string Name(F.getName()); + std::string Name(std::string(F.getName())); printf("%s ", Name.c_str()); } else printf(" "); diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp index c339dfe1f33..61ab8051ede 100644 --- a/tools/llvm-ar/llvm-ar.cpp +++ b/tools/llvm-ar/llvm-ar.cpp @@ -650,7 +650,7 @@ static void addChildMember(std::vector &Members, // the archive it's in, so the file resolves correctly. if (Thin && FlattenArchive) { StringSaver Saver(Alloc); - Expected FileNameOrErr = M.getName(); + Expected FileNameOrErr(M.getName()); failIfError(FileNameOrErr.takeError()); if (sys::path::is_absolute(*FileNameOrErr)) { NMOrErr->MemberName = Saver.save(sys::path::convert_to_slash(*FileNameOrErr)); @@ -792,7 +792,7 @@ computeNewArchiveMembers(ArchiveOperation Operation, int Pos = Ret.size(); Expected NameOrErr = Child.getName(); failIfError(NameOrErr.takeError()); - std::string Name = NameOrErr.get(); + std::string Name = std::string(NameOrErr.get()); if (comparePaths(Name, RelPos)) { assert(AddAfter || AddBefore); if (AddBefore) @@ -1058,7 +1058,7 @@ static void runMRIScript() { fail("editing multiple archives not supported"); if (Saved) fail("file already saved"); - ArchiveName = Rest; + ArchiveName = std::string(Rest); break; case MRICommand::Delete: { llvm::erase_if(NewMembers, [=](NewArchiveMember &M) { diff --git a/tools/llvm-cfi-verify/lib/FileAnalysis.cpp b/tools/llvm-cfi-verify/lib/FileAnalysis.cpp index 7ae4d0dd613..d2b4db3b575 100644 --- a/tools/llvm-cfi-verify/lib/FileAnalysis.cpp +++ b/tools/llvm-cfi-verify/lib/FileAnalysis.cpp @@ -274,7 +274,8 @@ Expected FileAnalysis::symbolizeInlinedCode(object::SectionedAddress Address) { assert(Symbolizer != nullptr && "Symbolizer is invalid."); - return Symbolizer->symbolizeInlinedCode(Object->getFileName(), Address); + return Symbolizer->symbolizeInlinedCode(std::string(Object->getFileName()), + Address); } CFIProtectionStatus @@ -515,8 +516,9 @@ void FileAnalysis::parseSectionContents(ArrayRef SectionBytes, // Check if this instruction exists in the range of the DWARF metadata. if (!IgnoreDWARFFlag) { - auto LineInfo = Symbolizer->symbolizeCode( - Object->getFileName(), {VMAddress, Address.SectionIndex}); + auto LineInfo = + Symbolizer->symbolizeCode(std::string(Object->getFileName()), + {VMAddress, Address.SectionIndex}); if (!LineInfo) { handleAllErrors(LineInfo.takeError(), [](const ErrorInfoBase &E) { errs() << "Symbolizer failed to get line: " << E.message() << "\n"; @@ -577,7 +579,8 @@ Error FileAnalysis::parseSymbolTable() { return Error::success(); } -UnsupportedDisassembly::UnsupportedDisassembly(StringRef Text) : Text(Text) {} +UnsupportedDisassembly::UnsupportedDisassembly(StringRef Text) + : Text(std::string(Text)) {} char UnsupportedDisassembly::ID; void UnsupportedDisassembly::log(raw_ostream &OS) const { diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp index 6c31df3e173..df45c389d0a 100644 --- a/tools/llvm-config/llvm-config.cpp +++ b/tools/llvm-config/llvm-config.cpp @@ -338,7 +338,7 @@ int main(int argc, char **argv) { ActiveIncludeDir = ActivePrefix + "/include"; SmallString<256> path(StringRef(LLVM_TOOLS_INSTALL_DIR)); sys::fs::make_absolute(ActivePrefix, path); - ActiveBinDir = path.str(); + ActiveBinDir = std::string(path.str()); ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX; ActiveCMakeDir = ActiveLibDir + "/cmake/llvm"; ActiveIncludeOption = "-I" + ActiveIncludeDir; @@ -352,7 +352,8 @@ int main(int argc, char **argv) { /// in the first place. This can't be done at configure/build time. StringRef SharedExt, SharedVersionedExt, SharedDir, SharedPrefix, StaticExt, - StaticPrefix, StaticDir = "lib", DirSep = "/"; + StaticPrefix, StaticDir = "lib"; + std::string DirSep = "/"; const Triple HostTriple(Triple::normalize(LLVM_HOST_TRIPLE)); if (HostTriple.isOSWindows()) { SharedExt = "dll"; @@ -449,7 +450,7 @@ int main(int argc, char **argv) { // already has the necessary prefix and suffix (e.g. `.so`) added so // just return it unmodified. assert(Lib.endswith(SharedExt) && "DyLib is missing suffix"); - LibFileName = Lib; + LibFileName = std::string(Lib); } else { LibFileName = (SharedPrefix + Lib + "." + SharedExt).str(); } diff --git a/tools/llvm-cov/CodeCoverage.cpp b/tools/llvm-cov/CodeCoverage.cpp index 5f1e23f20d7..4444fe6bc1a 100644 --- a/tools/llvm-cov/CodeCoverage.cpp +++ b/tools/llvm-cov/CodeCoverage.cpp @@ -413,7 +413,8 @@ void CodeCoverageTool::remapPathNames(const CoverageMapping &Coverage) { // Convert input files from local paths to coverage data file paths. StringMap InvRemappedFilenames; for (const auto &RemappedFilename : RemappedFilenames) - InvRemappedFilenames[RemappedFilename.getValue()] = RemappedFilename.getKey(); + InvRemappedFilenames[RemappedFilename.getValue()] = + std::string(RemappedFilename.getKey()); for (std::string &Filename : SourceFiles) { SmallString<128> NativeFilename; @@ -510,7 +511,7 @@ void CodeCoverageTool::demangleSymbols(const CoverageMapping &Coverage) { for (const auto &Function : Coverage.getCoveredFunctions()) // On Windows, lines in the demangler's output file end with "\r\n". // Splitting by '\n' keeps '\r's, so cut them now. - DC.DemangledNames[Function.Name] = Symbols[I++].rtrim(); + DC.DemangledNames[Function.Name] = std::string(Symbols[I++].rtrim()); } void CodeCoverageTool::writeSourceFileView(StringRef SourceFile, @@ -688,7 +689,8 @@ int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) { // PathRemapping. auto EquivPair = StringRef(PathRemap).split(','); if (!(EquivPair.first.empty() && EquivPair.second.empty())) - PathRemapping = EquivPair; + PathRemapping = {std::string(EquivPair.first), + std::string(EquivPair.second)}; // If a demangler is supplied, check if it exists and register it. if (!DemanglerOpts.empty()) { @@ -886,7 +888,7 @@ int CodeCoverageTool::doShow(int argc, const char **argv, // Get the source files from the function coverage mapping. for (StringRef Filename : Coverage->getUniqueSourceFiles()) { if (!IgnoreFilenameFilters.matchesFilename(Filename)) - SourceFiles.push_back(Filename); + SourceFiles.push_back(std::string(Filename)); } // Create an index out of the source files. diff --git a/tools/llvm-cov/CoverageSummaryInfo.cpp b/tools/llvm-cov/CoverageSummaryInfo.cpp index 1029f778404..929529c27b6 100644 --- a/tools/llvm-cov/CoverageSummaryInfo.cpp +++ b/tools/llvm-cov/CoverageSummaryInfo.cpp @@ -51,7 +51,7 @@ FunctionCoverageSummary::get(const InstantiationGroup &Group, ArrayRef Summaries) { std::string Name; if (Group.hasName()) { - Name = Group.getName(); + Name = std::string(Group.getName()); } else { llvm::raw_string_ostream OS(Name); OS << "Definition at line " << Group.getLine() << ", column " diff --git a/tools/llvm-cov/SourceCoverageView.cpp b/tools/llvm-cov/SourceCoverageView.cpp index 0e20ea63cd6..cd7395a1a87 100644 --- a/tools/llvm-cov/SourceCoverageView.cpp +++ b/tools/llvm-cov/SourceCoverageView.cpp @@ -48,7 +48,7 @@ std::string CoveragePrinter::getOutputPath(StringRef Path, StringRef Extension, sys::path::append(FullPath, PathFilename); sys::path::native(FullPath); - return FullPath.str(); + return std::string(FullPath.str()); } Expected @@ -158,7 +158,7 @@ std::string SourceCoverageView::getSourceName() const { SmallString<128> SourceText(SourceName); sys::path::remove_dots(SourceText, /*remove_dot_dots=*/true); sys::path::native(SourceText); - return SourceText.str(); + return std::string(SourceText.str()); } void SourceCoverageView::addExpansion( diff --git a/tools/llvm-cov/SourceCoverageViewHTML.cpp b/tools/llvm-cov/SourceCoverageViewHTML.cpp index e3332245f9c..1363e0a52c1 100644 --- a/tools/llvm-cov/SourceCoverageViewHTML.cpp +++ b/tools/llvm-cov/SourceCoverageViewHTML.cpp @@ -250,7 +250,7 @@ const char *CreatedTimeTag = "h4"; std::string getPathToStyle(StringRef ViewPath) { std::string PathToStyle = ""; - std::string PathSep = sys::path::get_separator(); + std::string PathSep = std::string(sys::path::get_separator()); unsigned NumSeps = ViewPath.count(PathSep); for (unsigned I = 0, E = NumSeps; I < E; ++I) PathToStyle += ".." + PathSep; @@ -359,7 +359,7 @@ void CoveragePrinterHTML::emitFileSummary(raw_ostream &OS, StringRef SF, // Simplify the display file path, and wrap it in a link if requested. std::string Filename; if (IsTotals) { - Filename = SF; + Filename = std::string(SF); } else { Filename = buildLinkToFile(SF, FCS); } @@ -507,7 +507,7 @@ void SourceCoverageViewHTML::renderLine(raw_ostream &OS, LineRef L, unsigned LCol = 1; auto Snip = [&](unsigned Start, unsigned Len) { - Snippets.push_back(Line.substr(Start, Len)); + Snippets.push_back(std::string(Line.substr(Start, Len))); LCol += Len; }; @@ -533,7 +533,7 @@ void SourceCoverageViewHTML::renderLine(raw_ostream &OS, LineRef L, auto Highlight = [&](const std::string &Snippet, unsigned LC, unsigned RC) { if (getOptions().Debug) HighlightedRanges.emplace_back(LC, RC); - return tag("span", Snippet, Color.getValue()); + return tag("span", Snippet, std::string(Color.getValue())); }; auto CheckIfUncovered = [&](const CoverageSegment *S) { diff --git a/tools/llvm-cxxfilt/llvm-cxxfilt.cpp b/tools/llvm-cxxfilt/llvm-cxxfilt.cpp index 6de512fc18d..93d6322a167 100644 --- a/tools/llvm-cxxfilt/llvm-cxxfilt.cpp +++ b/tools/llvm-cxxfilt/llvm-cxxfilt.cpp @@ -145,9 +145,9 @@ static void demangleLine(llvm::raw_ostream &OS, StringRef Mangled, bool Split) { SmallVector, 16> Words; SplitStringDelims(Mangled, Words, IsLegalItaniumChar); for (const auto &Word : Words) - Result += ::demangle(Word.first) + Word.second.str(); + Result += ::demangle(std::string(Word.first)) + Word.second.str(); } else - Result = ::demangle(Mangled); + Result = ::demangle(std::string(Mangled)); OS << Result << '\n'; OS.flush(); } diff --git a/tools/llvm-dwarfdump/Statistics.cpp b/tools/llvm-dwarfdump/Statistics.cpp index f0656c19986..b4683bbd7a4 100644 --- a/tools/llvm-dwarfdump/Statistics.cpp +++ b/tools/llvm-dwarfdump/Statistics.cpp @@ -180,7 +180,7 @@ static std::string constructDieID(DWARFDie Die, if (LT->getFileNameByIndex( dwarf::toUnsigned(DeclFile, 0), U->getCompilationDir(), DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath, File)) - File = sys::path::filename(File); + File = std::string(sys::path::filename(File)); } ID << ":" << (File.empty() ? "/" : File); ID << ":" diff --git a/tools/llvm-elfabi/ELFObjHandler.cpp b/tools/llvm-elfabi/ELFObjHandler.cpp index b886a8dff25..124fffbb9cf 100644 --- a/tools/llvm-elfabi/ELFObjHandler.cpp +++ b/tools/llvm-elfabi/ELFObjHandler.cpp @@ -233,7 +233,7 @@ static ELFSymbolType convertInfoToType(uint8_t Info) { template static ELFSymbol createELFSym(StringRef SymName, const typename ELFT::Sym &RawSym) { - ELFSymbol TargetSym(SymName); + ELFSymbol TargetSym{std::string(SymName)}; uint8_t Binding = RawSym.getBinding(); if (Binding == STB_WEAK) TargetSym.Weak = true; @@ -331,7 +331,7 @@ buildStub(const ELFObjectFile &ElfObj) { if (!NameOrErr) { return appendToError(NameOrErr.takeError(), "when reading DT_SONAME"); } - DestStub->SoName = *NameOrErr; + DestStub->SoName = std::string(*NameOrErr); } // Populate NeededLibs from .dynamic entries and dynamic string table. @@ -341,7 +341,7 @@ buildStub(const ELFObjectFile &ElfObj) { if (!LibNameOrErr) { return appendToError(LibNameOrErr.takeError(), "when reading DT_NEEDED"); } - DestStub->NeededLibs.push_back(*LibNameOrErr); + DestStub->NeededLibs.push_back(std::string(*LibNameOrErr)); } // Populate Symbols from .dynsym table and dynamic string table. diff --git a/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/tools/llvm-exegesis/lib/BenchmarkRunner.cpp index 452cebf0ce5..b4a1c62a2af 100644 --- a/tools/llvm-exegesis/lib/BenchmarkRunner.cpp +++ b/tools/llvm-exegesis/lib/BenchmarkRunner.cpp @@ -84,7 +84,7 @@ InstructionBenchmark BenchmarkRunner::runConfiguration( const SnippetRepetitor &Repetitor, bool DumpObjectToDisk) const { InstructionBenchmark InstrBenchmark; InstrBenchmark.Mode = Mode; - InstrBenchmark.CpuName = State.getTargetMachine().getTargetCPU(); + InstrBenchmark.CpuName = std::string(State.getTargetMachine().getTargetCPU()); InstrBenchmark.LLVMTriple = State.getTargetMachine().getTargetTriple().normalize(); InstrBenchmark.NumRepetitions = NumRepetitions; @@ -165,7 +165,7 @@ BenchmarkRunner::writeObjectFile(const BenchmarkCode &BC, raw_fd_ostream OFS(ResultFD, true /*ShouldClose*/); assembleToStream(State.getExegesisTarget(), State.createTargetMachine(), BC.LiveIns, BC.Key.RegisterInitialValues, FillFunction, OFS); - return ResultPath.str(); + return std::string(ResultPath.str()); } BenchmarkRunner::FunctionExecutor::~FunctionExecutor() {} diff --git a/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp b/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp index 3451edf2733..fea6dc95ce8 100644 --- a/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp +++ b/tools/llvm-exegesis/lib/SerialSnippetGenerator.cpp @@ -102,7 +102,7 @@ static void appendCodeTemplates(const LLVMState &State, // serial. CodeTemplate CT; CT.Execution = ExecutionModeBit; - CT.Info = ExecutionClassDescription; + CT.Info = std::string(ExecutionClassDescription); CT.Instructions.push_back(Instr); CodeTemplates.push_back(std::move(CT)); return; @@ -124,7 +124,7 @@ static void appendCodeTemplates(const LLVMState &State, setRandomAliasing(SelfAliasing, IT, IT); CodeTemplate CT; CT.Execution = ExecutionModeBit; - CT.Info = ExecutionClassDescription; + CT.Info = std::string(ExecutionClassDescription); CT.Instructions.push_back(std::move(IT)); CodeTemplates.push_back(std::move(CT)); return; @@ -143,7 +143,7 @@ static void appendCodeTemplates(const LLVMState &State, setRandomAliasing(Back, OtherIT, ThisIT); CodeTemplate CT; CT.Execution = ExecutionModeBit; - CT.Info = ExecutionClassDescription; + CT.Info = std::string(ExecutionClassDescription); CT.Instructions.push_back(std::move(ThisIT)); CT.Instructions.push_back(std::move(OtherIT)); CodeTemplates.push_back(std::move(CT)); diff --git a/tools/llvm-exegesis/lib/SnippetGenerator.cpp b/tools/llvm-exegesis/lib/SnippetGenerator.cpp index af3709486ec..21932f416aa 100644 --- a/tools/llvm-exegesis/lib/SnippetGenerator.cpp +++ b/tools/llvm-exegesis/lib/SnippetGenerator.cpp @@ -160,7 +160,8 @@ generateUnconstrainedCodeTemplates(const Instruction &Instr, StringRef Msg) { std::vector Result; Result.emplace_back(); CodeTemplate &CT = Result.back(); - CT.Info = formatv("{0}, repeating an unconstrained assignment", Msg); + CT.Info = + std::string(formatv("{0}, repeating an unconstrained assignment", Msg)); CT.Instructions.emplace_back(&Instr); return std::move(Result); } diff --git a/tools/llvm-ifs/llvm-ifs.cpp b/tools/llvm-ifs/llvm-ifs.cpp index d5816f49f65..3b0d2ee725f 100644 --- a/tools/llvm-ifs/llvm-ifs.cpp +++ b/tools/llvm-ifs/llvm-ifs.cpp @@ -346,7 +346,7 @@ int writeElfStub(const llvm::Triple &T, const std::set &Symbols, } OS << "...\n"; - std::string YamlStr = OS.str(); + std::string YamlStr = std::string(OS.str()); // Only or debugging. Not an offical format. LLVM_DEBUG({ diff --git a/tools/llvm-link/llvm-link.cpp b/tools/llvm-link/llvm-link.cpp index fa36e083b6f..d0c2b4555b9 100644 --- a/tools/llvm-link/llvm-link.cpp +++ b/tools/llvm-link/llvm-link.cpp @@ -264,7 +264,7 @@ static bool importFunctions(const char *argv0, Module &DestModule) { Entry.insert(F->getGUID()); } auto CachedModuleLoader = [&](StringRef Identifier) { - return ModuleLoaderCache.takeModule(Identifier); + return ModuleLoaderCache.takeModule(std::string(Identifier)); }; FunctionImporter Importer(*Index, CachedModuleLoader); ExitOnErr(Importer.importFunctions(DestModule, ImportList)); diff --git a/tools/llvm-lipo/llvm-lipo.cpp b/tools/llvm-lipo/llvm-lipo.cpp index a82030b1359..e75327ee53a 100644 --- a/tools/llvm-lipo/llvm-lipo.cpp +++ b/tools/llvm-lipo/llvm-lipo.cpp @@ -169,7 +169,8 @@ public: Slice(const MachOObjectFile *O, uint32_t Align) : B(O), CPUType(O->getHeader().cputype), CPUSubType(O->getHeader().cpusubtype), - ArchName(O->getArchTriple().getArchName()), P2Alignment(Align) {} + ArchName(std::string(O->getArchTriple().getArchName())), + P2Alignment(Align) {} explicit Slice(const MachOObjectFile *O) : Slice(O, calculateAlignment(O)){}; @@ -214,7 +215,7 @@ public: .str()); CPUType = FO->getHeader().cputype; CPUSubType = FO->getHeader().cpusubtype; - ArchName = FO->getArchTriple().getArchName(); + ArchName = std::string(FO->getArchTriple().getArchName()); // Replicate the behavior of cctools lipo. P2Alignment = FO->is64Bit() ? 3 : 2; } @@ -316,7 +317,7 @@ static Config parseLipoOptions(ArrayRef ArgsArr) { reportError("at least one input file should be specified"); if (InputArgs.hasArg(LIPO_output)) - C.OutputFile = InputArgs.getLastArgValue(LIPO_output); + C.OutputFile = std::string(InputArgs.getLastArgValue(LIPO_output)); for (auto Segalign : InputArgs.filtered(LIPO_segalign)) { if (!Segalign->getValue(1)) diff --git a/tools/llvm-lto/llvm-lto.cpp b/tools/llvm-lto/llvm-lto.cpp index b47e68e8285..12851799f33 100644 --- a/tools/llvm-lto/llvm-lto.cpp +++ b/tools/llvm-lto/llvm-lto.cpp @@ -454,7 +454,7 @@ static std::string getThinLTOOutputFile(const std::string &Path, if (std::error_code EC = llvm::sys::fs::create_directories(ParentPath)) error(EC, "error creating the directory '" + ParentPath + "'"); } - return NewPath.str(); + return std::string(NewPath.str()); } namespace thinlto { @@ -957,7 +957,7 @@ int main(int argc, char **argv) { lto_symbol_attributes Attrs = Module->getSymbolAttributes(I); unsigned Scope = Attrs & LTO_SYMBOL_SCOPE_MASK; if (Scope != LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN) - KeptDSOSyms.push_back(Name); + KeptDSOSyms.push_back(std::string(Name)); } // We use the first input module as the destination module when diff --git a/tools/llvm-lto2/llvm-lto2.cpp b/tools/llvm-lto2/llvm-lto2.cpp index 67a677dd45f..8deedd49e05 100644 --- a/tools/llvm-lto2/llvm-lto2.cpp +++ b/tools/llvm-lto2/llvm-lto2.cpp @@ -203,7 +203,8 @@ static int run(int argc, char **argv) { return 1; } } - CommandLineResolutions[{FileName, SymbolName}].push_back(Res); + CommandLineResolutions[{std::string(FileName), std::string(SymbolName)}] + .push_back(Res); } std::vector> MBs; @@ -292,14 +293,14 @@ static int run(int argc, char **argv) { std::vector Res; for (const InputFile::Symbol &Sym : Input->symbols()) { - auto I = CommandLineResolutions.find({F, Sym.getName()}); + auto I = CommandLineResolutions.find({F, std::string(Sym.getName())}); // If it isn't found, look for "$", which would have been added // (followed by a hash) when the symbol was promoted during module // splitting if it was defined in one part and used in the other. // Try looking up the symbol name before the "$". if (I == CommandLineResolutions.end()) { auto SplitName = Sym.getName().rsplit("$"); - I = CommandLineResolutions.find({F, SplitName.first}); + I = CommandLineResolutions.find({F, std::string(SplitName.first)}); } if (I == CommandLineResolutions.end()) { llvm::errs() << argv[0] << ": missing symbol resolution for " << F @@ -354,8 +355,10 @@ static int run(int argc, char **argv) { static int dumpSymtab(int argc, char **argv) { for (StringRef F : make_range(argv + 1, argv + argc)) { - std::unique_ptr MB = check(MemoryBuffer::getFile(F), F); - BitcodeFileContents BFC = check(getBitcodeFileContents(*MB), F); + std::unique_ptr MB = + check(MemoryBuffer::getFile(F), std::string(F)); + BitcodeFileContents BFC = + check(getBitcodeFileContents(*MB), std::string(F)); if (BFC.Symtab.size() >= sizeof(irsymtab::storage::Header)) { auto *Hdr = reinterpret_cast( @@ -367,7 +370,7 @@ static int dumpSymtab(int argc, char **argv) { } std::unique_ptr Input = - check(InputFile::create(MB->getMemBufferRef()), F); + check(InputFile::create(MB->getMemBufferRef()), std::string(F)); outs() << "target triple: " << Input->getTargetTriple() << '\n'; Triple TT(Input->getTargetTriple()); diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp index 6aa347d98be..25f02b92dad 100644 --- a/tools/llvm-mc/llvm-mc.cpp +++ b/tools/llvm-mc/llvm-mc.cpp @@ -399,7 +399,7 @@ int main(int argc, char **argv) { } for (const auto &Arg : DebugPrefixMap) { const auto &KV = StringRef(Arg).split('='); - Ctx.addDebugPrefixMapEntry(KV.first, KV.second); + Ctx.addDebugPrefixMapEntry(std::string(KV.first), std::string(KV.second)); } if (!MainFileName.empty()) Ctx.setMainFileName(MainFileName); diff --git a/tools/llvm-mca/llvm-mca.cpp b/tools/llvm-mca/llvm-mca.cpp index fff5906bb59..06c1ce957f7 100644 --- a/tools/llvm-mca/llvm-mca.cpp +++ b/tools/llvm-mca/llvm-mca.cpp @@ -324,7 +324,7 @@ int main(int argc, char **argv) { processViewOptions(); if (!MCPU.compare("native")) - MCPU = llvm::sys::getHostCPUName(); + MCPU = std::string(llvm::sys::getHostCPUName()); std::unique_ptr STI( TheTarget->createMCSubtargetInfo(TripleName, MCPU, MATTR)); diff --git a/tools/llvm-ml/llvm-ml.cpp b/tools/llvm-ml/llvm-ml.cpp index 38c4861c480..1b30f3e831e 100644 --- a/tools/llvm-ml/llvm-ml.cpp +++ b/tools/llvm-ml/llvm-ml.cpp @@ -278,7 +278,7 @@ int main(int argc, char **argv) { } for (const auto &Arg : DebugPrefixMap) { const auto &KV = StringRef(Arg).split('='); - Ctx.addDebugPrefixMapEntry(KV.first, KV.second); + Ctx.addDebugPrefixMapEntry(std::string(KV.first), std::string(KV.second)); } if (!MainFileName.empty()) Ctx.setMainFileName(MainFileName); diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index 2cd74af08c8..e0485514d93 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -1903,7 +1903,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) { if (SymbolicFile *O = dyn_cast(&*ChildOrErr.get())) { if (PrintFileName) { - ArchiveName = A->getFileName(); + ArchiveName = std::string(A->getFileName()); if (ArchFlags.size() > 1) ArchitectureName = I->getArchFlagName(); } else { @@ -1972,7 +1972,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) { if (SymbolicFile *O = dyn_cast(&*ChildOrErr.get())) { if (PrintFileName) - ArchiveName = A->getFileName(); + ArchiveName = std::string(A->getFileName()); else outs() << "\n" << A->getFileName() << "(" << O->getFileName() << ")" @@ -2037,7 +2037,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) { } if (SymbolicFile *F = dyn_cast(&*ChildOrErr.get())) { if (PrintFileName) { - ArchiveName = A->getFileName(); + ArchiveName = std::string(A->getFileName()); if (isa(F) && moreThanOneArch) ArchitectureName = O.getArchFlagName(); } else { diff --git a/tools/llvm-objcopy/ELF/ELFObjcopy.cpp b/tools/llvm-objcopy/ELF/ELFObjcopy.cpp index fcf210903f6..d12eff718f5 100644 --- a/tools/llvm-objcopy/ELF/ELFObjcopy.cpp +++ b/tools/llvm-objcopy/ELF/ELFObjcopy.cpp @@ -390,7 +390,7 @@ static Error updateAndRemoveSymbols(const CopyConfig &Config, Object &Obj) { const auto I = Config.SymbolsToRename.find(Sym.Name); if (I != Config.SymbolsToRename.end()) - Sym.Name = I->getValue(); + Sym.Name = std::string(I->getValue()); if (!Config.SymbolsPrefix.empty() && Sym.Type != STT_SECTION) Sym.Name = (Config.SymbolsPrefix + Sym.Name).str(); @@ -627,7 +627,7 @@ static Error handleArgs(const CopyConfig &Config, Object &Obj, const auto Iter = Config.SectionsToRename.find(Sec.Name); if (Iter != Config.SectionsToRename.end()) { const SectionRename &SR = Iter->second; - Sec.Name = SR.NewName; + Sec.Name = std::string(SR.NewName); if (SR.NewFlags.hasValue()) setSectionFlagsAndType(Sec, SR.NewFlags.getValue()); } diff --git a/tools/llvm-objcopy/ELF/Object.cpp b/tools/llvm-objcopy/ELF/Object.cpp index ad53c75663e..14ac7bba24f 100644 --- a/tools/llvm-objcopy/ELF/Object.cpp +++ b/tools/llvm-objcopy/ELF/Object.cpp @@ -1520,7 +1520,7 @@ template void ELFBuilder::readSectionHeaders() { continue; } auto &Sec = makeSection(Shdr); - Sec.Name = unwrapOrError(ElfFile.getSectionName(&Shdr)); + Sec.Name = std::string(unwrapOrError(ElfFile.getSectionName(&Shdr))); Sec.Type = Sec.OriginalType = Shdr.sh_type; Sec.Flags = Sec.OriginalFlags = Shdr.sh_flags; Sec.Addr = Shdr.sh_addr; diff --git a/tools/llvm-objcopy/MachO/MachOObjcopy.cpp b/tools/llvm-objcopy/MachO/MachOObjcopy.cpp index 4578d0bb75d..a4b771e8772 100644 --- a/tools/llvm-objcopy/MachO/MachOObjcopy.cpp +++ b/tools/llvm-objcopy/MachO/MachOObjcopy.cpp @@ -60,7 +60,7 @@ static void updateAndRemoveSymbols(const CopyConfig &Config, Object &Obj) { for (SymbolEntry &Sym : Obj.SymTable) { auto I = Config.SymbolsToRename.find(Sym.Name); if (I != Config.SymbolsToRename.end()) - Sym.Name = I->getValue(); + Sym.Name = std::string(I->getValue()); } auto RemovePred = [Config](const std::unique_ptr &N) { diff --git a/tools/llvm-objcopy/MachO/Object.h b/tools/llvm-objcopy/MachO/Object.h index dc2606eefa4..eb8db5735ab 100644 --- a/tools/llvm-objcopy/MachO/Object.h +++ b/tools/llvm-objcopy/MachO/Object.h @@ -55,11 +55,11 @@ struct Section { std::vector Relocations; Section(StringRef SegName, StringRef SectName) - : Segname(SegName), Sectname(SectName), + : Segname(std::string(SegName)), Sectname(std::string(SectName)), CanonicalName((Twine(SegName) + Twine(',') + SectName).str()) {} Section(StringRef SegName, StringRef SectName, StringRef Content) - : Segname(SegName), Sectname(SectName), + : Segname(std::string(SegName)), Sectname(std::string(SectName)), CanonicalName((Twine(SegName) + Twine(',') + SectName).str()), Content(Content) {} diff --git a/tools/llvm-objdump/ELFDump.cpp b/tools/llvm-objdump/ELFDump.cpp index f2d6754b403..d2543dff7d1 100644 --- a/tools/llvm-objdump/ELFDump.cpp +++ b/tools/llvm-objdump/ELFDump.cpp @@ -98,7 +98,7 @@ static Error getRelocationValueString(const ELFObjectFile *Obj, if (!SymName) return SymName.takeError(); if (Demangle) - Fmt << demangle(*SymName); + Fmt << demangle(std::string(*SymName)); else Fmt << *SymName; } diff --git a/tools/llvm-objdump/MachODump.cpp b/tools/llvm-objdump/MachODump.cpp index 87c7a92933f..a55ddb70e2c 100644 --- a/tools/llvm-objdump/MachODump.cpp +++ b/tools/llvm-objdump/MachODump.cpp @@ -7346,7 +7346,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF, SmallString<1024> FullPath(DSYMPath); llvm::sys::path::append(FullPath, "Contents", "Resources", "DWARF", ShortName); - DSYMPath = FullPath.str(); + DSYMPath = std::string(FullPath.str()); } // Load the file. diff --git a/tools/llvm-objdump/llvm-objdump.cpp b/tools/llvm-objdump/llvm-objdump.cpp index 6bd37a1fb86..984b3f58dad 100644 --- a/tools/llvm-objdump/llvm-objdump.cpp +++ b/tools/llvm-objdump/llvm-objdump.cpp @@ -397,7 +397,7 @@ std::string getFileNameForError(const object::Archive::Child &C, unsigned Index) { Expected NameOrErr = C.getName(); if (NameOrErr) - return NameOrErr.get(); + return std::string(NameOrErr.get()); // If we have an error getting the name then we print the index of the archive // member. Since we are already in an error state, we just ignore this error. consumeError(NameOrErr.takeError()); @@ -562,7 +562,7 @@ public: symbolize::LLVMSymbolizer::Options SymbolizerOpts; SymbolizerOpts.PrintFunctions = DILineInfoSpecifier::FunctionNameKind::None; SymbolizerOpts.Demangle = false; - SymbolizerOpts.DefaultArch = DefaultArch; + SymbolizerOpts.DefaultArch = std::string(DefaultArch); Symbolizer.reset(new symbolize::LLVMSymbolizer(SymbolizerOpts)); } virtual ~SourcePrinter() = default; @@ -1927,7 +1927,7 @@ void printSymbolTable(const ObjectFile *O, StringRef ArchiveName, } if (Demangle) - outs() << ' ' << demangle(Name) << '\n'; + outs() << ' ' << demangle(std::string(Name)) << '\n'; else outs() << ' ' << Name << '\n'; } diff --git a/tools/llvm-opt-report/OptReport.cpp b/tools/llvm-opt-report/OptReport.cpp index 4aecec2749e..8d7ecfb2d01 100644 --- a/tools/llvm-opt-report/OptReport.cpp +++ b/tools/llvm-opt-report/OptReport.cpp @@ -225,14 +225,17 @@ static bool readLocationInfo(LocationInfoTy &LocationInfo) { }; if (Remark.PassName == "inline") { - auto &LI = LocationInfo[File][Line][Remark.FunctionName][Column]; + auto &LI = LocationInfo[std::string(File)][Line] + [std::string(Remark.FunctionName)][Column]; UpdateLLII(LI.Inlined); } else if (Remark.PassName == "loop-unroll") { - auto &LI = LocationInfo[File][Line][Remark.FunctionName][Column]; + auto &LI = LocationInfo[std::string(File)][Line] + [std::string(Remark.FunctionName)][Column]; LI.UnrollCount = UnrollCount; UpdateLLII(LI.Unrolled); } else if (Remark.PassName == "loop-vectorize") { - auto &LI = LocationInfo[File][Line][Remark.FunctionName][Column]; + auto &LI = LocationInfo[std::string(File)][Line] + [std::string(Remark.FunctionName)][Column]; LI.VectorizationFactor = VectorizationFactor; LI.InterleaveCount = InterleaveCount; UpdateLLII(LI.Vectorized); diff --git a/tools/llvm-pdbutil/DumpOutputStyle.cpp b/tools/llvm-pdbutil/DumpOutputStyle.cpp index bf725ad8d60..32448cec88f 100644 --- a/tools/llvm-pdbutil/DumpOutputStyle.cpp +++ b/tools/llvm-pdbutil/DumpOutputStyle.cpp @@ -896,7 +896,7 @@ Error DumpOutputStyle::dumpUdtStats() { return L.Stat.Size > R.Stat.Size; }); for (const auto &Stat : NamespacedStatsSorted) { - std::string Label = formatv("namespace '{0}'", Stat.Key); + std::string Label = std::string(formatv("namespace '{0}'", Stat.Key)); P.formatLine("{0} | {1:N} {2:N}", fmt_align(Label, AlignStyle::Right, FieldWidth), fmt_align(Stat.Stat.Count, AlignStyle::Right, CD), @@ -1039,7 +1039,7 @@ Error DumpOutputStyle::dumpXmi() { } std::vector TIs; for (const auto I : Xmi.Imports) - TIs.push_back(formatv("{0,+10:X+}", fmtle(I))); + TIs.push_back(std::string(formatv("{0,+10:X+}", fmtle(I)))); std::string Result = typesetItemList(TIs, P.getIndentLevel() + 35, 12, " "); P.formatLine("{0,+32} | {1}", Module, Result); diff --git a/tools/llvm-pdbutil/FormatUtil.cpp b/tools/llvm-pdbutil/FormatUtil.cpp index 1a13f383e53..c9ef1960949 100644 --- a/tools/llvm-pdbutil/FormatUtil.cpp +++ b/tools/llvm-pdbutil/FormatUtil.cpp @@ -20,7 +20,7 @@ using namespace llvm::pdb; std::string llvm::pdb::truncateStringBack(StringRef S, uint32_t MaxLen) { if (MaxLen == 0 || S.size() <= MaxLen || S.size() <= 3) - return S; + return std::string(S); assert(MaxLen >= 3); uint32_t FinalLen = std::min(S.size(), MaxLen - 3); @@ -30,7 +30,7 @@ std::string llvm::pdb::truncateStringBack(StringRef S, uint32_t MaxLen) { std::string llvm::pdb::truncateStringMiddle(StringRef S, uint32_t MaxLen) { if (MaxLen == 0 || S.size() <= MaxLen || S.size() <= 3) - return S; + return std::string(S); assert(MaxLen >= 3); uint32_t FinalLen = std::min(S.size(), MaxLen - 3); @@ -41,7 +41,7 @@ std::string llvm::pdb::truncateStringMiddle(StringRef S, uint32_t MaxLen) { std::string llvm::pdb::truncateStringFront(StringRef S, uint32_t MaxLen) { if (MaxLen == 0 || S.size() <= MaxLen || S.size() <= 3) - return S; + return std::string(S); assert(MaxLen >= 3); S = S.take_back(MaxLen - 3); @@ -82,7 +82,7 @@ std::string llvm::pdb::typesetItemList(ArrayRef Opts, if (!Opts.empty()) { Result += Sep; Result += "\n"; - Result += formatv("{0}", fmt_repeat(' ', IndentLevel)); + Result += std::string(formatv("{0}", fmt_repeat(' ', IndentLevel))); } } return Result; @@ -92,7 +92,7 @@ std::string llvm::pdb::typesetStringList(uint32_t IndentLevel, ArrayRef Strings) { std::string Result = "["; for (const auto &S : Strings) { - Result += formatv("\n{0}{1}", fmt_repeat(' ', IndentLevel), S); + Result += std::string(formatv("\n{0}{1}", fmt_repeat(' ', IndentLevel), S)); } Result += "]"; return Result; @@ -169,7 +169,7 @@ StringRef llvm::pdb::formatTypeLeafKind(TypeLeafKind K) { } std::string llvm::pdb::formatSegmentOffset(uint16_t Segment, uint32_t Offset) { - return formatv("{0:4}:{1:4}", Segment, Offset); + return std::string(formatv("{0:4}:{1:4}", Segment, Offset)); } #define PUSH_CHARACTERISTIC_FLAG(Enum, TheOpt, Value, Style, Descriptive) \ diff --git a/tools/llvm-pdbutil/MinimalSymbolDumper.cpp b/tools/llvm-pdbutil/MinimalSymbolDumper.cpp index ebfa50625e7..7a06140855f 100644 --- a/tools/llvm-pdbutil/MinimalSymbolDumper.cpp +++ b/tools/llvm-pdbutil/MinimalSymbolDumper.cpp @@ -371,9 +371,9 @@ std::string MinimalSymbolDumper::typeOrIdIndex(codeview::TypeIndex TI, StringRef Name = Container.getTypeName(TI); if (Name.size() > 32) { Name = Name.take_front(32); - return formatv("{0} ({1}...)", TI, Name); + return std::string(formatv("{0} ({1}...)", TI, Name)); } else - return formatv("{0} ({1})", TI, Name); + return std::string(formatv("{0} ({1})", TI, Name)); } std::string MinimalSymbolDumper::idIndex(codeview::TypeIndex TI) const { diff --git a/tools/llvm-pdbutil/MinimalTypeDumper.cpp b/tools/llvm-pdbutil/MinimalTypeDumper.cpp index 3fdef085f19..8e46a97272d 100644 --- a/tools/llvm-pdbutil/MinimalTypeDumper.cpp +++ b/tools/llvm-pdbutil/MinimalTypeDumper.cpp @@ -201,8 +201,9 @@ static std::string formatPointerAttrs(const PointerRecord &Record) { PointerMode Mode = Record.getMode(); PointerOptions Opts = Record.getOptions(); PointerKind Kind = Record.getPointerKind(); - return formatv("mode = {0}, opts = {1}, kind = {2}", formatPointerMode(Mode), - pointerOptions(Opts), pointerKind(Kind)); + return std::string(formatv("mode = {0}, opts = {1}, kind = {2}", + formatPointerMode(Mode), pointerOptions(Opts), + pointerKind(Kind))); } static std::string formatFunctionOptions(FunctionOptions Options) { diff --git a/tools/llvm-pdbutil/StreamUtil.cpp b/tools/llvm-pdbutil/StreamUtil.cpp index 7dfc2beefe7..d0d0a9fbe92 100644 --- a/tools/llvm-pdbutil/StreamUtil.cpp +++ b/tools/llvm-pdbutil/StreamUtil.cpp @@ -32,7 +32,7 @@ std::string StreamInfo::getLongName() const { StreamInfo StreamInfo::createStream(StreamPurpose Purpose, StringRef Name, uint32_t StreamIndex) { StreamInfo Result; - Result.Name = Name; + Result.Name = std::string(Name); Result.StreamIndex = StreamIndex; Result.Purpose = Purpose; return Result; @@ -41,7 +41,7 @@ StreamInfo StreamInfo::createStream(StreamPurpose Purpose, StringRef Name, StreamInfo StreamInfo::createModuleStream(StringRef Module, uint32_t StreamIndex, uint32_t Modi) { StreamInfo Result; - Result.Name = Module; + Result.Name = std::string(Module); Result.StreamIndex = StreamIndex; Result.ModuleIndex = Modi; Result.Purpose = StreamPurpose::ModuleStream; @@ -90,7 +90,7 @@ void llvm::pdb::discoverStreamPurposes(PDBFile &File, if (Info) { for (auto &NSE : Info->named_streams()) { if (NSE.second != kInvalidStreamIndex) - NamedStreams[NSE.second] = NSE.first(); + NamedStreams[NSE.second] = std::string(NSE.first()); } } diff --git a/tools/llvm-pdbutil/llvm-pdbutil.cpp b/tools/llvm-pdbutil/llvm-pdbutil.cpp index 9307300861d..5dc666e06a1 100644 --- a/tools/llvm-pdbutil/llvm-pdbutil.cpp +++ b/tools/llvm-pdbutil/llvm-pdbutil.cpp @@ -1507,7 +1507,7 @@ int main(int Argc, const char **Argv) { if (opts::yaml2pdb::YamlPdbOutputFile.empty()) { SmallString<16> OutputFilename(opts::yaml2pdb::InputFilename.getValue()); sys::path::replace_extension(OutputFilename, ".pdb"); - opts::yaml2pdb::YamlPdbOutputFile = OutputFilename.str(); + opts::yaml2pdb::YamlPdbOutputFile = std::string(OutputFilename.str()); } yamlToPdb(opts::yaml2pdb::InputFilename); } else if (opts::DiaDumpSubcommand) { diff --git a/tools/llvm-profdata/llvm-profdata.cpp b/tools/llvm-profdata/llvm-profdata.cpp index d98934b60a8..424edf446d0 100644 --- a/tools/llvm-profdata/llvm-profdata.cpp +++ b/tools/llvm-profdata/llvm-profdata.cpp @@ -73,15 +73,15 @@ static void exitWithError(Error E, StringRef Whence = "") { // Hint for common error of forgetting --sample for sample profiles. Hint = "Perhaps you forgot to use the --sample option?"; } - exitWithError(IPE.message(), Whence, Hint); + exitWithError(IPE.message(), std::string(Whence), std::string(Hint)); }); } - exitWithError(toString(std::move(E)), Whence); + exitWithError(toString(std::move(E)), std::string(Whence)); } static void exitWithErrorCode(std::error_code EC, StringRef Whence = "") { - exitWithError(EC.message(), Whence); + exitWithError(EC.message(), std::string(Whence)); } namespace { @@ -94,7 +94,7 @@ static void warnOrExitGivenError(FailureMode FailMode, std::error_code EC, if (FailMode == failIfAnyAreInvalid) exitWithErrorCode(EC, Whence); else - warn(EC.message(), Whence); + warn(EC.message(), std::string(Whence)); } static void handleMergeWriterError(Error E, StringRef WhenceFile = "", @@ -401,7 +401,8 @@ remapSamples(const sampleprof::FunctionSamples &Samples, for (const auto &Callsite : CallsiteSamples.second) { sampleprof::FunctionSamples Remapped = remapSamples(Callsite.second, Remapper, Error); - MergeResult(Error, Target[Remapped.getName()].merge(Remapped)); + MergeResult(Error, + Target[std::string(Remapped.getName())].merge(Remapped)); } } return Result; @@ -537,7 +538,7 @@ static WeightedFile parseWeightedFile(const StringRef &WeightedFilename) { if (WeightStr.getAsInteger(10, Weight) || Weight < 1) exitWithError("Input weight must be a positive integer."); - return {FileName, Weight}; + return {std::string(FileName), Weight}; } static void addWeightedInput(WeightedFileVector &WNI, const WeightedFile &WF) { @@ -546,7 +547,7 @@ static void addWeightedInput(WeightedFileVector &WNI, const WeightedFile &WF) { // If it's STDIN just pass it on. if (Filename == "-") { - WNI.push_back({Filename, Weight}); + WNI.push_back({std::string(Filename), Weight}); return; } @@ -557,7 +558,7 @@ static void addWeightedInput(WeightedFileVector &WNI, const WeightedFile &WF) { Filename); // If it's a source file, collect it. if (llvm::sys::fs::is_regular_file(Status)) { - WNI.push_back({Filename, Weight}); + WNI.push_back({std::string(Filename), Weight}); return; } @@ -589,7 +590,7 @@ static void parseInputFilenamesFile(MemoryBuffer *Buffer, continue; // If there's no comma, it's an unweighted profile. else if (SanitizedEntry.find(',') == StringRef::npos) - addWeightedInput(WFV, {SanitizedEntry, 1}); + addWeightedInput(WFV, {std::string(SanitizedEntry), 1}); else addWeightedInput(WFV, parseWeightedFile(SanitizedEntry)); } @@ -658,7 +659,7 @@ static int merge_main(int argc, const char *argv[]) { WeightedFileVector WeightedInputs; for (StringRef Filename : InputFilenames) - addWeightedInput(WeightedInputs, {Filename, 1}); + addWeightedInput(WeightedInputs, {std::string(Filename), 1}); for (StringRef WeightedFilename : WeightedInputFilenames) addWeightedInput(WeightedInputs, parseWeightedFile(WeightedFilename)); diff --git a/tools/llvm-rc/llvm-rc.cpp b/tools/llvm-rc/llvm-rc.cpp index 97cc7c88b68..a09960de418 100644 --- a/tools/llvm-rc/llvm-rc.cpp +++ b/tools/llvm-rc/llvm-rc.cpp @@ -168,7 +168,7 @@ int main(int Argc, const char **Argv) { if (OutArgsInfo.empty()) { SmallString<128> OutputFile = InputFile; llvm::sys::path::replace_extension(OutputFile, "res"); - OutArgsInfo.push_back(OutputFile.str()); + OutArgsInfo.push_back(std::string(OutputFile.str())); } if (OutArgsInfo.size() != 1) diff --git a/tools/llvm-readobj/COFFDumper.cpp b/tools/llvm-readobj/COFFDumper.cpp index 9b2c6adb9d9..ffe331a3d24 100644 --- a/tools/llvm-readobj/COFFDumper.cpp +++ b/tools/llvm-readobj/COFFDumper.cpp @@ -1135,7 +1135,7 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName, return; } - std::string PC = formatv("+{0:X}", uint32_t(Line.Offset)); + std::string PC = std::string(formatv("+{0:X}", uint32_t(Line.Offset))); ListScope PCScope(W, PC); codeview::LineInfo LI(Line.Flags); diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp index f321bab44c4..626ac415ee3 100644 --- a/tools/llvm-readobj/ELFDumper.cpp +++ b/tools/llvm-readobj/ELFDumper.cpp @@ -490,7 +490,7 @@ ELFDumper::getVersionDefinitions(const Elf_Shdr *Sec) const { VerdAux Aux; Aux.Offset = VerdauxBuf - Start; if (Verdaux->vda_name <= StrTabOrErr->size()) - Aux.Name = StrTabOrErr->drop_front(Verdaux->vda_name); + Aux.Name = std::string(StrTabOrErr->drop_front(Verdaux->vda_name)); else Aux.Name = "vda_name) + ">"; return Aux; @@ -600,7 +600,7 @@ ELFDumper::getVersionDependencies(const Elf_Shdr *Sec) const { VN.Offset = VerneedBuf - Start; if (Verneed->vn_file < StrTab.size()) - VN.File = StrTab.drop_front(Verneed->vn_file); + VN.File = std::string(StrTab.drop_front(Verneed->vn_file)); else VN.File = "vn_file) + ">"; @@ -630,7 +630,7 @@ ELFDumper::getVersionDependencies(const Elf_Shdr *Sec) const { if (StrTab.size() <= Vernaux->vna_name) Aux.Name = ""; else - Aux.Name = StrTab.drop_front(Vernaux->vna_name); + Aux.Name = std::string(StrTab.drop_front(Vernaux->vna_name)); VernauxBuf += Vernaux->vna_next; } @@ -806,7 +806,7 @@ private: std::string Str; unsigned Column; - Field(StringRef S, unsigned Col) : Str(S), Column(Col) {} + Field(StringRef S, unsigned Col) : Str(std::string(S)), Column(Col) {} Field(unsigned Col) : Column(Col) {} }; @@ -814,7 +814,7 @@ private: std::string printEnum(T Value, ArrayRef> EnumValues) { for (const auto &EnumItem : EnumValues) if (EnumItem.Value == Value) - return EnumItem.AltName; + return std::string(EnumItem.AltName); return to_hexString(Value, false); } @@ -988,7 +988,7 @@ template Error ELFDumper::LoadVersionMap() const { auto InsertEntry = [this](unsigned N, StringRef Version, bool IsVerdef) { if (N >= VersionMap.size()) VersionMap.resize(N + 1); - VersionMap[N] = {Version, IsVerdef}; + VersionMap[N] = {std::string(Version), IsVerdef}; }; if (SymbolVersionDefSection) { @@ -1036,7 +1036,7 @@ Expected ELFDumper::getSymbolVersion(const Elf_Sym *Sym, } static std::string maybeDemangle(StringRef Name) { - return opts::Demangle ? demangle(Name) : Name.str(); + return opts::Demangle ? demangle(std::string(Name)) : Name.str(); } template @@ -1106,7 +1106,7 @@ std::string ELFDumper::getFullSymbolName(const Elf_Sym *Symbol, ELFDumperStyle->reportUniqueWarning(NameOrErr.takeError()); return ("
").str(); } - return *NameOrErr; + return std::string(*NameOrErr); } if (!IsDynamic) @@ -3211,7 +3211,8 @@ void GNUStyle::printRelocation(const ELFO *Obj, const Elf_Shdr *SymTab, const Elf_Shdr *Sec = unwrapOrError( this->FileName, Obj->getSection(Sym, SymTab, this->dumper()->getShndxTable())); - TargetName = unwrapOrError(this->FileName, Obj->getSectionName(Sec)); + TargetName = + std::string(unwrapOrError(this->FileName, Obj->getSectionName(Sec))); } else if (Sym) { StringRef StrTable = unwrapOrError(this->FileName, Obj->getStringTableForSymtab(*SymTab)); @@ -3240,7 +3241,7 @@ void GNUStyle::printRelocation(const ELFO *Obj, const Elf_Sym *Sym, if (Sym && (!SymbolName.empty() || Sym->getValue() != 0)) Fields[3].Str = to_string(format_hex_no_prefix(Sym->getValue(), Width)); - Fields[4].Str = SymbolName; + Fields[4].Str = std::string(SymbolName); for (const Field &F : Fields) printField(F); @@ -3524,8 +3525,8 @@ void GNUStyle::printSectionHeaders(const ELFO *Obj) { if (SecStrTable.empty()) Fields[1].Str = ""; else - Fields[1].Str = unwrapOrError( - ElfObj->getFileName(), Obj->getSectionName(&Sec, SecStrTable)); + Fields[1].Str = std::string(unwrapOrError( + ElfObj->getFileName(), Obj->getSectionName(&Sec, SecStrTable))); Fields[2].Str = getSectionTypeString(Obj->getHeader()->e_machine, Sec.sh_type); Fields[3].Str = @@ -4732,7 +4733,7 @@ template static GNUAbiTag getGNUAbiTag(ArrayRef Desc) { std::string str; raw_string_ostream ABI(str); ABI << Major << "." << Minor << "." << Patch; - return {OSName, ABI.str(), /*IsValid=*/true}; + return {std::string(OSName), ABI.str(), /*IsValid=*/true}; } static std::string getGNUBuildId(ArrayRef Desc) { @@ -5626,7 +5627,8 @@ void LLVMStyle::printRelocation(const ELFO *Obj, Elf_Rela Rel, const Elf_Shdr *Sec = unwrapOrError( this->FileName, Obj->getSection(Sym, SymTab, this->dumper()->getShndxTable())); - TargetName = unwrapOrError(this->FileName, Obj->getSectionName(Sec)); + TargetName = + std::string(unwrapOrError(this->FileName, Obj->getSectionName(Sec))); } else if (Sym) { StringRef StrTable = unwrapOrError(this->FileName, Obj->getStringTableForSymtab(*SymTab)); diff --git a/tools/llvm-readobj/ObjDumper.cpp b/tools/llvm-readobj/ObjDumper.cpp index 6229b52693d..2359699e6eb 100644 --- a/tools/llvm-readobj/ObjDumper.cpp +++ b/tools/llvm-readobj/ObjDumper.cpp @@ -54,7 +54,7 @@ getSectionRefsByNameOrIndex(const object::ObjectFile *Obj, SecIndex = Obj->isELF() ? 0 : 1; for (object::SectionRef SecRef : Obj->sections()) { StringRef SecName = unwrapOrError(Obj->getFileName(), SecRef.getName()); - auto NameIt = SecNames.find(SecName); + auto NameIt = SecNames.find(std::string(SecName)); if (NameIt != SecNames.end()) NameIt->second = true; auto IndexIt = SecIndices.find(SecIndex); diff --git a/tools/llvm-readobj/llvm-readobj.cpp b/tools/llvm-readobj/llvm-readobj.cpp index fadeec1072d..869292a1907 100644 --- a/tools/llvm-readobj/llvm-readobj.cpp +++ b/tools/llvm-readobj/llvm-readobj.cpp @@ -456,8 +456,9 @@ static void dumpObject(const ObjectFile *Obj, ScopedPrinter &Writer, Writer.printString("Format", Obj->getFileFormatName()); Writer.printString("Arch", Triple::getArchTypeName( (llvm::Triple::ArchType)Obj->getArch())); - Writer.printString("AddressSize", - formatv("{0}bit", 8 * Obj->getBytesInAddress())); + Writer.printString( + "AddressSize", + std::string(formatv("{0}bit", 8 * Obj->getBytesInAddress()))); Dumper->printLoadName(); } diff --git a/tools/llvm-reduce/deltas/Delta.cpp b/tools/llvm-reduce/deltas/Delta.cpp index 0642241ddeb..3c55adf64db 100644 --- a/tools/llvm-reduce/deltas/Delta.cpp +++ b/tools/llvm-reduce/deltas/Delta.cpp @@ -47,7 +47,7 @@ bool IsReduced(Module &M, TestRunner &Test, SmallString<128> &CurrentFilepath) { static int getLines(StringRef Filepath) { int Lines = 0; std::string CurrLine; - std::ifstream FileStream(Filepath); + std::ifstream FileStream{std::string(Filepath)}; while (std::getline(FileStream, CurrLine)) ++Lines; diff --git a/tools/llvm-reduce/deltas/ReduceArguments.cpp b/tools/llvm-reduce/deltas/ReduceArguments.cpp index f5f14b83f42..d5f60aad36b 100644 --- a/tools/llvm-reduce/deltas/ReduceArguments.cpp +++ b/tools/llvm-reduce/deltas/ReduceArguments.cpp @@ -93,7 +93,7 @@ static void extractArgumentsFromModule(std::vector ChunksToKeep, replaceFunctionCalls(*F, *ClonedFunc, ArgIndexesToKeep); // Rename Cloned Function to Old's name - std::string FName = F->getName(); + std::string FName = std::string(F->getName()); F->eraseFromParent(); ClonedFunc->setName(FName); } diff --git a/tools/llvm-rtdyld/llvm-rtdyld.cpp b/tools/llvm-rtdyld/llvm-rtdyld.cpp index 9b84c46d390..be5dbdd1c55 100644 --- a/tools/llvm-rtdyld/llvm-rtdyld.cpp +++ b/tools/llvm-rtdyld/llvm-rtdyld.cpp @@ -189,7 +189,7 @@ class TrivialMemoryManager : public RTDyldMemoryManager { public: struct SectionInfo { SectionInfo(StringRef Name, sys::MemoryBlock MB, unsigned SectionID) - : Name(Name), MB(std::move(MB)), SectionID(SectionID) {} + : Name(std::string(Name)), MB(std::move(MB)), SectionID(SectionID) {} std::string Name; sys::MemoryBlock MB; unsigned SectionID = ~0U; @@ -599,7 +599,7 @@ void applySpecificSectionMappings(RuntimeDyld &Dyld, for (StringRef Mapping : SpecificSectionMappings) { size_t EqualsIdx = Mapping.find_first_of("="); - std::string SectionIDStr = Mapping.substr(0, EqualsIdx); + std::string SectionIDStr = std::string(Mapping.substr(0, EqualsIdx)); size_t ComaIdx = Mapping.find_first_of(","); if (ComaIdx == StringRef::npos) @@ -612,7 +612,7 @@ void applySpecificSectionMappings(RuntimeDyld &Dyld, ExitOnErr(getSectionId(FileToSecIDMap, FileName, SectionName)); auto* OldAddr = Dyld.getSectionContent(SectionID).data(); - std::string NewAddrStr = Mapping.substr(EqualsIdx + 1); + std::string NewAddrStr = std::string(Mapping.substr(EqualsIdx + 1)); uint64_t NewAddr; if (StringRef(NewAddrStr).getAsInteger(0, NewAddr)) diff --git a/tools/llvm-undname/llvm-undname.cpp b/tools/llvm-undname/llvm-undname.cpp index aee9946b290..7c3682510f6 100644 --- a/tools/llvm-undname/llvm-undname.cpp +++ b/tools/llvm-undname/llvm-undname.cpp @@ -87,7 +87,7 @@ int main(int argc, char **argv) { << "\': " << EC.message() << '\n'; return 1; } - return msDemangle(FileOrErr->get()->getBuffer()) ? 0 : 1; + return msDemangle(std::string(FileOrErr->get()->getBuffer())) ? 0 : 1; } bool Success = true; @@ -111,7 +111,7 @@ int main(int argc, char **argv) { outs() << Line << "\n"; outs().flush(); } - if (!msDemangle(Line)) + if (!msDemangle(std::string(Line))) Success = false; outs() << "\n"; } @@ -119,7 +119,7 @@ int main(int argc, char **argv) { for (StringRef S : Symbols) { outs() << S << "\n"; outs().flush(); - if (!msDemangle(S)) + if (!msDemangle(std::string(S))) Success = false; outs() << "\n"; } diff --git a/tools/llvm-xray/xray-color-helper.cpp b/tools/llvm-xray/xray-color-helper.cpp index c09cad3ba7d..ea7ff357826 100644 --- a/tools/llvm-xray/xray-color-helper.cpp +++ b/tools/llvm-xray/xray-color-helper.cpp @@ -208,8 +208,8 @@ ColorHelper::getColorTuple(double Point) const { // string. std::string ColorHelper::getColorString(std::tuple t) { - return llvm::formatv("#{0:X-2}{1:X-2}{2:X-2}", std::get<0>(t), std::get<1>(t), - std::get<2>(t)); + return std::string(llvm::formatv("#{0:X-2}{1:X-2}{2:X-2}", std::get<0>(t), + std::get<1>(t), std::get<2>(t))); } // Gets a color in a gradient given a number in the interval [0,1], it does this diff --git a/tools/llvm-xray/xray-graph-diff.cpp b/tools/llvm-xray/xray-graph-diff.cpp index a1bca326930..11210e2004a 100644 --- a/tools/llvm-xray/xray-graph-diff.cpp +++ b/tools/llvm-xray/xray-graph-diff.cpp @@ -314,7 +314,7 @@ static std::string getLabel(const GraphDiffRenderer::GraphT::EdgeValueType &E, const auto &RightStat = EdgeAttr.CorrEdgePtr[1]->second.S; double RelDiff = statRelDiff(LeftStat, RightStat, EL); - return formatv(R"({0:P})", RelDiff); + return std::string(formatv(R"({0:P})", RelDiff)); } } @@ -324,17 +324,19 @@ static std::string getLabel(const GraphDiffRenderer::GraphT::VertexValueType &V, const auto &VertexAttr = V.second; switch (VL) { case GraphDiffRenderer::StatType::NONE: - return formatv(R"({0})", truncateString(VertexId, TrunLen).str()); + return std::string( + formatv(R"({0})", truncateString(VertexId, TrunLen).str())); default: if (containsNullptr(VertexAttr.CorrVertexPtr)) - return formatv(R"({0})", truncateString(VertexId, TrunLen).str()); + return std::string( + formatv(R"({0})", truncateString(VertexId, TrunLen).str())); const auto &LeftStat = VertexAttr.CorrVertexPtr[0]->second.S; const auto &RightStat = VertexAttr.CorrVertexPtr[1]->second.S; double RelDiff = statRelDiff(LeftStat, RightStat, VL); - return formatv(R"({{{0}|{1:P}})", truncateString(VertexId, TrunLen).str(), - RelDiff); + return std::string(formatv( + R"({{{0}|{1:P}})", truncateString(VertexId, TrunLen).str(), RelDiff)); } } diff --git a/tools/llvm-xray/xray-stacks.cpp b/tools/llvm-xray/xray-stacks.cpp index cf292887b6b..1e449028953 100644 --- a/tools/llvm-xray/xray-stacks.cpp +++ b/tools/llvm-xray/xray-stacks.cpp @@ -674,11 +674,12 @@ std::string CreateErrorMessage(StackTrie::AccountRecordStatus Error, const FuncIdConversionHelper &Converter) { switch (Error) { case StackTrie::AccountRecordStatus::ENTRY_NOT_FOUND: - return formatv("Found record {0} with no matching function entry\n", - format_xray_record(Record, Converter)); + return std::string( + formatv("Found record {0} with no matching function entry\n", + format_xray_record(Record, Converter))); default: - return formatv("Unknown error type for record {0}\n", - format_xray_record(Record, Converter)); + return std::string(formatv("Unknown error type for record {0}\n", + format_xray_record(Record, Converter))); } } diff --git a/tools/obj2yaml/elf2yaml.cpp b/tools/obj2yaml/elf2yaml.cpp index 904d1ad9d0a..199a482fc39 100644 --- a/tools/obj2yaml/elf2yaml.cpp +++ b/tools/obj2yaml/elf2yaml.cpp @@ -115,7 +115,7 @@ ELFDumper::getUniquedSectionName(const Elf_Shdr *Sec) { if (!It.second) Ret = (Name + " [" + Twine(++It.first->second) + "]").str(); else - Ret = Name; + Ret = std::string(Name); return Ret; } @@ -147,7 +147,7 @@ ELFDumper::getUniquedSymbolName(const Elf_Sym *Sym, StringRef StrTable, SymbolNames[Index] = (Name + " [" + Twine(++It.first->second) + "]").str(); else - SymbolNames[Index] = Name; + SymbolNames[Index] = std::string(Name); return SymbolNames[Index]; } diff --git a/tools/opt/PassPrinters.cpp b/tools/opt/PassPrinters.cpp index a877d9dc90f..ed4fc1a8174 100644 --- a/tools/opt/PassPrinters.cpp +++ b/tools/opt/PassPrinters.cpp @@ -37,7 +37,7 @@ struct FunctionPassPrinter : public FunctionPass { FunctionPassPrinter(const PassInfo *PI, raw_ostream &out, bool Quiet) : FunctionPass(ID), PassToPrint(PI), Out(out), QuietPass(Quiet) { - std::string PassToPrintName = PassToPrint->getPassName(); + std::string PassToPrintName = std::string(PassToPrint->getPassName()); PassName = "FunctionPass Printer: " + PassToPrintName; } @@ -70,7 +70,7 @@ struct CallGraphSCCPassPrinter : public CallGraphSCCPass { CallGraphSCCPassPrinter(const PassInfo *PI, raw_ostream &out, bool Quiet) : CallGraphSCCPass(ID), PassToPrint(PI), Out(out), QuietPass(Quiet) { - std::string PassToPrintName = PassToPrint->getPassName(); + std::string PassToPrintName = std::string(PassToPrint->getPassName()); PassName = "CallGraphSCCPass Printer: " + PassToPrintName; } @@ -107,7 +107,7 @@ struct ModulePassPrinter : public ModulePass { ModulePassPrinter(const PassInfo *PI, raw_ostream &out, bool Quiet) : ModulePass(ID), PassToPrint(PI), Out(out), QuietPass(Quiet) { - std::string PassToPrintName = PassToPrint->getPassName(); + std::string PassToPrintName = std::string(PassToPrint->getPassName()); PassName = "ModulePass Printer: " + PassToPrintName; } @@ -139,7 +139,7 @@ struct LoopPassPrinter : public LoopPass { LoopPassPrinter(const PassInfo *PI, raw_ostream &out, bool Quiet) : LoopPass(ID), PassToPrint(PI), Out(out), QuietPass(Quiet) { - std::string PassToPrintName = PassToPrint->getPassName(); + std::string PassToPrintName = std::string(PassToPrint->getPassName()); PassName = "LoopPass Printer: " + PassToPrintName; } @@ -172,7 +172,7 @@ struct RegionPassPrinter : public RegionPass { RegionPassPrinter(const PassInfo *PI, raw_ostream &out, bool Quiet) : RegionPass(ID), PassToPrint(PI), Out(out), QuietPass(Quiet) { - std::string PassToPrintName = PassToPrint->getPassName(); + std::string PassToPrintName = std::string(PassToPrint->getPassName()); PassName = "RegionPass Printer: " + PassToPrintName; } diff --git a/tools/sancov/sancov.cpp b/tools/sancov/sancov.cpp index 55231742878..d4046607edc 100644 --- a/tools/sancov/sancov.cpp +++ b/tools/sancov/sancov.cpp @@ -358,7 +358,7 @@ static std::string parseScalarString(yaml::Node *N) { SmallString<64> StringStorage; yaml::ScalarNode *S = dyn_cast(N); failIf(!S, "expected string"); - return S->getValue(StringStorage); + return std::string(S->getValue(StringStorage)); } std::unique_ptr @@ -1070,11 +1070,11 @@ readSymbolizeAndMergeCmdArguments(std::vector FileNames) { CovFiles.insert(FileName); } else { auto ShortFileName = llvm::sys::path::filename(FileName); - if (ObjFiles.find(ShortFileName) != ObjFiles.end()) { + if (ObjFiles.find(std::string(ShortFileName)) != ObjFiles.end()) { fail("Duplicate binary file with a short name: " + ShortFileName); } - ObjFiles[ShortFileName] = FileName; + ObjFiles[std::string(ShortFileName)] = FileName; if (FirstObjFile.empty()) FirstObjFile = FileName; } @@ -1093,7 +1093,7 @@ readSymbolizeAndMergeCmdArguments(std::vector FileNames) { FileName); } - auto Iter = ObjFiles.find(Components[1]); + auto Iter = ObjFiles.find(std::string(Components[1])); if (Iter == ObjFiles.end()) { fail("Object file for coverage not found: " + FileName); } diff --git a/unittests/ADT/TripleTest.cpp b/unittests/ADT/TripleTest.cpp index ef7f82d268e..ca00837aaf5 100644 --- a/unittests/ADT/TripleTest.cpp +++ b/unittests/ADT/TripleTest.cpp @@ -584,7 +584,7 @@ TEST(TripleTest, ParsedIDs) { } static std::string Join(StringRef A, StringRef B, StringRef C) { - std::string Str = A; + std::string Str = std::string(A); Str += '-'; Str += B; Str += '-'; @@ -593,7 +593,7 @@ static std::string Join(StringRef A, StringRef B, StringRef C) { } static std::string Join(StringRef A, StringRef B, StringRef C, StringRef D) { - std::string Str = A; + std::string Str = std::string(A); Str += '-'; Str += B; Str += '-'; diff --git a/unittests/Analysis/LazyCallGraphTest.cpp b/unittests/Analysis/LazyCallGraphTest.cpp index 42bdcfb8b7c..0da34ebd1d9 100644 --- a/unittests/Analysis/LazyCallGraphTest.cpp +++ b/unittests/Analysis/LazyCallGraphTest.cpp @@ -264,7 +264,7 @@ TEST(LazyCallGraphTest, BasicGraphFormation) { std::vector Nodes; for (LazyCallGraph::Edge &E : A1.populate()) - Nodes.push_back(E.getFunction().getName()); + Nodes.push_back(std::string(E.getFunction().getName())); llvm::sort(Nodes); EXPECT_EQ("a2", Nodes[0]); EXPECT_EQ("b2", Nodes[1]); @@ -279,7 +279,7 @@ TEST(LazyCallGraphTest, BasicGraphFormation) { EXPECT_EQ("a1", A3->begin()->getFunction().getName()); for (LazyCallGraph::Edge &E : B1.populate()) - Nodes.push_back(E.getFunction().getName()); + Nodes.push_back(std::string(E.getFunction().getName())); llvm::sort(Nodes); EXPECT_EQ("b2", Nodes[0]); EXPECT_EQ("d3", Nodes[1]); @@ -293,7 +293,7 @@ TEST(LazyCallGraphTest, BasicGraphFormation) { EXPECT_EQ("b1", B3->begin()->getFunction().getName()); for (LazyCallGraph::Edge &E : C1.populate()) - Nodes.push_back(E.getFunction().getName()); + Nodes.push_back(std::string(E.getFunction().getName())); llvm::sort(Nodes); EXPECT_EQ("c2", Nodes[0]); EXPECT_EQ("d2", Nodes[1]); @@ -323,7 +323,7 @@ TEST(LazyCallGraphTest, BasicGraphFormation) { LazyCallGraph::RefSCC &D = *J++; ASSERT_EQ(1, D.size()); for (LazyCallGraph::Node &N : *D.begin()) - Nodes.push_back(N.getFunction().getName()); + Nodes.push_back(std::string(N.getFunction().getName())); llvm::sort(Nodes); EXPECT_EQ(3u, Nodes.size()); EXPECT_EQ("d1", Nodes[0]); @@ -339,7 +339,7 @@ TEST(LazyCallGraphTest, BasicGraphFormation) { LazyCallGraph::RefSCC &C = *J++; ASSERT_EQ(1, C.size()); for (LazyCallGraph::Node &N : *C.begin()) - Nodes.push_back(N.getFunction().getName()); + Nodes.push_back(std::string(N.getFunction().getName())); llvm::sort(Nodes); EXPECT_EQ(3u, Nodes.size()); EXPECT_EQ("c1", Nodes[0]); @@ -355,7 +355,7 @@ TEST(LazyCallGraphTest, BasicGraphFormation) { LazyCallGraph::RefSCC &B = *J++; ASSERT_EQ(1, B.size()); for (LazyCallGraph::Node &N : *B.begin()) - Nodes.push_back(N.getFunction().getName()); + Nodes.push_back(std::string(N.getFunction().getName())); llvm::sort(Nodes); EXPECT_EQ(3u, Nodes.size()); EXPECT_EQ("b1", Nodes[0]); @@ -373,7 +373,7 @@ TEST(LazyCallGraphTest, BasicGraphFormation) { LazyCallGraph::RefSCC &A = *J++; ASSERT_EQ(1, A.size()); for (LazyCallGraph::Node &N : *A.begin()) - Nodes.push_back(N.getFunction().getName()); + Nodes.push_back(std::string(N.getFunction().getName())); llvm::sort(Nodes); EXPECT_EQ(3u, Nodes.size()); EXPECT_EQ("a1", Nodes[0]); @@ -477,7 +477,7 @@ TEST(LazyCallGraphTest, InnerSCCFormation) { auto J = RC.begin(); LazyCallGraph::SCC &D = *J++; for (LazyCallGraph::Node &N : D) - Nodes.push_back(N.getFunction().getName()); + Nodes.push_back(std::string(N.getFunction().getName())); llvm::sort(Nodes); EXPECT_EQ(3u, Nodes.size()); EXPECT_EQ("d1", Nodes[0]); @@ -487,7 +487,7 @@ TEST(LazyCallGraphTest, InnerSCCFormation) { LazyCallGraph::SCC &B = *J++; for (LazyCallGraph::Node &N : B) - Nodes.push_back(N.getFunction().getName()); + Nodes.push_back(std::string(N.getFunction().getName())); llvm::sort(Nodes); EXPECT_EQ(3u, Nodes.size()); EXPECT_EQ("b1", Nodes[0]); @@ -497,7 +497,7 @@ TEST(LazyCallGraphTest, InnerSCCFormation) { LazyCallGraph::SCC &C = *J++; for (LazyCallGraph::Node &N : C) - Nodes.push_back(N.getFunction().getName()); + Nodes.push_back(std::string(N.getFunction().getName())); llvm::sort(Nodes); EXPECT_EQ(3u, Nodes.size()); EXPECT_EQ("c1", Nodes[0]); @@ -507,7 +507,7 @@ TEST(LazyCallGraphTest, InnerSCCFormation) { LazyCallGraph::SCC &A = *J++; for (LazyCallGraph::Node &N : A) - Nodes.push_back(N.getFunction().getName()); + Nodes.push_back(std::string(N.getFunction().getName())); llvm::sort(Nodes); EXPECT_EQ(3u, Nodes.size()); EXPECT_EQ("a1", Nodes[0]); diff --git a/unittests/DebugInfo/GSYM/GSYMTest.cpp b/unittests/DebugInfo/GSYM/GSYMTest.cpp index bee1d4091cd..5bd076e9117 100644 --- a/unittests/DebugInfo/GSYM/GSYMTest.cpp +++ b/unittests/DebugInfo/GSYM/GSYMTest.cpp @@ -160,7 +160,7 @@ TEST(GSYMTest, TestFunctionInfo) { } static void TestFunctionInfoDecodeError(llvm::support::endianness ByteOrder, - std::string Bytes, + StringRef Bytes, const uint64_t BaseAddr, std::string ExpectedErrorMsg) { uint8_t AddressSize = 4; @@ -335,8 +335,7 @@ static void TestInlineInfoEncodeDecode(llvm::support::endianness ByteOrder, } static void TestInlineInfoDecodeError(llvm::support::endianness ByteOrder, - std::string Bytes, - const uint64_t BaseAddr, + StringRef Bytes, const uint64_t BaseAddr, std::string ExpectedErrorMsg) { uint8_t AddressSize = 4; DataExtractor Data(Bytes, ByteOrder == llvm::support::little, AddressSize); @@ -874,8 +873,7 @@ TEST(GSYMTest, TestLineTable) { } static void TestLineTableDecodeError(llvm::support::endianness ByteOrder, - std::string Bytes, - const uint64_t BaseAddr, + StringRef Bytes, const uint64_t BaseAddr, std::string ExpectedErrorMsg) { uint8_t AddressSize = 4; DataExtractor Data(Bytes, ByteOrder == llvm::support::little, AddressSize); @@ -962,7 +960,7 @@ static void TestHeaderEncodeError(const Header &H, checkError(ExpectedErrorMsg, std::move(Err)); } -static void TestHeaderDecodeError(std::string Bytes, +static void TestHeaderDecodeError(StringRef Bytes, std::string ExpectedErrorMsg) { const support::endianness ByteOrder = llvm::support::little; uint8_t AddressSize = 4; diff --git a/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp b/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp index 7b6d4b078fb..4b0d67c78d3 100644 --- a/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp +++ b/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp @@ -72,7 +72,7 @@ TEST_F(LegacyAPIsStandardTest, LegacyLookupHelpersFn) { bool BarMaterialized = false; BarSym.setFlags(BarSym.getFlags() | JITSymbolFlags::Weak); - auto LegacyLookup = [&](const std::string &Name) -> JITSymbol { + auto LegacyLookup = [&](StringRef Name) -> JITSymbol { if (Name == "foo") return FooSym; diff --git a/unittests/ExecutionEngine/Orc/LegacyRTDyldObjectLinkingLayerTest.cpp b/unittests/ExecutionEngine/Orc/LegacyRTDyldObjectLinkingLayerTest.cpp index 896914da624..c1eb45566cf 100644 --- a/unittests/ExecutionEngine/Orc/LegacyRTDyldObjectLinkingLayerTest.cpp +++ b/unittests/ExecutionEngine/Orc/LegacyRTDyldObjectLinkingLayerTest.cpp @@ -185,7 +185,7 @@ TEST_F(LegacyRTDyldObjectLinkingLayerExecutionTest, NoDuplicateFinalization) { cantFail(ObjLayer.addObject(K1, std::move(Obj1))); auto K2 = ES.allocateVModule(); - auto LegacyLookup = [&](const std::string &Name) { + auto LegacyLookup = [&](StringRef Name) { return ObjLayer.findSymbol(Name, true); }; diff --git a/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp b/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp index 429d917237d..31a4247e27d 100644 --- a/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp +++ b/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp @@ -354,7 +354,7 @@ TEST(RemoteObjectLayer, FindSymbol) { if (Name == "foobar") return JITSymbol(0x12348765, JITSymbolFlags::Exported); if (Name == "badsymbol") - return make_error(Name); + return make_error(std::string(Name)); return nullptr; }; return 42; @@ -435,7 +435,7 @@ TEST(RemoteObjectLayer, FindSymbolIn) { [](StringRef Name, bool ExportedSymbolsOnly) -> JITSymbol { if (Name == "foobar") return JITSymbol(0x12348765, JITSymbolFlags::Exported); - return make_error(Name); + return make_error(std::string(Name)); }; // Dummy symbol table entry - this should not be visible to // findSymbolIn. @@ -443,7 +443,7 @@ TEST(RemoteObjectLayer, FindSymbolIn) { [](StringRef Name, bool ExportedSymbolsOnly) -> JITSymbol { if (Name == "barbaz") return JITSymbol(0xdeadbeef, JITSymbolFlags::Exported); - return make_error(Name); + return make_error(std::string(Name)); }; return 42; diff --git a/unittests/IR/PassBuilderCallbacksTest.cpp b/unittests/IR/PassBuilderCallbacksTest.cpp index 3f800b308e2..1f17a4f34b1 100644 --- a/unittests/IR/PassBuilderCallbacksTest.cpp +++ b/unittests/IR/PassBuilderCallbacksTest.cpp @@ -270,10 +270,12 @@ static std::unique_ptr parseIR(LLVMContext &C, const char *IR) { /// Helper for HasName matcher that returns getName both for IRUnit and /// for IRUnit pointer wrapper into llvm::Any (wrapped by PassInstrumentation). template std::string getName(const IRUnitT &IR) { - return IR.getName(); + return std::string(IR.getName()); } -template <> std::string getName(const StringRef &name) { return name; } +template <> std::string getName(const StringRef &name) { + return std::string(name); +} template <> std::string getName(const llvm::Any &WrappedIR) { if (any_isa(WrappedIR)) diff --git a/unittests/Passes/PluginsTest.cpp b/unittests/Passes/PluginsTest.cpp index dd889e68492..e250f1967de 100644 --- a/unittests/Passes/PluginsTest.cpp +++ b/unittests/Passes/PluginsTest.cpp @@ -34,7 +34,7 @@ static std::string LibPath(const std::string Name = "TestPlugin") { std::string Path = sys::fs::getMainExecutable(Argv0, Ptr); llvm::SmallString<256> Buf{sys::path::parent_path(Path)}; sys::path::append(Buf, (Name + LTDL_SHLIB_EXT).c_str()); - return Buf.str(); + return std::string(Buf.str()); } TEST(PluginsTests, LoadPlugin) { diff --git a/unittests/ProfileData/SampleProfTest.cpp b/unittests/ProfileData/SampleProfTest.cpp index 816f403f570..4c58d25cedb 100644 --- a/unittests/ProfileData/SampleProfTest.cpp +++ b/unittests/ProfileData/SampleProfTest.cpp @@ -52,7 +52,8 @@ struct SampleProfTest : ::testing::Test { void readProfile(const Module &M, StringRef Profile, StringRef RemapFile = "") { - auto ReaderOrErr = SampleProfileReader::create(Profile, Context, RemapFile); + auto ReaderOrErr = SampleProfileReader::create( + std::string(Profile), Context, std::string(RemapFile)); ASSERT_TRUE(NoError(ReaderOrErr.getError())); Reader = std::move(ReaderOrErr.get()); Reader->collectFuncsFrom(M); diff --git a/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp b/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp index d1afd50fb4c..3fa3ea97759 100644 --- a/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp +++ b/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp @@ -27,7 +27,7 @@ std::string LibPath(const std::string Name = "PipSqueak") { std::string Path = fs::getMainExecutable(Argv0, Ptr); llvm::SmallString<256> Buf(path::parent_path(Path)); path::append(Buf, (Name + LTDL_SHLIB_EXT).c_str()); - return Buf.str(); + return std::string(Buf.str()); } #if defined(_WIN32) || (defined(HAVE_DLFCN_H) && defined(HAVE_DLOPEN)) diff --git a/unittests/Support/FileCheckTest.cpp b/unittests/Support/FileCheckTest.cpp index a329d8c6d6f..a451e0beaf9 100644 --- a/unittests/Support/FileCheckTest.cpp +++ b/unittests/Support/FileCheckTest.cpp @@ -262,12 +262,13 @@ TEST_F(FileCheckTest, Expression) { static void expectUndefErrors(std::unordered_set ExpectedUndefVarNames, Error Err) { - EXPECT_THAT_ERROR( - handleErrors(std::move(Err), - [&](const UndefVarError &E) { - EXPECT_EQ(ExpectedUndefVarNames.erase(E.getVarName()), 1U); - }), - Succeeded()); + EXPECT_THAT_ERROR(handleErrors(std::move(Err), + [&](const UndefVarError &E) { + EXPECT_EQ(ExpectedUndefVarNames.erase( + std::string(E.getVarName())), + 1U); + }), + Succeeded()); EXPECT_TRUE(ExpectedUndefVarNames.empty()) << toString(ExpectedUndefVarNames); } @@ -936,12 +937,12 @@ TEST_F(FileCheckTest, FileCheckContext) { EXPECT_EQ(*ExpressionVal, 12U); ASSERT_THAT_EXPECTED(EmptyVar, Succeeded()); EXPECT_EQ(*EmptyVar, ""); - expectUndefErrors({UnknownVarStr}, UnknownVar.takeError()); + expectUndefErrors({std::string(UnknownVarStr)}, UnknownVar.takeError()); // Clear local variables and check they become absent. Cxt.clearLocalVars(); LocalVar = Cxt.getPatternVarValue(LocalVarStr); - expectUndefErrors({LocalVarStr}, LocalVar.takeError()); + expectUndefErrors({std::string(LocalVarStr)}, LocalVar.takeError()); // Check a numeric expression's evaluation fails if called after clearing of // local variables, if it was created before. This is important because local // variable clearing due to --enable-var-scope happens after numeric diff --git a/unittests/Support/FileCollectorTest.cpp b/unittests/Support/FileCollectorTest.cpp index c6aeedd3865..42a4877dba3 100644 --- a/unittests/Support/FileCollectorTest.cpp +++ b/unittests/Support/FileCollectorTest.cpp @@ -101,7 +101,7 @@ struct ScopedFile { TEST(FileCollectorTest, addFile) { ScopedDir root("add_file_root", true); - std::string root_fs = root.Path.str(); + std::string root_fs = std::string(root.Path.str()); TestingFileCollector FileCollector(root_fs, root_fs); FileCollector.addFile("/path/to/a"); @@ -128,7 +128,7 @@ TEST(FileCollectorTest, copyFiles) { // Create file collector and add files. ScopedDir root("copy_files_root", true); - std::string root_fs = root.Path.str(); + std::string root_fs = std::string(root.Path.str()); TestingFileCollector FileCollector(root_fs, root_fs); FileCollector.addFile(a.Path); FileCollector.addFile(b.Path); @@ -156,7 +156,7 @@ TEST(FileCollectorTest, recordAndConstructDirectory) { // Create file collector and add files. ScopedDir root("copy_files_root", true); - std::string root_fs = root.Path.str(); + std::string root_fs = std::string(root.Path.str()); TestingFileCollector FileCollector(root_fs, root_fs); FileCollector.addFile(a.Path); @@ -194,7 +194,7 @@ TEST(FileCollectorTest, recordVFSAccesses) { // Create file collector and add files. ScopedDir root("copy_files_root", true); - std::string root_fs = root.Path.str(); + std::string root_fs = std::string(root.Path.str()); auto Collector = std::make_shared(root_fs, root_fs); auto VFS = FileCollector::createCollectorVFS(vfs::getRealFileSystem(), Collector); @@ -241,7 +241,7 @@ TEST(FileCollectorTest, Symlinks) { // Root where files are copied to. ScopedDir reproducer_root("reproducer_root", true); - std::string root_fs = reproducer_root.Path.str(); + std::string root_fs = std::string(reproducer_root.Path.str()); TestingFileCollector FileCollector(root_fs, root_fs); // Add all the files to the collector. @@ -287,7 +287,7 @@ TEST(FileCollectorTest, recordVFSSymlinkAccesses) { // Create file collector and add files. ScopedDir root("copy_files_root", true); - std::string root_fs = root.Path.str(); + std::string root_fs = std::string(root.Path.str()); auto Collector = std::make_shared(root_fs, root_fs); auto VFS = FileCollector::createCollectorVFS(vfs::getRealFileSystem(), Collector); diff --git a/unittests/Support/FileUtilitiesTest.cpp b/unittests/Support/FileUtilitiesTest.cpp index 2bf9dc5eb8c..7fbb601eb78 100644 --- a/unittests/Support/FileUtilitiesTest.cpp +++ b/unittests/Support/FileUtilitiesTest.cpp @@ -44,7 +44,7 @@ TEST(writeFileAtomicallyTest, Test) { llvm::Error Err = llvm::writeFileAtomically(TempUniqTestFileModel, FinalTestfilePath, TestfileContent); ASSERT_FALSE(static_cast(Err)); - std::ifstream FinalFileStream(FinalTestfilePath.str()); + std::ifstream FinalFileStream(std::string(FinalTestfilePath.str())); std::string FinalFileContent; FinalFileStream >> FinalFileContent; ASSERT_EQ(FinalFileContent, TestfileContent); diff --git a/unittests/Support/FormatVariadicTest.cpp b/unittests/Support/FormatVariadicTest.cpp index e9565c13dd3..a4e8826ecf4 100644 --- a/unittests/Support/FormatVariadicTest.cpp +++ b/unittests/Support/FormatVariadicTest.cpp @@ -618,11 +618,11 @@ TEST(FormatVariadicTest, Adapter) { TEST(FormatVariadicTest, MoveConstructor) { auto fmt = formatv("{0} {1}", 1, 2); auto fmt2 = std::move(fmt); - std::string S = fmt2; + std::string S = std::string(fmt2); EXPECT_EQ("1 2", S); } TEST(FormatVariadicTest, ImplicitConversions) { - std::string S = formatv("{0} {1}", 1, 2); + std::string S = std::string(formatv("{0} {1}", 1, 2)); EXPECT_EQ("1 2", S); SmallString<4> S2 = formatv("{0} {1}", 1, 2); diff --git a/unittests/Support/JSONTest.cpp b/unittests/Support/JSONTest.cpp index 93efcf2f6ad..0357e2185c3 100644 --- a/unittests/Support/JSONTest.cpp +++ b/unittests/Support/JSONTest.cpp @@ -196,7 +196,7 @@ TEST(JSONTest, ParseErrors) { FAIL() << "Parsed JSON >>> " << S << " <<< but wanted error: " << Msg; } else { handleAllErrors(E.takeError(), [S, Msg](const llvm::ErrorInfoBase &E) { - EXPECT_THAT(E.message(), testing::HasSubstr(Msg)) << S; + EXPECT_THAT(E.message(), testing::HasSubstr(std::string(Msg))) << S; }); } }; diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp index b143ea6d206..601223b11ab 100644 --- a/unittests/Support/Path.cpp +++ b/unittests/Support/Path.cpp @@ -849,7 +849,7 @@ TEST_F(FileSystemTest, DirectoryIteration) { } if (path::filename(i->path()) == "dontlookhere") i.no_push(); - visited.push_back(path::filename(i->path())); + visited.push_back(std::string(path::filename(i->path()))); } v_t::const_iterator a0 = find(visited, "a0"); v_t::const_iterator aa1 = find(visited, "aa1"); @@ -939,10 +939,10 @@ TEST_F(FileSystemTest, BrokenSymlinkDirectoryIteration) { ASSERT_NO_ERROR(ec); if (i->status().getError() == std::make_error_code(std::errc::no_such_file_or_directory)) { - VisitedBrokenSymlinks.push_back(path::filename(i->path())); + VisitedBrokenSymlinks.push_back(std::string(path::filename(i->path()))); continue; } - VisitedNonBrokenSymlinks.push_back(path::filename(i->path())); + VisitedNonBrokenSymlinks.push_back(std::string(path::filename(i->path()))); } EXPECT_THAT(VisitedNonBrokenSymlinks, UnorderedElementsAre("b", "d")); VisitedNonBrokenSymlinks.clear(); @@ -956,10 +956,10 @@ TEST_F(FileSystemTest, BrokenSymlinkDirectoryIteration) { ASSERT_NO_ERROR(ec); if (i->status().getError() == std::make_error_code(std::errc::no_such_file_or_directory)) { - VisitedBrokenSymlinks.push_back(path::filename(i->path())); + VisitedBrokenSymlinks.push_back(std::string(path::filename(i->path()))); continue; } - VisitedNonBrokenSymlinks.push_back(path::filename(i->path())); + VisitedNonBrokenSymlinks.push_back(std::string(path::filename(i->path()))); } EXPECT_THAT(VisitedNonBrokenSymlinks, UnorderedElementsAre("b", "bb", "d", "da", "dd", "ddd", "ddd")); @@ -975,10 +975,10 @@ TEST_F(FileSystemTest, BrokenSymlinkDirectoryIteration) { ASSERT_NO_ERROR(ec); if (i->status().getError() == std::make_error_code(std::errc::no_such_file_or_directory)) { - VisitedBrokenSymlinks.push_back(path::filename(i->path())); + VisitedBrokenSymlinks.push_back(std::string(path::filename(i->path()))); continue; } - VisitedNonBrokenSymlinks.push_back(path::filename(i->path())); + VisitedNonBrokenSymlinks.push_back(std::string(path::filename(i->path()))); } EXPECT_THAT(VisitedNonBrokenSymlinks, UnorderedElementsAreArray({"a", "b", "ba", "bb", "bc", "c", "d", @@ -1187,7 +1187,7 @@ static std::string remove_dots(StringRef path, bool remove_dot_dot, path::Style style) { SmallString<256> buffer(path); path::remove_dots(buffer, remove_dot_dot, style); - return buffer.str(); + return std::string(buffer.str()); } TEST(Support, RemoveDots) { diff --git a/unittests/Support/SpecialCaseListTest.cpp b/unittests/Support/SpecialCaseListTest.cpp index de1f058b67f..4be143d8f41 100644 --- a/unittests/Support/SpecialCaseListTest.cpp +++ b/unittests/Support/SpecialCaseListTest.cpp @@ -39,7 +39,7 @@ protected: raw_fd_ostream OF(FD, true, true); OF << Contents; OF.close(); - return Path.str(); + return std::string(Path.str()); } }; diff --git a/unittests/Support/VirtualFileSystemTest.cpp b/unittests/Support/VirtualFileSystemTest.cpp index d61652bc0c5..ef92111cec7 100644 --- a/unittests/Support/VirtualFileSystemTest.cpp +++ b/unittests/Support/VirtualFileSystemTest.cpp @@ -107,8 +107,8 @@ public: Path(_Path.str()) { for (; I != FilesAndDirs.end(); ++I) { if (isInPath(I->first)) { - CurrentEntry = - vfs::directory_entry(I->second.getName(), I->second.getType()); + CurrentEntry = vfs::directory_entry(std::string(I->second.getName()), + I->second.getType()); break; } } @@ -117,8 +117,8 @@ public: ++I; for (; I != FilesAndDirs.end(); ++I) { if (isInPath(I->first)) { - CurrentEntry = - vfs::directory_entry(I->second.getName(), I->second.getType()); + CurrentEntry = vfs::directory_entry(std::string(I->second.getName()), + I->second.getType()); break; } } @@ -135,7 +135,7 @@ public: } void addEntry(StringRef Path, const vfs::Status &Status) { - FilesAndDirs[Path] = Status; + FilesAndDirs[std::string(Path)] = Status; } const_iterator findEntry(const Twine &Path) const { @@ -144,7 +144,7 @@ public: std::error_code EC = makeAbsolute(P); assert(!EC); (void)EC; - return FilesAndDirs.find(P.str()); + return FilesAndDirs.find(std::string(P.str())); } void addRegularFile(StringRef Path, sys::fs::perms Perms = sys::fs::all_all) { @@ -179,7 +179,7 @@ class ErrorDummyFileSystem : public DummyFileSystem { std::string getPosixPath(std::string S) { SmallString<128> Result; llvm::sys::path::native(S, Result, llvm::sys::path::Style::posix); - return Result.str(); + return std::string(Result.str()); } } // end anonymous namespace @@ -419,7 +419,7 @@ struct ScopedDir { EC = llvm::sys::fs::createUniqueDirectory(Name, Path); if (!EC) { // Resolve any symlinks in the new directory. - std::string UnresolvedPath = Path.str(); + std::string UnresolvedPath = std::string(Path.str()); EC = llvm::sys::fs::real_path(UnresolvedPath, Path); } } else { @@ -579,7 +579,7 @@ TEST(VirtualFileSystemTest, BrokenSymlinkRealFSIteration) { for (vfs::directory_iterator I = FS->dir_begin(Twine(TestDirectory), EC), E; I != E; I.increment(EC)) { EXPECT_FALSE(EC); - StatResults[sys::path::filename(I->path())] = + StatResults[std::string(sys::path::filename(I->path()))] = FS->status(I->path()).getError(); } EXPECT_THAT( @@ -613,7 +613,7 @@ TEST(VirtualFileSystemTest, BasicRealFSRecursiveIteration) { std::vector Contents; for (auto E = vfs::recursive_directory_iterator(); !EC && I != E; I.increment(EC)) { - Contents.push_back(I->path()); + Contents.push_back(std::string(I->path())); } // Check contents, which may be in any order @@ -653,7 +653,7 @@ TEST(VirtualFileSystemTest, BasicRealFSRecursiveIterationNoPush) { std::vector Contents; for (auto E = vfs::recursive_directory_iterator(); !EC && I != E; I.increment(EC)) { - Contents.push_back(I->path()); + Contents.push_back(std::string(I->path())); char last = I->path().back(); switch (last) { case 'b': @@ -678,7 +678,7 @@ TEST(VirtualFileSystemTest, BasicRealFSRecursiveIterationNoPush) { std::vector Contents; for (auto E = vfs::recursive_directory_iterator(); !EC && I != E; I.increment(EC)) { - Contents.push_back(I->path()); + Contents.push_back(std::string(I->path())); char last = I->path().back(); switch (last) { case 'a': @@ -733,17 +733,18 @@ TEST(VirtualFileSystemTest, BrokenSymlinkRealFSRecursiveIteration) { I != E; I.increment(EC)) { EXPECT_FALSE(EC); (FS->status(I->path()) ? VisitedNonBrokenSymlinks : VisitedBrokenSymlinks) - .push_back(I->path()); + .push_back(std::string(I->path())); } // Check visited file names. EXPECT_THAT(VisitedBrokenSymlinks, - UnorderedElementsAre(StringRef(_a), StringRef(_ba), - StringRef(_bc), StringRef(_c), - StringRef(_e))); + UnorderedElementsAre(StringRef(_a).str(), StringRef(_ba).str(), + StringRef(_bc).str(), StringRef(_c).str(), + StringRef(_e).str())); EXPECT_THAT(VisitedNonBrokenSymlinks, - UnorderedElementsAre(StringRef(_b), StringRef(_bb), StringRef(_d), - StringRef(_dd), StringRef(_ddd))); + UnorderedElementsAre(StringRef(_b).str(), StringRef(_bb).str(), + StringRef(_d).str(), StringRef(_dd).str(), + StringRef(_ddd).str())); } #endif @@ -756,7 +757,7 @@ static void checkContents(DirIter I, ArrayRef ExpectedOut) { // Do not rely on iteration order to check for contents, sort both // content vectors before comparison. for (DirIter E; !EC && I != E; I.increment(EC)) - InputToCheck.push_back(I->path()); + InputToCheck.push_back(std::string(I->path())); llvm::sort(InputToCheck); llvm::sort(Expected); @@ -1048,7 +1049,7 @@ TEST_F(InMemoryFileSystemTest, DirectoryIteration) { ASSERT_FALSE(EC); // When on Windows, we end up with "/b\\c" as the name. Convert to Posix // path for the sake of the comparison. - ASSERT_EQ("/b/c", getPosixPath(I->path())); + ASSERT_EQ("/b/c", getPosixPath(std::string(I->path()))); I.increment(EC); ASSERT_FALSE(EC); ASSERT_EQ(vfs::directory_iterator(), I); @@ -1224,7 +1225,7 @@ TEST_F(InMemoryFileSystemTest, StatusName) { llvm::vfs::directory_iterator It = NormalizedFS.dir_begin("../b", EC); // When on Windows, we end up with "../b\\c" as the name. Convert to Posix // path for the sake of the comparison. - ASSERT_EQ("../b/c", getPosixPath(It->path())); + ASSERT_EQ("../b/c", getPosixPath(std::string(It->path()))); } TEST_F(InMemoryFileSystemTest, AddHardLinkToFile) { @@ -1324,7 +1325,7 @@ TEST_F(InMemoryFileSystemTest, RecursiveIterationWithHardLink) { std::vector Nodes; for (auto E = vfs::recursive_directory_iterator(); !EC && I != E; I.increment(EC)) { - Nodes.push_back(getPosixPath(I->path())); + Nodes.push_back(getPosixPath(std::string(I->path()))); } EXPECT_THAT(Nodes, testing::UnorderedElementsAre("/a", "/a/b", "/c", "/c/d")); } diff --git a/unittests/Support/raw_ostream_test.cpp b/unittests/Support/raw_ostream_test.cpp index 0e56464e573..49685ef5c01 100644 --- a/unittests/Support/raw_ostream_test.cpp +++ b/unittests/Support/raw_ostream_test.cpp @@ -35,7 +35,7 @@ template std::string printToString(const T &Value, for (unsigned i = 0; i != StartIndex; ++i) OS << '?'; OS << Value; - return OS.str().substr(StartIndex); + return std::string(OS.str().substr(StartIndex)); } template std::string printToStringUnbuffered(const T &Value) { diff --git a/unittests/Target/AArch64/InstSizes.cpp b/unittests/Target/AArch64/InstSizes.cpp index 74c5d383d8f..01ec44e35ff 100644 --- a/unittests/Target/AArch64/InstSizes.cpp +++ b/unittests/Target/AArch64/InstSizes.cpp @@ -28,8 +28,9 @@ std::unique_ptr createTargetMachine() { } std::unique_ptr createInstrInfo(TargetMachine *TM) { - AArch64Subtarget ST(TM->getTargetTriple(), TM->getTargetCPU(), - TM->getTargetFeatureString(), *TM, /* isLittle */ false); + AArch64Subtarget ST(TM->getTargetTriple(), std::string(TM->getTargetCPU()), + std::string(TM->getTargetFeatureString()), *TM, + /* isLittle */ false); return std::make_unique(ST); } diff --git a/unittests/Target/ARM/MachineInstrTest.cpp b/unittests/Target/ARM/MachineInstrTest.cpp index 2510011c3ee..284eb765d17 100644 --- a/unittests/Target/ARM/MachineInstrTest.cpp +++ b/unittests/Target/ARM/MachineInstrTest.cpp @@ -493,9 +493,9 @@ TEST(MachineInstrValidTailPredication, IsCorrect) { static_cast( T->createTargetMachine(TT, "generic", "", Options, None, None, CodeGenOpt::Default))); - ARMSubtarget ST(TM->getTargetTriple(), TM->getTargetCPU(), - TM->getTargetFeatureString(), - *static_cast(TM.get()), false); + ARMSubtarget ST(TM->getTargetTriple(), std::string(TM->getTargetCPU()), + std::string(TM->getTargetFeatureString()), + *static_cast(TM.get()), false); const ARMBaseInstrInfo *TII = ST.getInstrInfo(); auto MII = TM->getMCInstrInfo(); @@ -591,8 +591,8 @@ TEST(MachineInstr, HasSideEffects) { auto TM = std::unique_ptr( static_cast(T->createTargetMachine( TT, "generic", "", Options, None, None, CodeGenOpt::Default))); - ARMSubtarget ST(TM->getTargetTriple(), TM->getTargetCPU(), - TM->getTargetFeatureString(), + ARMSubtarget ST(TM->getTargetTriple(), std::string(TM->getTargetCPU()), + std::string(TM->getTargetFeatureString()), *static_cast(TM.get()), false); const ARMBaseInstrInfo *TII = ST.getInstrInfo(); auto MII = TM->getMCInstrInfo(); diff --git a/unittests/TextAPI/TextStubV1Tests.cpp b/unittests/TextAPI/TextStubV1Tests.cpp index 4472b1c5993..68baac102db 100644 --- a/unittests/TextAPI/TextStubV1Tests.cpp +++ b/unittests/TextAPI/TextStubV1Tests.cpp @@ -113,9 +113,9 @@ TEST(TBDv1, ReadFile) { for (const auto *Sym : File->symbols()) { EXPECT_FALSE(Sym->isWeakReferenced()); EXPECT_FALSE(Sym->isUndefined()); - Exports.emplace_back(ExportedSymbol{Sym->getKind(), Sym->getName(), - Sym->isWeakDefined(), - Sym->isThreadLocalValue()}); + Exports.emplace_back( + ExportedSymbol{Sym->getKind(), std::string(Sym->getName()), + Sym->isWeakDefined(), Sym->isThreadLocalValue()}); } llvm::sort(Exports.begin(), Exports.end()); diff --git a/unittests/TextAPI/TextStubV2Tests.cpp b/unittests/TextAPI/TextStubV2Tests.cpp index dfe3afbf0a9..31de7fd2008 100644 --- a/unittests/TextAPI/TextStubV2Tests.cpp +++ b/unittests/TextAPI/TextStubV2Tests.cpp @@ -115,9 +115,9 @@ TEST(TBDv2, ReadFile) { for (const auto *Sym : File->symbols()) { EXPECT_FALSE(Sym->isWeakReferenced()); EXPECT_FALSE(Sym->isUndefined()); - Exports.emplace_back(ExportedSymbol{Sym->getKind(), Sym->getName(), - Sym->isWeakDefined(), - Sym->isThreadLocalValue()}); + Exports.emplace_back( + ExportedSymbol{Sym->getKind(), std::string(Sym->getName()), + Sym->isWeakDefined(), Sym->isThreadLocalValue()}); } llvm::sort(Exports.begin(), Exports.end()); diff --git a/unittests/TextAPI/TextStubV3Tests.cpp b/unittests/TextAPI/TextStubV3Tests.cpp index 4a05920805e..0180989ff33 100644 --- a/unittests/TextAPI/TextStubV3Tests.cpp +++ b/unittests/TextAPI/TextStubV3Tests.cpp @@ -129,9 +129,9 @@ TEST(TBDv3, ReadFile) { for (const auto *Sym : File->symbols()) { EXPECT_FALSE(Sym->isWeakReferenced()); EXPECT_FALSE(Sym->isUndefined()); - Exports.emplace_back(ExportedSymbol{Sym->getKind(), Sym->getName(), - Sym->isWeakDefined(), - Sym->isThreadLocalValue()}); + Exports.emplace_back( + ExportedSymbol{Sym->getKind(), std::string(Sym->getName()), + Sym->isWeakDefined(), Sym->isThreadLocalValue()}); } llvm::sort(Exports.begin(), Exports.end()); diff --git a/unittests/TextAPI/TextStubV4Tests.cpp b/unittests/TextAPI/TextStubV4Tests.cpp index c007482354a..3ffb6682181 100644 --- a/unittests/TextAPI/TextStubV4Tests.cpp +++ b/unittests/TextAPI/TextStubV4Tests.cpp @@ -144,8 +144,8 @@ TEST(TBDv4, ReadFile) { ExampleSymbolSeq Exports, Reexports, Undefineds; ExampleSymbol temp; for (const auto *Sym : File->symbols()) { - temp = ExampleSymbol{Sym->getKind(), Sym->getName(), Sym->isWeakDefined(), - Sym->isThreadLocalValue()}; + temp = ExampleSymbol{Sym->getKind(), std::string(Sym->getName()), + Sym->isWeakDefined(), Sym->isThreadLocalValue()}; EXPECT_FALSE(Sym->isWeakReferenced()); if (Sym->isUndefined()) Undefineds.emplace_back(std::move(temp)); diff --git a/unittests/tools/llvm-exegesis/PerfHelperTest.cpp b/unittests/tools/llvm-exegesis/PerfHelperTest.cpp index 7ff256f454f..5332b84fb48 100644 --- a/unittests/tools/llvm-exegesis/PerfHelperTest.cpp +++ b/unittests/tools/llvm-exegesis/PerfHelperTest.cpp @@ -30,8 +30,8 @@ TEST(PerfHelperTest, FunctionalTest) { Measure( makeArrayRef(SingleEvent), [&](const PerfEvent &Event, int64_t Value) { - CallbackEventName = Event.name(); - CallbackEventNameFullyQualifed = Event.getPfmEventString(); + CallbackEventName = std::string(Event.name()); + CallbackEventNameFullyQualifed = std::string(Event.getPfmEventString()); CallbackEventCycles = Value; }, EmptyFn); diff --git a/utils/TableGen/AsmMatcherEmitter.cpp b/utils/TableGen/AsmMatcherEmitter.cpp index ccf0959389b..ce824f74051 100644 --- a/utils/TableGen/AsmMatcherEmitter.cpp +++ b/utils/TableGen/AsmMatcherEmitter.cpp @@ -1085,7 +1085,7 @@ bool MatchableInfo::validate(StringRef CommentDelimiter, bool IsAlias) const { // Verify that any operand is only mentioned once. // We reject aliases and ignore instructions for now. if (!IsAlias && TheDef->getValueAsString("AsmMatchConverter").empty() && - Tok[0] == '$' && !OperandNames.insert(Tok).second) { + Tok[0] == '$' && !OperandNames.insert(std::string(Tok)).second) { LLVM_DEBUG({ errs() << "warning: '" << TheDef->getName() << "': " << "ignoring instruction with tied operand '" @@ -1126,7 +1126,7 @@ static std::string getEnumNameForToken(StringRef Str) { } ClassInfo *AsmMatcherInfo::getTokenClass(StringRef Token) { - ClassInfo *&Entry = TokenClasses[Token]; + ClassInfo *&Entry = TokenClasses[std::string(Token)]; if (!Entry) { Classes.emplace_front(); @@ -1134,7 +1134,7 @@ ClassInfo *AsmMatcherInfo::getTokenClass(StringRef Token) { Entry->Kind = ClassInfo::Token; Entry->ClassName = "Token"; Entry->Name = "MCK_" + getEnumNameForToken(Token); - Entry->ValueName = Token; + Entry->ValueName = std::string(Token); Entry->PredicateMethod = ""; Entry->RenderMethod = ""; Entry->ParserMethod = ""; @@ -1310,11 +1310,11 @@ buildRegisterClasses(SmallPtrSetImpl &SingletonRegisters) { Init *DiagnosticType = Def->getValueInit("DiagnosticType"); if (StringInit *SI = dyn_cast(DiagnosticType)) - CI->DiagnosticType = SI->getValue(); + CI->DiagnosticType = std::string(SI->getValue()); Init *DiagnosticString = Def->getValueInit("DiagnosticString"); if (StringInit *SI = dyn_cast(DiagnosticString)) - CI->DiagnosticString = SI->getValue(); + CI->DiagnosticString = std::string(SI->getValue()); // If we have a diagnostic string but the diagnostic type is not specified // explicitly, create an anonymous diagnostic type. @@ -1335,9 +1335,9 @@ buildRegisterClasses(SmallPtrSetImpl &SingletonRegisters) { assert(CI && "Missing singleton register class info!"); if (CI->ValueName.empty()) { - CI->ClassName = Rec->getName(); + CI->ClassName = std::string(Rec->getName()); CI->Name = "MCK_" + Rec->getName().str(); - CI->ValueName = Rec->getName(); + CI->ValueName = std::string(Rec->getName()); } else CI->ValueName = CI->ValueName + "," + Rec->getName().str(); } @@ -1372,14 +1372,14 @@ void AsmMatcherInfo::buildOperandClasses() { else CI->SuperClasses.push_back(SC); } - CI->ClassName = Rec->getValueAsString("Name"); + CI->ClassName = std::string(Rec->getValueAsString("Name")); CI->Name = "MCK_" + CI->ClassName; - CI->ValueName = Rec->getName(); + CI->ValueName = std::string(Rec->getName()); // Get or construct the predicate method name. Init *PMName = Rec->getValueInit("PredicateMethod"); if (StringInit *SI = dyn_cast(PMName)) { - CI->PredicateMethod = SI->getValue(); + CI->PredicateMethod = std::string(SI->getValue()); } else { assert(isa(PMName) && "Unexpected PredicateMethod field!"); CI->PredicateMethod = "is" + CI->ClassName; @@ -1388,7 +1388,7 @@ void AsmMatcherInfo::buildOperandClasses() { // Get or construct the render method name. Init *RMName = Rec->getValueInit("RenderMethod"); if (StringInit *SI = dyn_cast(RMName)) { - CI->RenderMethod = SI->getValue(); + CI->RenderMethod = std::string(SI->getValue()); } else { assert(isa(RMName) && "Unexpected RenderMethod field!"); CI->RenderMethod = "add" + CI->ClassName + "Operands"; @@ -1397,15 +1397,15 @@ void AsmMatcherInfo::buildOperandClasses() { // Get the parse method name or leave it as empty. Init *PRMName = Rec->getValueInit("ParserMethod"); if (StringInit *SI = dyn_cast(PRMName)) - CI->ParserMethod = SI->getValue(); + CI->ParserMethod = std::string(SI->getValue()); // Get the diagnostic type and string or leave them as empty. Init *DiagnosticType = Rec->getValueInit("DiagnosticType"); if (StringInit *SI = dyn_cast(DiagnosticType)) - CI->DiagnosticType = SI->getValue(); + CI->DiagnosticType = std::string(SI->getValue()); Init *DiagnosticString = Rec->getValueInit("DiagnosticString"); if (StringInit *SI = dyn_cast(DiagnosticString)) - CI->DiagnosticString = SI->getValue(); + CI->DiagnosticString = std::string(SI->getValue()); // If we have a DiagnosticString, we need a DiagnosticType for use within // the matcher. if (!CI->DiagnosticString.empty() && CI->DiagnosticType.empty()) @@ -1418,7 +1418,7 @@ void AsmMatcherInfo::buildOperandClasses() { // Get or construct the default method name. Init *DMName = Rec->getValueInit("DefaultMethod"); if (StringInit *SI = dyn_cast(DMName)) { - CI->DefaultMethod = SI->getValue(); + CI->DefaultMethod = std::string(SI->getValue()); } else { assert(isa(DMName) && "Unexpected DefaultMethod field!"); CI->DefaultMethod = "default" + CI->ClassName + "Operands"; @@ -2729,7 +2729,8 @@ static void emitMnemonicAliasVariant(raw_ostream &OS,const AsmMatcherInfo &Info, StringRef AsmVariantName = R->getValueAsString("AsmVariantName"); if (AsmVariantName != AsmParserVariantName) continue; - AliasesFromMnemonic[R->getValueAsString("FromMnemonic")].push_back(R); + AliasesFromMnemonic[std::string(R->getValueAsString("FromMnemonic"))] + .push_back(R); } if (AliasesFromMnemonic.empty()) return; @@ -3001,7 +3002,7 @@ static void emitAsmTiedOperandConstraints(CodeGenTarget &Target, AsmMatcherInfo &Info, raw_ostream &OS) { std::string AsmParserName = - Info.AsmParser->getValueAsString("AsmParserClassName"); + std::string(Info.AsmParser->getValueAsString("AsmParserClassName")); OS << "static bool "; OS << "checkAsmTiedOperandConstraints(const " << Target.getName() << AsmParserName << "&AsmParser,\n"; diff --git a/utils/TableGen/AsmWriterEmitter.cpp b/utils/TableGen/AsmWriterEmitter.cpp index c65a8ea390b..f2700b4b77d 100644 --- a/utils/TableGen/AsmWriterEmitter.cpp +++ b/utils/TableGen/AsmWriterEmitter.cpp @@ -185,7 +185,7 @@ FindUniqueOperandCommands(std::vector &UniqueOperandCommands, InstIdxs[idx].push_back(i); } else { UniqueOperandCommands.push_back(std::move(Command)); - InstrsForCase.push_back(Inst.CGI->TheDef->getName()); + InstrsForCase.push_back(std::string(Inst.CGI->TheDef->getName())); InstIdxs.emplace_back(); InstIdxs.back().push_back(i); @@ -507,9 +507,9 @@ emitRegisterNameString(raw_ostream &O, StringRef AltName, // "NoRegAltName" is special. We don't need to do a lookup for that, // as it's just a reference to the default register name. if (AltName == "" || AltName == "NoRegAltName") { - AsmName = Reg.TheDef->getValueAsString("AsmName"); + AsmName = std::string(Reg.TheDef->getValueAsString("AsmName")); if (AsmName.empty()) - AsmName = Reg.getName(); + AsmName = std::string(Reg.getName()); } else { // Make sure the register has an alternate name for this index. std::vector AltNameList = @@ -528,7 +528,7 @@ emitRegisterNameString(raw_ostream &O, StringRef AltName, PrintFatalError(Reg.TheDef->getLoc(), "Register definition missing alt name for '" + AltName + "'."); - AsmName = AltNames[Idx]; + AsmName = std::string(AltNames[Idx]); } } StringTable.add(AsmName); @@ -859,7 +859,7 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) { PrintMethodIdx = llvm::find(PrintMethods, PrintMethod) - PrintMethods.begin(); if (static_cast(PrintMethodIdx) == PrintMethods.size()) - PrintMethods.push_back(PrintMethod); + PrintMethods.push_back(std::string(PrintMethod)); } } @@ -871,12 +871,12 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) { Record *R = CGA.ResultOperands[i].getRecord(); if (R->isSubClassOf("RegisterOperand")) R = R->getValueAsDef("RegClass"); - IAP.addCond(formatv( - "AliasPatternCond::K_RegClass, {0}::{1}RegClassID", Namespace, - R->getName())); + IAP.addCond(std::string( + formatv("AliasPatternCond::K_RegClass, {0}::{1}RegClassID", + Namespace, R->getName()))); } else { - IAP.addCond(formatv("AliasPatternCond::K_TiedReg, {0}", - IAP.getOpIndex(ROName))); + IAP.addCond(std::string(formatv( + "AliasPatternCond::K_TiedReg, {0}", IAP.getOpIndex(ROName)))); } } else { // Assume all printable operands are desired for now. This can be @@ -893,7 +893,8 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) { } else break; // No conditions on this operand at all } - IAP.addCond(formatv("AliasPatternCond::K_Custom, {0}", Entry)); + IAP.addCond( + std::string(formatv("AliasPatternCond::K_Custom, {0}", Entry))); } break; } @@ -905,7 +906,8 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) { if (Imm != Imm32) PrintFatalError("Matching an alias with an immediate out of the " "range of int32_t is not supported"); - IAP.addCond(formatv("AliasPatternCond::K_Imm, uint32_t({0})", Imm32)); + IAP.addCond(std::string( + formatv("AliasPatternCond::K_Imm, uint32_t({0})", Imm32))); break; } case CodeGenInstAlias::ResultOperand::K_Reg: @@ -917,8 +919,8 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) { } StringRef Reg = CGA.ResultOperands[i].getRegister()->getName(); - IAP.addCond( - formatv("AliasPatternCond::K_Reg, {0}::{1}", Namespace, Reg)); + IAP.addCond(std::string( + formatv("AliasPatternCond::K_Reg, {0}::{1}", Namespace, Reg))); break; } @@ -950,8 +952,9 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) { assert(!Op.empty() && "Empty operator"); bool IsNeg = Op[0] == '!'; StringRef Feature = Op.drop_front(IsNeg ? 1 : 0); - IAP.addCond(formatv("AliasPatternCond::K_{0}Feature, {1}::{2}", - IsNeg ? "Neg" : "", Namespace, Feature)); + IAP.addCond( + std::string(formatv("AliasPatternCond::K_{0}Feature, {1}::{2}", + IsNeg ? "Neg" : "", Namespace, Feature))); } } diff --git a/utils/TableGen/CodeEmitterGen.cpp b/utils/TableGen/CodeEmitterGen.cpp index 68cb8f181e6..6338d44fb2a 100644 --- a/utils/TableGen/CodeEmitterGen.cpp +++ b/utils/TableGen/CodeEmitterGen.cpp @@ -313,8 +313,8 @@ std::string CodeEmitterGen::getInstructionCaseForEncoding(Record *R, Record *Enc // bits<5> RST = { ?, ?, ?, ?, ? }; if (RV.getPrefix() || RV.getValue()->isComplete()) continue; - - AddCodeToMergeInOperand(R, BI, RV.getName(), NumberedOp, + + AddCodeToMergeInOperand(R, BI, std::string(RV.getName()), NumberedOp, NamedOpIndices, Case, Target); } diff --git a/utils/TableGen/CodeGenDAGPatterns.cpp b/utils/TableGen/CodeGenDAGPatterns.cpp index 7e0ba98da94..043cb389ad8 100644 --- a/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/utils/TableGen/CodeGenDAGPatterns.cpp @@ -1091,7 +1091,8 @@ std::string TreePredicateFn::getPredCode() const { .str(); } - std::string PredicateCode = PatFragRec->getRecord()->getValueAsString("PredicateCode"); + std::string PredicateCode = + std::string(PatFragRec->getRecord()->getValueAsString("PredicateCode")); Code += PredicateCode; @@ -1106,7 +1107,8 @@ bool TreePredicateFn::hasImmCode() const { } std::string TreePredicateFn::getImmCode() const { - return PatFragRec->getRecord()->getValueAsString("ImmediateCode"); + return std::string( + PatFragRec->getRecord()->getValueAsString("ImmediateCode")); } bool TreePredicateFn::immCodeUsesAPInt() const { @@ -1223,7 +1225,8 @@ bool TreePredicateFn::hasGISelPredicateCode() const { .empty(); } std::string TreePredicateFn::getGISelPredicateCode() const { - return PatFragRec->getRecord()->getValueAsString("GISelPredicateCode"); + return std::string( + PatFragRec->getRecord()->getValueAsString("GISelPredicateCode")); } StringRef TreePredicateFn::getImmType() const { @@ -2741,7 +2744,7 @@ TreePatternNodePtr TreePattern::ParseTreePattern(Init *TheInit, if (R->getName() == "node" && !OpName.empty()) { if (OpName.empty()) error("'node' argument requires a name to match with operand list"); - Args.push_back(OpName); + Args.push_back(std::string(OpName)); } Res->setName(OpName); @@ -2753,7 +2756,7 @@ TreePatternNodePtr TreePattern::ParseTreePattern(Init *TheInit, if (OpName.empty()) error("'?' argument requires a name to match with operand list"); TreePatternNodePtr Res = std::make_shared(TheInit, 1); - Args.push_back(OpName); + Args.push_back(std::string(OpName)); Res->setName(OpName); return Res; } @@ -3173,7 +3176,7 @@ void CodeGenDAGPatterns::ParsePatternFragments(bool OutFrags) { P->error("'" + ArgNameStr + "' does not occur in pattern or was multiply specified!"); OperandsSet.erase(ArgNameStr); - Args.push_back(ArgNameStr); + Args.push_back(std::string(ArgNameStr)); } if (!OperandsSet.empty()) diff --git a/utils/TableGen/CodeGenDAGPatterns.h b/utils/TableGen/CodeGenDAGPatterns.h index 2c081b67060..a3b84d76fde 100644 --- a/utils/TableGen/CodeGenDAGPatterns.h +++ b/utils/TableGen/CodeGenDAGPatterns.h @@ -430,7 +430,7 @@ class ScopedName { std::string Identifier; public: ScopedName(unsigned Scope, StringRef Identifier) - : Scope(Scope), Identifier(Identifier) { + : Scope(Scope), Identifier(std::string(Identifier)) { assert(Scope != 0 && "Scope == 0 is used to indicate predicates without arguments"); } @@ -1075,8 +1075,9 @@ public: // The string will excute in a subclass of SelectionDAGISel. // Cast to std::string explicitly to avoid ambiguity with StringRef. std::string C = IsHwMode - ? std::string("MF->getSubtarget().checkFeatures(\"" + Features + "\")") - : std::string(Def->getValueAsString("CondString")); + ? std::string("MF->getSubtarget().checkFeatures(\"" + + Features + "\")") + : std::string(Def->getValueAsString("CondString")); if (C.empty()) return ""; return IfCond ? C : "!("+C+')'; diff --git a/utils/TableGen/CodeGenHwModes.cpp b/utils/TableGen/CodeGenHwModes.cpp index 9052cdd2bd3..2fec46c4410 100644 --- a/utils/TableGen/CodeGenHwModes.cpp +++ b/utils/TableGen/CodeGenHwModes.cpp @@ -20,7 +20,7 @@ StringRef CodeGenHwModes::DefaultModeName = "DefaultMode"; HwMode::HwMode(Record *R) { Name = R->getName(); - Features = R->getValueAsString("Features"); + Features = std::string(R->getValueAsString("Features")); } LLVM_DUMP_METHOD diff --git a/utils/TableGen/CodeGenInstruction.cpp b/utils/TableGen/CodeGenInstruction.cpp index 6bb4dbb511b..b97193d2df4 100644 --- a/utils/TableGen/CodeGenInstruction.cpp +++ b/utils/TableGen/CodeGenInstruction.cpp @@ -80,16 +80,16 @@ CGIOperandList::CGIOperandList(Record *R) : TheDef(R) { unsigned NumOps = 1; DagInit *MIOpInfo = nullptr; if (Rec->isSubClassOf("RegisterOperand")) { - PrintMethod = Rec->getValueAsString("PrintMethod"); - OperandType = Rec->getValueAsString("OperandType"); - OperandNamespace = Rec->getValueAsString("OperandNamespace"); - EncoderMethod = Rec->getValueAsString("EncoderMethod"); + PrintMethod = std::string(Rec->getValueAsString("PrintMethod")); + OperandType = std::string(Rec->getValueAsString("OperandType")); + OperandNamespace = std::string(Rec->getValueAsString("OperandNamespace")); + EncoderMethod = std::string(Rec->getValueAsString("EncoderMethod")); } else if (Rec->isSubClassOf("Operand")) { - PrintMethod = Rec->getValueAsString("PrintMethod"); - OperandType = Rec->getValueAsString("OperandType"); - OperandNamespace = Rec->getValueAsString("OperandNamespace"); + PrintMethod = std::string(Rec->getValueAsString("PrintMethod")); + OperandType = std::string(Rec->getValueAsString("OperandType")); + OperandNamespace = std::string(Rec->getValueAsString("OperandNamespace")); // If there is an explicit encoder method, use it. - EncoderMethod = Rec->getValueAsString("EncoderMethod"); + EncoderMethod = std::string(Rec->getValueAsString("EncoderMethod")); MIOpInfo = Rec->getValueAsDag("MIOperandInfo"); // Verify that MIOpInfo has an 'ops' root value. @@ -124,15 +124,16 @@ CGIOperandList::CGIOperandList(Record *R) : TheDef(R) { PrintFatalError(R->getLoc(), "In instruction '" + R->getName() + "', operand #" + Twine(i) + " has no name!"); - if (!OperandNames.insert(ArgName).second) + if (!OperandNames.insert(std::string(ArgName)).second) PrintFatalError(R->getLoc(), "In instruction '" + R->getName() + "', operand #" + Twine(i) + " has the same name as a previous operand!"); - OperandList.emplace_back(Rec, ArgName, PrintMethod, EncoderMethod, - OperandNamespace + "::" + OperandType, MIOperandNo, - NumOps, MIOpInfo); + OperandList.emplace_back( + Rec, std::string(ArgName), std::string(PrintMethod), + std::string(EncoderMethod), OperandNamespace + "::" + OperandType, + MIOperandNo, NumOps, MIOpInfo); MIOperandNo += NumOps; } @@ -265,7 +266,8 @@ static void ParseConstraint(const std::string &CStr, CGIOperandList &Ops, PrintFatalError( Rec->getLoc(), "Illegal format for tied-to constraint in '" + Rec->getName() + "': '" + CStr + "'"); - std::string LHSOpName = StringRef(CStr).substr(start, wpos - start); + std::string LHSOpName = + std::string(StringRef(CStr).substr(start, wpos - start)); std::pair LHSOp = Ops.ParseOperandName(LHSOpName, false); wpos = CStr.find_first_not_of(" \t", pos + 1); @@ -273,7 +275,7 @@ static void ParseConstraint(const std::string &CStr, CGIOperandList &Ops, PrintFatalError( Rec->getLoc(), "Illegal format for tied-to constraint: '" + CStr + "'"); - std::string RHSOpName = StringRef(CStr).substr(wpos); + std::string RHSOpName = std::string(StringRef(CStr).substr(wpos)); std::pair RHSOp = Ops.ParseOperandName(RHSOpName, false); // Sort the operands into order, which should put the output one @@ -339,8 +341,8 @@ static void ParseConstraints(const std::string &CStr, CGIOperandList &Ops, void CGIOperandList::ProcessDisableEncoding(std::string DisableEncoding) { while (1) { std::pair P = getToken(DisableEncoding, " ,\t"); - std::string OpName = P.first; - DisableEncoding = P.second; + std::string OpName = std::string(P.first); + DisableEncoding = std::string(P.second); if (OpName.empty()) break; // Figure out which operand this is. @@ -361,7 +363,7 @@ void CGIOperandList::ProcessDisableEncoding(std::string DisableEncoding) { CodeGenInstruction::CodeGenInstruction(Record *R) : TheDef(R), Operands(R), InferredFrom(nullptr) { Namespace = R->getValueAsString("Namespace"); - AsmString = R->getValueAsString("AsmString"); + AsmString = std::string(R->getValueAsString("AsmString")); isPreISelOpcode = R->getValueAsBit("isPreISelOpcode"); isReturn = R->getValueAsBit("isReturn"); @@ -420,15 +422,18 @@ CodeGenInstruction::CodeGenInstruction(Record *R) hasChain_Inferred = false; // Parse Constraints. - ParseConstraints(R->getValueAsString("Constraints"), Operands, R); + ParseConstraints(std::string(R->getValueAsString("Constraints")), Operands, + R); // Parse the DisableEncoding field. - Operands.ProcessDisableEncoding(R->getValueAsString("DisableEncoding")); + Operands.ProcessDisableEncoding( + std::string(R->getValueAsString("DisableEncoding"))); // First check for a ComplexDeprecationPredicate. if (R->getValue("ComplexDeprecationPredicate")) { HasComplexDeprecationPredicate = true; - DeprecatedReason = R->getValueAsString("ComplexDeprecationPredicate"); + DeprecatedReason = + std::string(R->getValueAsString("ComplexDeprecationPredicate")); } else if (RecordVal *Dep = R->getValue("DeprecatedFeatureMask")) { // Check if we have a Subtarget feature mask. HasComplexDeprecationPredicate = false; @@ -541,7 +546,8 @@ bool CodeGenInstAlias::tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo, if (!Result->getArgName(AliasOpNo)) PrintFatalError(Loc, "result argument #" + Twine(AliasOpNo) + " must have a name!"); - ResOp = ResultOperand(Result->getArgNameStr(AliasOpNo), ResultRecord); + ResOp = ResultOperand(std::string(Result->getArgNameStr(AliasOpNo)), + ResultRecord); return true; } @@ -559,7 +565,8 @@ bool CodeGenInstAlias::tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo, if (!T.getRegisterClass(InstOpRec) .hasSubClass(&T.getRegisterClass(ADI->getDef()))) return false; - ResOp = ResultOperand(Result->getArgNameStr(AliasOpNo), ResultRecord); + ResOp = ResultOperand(std::string(Result->getArgNameStr(AliasOpNo)), + ResultRecord); return true; } @@ -641,7 +648,8 @@ bool CodeGenInstAlias::tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo, // MIOperandInfo perhaps? if (InstOpRec->getValueInit("Type") != ADI->getDef()->getValueInit("Type")) return false; - ResOp = ResultOperand(Result->getArgNameStr(AliasOpNo), ADI->getDef()); + ResOp = ResultOperand(std::string(Result->getArgNameStr(AliasOpNo)), + ADI->getDef()); return true; } @@ -668,8 +676,7 @@ unsigned CodeGenInstAlias::ResultOperand::getMINumOperands() const { CodeGenInstAlias::CodeGenInstAlias(Record *R, CodeGenTarget &T) : TheDef(R) { Result = R->getValueAsDag("ResultInst"); - AsmString = R->getValueAsString("AsmString"); - + AsmString = std::string(R->getValueAsString("AsmString")); // Verify that the root of the result is an instruction. DefInit *DI = dyn_cast(Result->getOperator()); diff --git a/utils/TableGen/CodeGenMapTable.cpp b/utils/TableGen/CodeGenMapTable.cpp index 793bb61481e..baca0768b26 100644 --- a/utils/TableGen/CodeGenMapTable.cpp +++ b/utils/TableGen/CodeGenMapTable.cpp @@ -98,7 +98,7 @@ private: public: InstrMap(Record* MapRec) { - Name = MapRec->getName(); + Name = std::string(MapRec->getName()); // FilterClass - It's used to reduce the search space only to the // instructions that define the kind of relationship modeled by diff --git a/utils/TableGen/CodeGenRegisters.cpp b/utils/TableGen/CodeGenRegisters.cpp index 9df09fdf657..66a37aae00e 100644 --- a/utils/TableGen/CodeGenRegisters.cpp +++ b/utils/TableGen/CodeGenRegisters.cpp @@ -52,18 +52,18 @@ using namespace llvm; CodeGenSubRegIndex::CodeGenSubRegIndex(Record *R, unsigned Enum) : TheDef(R), EnumValue(Enum), AllSuperRegsCovered(true), Artificial(true) { - Name = R->getName(); + Name = std::string(R->getName()); if (R->getValue("Namespace")) - Namespace = R->getValueAsString("Namespace"); + Namespace = std::string(R->getValueAsString("Namespace")); Size = R->getValueAsInt("Size"); Offset = R->getValueAsInt("Offset"); } CodeGenSubRegIndex::CodeGenSubRegIndex(StringRef N, StringRef Nspace, unsigned Enum) - : TheDef(nullptr), Name(N), Namespace(Nspace), Size(-1), Offset(-1), - EnumValue(Enum), AllSuperRegsCovered(true), Artificial(true) { -} + : TheDef(nullptr), Name(std::string(N)), Namespace(std::string(Nspace)), + Size(-1), Offset(-1), EnumValue(Enum), AllSuperRegsCovered(true), + Artificial(true) {} std::string CodeGenSubRegIndex::getQualifiedName() const { std::string N = getNamespace(); @@ -739,11 +739,8 @@ static void sortAndUniqueRegisters(CodeGenRegister::Vec &M) { } CodeGenRegisterClass::CodeGenRegisterClass(CodeGenRegBank &RegBank, Record *R) - : TheDef(R), - Name(R->getName()), - TopoSigs(RegBank.getNumTopoSigs()), - EnumValue(-1) { - + : TheDef(R), Name(std::string(R->getName())), + TopoSigs(RegBank.getNumTopoSigs()), EnumValue(-1) { std::vector TypeList = R->getValueAsListOfDefs("RegTypes"); for (unsigned i = 0, e = TypeList.size(); i != e; ++i) { Record *Type = TypeList[i]; @@ -816,15 +813,9 @@ CodeGenRegisterClass::CodeGenRegisterClass(CodeGenRegBank &RegBank, Record *R) // class structure has been computed. CodeGenRegisterClass::CodeGenRegisterClass(CodeGenRegBank &RegBank, StringRef Name, Key Props) - : Members(*Props.Members), - TheDef(nullptr), - Name(Name), - TopoSigs(RegBank.getNumTopoSigs()), - EnumValue(-1), - RSI(Props.RSI), - CopyCost(0), - Allocatable(true), - AllocationPriority(0) { + : Members(*Props.Members), TheDef(nullptr), Name(std::string(Name)), + TopoSigs(RegBank.getNumTopoSigs()), EnumValue(-1), RSI(Props.RSI), + CopyCost(0), Allocatable(true), AllocationPriority(0) { Artificial = true; for (const auto R : Members) { TopoSigs.set(R->getTopoSig()); diff --git a/utils/TableGen/CodeGenSchedule.cpp b/utils/TableGen/CodeGenSchedule.cpp index f12d7d484a8..09cbb234f89 100644 --- a/utils/TableGen/CodeGenSchedule.cpp +++ b/utils/TableGen/CodeGenSchedule.cpp @@ -106,7 +106,7 @@ struct InstRegexOp : public SetTheory::Operator { StringRef PatStr = Original.substr(FirstMeta); if (!PatStr.empty()) { // For the rest use a python-style prefix match. - std::string pat = PatStr; + std::string pat = std::string(PatStr); if (pat[0] != '^') { pat.insert(0, "^("); pat.insert(pat.end(), ')'); @@ -546,7 +546,7 @@ void CodeGenSchedModels::addProcModel(Record *ProcDef) { if (!ProcModelMap.insert(std::make_pair(ModelKey, ProcModels.size())).second) return; - std::string Name = ModelKey->getName(); + std::string Name = std::string(ModelKey->getName()); if (ModelKey->isSubClassOf("SchedMachineModel")) { Record *ItinsDef = ModelKey->getValueAsDef("Itineraries"); ProcModels.emplace_back(ProcModels.size(), Name, ModelKey, ItinsDef); @@ -977,7 +977,7 @@ CodeGenSchedModels::createSchedClassName(Record *ItinClassDef, std::string Name; if (ItinClassDef && ItinClassDef->getName() != "NoItinerary") - Name = ItinClassDef->getName(); + Name = std::string(ItinClassDef->getName()); for (unsigned Idx : OperWrites) { if (!Name.empty()) Name += '_'; diff --git a/utils/TableGen/CodeGenSchedule.h b/utils/TableGen/CodeGenSchedule.h index c26fb1f9780..c487d142d46 100644 --- a/utils/TableGen/CodeGenSchedule.h +++ b/utils/TableGen/CodeGenSchedule.h @@ -58,7 +58,7 @@ struct CodeGenSchedRW { HasVariants(false), IsVariadic(false), IsSequence(false) {} CodeGenSchedRW(unsigned Idx, Record *Def) : Index(Idx), TheDef(Def), IsAlias(false), IsVariadic(false) { - Name = Def->getName(); + Name = std::string(Def->getName()); IsRead = Def->isSubClassOf("SchedRead"); HasVariants = Def->isSubClassOf("SchedVariant"); if (HasVariants) diff --git a/utils/TableGen/CodeGenTarget.cpp b/utils/TableGen/CodeGenTarget.cpp index acfb143120a..de41692c6f4 100644 --- a/utils/TableGen/CodeGenTarget.cpp +++ b/utils/TableGen/CodeGenTarget.cpp @@ -206,8 +206,9 @@ StringRef llvm::getEnumName(MVT::SimpleValueType T) { std::string llvm::getQualifiedName(const Record *R) { std::string Namespace; if (R->getValue("Namespace")) - Namespace = R->getValueAsString("Namespace"); - if (Namespace.empty()) return R->getName(); + Namespace = std::string(R->getValueAsString("Namespace")); + if (Namespace.empty()) + return std::string(R->getName()); return Namespace + "::" + R->getName().str(); } @@ -526,7 +527,7 @@ bool CodeGenTarget::guessInstructionProperties() const { ComplexPattern::ComplexPattern(Record *R) { Ty = ::getValueType(R->getValueAsDef("Ty")); NumOperands = R->getValueAsInt("NumOperands"); - SelectFunc = R->getValueAsString("SelectFunc"); + SelectFunc = std::string(R->getValueAsString("SelectFunc")); RootNodes = R->getValueAsListOfDefs("RootNodes"); // FIXME: This is a hack to statically increase the priority of patterns which @@ -598,7 +599,7 @@ CodeGenIntrinsicTable::CodeGenIntrinsicTable(const RecordKeeper &RC) { CodeGenIntrinsic::CodeGenIntrinsic(Record *R) { TheDef = R; - std::string DefName = R->getName(); + std::string DefName = std::string(R->getName()); ArrayRef DefLoc = R->getLoc(); ModRef = ReadWriteMem; Properties = 0; @@ -621,12 +622,12 @@ CodeGenIntrinsic::CodeGenIntrinsic(Record *R) { EnumName = std::string(DefName.begin()+4, DefName.end()); if (R->getValue("GCCBuiltinName")) // Ignore a missing GCCBuiltinName field. - GCCBuiltinName = R->getValueAsString("GCCBuiltinName"); + GCCBuiltinName = std::string(R->getValueAsString("GCCBuiltinName")); if (R->getValue("MSBuiltinName")) // Ignore a missing MSBuiltinName field. - MSBuiltinName = R->getValueAsString("MSBuiltinName"); + MSBuiltinName = std::string(R->getValueAsString("MSBuiltinName")); - TargetPrefix = R->getValueAsString("TargetPrefix"); - Name = R->getValueAsString("LLVMName"); + TargetPrefix = std::string(R->getValueAsString("TargetPrefix")); + Name = std::string(R->getValueAsString("LLVMName")); if (Name == "") { // If an explicit name isn't specified, derive one from the DefName. diff --git a/utils/TableGen/DAGISelMatcherEmitter.cpp b/utils/TableGen/DAGISelMatcherEmitter.cpp index e9f1fb93d51..60f501cbfeb 100644 --- a/utils/TableGen/DAGISelMatcherEmitter.cpp +++ b/utils/TableGen/DAGISelMatcherEmitter.cpp @@ -960,7 +960,8 @@ void MatcherTableEmitter::EmitPredicateFunctions(raw_ostream &OS) { OS << "// " << NodeXForms[i]->getName(); OS << '\n'; - std::string ClassName = CGP.getSDNodeInfo(SDNode).getSDClassName(); + std::string ClassName = + std::string(CGP.getSDNodeInfo(SDNode).getSDClassName()); if (ClassName == "SDNode") OS << " SDNode *N = V.getNode();\n"; else diff --git a/utils/TableGen/DAGISelMatcherGen.cpp b/utils/TableGen/DAGISelMatcherGen.cpp index 6a86868a9bc..cce9383049f 100644 --- a/utils/TableGen/DAGISelMatcherGen.cpp +++ b/utils/TableGen/DAGISelMatcherGen.cpp @@ -311,7 +311,7 @@ void MatcherGen::EmitOperatorMatchCode(const TreePatternNode *N, // The "name" of a non-leaf complex pattern (MY_PAT $op1, $op2) is // "MY_PAT:op1:op2". We should already have validated that the uses are // consistent. - std::string PatternName = N->getOperator()->getName(); + std::string PatternName = std::string(N->getOperator()->getName()); for (unsigned i = 0; i < N->getNumChildren(); ++i) { PatternName += ":"; PatternName += N->getChild(i)->getName(); diff --git a/utils/TableGen/DFAEmitter.cpp b/utils/TableGen/DFAEmitter.cpp index dd3db7c150b..6521dc16057 100644 --- a/utils/TableGen/DFAEmitter.cpp +++ b/utils/TableGen/DFAEmitter.cpp @@ -345,7 +345,7 @@ Transition::Transition(Record *R, Automaton *Parent) { Types.emplace_back("unsigned"); } else if (isa(SymbolV->getType()) || isa(SymbolV->getType())) { - Actions.emplace_back(nullptr, 0, R->getValueAsString(A)); + Actions.emplace_back(nullptr, 0, std::string(R->getValueAsString(A))); Types.emplace_back("std::string"); } else { report_fatal_error("Unhandled symbol type!"); @@ -353,7 +353,7 @@ Transition::Transition(Record *R, Automaton *Parent) { StringRef TypeOverride = Parent->getActionSymbolType(A); if (!TypeOverride.empty()) - Types.back() = TypeOverride; + Types.back() = std::string(TypeOverride); } } diff --git a/utils/TableGen/DFAPacketizerEmitter.cpp b/utils/TableGen/DFAPacketizerEmitter.cpp index 018bda1b609..b4100fc36b5 100644 --- a/utils/TableGen/DFAPacketizerEmitter.cpp +++ b/utils/TableGen/DFAPacketizerEmitter.cpp @@ -93,7 +93,7 @@ public: } // end anonymous namespace DFAPacketizerEmitter::DFAPacketizerEmitter(RecordKeeper &R) - : TargetName(CodeGenTarget(R).getName()), Records(R) {} + : TargetName(std::string(CodeGenTarget(R).getName())), Records(R) {} int DFAPacketizerEmitter::collectAllFuncUnits( ArrayRef ProcModels) { @@ -120,7 +120,7 @@ int DFAPacketizerEmitter::collectAllFuncUnits( assert((j < DFA_MAX_RESOURCES) && "Exceeded maximum number of representable resources"); uint64_t FuncResources = 1ULL << j; - FUNameToBitsMap[FUs[j]->getName()] = FuncResources; + FUNameToBitsMap[std::string(FUs[j]->getName())] = FuncResources; LLVM_DEBUG(dbgs() << " " << FUs[j]->getName() << ":0x" << Twine::utohexstr(FuncResources)); } @@ -152,13 +152,13 @@ int DFAPacketizerEmitter::collectAllComboFuncs(ArrayRef ComboFuncList) Record *ComboFunc = FuncData->getValueAsDef("TheComboFunc"); const std::vector &FuncList = FuncData->getValueAsListOfDefs("FuncList"); - const std::string &ComboFuncName = ComboFunc->getName(); + const std::string &ComboFuncName = std::string(ComboFunc->getName()); uint64_t ComboBit = FUNameToBitsMap[ComboFuncName]; uint64_t ComboResources = ComboBit; LLVM_DEBUG(dbgs() << " combo: " << ComboFuncName << ":0x" << Twine::utohexstr(ComboResources) << "\n"); for (unsigned k = 0, M = FuncList.size(); k < M; ++k) { - std::string FuncName = FuncList[k]->getName(); + std::string FuncName = std::string(FuncList[k]->getName()); uint64_t FuncResources = FUNameToBitsMap[FuncName]; LLVM_DEBUG(dbgs() << " " << FuncName << ":0x" << Twine::utohexstr(FuncResources) << "\n"); @@ -181,7 +181,7 @@ DFAPacketizerEmitter::getResourcesForItinerary(Record *Itinerary) { for (Record *StageDef : Itinerary->getValueAsListOfDefs("Stages")) { uint64_t StageResources = 0; for (Record *Unit : StageDef->getValueAsListOfDefs("Units")) { - StageResources |= FUNameToBitsMap[Unit->getName()]; + StageResources |= FUNameToBitsMap[std::string(Unit->getName())]; } if (StageResources != 0) Resources.push_back(StageResources); @@ -219,7 +219,7 @@ void DFAPacketizerEmitter::run(raw_ostream &OS) { for (const CodeGenProcModel &ProcModel : CGS.procModels()) { if (ProcModel.hasItineraries()) { auto NS = ProcModel.ItinsDef->getValueAsString("PacketizerNamespace"); - ItinsByNamespace[NS].push_back(&ProcModel); + ItinsByNamespace[std::string(NS)].push_back(&ProcModel); } } diff --git a/utils/TableGen/DisassemblerEmitter.cpp b/utils/TableGen/DisassemblerEmitter.cpp index 0002b0e14db..7c3f53b31bf 100644 --- a/utils/TableGen/DisassemblerEmitter.cpp +++ b/utils/TableGen/DisassemblerEmitter.cpp @@ -136,7 +136,7 @@ void EmitDisassembler(RecordKeeper &Records, raw_ostream &OS) { // ARM and Thumb have a CHECK() macro to deal with DecodeStatuses. if (Target.getName() == "ARM" || Target.getName() == "Thumb" || Target.getName() == "AArch64" || Target.getName() == "ARM64") { - std::string PredicateNamespace = Target.getName(); + std::string PredicateNamespace = std::string(Target.getName()); if (PredicateNamespace == "Thumb") PredicateNamespace = "ARM"; @@ -148,9 +148,9 @@ void EmitDisassembler(RecordKeeper &Records, raw_ostream &OS) { return; } - EmitFixedLenDecoder(Records, OS, Target.getName(), - "if (", " == MCDisassembler::Fail)", - "MCDisassembler::Success", "MCDisassembler::Fail", ""); + EmitFixedLenDecoder(Records, OS, std::string(Target.getName()), "if (", + " == MCDisassembler::Fail)", "MCDisassembler::Success", + "MCDisassembler::Fail", ""); } } // end namespace llvm diff --git a/utils/TableGen/ExegesisEmitter.cpp b/utils/TableGen/ExegesisEmitter.cpp index 976d5f51776..8f784e4a412 100644 --- a/utils/TableGen/ExegesisEmitter.cpp +++ b/utils/TableGen/ExegesisEmitter.cpp @@ -101,7 +101,7 @@ ExegesisEmitter::ExegesisEmitter(RecordKeeper &RK) PrintFatalError("ERROR: No 'Target' subclasses defined!"); if (Targets.size() != 1) PrintFatalError("ERROR: Multiple subclasses of Target defined!"); - Target = Targets[0]->getName(); + Target = std::string(Targets[0]->getName()); } void ExegesisEmitter::emitPfmCountersInfo(const Record &Def, diff --git a/utils/TableGen/FastISelEmitter.cpp b/utils/TableGen/FastISelEmitter.cpp index b39956859fe..0729ab70d69 100644 --- a/utils/TableGen/FastISelEmitter.cpp +++ b/utils/TableGen/FastISelEmitter.cpp @@ -414,7 +414,7 @@ private: } // End anonymous namespace static std::string getOpcodeName(Record *Op, CodeGenDAGPatterns &CGP) { - return CGP.getSDNodeInfo(Op).getEnumName(); + return std::string(CGP.getSDNodeInfo(Op).getEnumName()); } static std::string getLegalCName(std::string OpName) { @@ -719,22 +719,20 @@ void FastISelMap::printFunctionDefinitions(raw_ostream &OS) { MVT::SimpleValueType RetVT = RI->first; const PredMap &PM = RI->second; - OS << "unsigned fastEmit_" - << getLegalCName(Opcode) - << "_" << getLegalCName(getName(VT)) - << "_" << getLegalCName(getName(RetVT)) << "_"; + OS << "unsigned fastEmit_" << getLegalCName(Opcode) << "_" + << getLegalCName(std::string(getName(VT))) << "_" + << getLegalCName(std::string(getName(RetVT))) << "_"; Operands.PrintManglingSuffix(OS, ImmediatePredicates); OS << "("; Operands.PrintParameters(OS); OS << ") {\n"; - emitInstructionCode(OS, Operands, PM, getName(RetVT)); + emitInstructionCode(OS, Operands, PM, std::string(getName(RetVT))); } // Emit one function for the type that demultiplexes on return type. - OS << "unsigned fastEmit_" - << getLegalCName(Opcode) << "_" - << getLegalCName(getName(VT)) << "_"; + OS << "unsigned fastEmit_" << getLegalCName(Opcode) << "_" + << getLegalCName(std::string(getName(VT))) << "_"; Operands.PrintManglingSuffix(OS, ImmediatePredicates); OS << "(MVT RetVT"; if (!Operands.empty()) @@ -745,8 +743,9 @@ void FastISelMap::printFunctionDefinitions(raw_ostream &OS) { RI != RE; ++RI) { MVT::SimpleValueType RetVT = RI->first; OS << " case " << getName(RetVT) << ": return fastEmit_" - << getLegalCName(Opcode) << "_" << getLegalCName(getName(VT)) - << "_" << getLegalCName(getName(RetVT)) << "_"; + << getLegalCName(Opcode) << "_" + << getLegalCName(std::string(getName(VT))) << "_" + << getLegalCName(std::string(getName(RetVT))) << "_"; Operands.PrintManglingSuffix(OS, ImmediatePredicates); OS << "("; Operands.PrintArguments(OS); @@ -756,9 +755,8 @@ void FastISelMap::printFunctionDefinitions(raw_ostream &OS) { } else { // Non-variadic return type. - OS << "unsigned fastEmit_" - << getLegalCName(Opcode) << "_" - << getLegalCName(getName(VT)) << "_"; + OS << "unsigned fastEmit_" << getLegalCName(Opcode) << "_" + << getLegalCName(std::string(getName(VT))) << "_"; Operands.PrintManglingSuffix(OS, ImmediatePredicates); OS << "(MVT RetVT"; if (!Operands.empty()) @@ -788,7 +786,7 @@ void FastISelMap::printFunctionDefinitions(raw_ostream &OS) { for (TypeRetPredMap::const_iterator TI = TM.begin(), TE = TM.end(); TI != TE; ++TI) { MVT::SimpleValueType VT = TI->first; - std::string TypeName = getName(VT); + std::string TypeName = std::string(getName(VT)); OS << " case " << TypeName << ": return fastEmit_" << getLegalCName(Opcode) << "_" << getLegalCName(TypeName) << "_"; Operands.PrintManglingSuffix(OS, ImmediatePredicates); diff --git a/utils/TableGen/FixedLenDecoderEmitter.cpp b/utils/TableGen/FixedLenDecoderEmitter.cpp index 21ec5897ea5..b587029f587 100644 --- a/utils/TableGen/FixedLenDecoderEmitter.cpp +++ b/utils/TableGen/FixedLenDecoderEmitter.cpp @@ -1772,7 +1772,7 @@ static std::string findOperandDecoderMethod(TypedInit *TI) { StringInit *String = DecoderString ? dyn_cast(DecoderString->getValue()) : nullptr; if (String) { - Decoder = String->getValue(); + Decoder = std::string(String->getValue()); if (!Decoder.empty()) return Decoder; } @@ -1809,7 +1809,8 @@ populateInstruction(CodeGenTarget &Target, const Record &EncodingDef, StringRef InstDecoder = EncodingDef.getValueAsString("DecoderMethod"); if (InstDecoder != "") { bool HasCompleteInstDecoder = EncodingDef.getValueAsBit("hasCompleteDecoder"); - InsnOperands.push_back(OperandInfo(InstDecoder, HasCompleteInstDecoder)); + InsnOperands.push_back( + OperandInfo(std::string(InstDecoder), HasCompleteInstDecoder)); Operands[Opc] = InsnOperands; return true; } @@ -1839,8 +1840,10 @@ populateInstruction(CodeGenTarget &Target, const Record &EncodingDef, if (tiedTo != -1) { std::pair SO = CGI.Operands.getSubOperandNumber(tiedTo); - TiedNames[InOutOperands[i].second] = InOutOperands[SO.first].second; - TiedNames[InOutOperands[SO.first].second] = InOutOperands[i].second; + TiedNames[std::string(InOutOperands[i].second)] = + std::string(InOutOperands[SO.first].second); + TiedNames[std::string(InOutOperands[SO.first].second)] = + std::string(InOutOperands[i].second); } } @@ -1936,7 +1939,7 @@ populateInstruction(CodeGenTarget &Target, const Record &EncodingDef, StringInit *String = DecoderString ? dyn_cast(DecoderString->getValue()) : nullptr; if (String && String->getValue() != "") - Decoder = String->getValue(); + Decoder = std::string(String->getValue()); if (Decoder == "" && CGI.Operands[SO.first].MIOperandInfo && @@ -1963,7 +1966,7 @@ populateInstruction(CodeGenTarget &Target, const Record &EncodingDef, String = DecoderString ? dyn_cast(DecoderString->getValue()) : nullptr; if (!isReg && String && String->getValue() != "") - Decoder = String->getValue(); + Decoder = std::string(String->getValue()); RecordVal *HasCompleteDecoderVal = TypeRecord->getValue("hasCompleteDecoder"); @@ -1989,16 +1992,17 @@ populateInstruction(CodeGenTarget &Target, const Record &EncodingDef, // For each operand, see if we can figure out where it is encoded. for (const auto &Op : InOutOperands) { - if (!NumberedInsnOperands[Op.second].empty()) { + if (!NumberedInsnOperands[std::string(Op.second)].empty()) { InsnOperands.insert(InsnOperands.end(), - NumberedInsnOperands[Op.second].begin(), - NumberedInsnOperands[Op.second].end()); + NumberedInsnOperands[std::string(Op.second)].begin(), + NumberedInsnOperands[std::string(Op.second)].end()); continue; } - if (!NumberedInsnOperands[TiedNames[Op.second]].empty()) { - if (!NumberedInsnOperandsNoTie.count(TiedNames[Op.second])) { + if (!NumberedInsnOperands[TiedNames[std::string(Op.second)]].empty()) { + if (!NumberedInsnOperandsNoTie.count(TiedNames[std::string(Op.second)])) { // Figure out to which (sub)operand we're tied. - unsigned i = CGI.Operands.getOperandNamed(TiedNames[Op.second]); + unsigned i = + CGI.Operands.getOperandNamed(TiedNames[std::string(Op.second)]); int tiedTo = CGI.Operands[i].getTiedRegister(); if (tiedTo == -1) { i = CGI.Operands.getOperandNamed(Op.second); @@ -2009,8 +2013,9 @@ populateInstruction(CodeGenTarget &Target, const Record &EncodingDef, std::pair SO = CGI.Operands.getSubOperandNumber(tiedTo); - InsnOperands.push_back(NumberedInsnOperands[TiedNames[Op.second]] - [SO.second]); + InsnOperands.push_back( + NumberedInsnOperands[TiedNames[std::string(Op.second)]] + [SO.second]); } } continue; @@ -2065,7 +2070,7 @@ populateInstruction(CodeGenTarget &Target, const Record &EncodingDef, } if (Var->getName() != Op.second && - Var->getName() != TiedNames[Op.second]) { + Var->getName() != TiedNames[std::string(Op.second)]) { if (Base != ~0U) { OpInfo.addField(Base, Width, Offset); Base = ~0U; @@ -2460,7 +2465,7 @@ void FixedLenDecoderEmitter::run(raw_ostream &o) { if (populateInstruction(Target, *EncodingDef, *Inst, i, Operands)) { std::string DecoderNamespace = - EncodingDef->getValueAsString("DecoderNamespace"); + std::string(EncodingDef->getValueAsString("DecoderNamespace")); if (!NumberedEncodings[i].HwModeName.empty()) DecoderNamespace += std::string("_") + NumberedEncodings[i].HwModeName.str(); diff --git a/utils/TableGen/GICombinerEmitter.cpp b/utils/TableGen/GICombinerEmitter.cpp index 34eb4edac8d..8c70ed157a5 100644 --- a/utils/TableGen/GICombinerEmitter.cpp +++ b/utils/TableGen/GICombinerEmitter.cpp @@ -636,7 +636,8 @@ void GICombinerEmitter::emitNameMatcher(raw_ostream &OS) const { std::string Code; raw_string_ostream SS(Code); SS << "return " << EnumeratedRule.getID() << ";\n"; - Cases.push_back(std::make_pair(EnumeratedRule.getName(), SS.str())); + Cases.push_back( + std::make_pair(std::string(EnumeratedRule.getName()), SS.str())); } OS << "static Optional getRuleIdxForIdentifier(StringRef " diff --git a/utils/TableGen/GlobalISelEmitter.cpp b/utils/TableGen/GlobalISelEmitter.cpp index d7949daee63..9a2f1a1b5ea 100644 --- a/utils/TableGen/GlobalISelEmitter.cpp +++ b/utils/TableGen/GlobalISelEmitter.cpp @@ -448,7 +448,6 @@ public: : LabelID(LabelID_.hasValue() ? LabelID_.getValue() : ~0u), EmitStr(EmitStr), NumElements(NumElements), Flags(Flags), RawValue(RawValue) { - assert((!LabelID_.hasValue() || LabelID != ~0u) && "This value is reserved for non-labels"); } @@ -1498,7 +1497,7 @@ public: const StringRef getSymbolicName() const { return SymbolicName; } void setSymbolicName(StringRef Name) { assert(SymbolicName.empty() && "Operand already has a symbolic name"); - SymbolicName = Name; + SymbolicName = std::string(Name); } /// Construct a new operand predicate and add it to the matcher. @@ -2790,7 +2789,7 @@ private: std::string S; public: - DebugCommentAction(StringRef S) : S(S) {} + DebugCommentAction(StringRef S) : S(std::string(S)) {} void emitActionOpcodes(MatchTable &Table, RuleMatcher &Rule) const override { Table << MatchTable::Comment(S) << MatchTable::LineBreak; @@ -3764,7 +3763,7 @@ Expected GlobalISelEmitter::createAndImportSelDAGMatcher( CCDef->getValueAsString("ICmpPredicate"); if (!PredType.empty()) { - OM.addPredicate(PredType); + OM.addPredicate(std::string(PredType)); // Process the other 2 operands normally. --NumChildren; } @@ -3863,9 +3862,10 @@ Error GlobalISelEmitter::importChildMatcher( Record *PhysReg = nullptr; StringRef SrcChildName = getSrcChildName(SrcChild, PhysReg); - OperandMatcher &OM = PhysReg ? - InsnMatcher.addPhysRegInput(PhysReg, OpIdx, TempOpIdx) : - InsnMatcher.addOperand(OpIdx, SrcChildName, TempOpIdx); + OperandMatcher &OM = + PhysReg + ? InsnMatcher.addPhysRegInput(PhysReg, OpIdx, TempOpIdx) + : InsnMatcher.addOperand(OpIdx, std::string(SrcChildName), TempOpIdx); if (OM.isSameAsAnotherOperand()) return Error::success(); diff --git a/utils/TableGen/InstrDocsEmitter.cpp b/utils/TableGen/InstrDocsEmitter.cpp index 07efa188540..66744bf9ece 100644 --- a/utils/TableGen/InstrDocsEmitter.cpp +++ b/utils/TableGen/InstrDocsEmitter.cpp @@ -61,7 +61,7 @@ void EmitInstrDocs(RecordKeeper &RK, raw_ostream &OS) { unsigned VariantCount = Target.getAsmParserVariantCount(); // Page title. - std::string Title = Target.getName(); + std::string Title = std::string(Target.getName()); Title += " Instructions"; writeTitle(Title, OS); OS << "\n"; diff --git a/utils/TableGen/InstrInfoEmitter.cpp b/utils/TableGen/InstrInfoEmitter.cpp index 36d9e6697ce..c857d36f901 100644 --- a/utils/TableGen/InstrInfoEmitter.cpp +++ b/utils/TableGen/InstrInfoEmitter.cpp @@ -524,7 +524,7 @@ void InstrInfoEmitter::run(raw_ostream &OS) { OS << "namespace llvm {\n\n"; CodeGenTarget &Target = CDP.getTargetInfo(); - const std::string &TargetName = Target.getName(); + const std::string &TargetName = std::string(Target.getName()); Record *InstrInfo = Target.getInstructionSet(); // Keep track of all of the def lists we have emitted already. @@ -561,7 +561,7 @@ void InstrInfoEmitter::run(raw_ostream &OS) { unsigned Num = 0; for (const CodeGenInstruction *Inst : NumberedInstructions) { // Keep a list of the instruction names. - InstrNames.add(Inst->TheDef->getName()); + InstrNames.add(std::string(Inst->TheDef->getName())); // Emit the record into the table. emitRecord(*Inst, Num++, InstrInfo, EmittedLists, OperandInfoIDs, OS); } @@ -578,7 +578,7 @@ void InstrInfoEmitter::run(raw_ostream &OS) { // Newline every eight entries. if (Num % 8 == 0) OS << "\n "; - OS << InstrNames.get(Inst->TheDef->getName()) << "U, "; + OS << InstrNames.get(std::string(Inst->TheDef->getName())) << "U, "; ++Num; } diff --git a/utils/TableGen/OptParserEmitter.cpp b/utils/TableGen/OptParserEmitter.cpp index c1978ac7ac6..bbc78911552 100644 --- a/utils/TableGen/OptParserEmitter.cpp +++ b/utils/TableGen/OptParserEmitter.cpp @@ -21,9 +21,9 @@ using namespace llvm; static const std::string getOptionName(const Record &R) { // Use the record name unless EnumName is defined. if (isa(R.getValueInit("EnumName"))) - return R.getName(); + return std::string(R.getName()); - return R.getValueAsString("EnumName"); + return std::string(R.getValueAsString("EnumName")); } static raw_ostream &write_cstring(raw_ostream &OS, llvm::StringRef Str) { @@ -241,8 +241,9 @@ void EmitOptParser(RecordKeeper &Records, raw_ostream &OS) { OS << "bool ValuesWereAdded;\n"; OS << R.getValueAsString("ValuesCode"); OS << "\n"; - for (std::string S : R.getValueAsListOfStrings("Prefixes")) { + for (StringRef Prefix : R.getValueAsListOfStrings("Prefixes")) { OS << "ValuesWereAdded = Opt.addValues("; + std::string S(Prefix); S += R.getValueAsString("Name"); write_cstring(OS, S); OS << ", Values);\n"; diff --git a/utils/TableGen/RISCVCompressInstEmitter.cpp b/utils/TableGen/RISCVCompressInstEmitter.cpp index 01cb659ad10..7f30b606dc8 100644 --- a/utils/TableGen/RISCVCompressInstEmitter.cpp +++ b/utils/TableGen/RISCVCompressInstEmitter.cpp @@ -547,7 +547,7 @@ void RISCVCompressInstEmitter::emitCompressInstEmitter(raw_ostream &o, "'PassSubtarget' is false. SubTargetInfo object is needed " "for target features.\n"); - std::string Namespace = Target.getName(); + std::string Namespace = std::string(Target.getName()); // Sort entries in CompressPatterns to handle instructions that can have more // than one candidate for compression\uncompression, e.g ADD can be diff --git a/utils/TableGen/RegisterInfoEmitter.cpp b/utils/TableGen/RegisterInfoEmitter.cpp index bf4ebca3365..944c97de386 100644 --- a/utils/TableGen/RegisterInfoEmitter.cpp +++ b/utils/TableGen/RegisterInfoEmitter.cpp @@ -897,7 +897,7 @@ RegisterInfoEmitter::runMCDesc(raw_ostream &OS, CodeGenTarget &Target, unsigned i = 0; for (auto I = Regs.begin(), E = Regs.end(); I != E; ++I, ++i) { const auto &Reg = *I; - RegStrings.add(Reg.getName()); + RegStrings.add(std::string(Reg.getName())); // Compute the ordered sub-register list. SetVector SR; @@ -963,7 +963,7 @@ RegisterInfoEmitter::runMCDesc(raw_ostream &OS, CodeGenTarget &Target, OS << "namespace llvm {\n\n"; - const std::string &TargetName = Target.getName(); + const std::string &TargetName = std::string(Target.getName()); // Emit the shared table of differential lists. OS << "extern const MCPhysReg " << TargetName << "RegDiffLists[] = {\n"; @@ -1002,7 +1002,7 @@ RegisterInfoEmitter::runMCDesc(raw_ostream &OS, CodeGenTarget &Target, // Emit the register descriptors now. i = 0; for (const auto &Reg : Regs) { - OS << " { " << RegStrings.get(Reg.getName()) << ", " + OS << " { " << RegStrings.get(std::string(Reg.getName())) << ", " << DiffSeqs.get(SubRegLists[i]) << ", " << DiffSeqs.get(SuperRegLists[i]) << ", " << SubRegIdxSeqs.get(SubRegIdxLists[i]) << ", " << (DiffSeqs.get(RegUnitLists[i]) * 16 + RegUnitInitScale[i]) << ", " @@ -1132,7 +1132,7 @@ RegisterInfoEmitter::runTargetHeader(raw_ostream &OS, CodeGenTarget &Target, OS << "\n#ifdef GET_REGINFO_HEADER\n"; OS << "#undef GET_REGINFO_HEADER\n\n"; - const std::string &TargetName = Target.getName(); + const std::string &TargetName = std::string(Target.getName()); std::string ClassName = TargetName + "GenRegisterInfo"; OS << "#include \"llvm/CodeGen/TargetRegisterInfo.h\"\n\n"; @@ -1428,7 +1428,7 @@ RegisterInfoEmitter::runTargetDesc(raw_ostream &OS, CodeGenTarget &Target, OS << "} // end anonymous namespace\n"; // Emit extra information about registers. - const std::string &TargetName = Target.getName(); + const std::string &TargetName = std::string(Target.getName()); OS << "\nstatic const TargetRegisterInfoDesc " << TargetName << "RegInfoDesc[] = { // Extra Descriptors\n"; OS << " { 0, false },\n"; diff --git a/utils/TableGen/SearchableTableEmitter.cpp b/utils/TableGen/SearchableTableEmitter.cpp index cfe48eb1949..2ac34bb5079 100644 --- a/utils/TableGen/SearchableTableEmitter.cpp +++ b/utils/TableGen/SearchableTableEmitter.cpp @@ -57,7 +57,7 @@ struct GenericField { bool IsInstruction = false; GenericEnum *Enum = nullptr; - GenericField(StringRef Name) : Name(Name) {} + GenericField(StringRef Name) : Name(std::string(Name)) {} }; struct SearchIndex { @@ -114,13 +114,14 @@ private: else if (BitInit *BI = dyn_cast(I)) return BI->getValue() ? "true" : "false"; else if (CodeInit *CI = dyn_cast(I)) - return CI->getValue(); + return std::string(CI->getValue()); else if (Field.IsIntrinsic) return "Intrinsic::" + getIntrinsic(I).EnumName; else if (Field.IsInstruction) return I->getAsString(); else if (Field.Enum) - return Field.Enum->EntryMap[cast(I)->getDef()]->first; + return std::string( + Field.Enum->EntryMap[cast(I)->getDef()]->first); PrintFatalError(Twine("invalid field type for field '") + Field.Name + "', expected: string, bits, bit or code"); } @@ -274,7 +275,7 @@ bool SearchableTableEmitter::compareBy(Record *LHS, Record *RHS, void SearchableTableEmitter::emitIfdef(StringRef Guard, raw_ostream &OS) { OS << "#ifdef " << Guard << "\n"; - PreprocessorGuards.insert(Guard); + PreprocessorGuards.insert(std::string(Guard)); } /// Emit a generic enum. @@ -542,7 +543,7 @@ SearchableTableEmitter::parseSearchIndex(GenericTable &Table, StringRef Name, const std::vector &Key, bool EarlyOut) { auto Index = std::make_unique(); - Index->Name = Name; + Index->Name = std::string(Name); Index->EarlyOut = EarlyOut; for (const auto &FieldName : Key) { @@ -648,8 +649,8 @@ void SearchableTableEmitter::run(raw_ostream &OS) { ValueField = EnumRec->getValueAsString("ValueField"); auto Enum = std::make_unique(); - Enum->Name = EnumRec->getName(); - Enum->PreprocessorGuard = EnumRec->getName(); + Enum->Name = std::string(EnumRec->getName()); + Enum->PreprocessorGuard = std::string(EnumRec->getName()); StringRef FilterClass = EnumRec->getValueAsString("FilterClass"); Enum->Class = Records.getClass(FilterClass); @@ -665,9 +666,9 @@ void SearchableTableEmitter::run(raw_ostream &OS) { for (auto TableRec : Records.getAllDerivedDefinitions("GenericTable")) { auto Table = std::make_unique(); - Table->Name = TableRec->getName(); - Table->PreprocessorGuard = TableRec->getName(); - Table->CppTypeName = TableRec->getValueAsString("CppTypeName"); + Table->Name = std::string(TableRec->getName()); + Table->PreprocessorGuard = std::string(TableRec->getName()); + Table->CppTypeName = std::string(TableRec->getValueAsString("CppTypeName")); std::vector Fields = TableRec->getValueAsListOfStrings("Fields"); for (const auto &FieldName : Fields) { @@ -746,10 +747,10 @@ void SearchableTableEmitter::run(raw_ostream &OS) { auto Table = std::make_unique(); Table->Name = (Twine(Class->getName()) + "sList").str(); Table->PreprocessorGuard = Class->getName().upper(); - Table->CppTypeName = Class->getName(); + Table->CppTypeName = std::string(Class->getName()); for (const RecordVal &Field : Class->getValues()) { - std::string FieldName = Field.getName(); + std::string FieldName = std::string(Field.getName()); // Skip uninteresting fields: either special to us, or injected // template parameters (if they contain a ':'). diff --git a/utils/TableGen/SubtargetEmitter.cpp b/utils/TableGen/SubtargetEmitter.cpp index 9b094adb7d5..4585644c3ae 100644 --- a/utils/TableGen/SubtargetEmitter.cpp +++ b/utils/TableGen/SubtargetEmitter.cpp @@ -128,8 +128,8 @@ class SubtargetEmitter { public: SubtargetEmitter(RecordKeeper &R, CodeGenTarget &TGT) - : TGT(TGT), Records(R), SchedModels(TGT.getSchedModels()), - Target(TGT.getName()) {} + : TGT(TGT), Records(R), SchedModels(TGT.getSchedModels()), + Target(TGT.getName()) {} void run(raw_ostream &o); }; @@ -460,7 +460,8 @@ EmitStageAndOperandCycleData(raw_ostream &OS, std::string ItinStageString; unsigned NStages = 0; if (ItinData) - FormItineraryStageString(Name, ItinData, ItinStageString, NStages); + FormItineraryStageString(std::string(Name), ItinData, ItinStageString, + NStages); // Get string and operand cycle count std::string ItinOperandCycleString; @@ -470,7 +471,7 @@ EmitStageAndOperandCycleData(raw_ostream &OS, FormItineraryOperandCycleString(ItinData, ItinOperandCycleString, NOperandCycles); - FormItineraryBypassString(Name, ItinData, ItinBypassString, + FormItineraryBypassString(std::string(Name), ItinData, ItinBypassString, NOperandCycles); } diff --git a/utils/TableGen/SubtargetFeatureInfo.cpp b/utils/TableGen/SubtargetFeatureInfo.cpp index 5430f73d5e0..e18ae47979c 100644 --- a/utils/TableGen/SubtargetFeatureInfo.cpp +++ b/utils/TableGen/SubtargetFeatureInfo.cpp @@ -120,7 +120,7 @@ void SubtargetFeatureInfo::emitComputeAssemblerAvailableFeatures( OS << " if ("; std::string CondStorage = - SFI.TheDef->getValueAsString("AssemblerCondString"); + std::string(SFI.TheDef->getValueAsString("AssemblerCondString")); StringRef Conds = CondStorage; std::pair Comma = Conds.split(','); bool First = true; diff --git a/utils/TableGen/X86RecognizableInstr.cpp b/utils/TableGen/X86RecognizableInstr.cpp index 1048ef81a37..ff3a111858e 100644 --- a/utils/TableGen/X86RecognizableInstr.cpp +++ b/utils/TableGen/X86RecognizableInstr.cpp @@ -65,7 +65,7 @@ RecognizableInstr::RecognizableInstr(DisassemblerTables &tables, UID = uid; Rec = insn.TheDef; - Name = Rec->getName(); + Name = std::string(Rec->getName()); Spec = &tables.specForUID(UID); if (!Rec->isSubClassOf("X86Inst")) { @@ -94,7 +94,7 @@ RecognizableInstr::RecognizableInstr(DisassemblerTables &tables, ForceDisassemble = Rec->getValueAsBit("ForceDisassemble"); CD8_Scale = byteFromRec(Rec, "CD8_Scale"); - Name = Rec->getName(); + Name = std::string(Rec->getName()); Operands = &insn.Operands.OperandList; @@ -383,12 +383,12 @@ void RecognizableInstr::handleOperand(bool optional, unsigned &operandIndex, StringRef typeName = (*Operands)[operandIndex].Rec->getName(); - OperandEncoding encoding = encodingFromString(typeName, OpSize); + OperandEncoding encoding = encodingFromString(std::string(typeName), OpSize); // Adjust the encoding type for an operand based on the instruction. adjustOperandEncoding(encoding); Spec->operands[operandIndex].encoding = encoding; - Spec->operands[operandIndex].type = typeFromString(typeName, - HasREX_WPrefix, OpSize); + Spec->operands[operandIndex].type = + typeFromString(std::string(typeName), HasREX_WPrefix, OpSize); ++operandIndex; ++physicalOperandIndex;