Skip to content

Commit 0013be1

Browse files
committed
Use makeArrayRef or None to avoid unnecessarily mentioning the ArrayRef type extra times. NFC
llvm-svn: 248140
1 parent 18929c5 commit 0013be1

File tree

13 files changed

+38
-39
lines changed

13 files changed

+38
-39
lines changed

llvm/include/llvm/CodeGen/SelectionDAG.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ class SelectionDAG {
536536
SDVTList VTs = getVTList(MVT::Other, MVT::Glue);
537537
SDValue Ops[] = { Chain, getRegister(Reg, N.getValueType()), N, Glue };
538538
return getNode(ISD::CopyToReg, dl, VTs,
539-
ArrayRef<SDValue>(Ops, Glue.getNode() ? 4 : 3));
539+
makeArrayRef(Ops, Glue.getNode() ? 4 : 3));
540540
}
541541

542542
// Similar to last getCopyToReg() except parameter Reg is a SDValue
@@ -545,7 +545,7 @@ class SelectionDAG {
545545
SDVTList VTs = getVTList(MVT::Other, MVT::Glue);
546546
SDValue Ops[] = { Chain, Reg, N, Glue };
547547
return getNode(ISD::CopyToReg, dl, VTs,
548-
ArrayRef<SDValue>(Ops, Glue.getNode() ? 4 : 3));
548+
makeArrayRef(Ops, Glue.getNode() ? 4 : 3));
549549
}
550550

551551
SDValue getCopyFromReg(SDValue Chain, SDLoc dl, unsigned Reg, EVT VT) {
@@ -562,7 +562,7 @@ class SelectionDAG {
562562
SDVTList VTs = getVTList(VT, MVT::Other, MVT::Glue);
563563
SDValue Ops[] = { Chain, getRegister(Reg, VT), Glue };
564564
return getNode(ISD::CopyFromReg, dl, VTs,
565-
ArrayRef<SDValue>(Ops, Glue.getNode() ? 3 : 2));
565+
makeArrayRef(Ops, Glue.getNode() ? 3 : 2));
566566
}
567567

568568
SDValue getCondCode(ISD::CondCode Cond);

llvm/include/llvm/Object/ELF.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ ELFFile<ELFT>::getSHNDXTable(const Elf_Shdr &Section) const {
481481
return object_error::parse_failed;
482482
if (NumSymbols != (SymTable.sh_size / sizeof(Elf_Sym)))
483483
return object_error::parse_failed;
484-
return ArrayRef<Elf_Word>(ShndxTableBegin, ShndxTableEnd);
484+
return makeArrayRef(ShndxTableBegin, ShndxTableEnd);
485485
}
486486

487487
template <class ELFT>

llvm/include/llvm/ProfileData/CoverageMapping.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class CounterMappingContext {
236236

237237
public:
238238
CounterMappingContext(ArrayRef<CounterExpression> Expressions,
239-
ArrayRef<uint64_t> CounterValues = ArrayRef<uint64_t>())
239+
ArrayRef<uint64_t> CounterValues = None)
240240
: Expressions(Expressions), CounterValues(CounterValues) {}
241241

242242
void setCounts(ArrayRef<uint64_t> Counts) { CounterValues = Counts; }

llvm/include/llvm/Support/Program.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ struct ProcessInfo {
6767
/// \returns The fully qualified path to the first \p Name in \p Paths if it
6868
/// exists. \p Name if \p Name has slashes in it. Otherwise an error.
6969
ErrorOr<std::string>
70-
findProgramByName(StringRef Name,
71-
ArrayRef<StringRef> Paths = ArrayRef<StringRef>());
70+
findProgramByName(StringRef Name, ArrayRef<StringRef> Paths = None);
7271

7372
// These functions change the specified standard stream (stdin or stdout) to
7473
// binary mode. They return errc::success if the specified stream

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12732,7 +12732,7 @@ static SDValue partitionShuffleOfConcats(SDNode *N, SelectionDAG &DAG) {
1273212732
std::all_of(SVN->getMask().begin() + NumElemsPerConcat,
1273312733
SVN->getMask().end(), [](int i) { return i == -1; })) {
1273412734
N0 = DAG.getVectorShuffle(ConcatVT, SDLoc(N), N0.getOperand(0), N0.getOperand(1),
12735-
ArrayRef<int>(SVN->getMask().begin(), NumElemsPerConcat));
12735+
makeArrayRef(SVN->getMask().begin(), NumElemsPerConcat));
1273612736
N1 = DAG.getUNDEF(ConcatVT);
1273712737
return DAG.getNode(ISD::CONCAT_VECTORS, SDLoc(N), VT, N0, N1);
1273812738
}

llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static const DWARFFormValue::FormClass DWARF4FormClasses[] = {
110110

111111
bool DWARFFormValue::isFormClass(DWARFFormValue::FormClass FC) const {
112112
// First, check DWARF4 form classes.
113-
if (Form < ArrayRef<FormClass>(DWARF4FormClasses).size() &&
113+
if (Form < makeArrayRef(DWARF4FormClasses).size() &&
114114
DWARF4FormClasses[Form] == FC)
115115
return true;
116116
// Check more forms from DWARF4 and DWARF5 proposals.
@@ -584,6 +584,6 @@ Optional<int64_t> DWARFFormValue::getAsSignedConstant() const {
584584
Optional<ArrayRef<uint8_t>> DWARFFormValue::getAsBlock() const {
585585
if (!isFormClass(FC_Block) && !isFormClass(FC_Exprloc))
586586
return None;
587-
return ArrayRef<uint8_t>(Value.data, Value.uval);
587+
return makeArrayRef(Value.data, Value.uval);
588588
}
589589

llvm/lib/MC/MCDwarf.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ MCDwarfLineTableHeader::Emit(MCStreamer *MCOS,
221221
};
222222
assert(array_lengthof(StandardOpcodeLengths) >=
223223
(Params.DWARF2LineOpcodeBase - 1U));
224-
return Emit(MCOS, Params, ArrayRef<char>(StandardOpcodeLengths,
225-
Params.DWARF2LineOpcodeBase - 1));
224+
return Emit(MCOS, Params, makeArrayRef(StandardOpcodeLengths,
225+
Params.DWARF2LineOpcodeBase - 1));
226226
}
227227

228228
static const MCExpr *forceExpAbs(MCStreamer &OS, const MCExpr* Expr) {

llvm/lib/Object/MachOObjectFile.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2204,65 +2204,65 @@ MachOObjectFile::getLinkOptHintsLoadCommand() const {
22042204

22052205
ArrayRef<uint8_t> MachOObjectFile::getDyldInfoRebaseOpcodes() const {
22062206
if (!DyldInfoLoadCmd)
2207-
return ArrayRef<uint8_t>();
2207+
return None;
22082208

22092209
MachO::dyld_info_command DyldInfo
22102210
= getStruct<MachO::dyld_info_command>(this, DyldInfoLoadCmd);
22112211
const uint8_t *Ptr = reinterpret_cast<const uint8_t*>(
22122212
getPtr(this, DyldInfo.rebase_off));
2213-
return ArrayRef<uint8_t>(Ptr, DyldInfo.rebase_size);
2213+
return makeArrayRef(Ptr, DyldInfo.rebase_size);
22142214
}
22152215

22162216
ArrayRef<uint8_t> MachOObjectFile::getDyldInfoBindOpcodes() const {
22172217
if (!DyldInfoLoadCmd)
2218-
return ArrayRef<uint8_t>();
2218+
return None;
22192219

22202220
MachO::dyld_info_command DyldInfo
22212221
= getStruct<MachO::dyld_info_command>(this, DyldInfoLoadCmd);
22222222
const uint8_t *Ptr = reinterpret_cast<const uint8_t*>(
22232223
getPtr(this, DyldInfo.bind_off));
2224-
return ArrayRef<uint8_t>(Ptr, DyldInfo.bind_size);
2224+
return makeArrayRef(Ptr, DyldInfo.bind_size);
22252225
}
22262226

22272227
ArrayRef<uint8_t> MachOObjectFile::getDyldInfoWeakBindOpcodes() const {
22282228
if (!DyldInfoLoadCmd)
2229-
return ArrayRef<uint8_t>();
2229+
return None;
22302230

22312231
MachO::dyld_info_command DyldInfo
22322232
= getStruct<MachO::dyld_info_command>(this, DyldInfoLoadCmd);
22332233
const uint8_t *Ptr = reinterpret_cast<const uint8_t*>(
22342234
getPtr(this, DyldInfo.weak_bind_off));
2235-
return ArrayRef<uint8_t>(Ptr, DyldInfo.weak_bind_size);
2235+
return makeArrayRef(Ptr, DyldInfo.weak_bind_size);
22362236
}
22372237

22382238
ArrayRef<uint8_t> MachOObjectFile::getDyldInfoLazyBindOpcodes() const {
22392239
if (!DyldInfoLoadCmd)
2240-
return ArrayRef<uint8_t>();
2240+
return None;
22412241

22422242
MachO::dyld_info_command DyldInfo
22432243
= getStruct<MachO::dyld_info_command>(this, DyldInfoLoadCmd);
22442244
const uint8_t *Ptr = reinterpret_cast<const uint8_t*>(
22452245
getPtr(this, DyldInfo.lazy_bind_off));
2246-
return ArrayRef<uint8_t>(Ptr, DyldInfo.lazy_bind_size);
2246+
return makeArrayRef(Ptr, DyldInfo.lazy_bind_size);
22472247
}
22482248

22492249
ArrayRef<uint8_t> MachOObjectFile::getDyldInfoExportsTrie() const {
22502250
if (!DyldInfoLoadCmd)
2251-
return ArrayRef<uint8_t>();
2251+
return None;
22522252

22532253
MachO::dyld_info_command DyldInfo
22542254
= getStruct<MachO::dyld_info_command>(this, DyldInfoLoadCmd);
22552255
const uint8_t *Ptr = reinterpret_cast<const uint8_t*>(
22562256
getPtr(this, DyldInfo.export_off));
2257-
return ArrayRef<uint8_t>(Ptr, DyldInfo.export_size);
2257+
return makeArrayRef(Ptr, DyldInfo.export_size);
22582258
}
22592259

22602260
ArrayRef<uint8_t> MachOObjectFile::getUuid() const {
22612261
if (!UuidLoadCmd)
2262-
return ArrayRef<uint8_t>();
2262+
return None;
22632263
// Returning a pointer is fine as uuid doesn't need endian swapping.
22642264
const char *Ptr = UuidLoadCmd + offsetof(MachO::uuid_command, uuid);
2265-
return ArrayRef<uint8_t>(reinterpret_cast<const uint8_t *>(Ptr), 16);
2265+
return makeArrayRef(reinterpret_cast<const uint8_t *>(Ptr), 16);
22662266
}
22672267

22682268
StringRef MachOObjectFile::getStringTableData() const {

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ SDValue SITargetLowering::LowerFormalArguments(
691691
}
692692

693693
if (Info->getShaderType() != ShaderType::COMPUTE) {
694-
unsigned ScratchIdx = CCInfo.getFirstUnallocated(ArrayRef<MCPhysReg>(
694+
unsigned ScratchIdx = CCInfo.getFirstUnallocated(makeArrayRef(
695695
AMDGPU::SGPR_32RegClass.begin(), AMDGPU::SGPR_32RegClass.getNumRegs()));
696696
Info->ScratchOffsetReg = AMDGPU::SGPR_32RegClass.getRegister(ScratchIdx);
697697
}

llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ static void dumpCXXData(const ObjectFile *Obj) {
218218
// Complete object locators in the MS-ABI start with '??_R4'
219219
else if (SymName.startswith("??_R4")) {
220220
CompleteObjectLocator COL;
221-
COL.Data = ArrayRef<little32_t>(
221+
COL.Data = makeArrayRef(
222222
reinterpret_cast<const little32_t *>(SymContents.data()), 3);
223223
StringRef *I = std::begin(COL.Symbols), *E = std::end(COL.Symbols);
224224
collectRelocatedSymbols(Obj, Sec, SecAddress, SymAddress, SymSize, I, E);
@@ -227,7 +227,7 @@ static void dumpCXXData(const ObjectFile *Obj) {
227227
// Class hierarchy descriptors in the MS-ABI start with '??_R3'
228228
else if (SymName.startswith("??_R3")) {
229229
ClassHierarchyDescriptor CHD;
230-
CHD.Data = ArrayRef<little32_t>(
230+
CHD.Data = makeArrayRef(
231231
reinterpret_cast<const little32_t *>(SymContents.data()), 3);
232232
StringRef *I = std::begin(CHD.Symbols), *E = std::end(CHD.Symbols);
233233
collectRelocatedSymbols(Obj, Sec, SecAddress, SymAddress, SymSize, I, E);
@@ -243,7 +243,7 @@ static void dumpCXXData(const ObjectFile *Obj) {
243243
// Base class descriptors in the MS-ABI start with '??_R1'
244244
else if (SymName.startswith("??_R1")) {
245245
BaseClassDescriptor BCD;
246-
BCD.Data = ArrayRef<little32_t>(
246+
BCD.Data = makeArrayRef(
247247
reinterpret_cast<const little32_t *>(SymContents.data()) + 1, 5);
248248
StringRef *I = std::begin(BCD.Symbols), *E = std::end(BCD.Symbols);
249249
collectRelocatedSymbols(Obj, Sec, SecAddress, SymAddress, SymSize, I, E);

llvm/tools/llvm-objdump/COFFDump.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static void printAllUnwindCodes(ArrayRef<UnwindCode> UCs) {
151151
<< " remaining in buffer";
152152
return ;
153153
}
154-
printUnwindCode(ArrayRef<UnwindCode>(I, E));
154+
printUnwindCode(makeArrayRef(I, E));
155155
I += UsedSlots;
156156
}
157157
}
@@ -433,7 +433,7 @@ static void printWin64EHUnwindInfo(const Win64EH::UnwindInfo *UI) {
433433
if (UI->NumCodes)
434434
outs() << " Unwind Codes:\n";
435435

436-
printAllUnwindCodes(ArrayRef<UnwindCode>(&UI->UnwindCodes[0], UI->NumCodes));
436+
printAllUnwindCodes(makeArrayRef(&UI->UnwindCodes[0], UI->NumCodes));
437437

438438
outs() << "\n";
439439
outs().flush();

llvm/tools/llvm-objdump/MachODump.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,19 +205,19 @@ static uint64_t DumpDataInCode(const uint8_t *bytes, uint64_t Length,
205205
case MachO::DICE_KIND_DATA:
206206
if (Length >= 4) {
207207
if (!NoShowRawInsn)
208-
dumpBytes(ArrayRef<uint8_t>(bytes, 4), outs());
208+
dumpBytes(makeArrayRef(bytes, 4), outs());
209209
Value = bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0];
210210
outs() << "\t.long " << Value;
211211
Size = 4;
212212
} else if (Length >= 2) {
213213
if (!NoShowRawInsn)
214-
dumpBytes(ArrayRef<uint8_t>(bytes, 2), outs());
214+
dumpBytes(makeArrayRef(bytes, 2), outs());
215215
Value = bytes[1] << 8 | bytes[0];
216216
outs() << "\t.short " << Value;
217217
Size = 2;
218218
} else {
219219
if (!NoShowRawInsn)
220-
dumpBytes(ArrayRef<uint8_t>(bytes, 2), outs());
220+
dumpBytes(makeArrayRef(bytes, 2), outs());
221221
Value = bytes[0];
222222
outs() << "\t.byte " << Value;
223223
Size = 1;
@@ -229,14 +229,14 @@ static uint64_t DumpDataInCode(const uint8_t *bytes, uint64_t Length,
229229
break;
230230
case MachO::DICE_KIND_JUMP_TABLE8:
231231
if (!NoShowRawInsn)
232-
dumpBytes(ArrayRef<uint8_t>(bytes, 1), outs());
232+
dumpBytes(makeArrayRef(bytes, 1), outs());
233233
Value = bytes[0];
234234
outs() << "\t.byte " << format("%3u", Value) << "\t@ KIND_JUMP_TABLE8\n";
235235
Size = 1;
236236
break;
237237
case MachO::DICE_KIND_JUMP_TABLE16:
238238
if (!NoShowRawInsn)
239-
dumpBytes(ArrayRef<uint8_t>(bytes, 2), outs());
239+
dumpBytes(makeArrayRef(bytes, 2), outs());
240240
Value = bytes[1] << 8 | bytes[0];
241241
outs() << "\t.short " << format("%5u", Value & 0xffff)
242242
<< "\t@ KIND_JUMP_TABLE16\n";
@@ -245,7 +245,7 @@ static uint64_t DumpDataInCode(const uint8_t *bytes, uint64_t Length,
245245
case MachO::DICE_KIND_JUMP_TABLE32:
246246
case MachO::DICE_KIND_ABS_JUMP_TABLE32:
247247
if (!NoShowRawInsn)
248-
dumpBytes(ArrayRef<uint8_t>(bytes, 4), outs());
248+
dumpBytes(makeArrayRef(bytes, 4), outs());
249249
Value = bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0];
250250
outs() << "\t.long " << Value;
251251
if (Kind == MachO::DICE_KIND_JUMP_TABLE32)
@@ -6217,7 +6217,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
62176217
DebugOut, Annotations);
62186218
if (gotInst) {
62196219
if (!NoShowRawInsn) {
6220-
dumpBytes(ArrayRef<uint8_t>(Bytes.data() + Index, Size), outs());
6220+
dumpBytes(makeArrayRef(Bytes.data() + Index, Size), outs());
62216221
}
62226222
formatted_raw_ostream FormattedOS(outs());
62236223
StringRef AnnotationsStr = Annotations.str();
@@ -6281,7 +6281,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
62816281
}
62826282
if (!NoShowRawInsn) {
62836283
outs() << "\t";
6284-
dumpBytes(ArrayRef<uint8_t>(Bytes.data() + Index, InstSize), outs());
6284+
dumpBytes(makeArrayRef(Bytes.data() + Index, InstSize), outs());
62856285
}
62866286
IP->printInst(&Inst, outs(), "", *STI);
62876287
outs() << "\n";

llvm/tools/llvm-readobj/Win64EHDumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ void Dumper::printUnwindInfo(const Context &Ctx, const coff_section *Section,
254254
return;
255255
}
256256

257-
printUnwindCode(UI, ArrayRef<UnwindCode>(UCI, UCE));
257+
printUnwindCode(UI, makeArrayRef(UCI, UCE));
258258
UCI = UCI + UsedSlots - 1;
259259
}
260260
}

0 commit comments

Comments
 (0)