From 795a06a0465c180d5881e82c04709918aace7278 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Mon, 21 Sep 2015 05:32:41 +0000 Subject: [PATCH] Use makeArrayRef or None to avoid unnecessarily mentioning the ArrayRef type extra times. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248140 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/SelectionDAG.h | 6 +++--- include/llvm/Object/ELF.h | 2 +- include/llvm/ProfileData/CoverageMapping.h | 2 +- include/llvm/Support/Program.h | 3 +-- lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 2 +- lib/DebugInfo/DWARF/DWARFFormValue.cpp | 4 ++-- lib/MC/MCDwarf.cpp | 4 ++-- lib/Object/MachOObjectFile.cpp | 24 +++++++++++----------- lib/Target/AMDGPU/SIISelLowering.cpp | 2 +- tools/llvm-cxxdump/llvm-cxxdump.cpp | 6 +++--- tools/llvm-objdump/COFFDump.cpp | 4 ++-- tools/llvm-objdump/MachODump.cpp | 16 +++++++-------- tools/llvm-readobj/Win64EHDumper.cpp | 2 +- 13 files changed, 38 insertions(+), 39 deletions(-) diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index da187ca319e..f23f0108462 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -536,7 +536,7 @@ public: SDVTList VTs = getVTList(MVT::Other, MVT::Glue); SDValue Ops[] = { Chain, getRegister(Reg, N.getValueType()), N, Glue }; return getNode(ISD::CopyToReg, dl, VTs, - ArrayRef(Ops, Glue.getNode() ? 4 : 3)); + makeArrayRef(Ops, Glue.getNode() ? 4 : 3)); } // Similar to last getCopyToReg() except parameter Reg is a SDValue @@ -545,7 +545,7 @@ public: SDVTList VTs = getVTList(MVT::Other, MVT::Glue); SDValue Ops[] = { Chain, Reg, N, Glue }; return getNode(ISD::CopyToReg, dl, VTs, - ArrayRef(Ops, Glue.getNode() ? 4 : 3)); + makeArrayRef(Ops, Glue.getNode() ? 4 : 3)); } SDValue getCopyFromReg(SDValue Chain, SDLoc dl, unsigned Reg, EVT VT) { @@ -562,7 +562,7 @@ public: SDVTList VTs = getVTList(VT, MVT::Other, MVT::Glue); SDValue Ops[] = { Chain, getRegister(Reg, VT), Glue }; return getNode(ISD::CopyFromReg, dl, VTs, - ArrayRef(Ops, Glue.getNode() ? 3 : 2)); + makeArrayRef(Ops, Glue.getNode() ? 3 : 2)); } SDValue getCondCode(ISD::CondCode Cond); diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index dfc06af1e08..00830ba7836 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -481,7 +481,7 @@ ELFFile::getSHNDXTable(const Elf_Shdr &Section) const { return object_error::parse_failed; if (NumSymbols != (SymTable.sh_size / sizeof(Elf_Sym))) return object_error::parse_failed; - return ArrayRef(ShndxTableBegin, ShndxTableEnd); + return makeArrayRef(ShndxTableBegin, ShndxTableEnd); } template diff --git a/include/llvm/ProfileData/CoverageMapping.h b/include/llvm/ProfileData/CoverageMapping.h index 71813c84c33..3790e135844 100644 --- a/include/llvm/ProfileData/CoverageMapping.h +++ b/include/llvm/ProfileData/CoverageMapping.h @@ -236,7 +236,7 @@ class CounterMappingContext { public: CounterMappingContext(ArrayRef Expressions, - ArrayRef CounterValues = ArrayRef()) + ArrayRef CounterValues = None) : Expressions(Expressions), CounterValues(CounterValues) {} void setCounts(ArrayRef Counts) { CounterValues = Counts; } diff --git a/include/llvm/Support/Program.h b/include/llvm/Support/Program.h index b89a0f73ec6..43302101e3e 100644 --- a/include/llvm/Support/Program.h +++ b/include/llvm/Support/Program.h @@ -67,8 +67,7 @@ struct ProcessInfo { /// \returns The fully qualified path to the first \p Name in \p Paths if it /// exists. \p Name if \p Name has slashes in it. Otherwise an error. ErrorOr - findProgramByName(StringRef Name, - ArrayRef Paths = ArrayRef()); + findProgramByName(StringRef Name, ArrayRef Paths = None); // These functions change the specified standard stream (stdin or stdout) to // binary mode. They return errc::success if the specified stream diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index c77c1e08c27..b8691bd9e10 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -12732,7 +12732,7 @@ static SDValue partitionShuffleOfConcats(SDNode *N, SelectionDAG &DAG) { std::all_of(SVN->getMask().begin() + NumElemsPerConcat, SVN->getMask().end(), [](int i) { return i == -1; })) { N0 = DAG.getVectorShuffle(ConcatVT, SDLoc(N), N0.getOperand(0), N0.getOperand(1), - ArrayRef(SVN->getMask().begin(), NumElemsPerConcat)); + makeArrayRef(SVN->getMask().begin(), NumElemsPerConcat)); N1 = DAG.getUNDEF(ConcatVT); return DAG.getNode(ISD::CONCAT_VECTORS, SDLoc(N), VT, N0, N1); } diff --git a/lib/DebugInfo/DWARF/DWARFFormValue.cpp b/lib/DebugInfo/DWARF/DWARFFormValue.cpp index 53a676efaf3..d22e63502d2 100644 --- a/lib/DebugInfo/DWARF/DWARFFormValue.cpp +++ b/lib/DebugInfo/DWARF/DWARFFormValue.cpp @@ -110,7 +110,7 @@ static const DWARFFormValue::FormClass DWARF4FormClasses[] = { bool DWARFFormValue::isFormClass(DWARFFormValue::FormClass FC) const { // First, check DWARF4 form classes. - if (Form < ArrayRef(DWARF4FormClasses).size() && + if (Form < makeArrayRef(DWARF4FormClasses).size() && DWARF4FormClasses[Form] == FC) return true; // Check more forms from DWARF4 and DWARF5 proposals. @@ -584,6 +584,6 @@ Optional DWARFFormValue::getAsSignedConstant() const { Optional> DWARFFormValue::getAsBlock() const { if (!isFormClass(FC_Block) && !isFormClass(FC_Exprloc)) return None; - return ArrayRef(Value.data, Value.uval); + return makeArrayRef(Value.data, Value.uval); } diff --git a/lib/MC/MCDwarf.cpp b/lib/MC/MCDwarf.cpp index 2d8912b71f1..9ab8319f4c8 100644 --- a/lib/MC/MCDwarf.cpp +++ b/lib/MC/MCDwarf.cpp @@ -221,8 +221,8 @@ MCDwarfLineTableHeader::Emit(MCStreamer *MCOS, }; assert(array_lengthof(StandardOpcodeLengths) >= (Params.DWARF2LineOpcodeBase - 1U)); - return Emit(MCOS, Params, ArrayRef(StandardOpcodeLengths, - Params.DWARF2LineOpcodeBase - 1)); + return Emit(MCOS, Params, makeArrayRef(StandardOpcodeLengths, + Params.DWARF2LineOpcodeBase - 1)); } static const MCExpr *forceExpAbs(MCStreamer &OS, const MCExpr* Expr) { diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp index d1faf7be3af..571ed7a14fb 100644 --- a/lib/Object/MachOObjectFile.cpp +++ b/lib/Object/MachOObjectFile.cpp @@ -2204,65 +2204,65 @@ MachOObjectFile::getLinkOptHintsLoadCommand() const { ArrayRef MachOObjectFile::getDyldInfoRebaseOpcodes() const { if (!DyldInfoLoadCmd) - return ArrayRef(); + return None; MachO::dyld_info_command DyldInfo = getStruct(this, DyldInfoLoadCmd); const uint8_t *Ptr = reinterpret_cast( getPtr(this, DyldInfo.rebase_off)); - return ArrayRef(Ptr, DyldInfo.rebase_size); + return makeArrayRef(Ptr, DyldInfo.rebase_size); } ArrayRef MachOObjectFile::getDyldInfoBindOpcodes() const { if (!DyldInfoLoadCmd) - return ArrayRef(); + return None; MachO::dyld_info_command DyldInfo = getStruct(this, DyldInfoLoadCmd); const uint8_t *Ptr = reinterpret_cast( getPtr(this, DyldInfo.bind_off)); - return ArrayRef(Ptr, DyldInfo.bind_size); + return makeArrayRef(Ptr, DyldInfo.bind_size); } ArrayRef MachOObjectFile::getDyldInfoWeakBindOpcodes() const { if (!DyldInfoLoadCmd) - return ArrayRef(); + return None; MachO::dyld_info_command DyldInfo = getStruct(this, DyldInfoLoadCmd); const uint8_t *Ptr = reinterpret_cast( getPtr(this, DyldInfo.weak_bind_off)); - return ArrayRef(Ptr, DyldInfo.weak_bind_size); + return makeArrayRef(Ptr, DyldInfo.weak_bind_size); } ArrayRef MachOObjectFile::getDyldInfoLazyBindOpcodes() const { if (!DyldInfoLoadCmd) - return ArrayRef(); + return None; MachO::dyld_info_command DyldInfo = getStruct(this, DyldInfoLoadCmd); const uint8_t *Ptr = reinterpret_cast( getPtr(this, DyldInfo.lazy_bind_off)); - return ArrayRef(Ptr, DyldInfo.lazy_bind_size); + return makeArrayRef(Ptr, DyldInfo.lazy_bind_size); } ArrayRef MachOObjectFile::getDyldInfoExportsTrie() const { if (!DyldInfoLoadCmd) - return ArrayRef(); + return None; MachO::dyld_info_command DyldInfo = getStruct(this, DyldInfoLoadCmd); const uint8_t *Ptr = reinterpret_cast( getPtr(this, DyldInfo.export_off)); - return ArrayRef(Ptr, DyldInfo.export_size); + return makeArrayRef(Ptr, DyldInfo.export_size); } ArrayRef MachOObjectFile::getUuid() const { if (!UuidLoadCmd) - return ArrayRef(); + return None; // Returning a pointer is fine as uuid doesn't need endian swapping. const char *Ptr = UuidLoadCmd + offsetof(MachO::uuid_command, uuid); - return ArrayRef(reinterpret_cast(Ptr), 16); + return makeArrayRef(reinterpret_cast(Ptr), 16); } StringRef MachOObjectFile::getStringTableData() const { diff --git a/lib/Target/AMDGPU/SIISelLowering.cpp b/lib/Target/AMDGPU/SIISelLowering.cpp index d0830a9e583..120966e92db 100644 --- a/lib/Target/AMDGPU/SIISelLowering.cpp +++ b/lib/Target/AMDGPU/SIISelLowering.cpp @@ -691,7 +691,7 @@ SDValue SITargetLowering::LowerFormalArguments( } if (Info->getShaderType() != ShaderType::COMPUTE) { - unsigned ScratchIdx = CCInfo.getFirstUnallocated(ArrayRef( + unsigned ScratchIdx = CCInfo.getFirstUnallocated(makeArrayRef( AMDGPU::SGPR_32RegClass.begin(), AMDGPU::SGPR_32RegClass.getNumRegs())); Info->ScratchOffsetReg = AMDGPU::SGPR_32RegClass.getRegister(ScratchIdx); } diff --git a/tools/llvm-cxxdump/llvm-cxxdump.cpp b/tools/llvm-cxxdump/llvm-cxxdump.cpp index bea34fee3aa..d45a28a3b0f 100644 --- a/tools/llvm-cxxdump/llvm-cxxdump.cpp +++ b/tools/llvm-cxxdump/llvm-cxxdump.cpp @@ -218,7 +218,7 @@ static void dumpCXXData(const ObjectFile *Obj) { // Complete object locators in the MS-ABI start with '??_R4' else if (SymName.startswith("??_R4")) { CompleteObjectLocator COL; - COL.Data = ArrayRef( + COL.Data = makeArrayRef( reinterpret_cast(SymContents.data()), 3); StringRef *I = std::begin(COL.Symbols), *E = std::end(COL.Symbols); collectRelocatedSymbols(Obj, Sec, SecAddress, SymAddress, SymSize, I, E); @@ -227,7 +227,7 @@ static void dumpCXXData(const ObjectFile *Obj) { // Class hierarchy descriptors in the MS-ABI start with '??_R3' else if (SymName.startswith("??_R3")) { ClassHierarchyDescriptor CHD; - CHD.Data = ArrayRef( + CHD.Data = makeArrayRef( reinterpret_cast(SymContents.data()), 3); StringRef *I = std::begin(CHD.Symbols), *E = std::end(CHD.Symbols); collectRelocatedSymbols(Obj, Sec, SecAddress, SymAddress, SymSize, I, E); @@ -243,7 +243,7 @@ static void dumpCXXData(const ObjectFile *Obj) { // Base class descriptors in the MS-ABI start with '??_R1' else if (SymName.startswith("??_R1")) { BaseClassDescriptor BCD; - BCD.Data = ArrayRef( + BCD.Data = makeArrayRef( reinterpret_cast(SymContents.data()) + 1, 5); StringRef *I = std::begin(BCD.Symbols), *E = std::end(BCD.Symbols); collectRelocatedSymbols(Obj, Sec, SecAddress, SymAddress, SymSize, I, E); diff --git a/tools/llvm-objdump/COFFDump.cpp b/tools/llvm-objdump/COFFDump.cpp index 53500a4bb76..001e352c8d0 100644 --- a/tools/llvm-objdump/COFFDump.cpp +++ b/tools/llvm-objdump/COFFDump.cpp @@ -151,7 +151,7 @@ static void printAllUnwindCodes(ArrayRef UCs) { << " remaining in buffer"; return ; } - printUnwindCode(ArrayRef(I, E)); + printUnwindCode(makeArrayRef(I, E)); I += UsedSlots; } } @@ -433,7 +433,7 @@ static void printWin64EHUnwindInfo(const Win64EH::UnwindInfo *UI) { if (UI->NumCodes) outs() << " Unwind Codes:\n"; - printAllUnwindCodes(ArrayRef(&UI->UnwindCodes[0], UI->NumCodes)); + printAllUnwindCodes(makeArrayRef(&UI->UnwindCodes[0], UI->NumCodes)); outs() << "\n"; outs().flush(); diff --git a/tools/llvm-objdump/MachODump.cpp b/tools/llvm-objdump/MachODump.cpp index df8ac09846c..8a76d8a3d1b 100644 --- a/tools/llvm-objdump/MachODump.cpp +++ b/tools/llvm-objdump/MachODump.cpp @@ -205,19 +205,19 @@ static uint64_t DumpDataInCode(const uint8_t *bytes, uint64_t Length, case MachO::DICE_KIND_DATA: if (Length >= 4) { if (!NoShowRawInsn) - dumpBytes(ArrayRef(bytes, 4), outs()); + dumpBytes(makeArrayRef(bytes, 4), outs()); Value = bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0]; outs() << "\t.long " << Value; Size = 4; } else if (Length >= 2) { if (!NoShowRawInsn) - dumpBytes(ArrayRef(bytes, 2), outs()); + dumpBytes(makeArrayRef(bytes, 2), outs()); Value = bytes[1] << 8 | bytes[0]; outs() << "\t.short " << Value; Size = 2; } else { if (!NoShowRawInsn) - dumpBytes(ArrayRef(bytes, 2), outs()); + dumpBytes(makeArrayRef(bytes, 2), outs()); Value = bytes[0]; outs() << "\t.byte " << Value; Size = 1; @@ -229,14 +229,14 @@ static uint64_t DumpDataInCode(const uint8_t *bytes, uint64_t Length, break; case MachO::DICE_KIND_JUMP_TABLE8: if (!NoShowRawInsn) - dumpBytes(ArrayRef(bytes, 1), outs()); + dumpBytes(makeArrayRef(bytes, 1), outs()); Value = bytes[0]; outs() << "\t.byte " << format("%3u", Value) << "\t@ KIND_JUMP_TABLE8\n"; Size = 1; break; case MachO::DICE_KIND_JUMP_TABLE16: if (!NoShowRawInsn) - dumpBytes(ArrayRef(bytes, 2), outs()); + dumpBytes(makeArrayRef(bytes, 2), outs()); Value = bytes[1] << 8 | bytes[0]; outs() << "\t.short " << format("%5u", Value & 0xffff) << "\t@ KIND_JUMP_TABLE16\n"; @@ -245,7 +245,7 @@ static uint64_t DumpDataInCode(const uint8_t *bytes, uint64_t Length, case MachO::DICE_KIND_JUMP_TABLE32: case MachO::DICE_KIND_ABS_JUMP_TABLE32: if (!NoShowRawInsn) - dumpBytes(ArrayRef(bytes, 4), outs()); + dumpBytes(makeArrayRef(bytes, 4), outs()); Value = bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0]; outs() << "\t.long " << Value; if (Kind == MachO::DICE_KIND_JUMP_TABLE32) @@ -6217,7 +6217,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF, DebugOut, Annotations); if (gotInst) { if (!NoShowRawInsn) { - dumpBytes(ArrayRef(Bytes.data() + Index, Size), outs()); + dumpBytes(makeArrayRef(Bytes.data() + Index, Size), outs()); } formatted_raw_ostream FormattedOS(outs()); StringRef AnnotationsStr = Annotations.str(); @@ -6281,7 +6281,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF, } if (!NoShowRawInsn) { outs() << "\t"; - dumpBytes(ArrayRef(Bytes.data() + Index, InstSize), outs()); + dumpBytes(makeArrayRef(Bytes.data() + Index, InstSize), outs()); } IP->printInst(&Inst, outs(), "", *STI); outs() << "\n"; diff --git a/tools/llvm-readobj/Win64EHDumper.cpp b/tools/llvm-readobj/Win64EHDumper.cpp index ffb0855606a..2da5ae3200f 100644 --- a/tools/llvm-readobj/Win64EHDumper.cpp +++ b/tools/llvm-readobj/Win64EHDumper.cpp @@ -254,7 +254,7 @@ void Dumper::printUnwindInfo(const Context &Ctx, const coff_section *Section, return; } - printUnwindCode(UI, ArrayRef(UCI, UCE)); + printUnwindCode(UI, makeArrayRef(UCI, UCE)); UCI = UCI + UsedSlots - 1; } } -- 2.34.1