Use makeArrayRef or None to avoid unnecessarily mentioning the ArrayRef type extra times. NFC

llvm-svn: 248140
This commit is contained in:
Craig Topper 2015-09-21 05:32:41 +00:00
parent 18929c5069
commit 0013be16ff
13 changed files with 38 additions and 39 deletions

View File

@ -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<SDValue>(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<SDValue>(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<SDValue>(Ops, Glue.getNode() ? 3 : 2));
makeArrayRef(Ops, Glue.getNode() ? 3 : 2));
}
SDValue getCondCode(ISD::CondCode Cond);

View File

@ -481,7 +481,7 @@ ELFFile<ELFT>::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<Elf_Word>(ShndxTableBegin, ShndxTableEnd);
return makeArrayRef(ShndxTableBegin, ShndxTableEnd);
}
template <class ELFT>

View File

@ -236,7 +236,7 @@ class CounterMappingContext {
public:
CounterMappingContext(ArrayRef<CounterExpression> Expressions,
ArrayRef<uint64_t> CounterValues = ArrayRef<uint64_t>())
ArrayRef<uint64_t> CounterValues = None)
: Expressions(Expressions), CounterValues(CounterValues) {}
void setCounts(ArrayRef<uint64_t> Counts) { CounterValues = Counts; }

View File

@ -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<std::string>
findProgramByName(StringRef Name,
ArrayRef<StringRef> Paths = ArrayRef<StringRef>());
findProgramByName(StringRef Name, ArrayRef<StringRef> Paths = None);
// These functions change the specified standard stream (stdin or stdout) to
// binary mode. They return errc::success if the specified stream

View File

@ -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<int>(SVN->getMask().begin(), NumElemsPerConcat));
makeArrayRef(SVN->getMask().begin(), NumElemsPerConcat));
N1 = DAG.getUNDEF(ConcatVT);
return DAG.getNode(ISD::CONCAT_VECTORS, SDLoc(N), VT, N0, N1);
}

View File

@ -110,7 +110,7 @@ static const DWARFFormValue::FormClass DWARF4FormClasses[] = {
bool DWARFFormValue::isFormClass(DWARFFormValue::FormClass FC) const {
// First, check DWARF4 form classes.
if (Form < ArrayRef<FormClass>(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<int64_t> DWARFFormValue::getAsSignedConstant() const {
Optional<ArrayRef<uint8_t>> DWARFFormValue::getAsBlock() const {
if (!isFormClass(FC_Block) && !isFormClass(FC_Exprloc))
return None;
return ArrayRef<uint8_t>(Value.data, Value.uval);
return makeArrayRef(Value.data, Value.uval);
}

View File

@ -221,8 +221,8 @@ MCDwarfLineTableHeader::Emit(MCStreamer *MCOS,
};
assert(array_lengthof(StandardOpcodeLengths) >=
(Params.DWARF2LineOpcodeBase - 1U));
return Emit(MCOS, Params, ArrayRef<char>(StandardOpcodeLengths,
Params.DWARF2LineOpcodeBase - 1));
return Emit(MCOS, Params, makeArrayRef(StandardOpcodeLengths,
Params.DWARF2LineOpcodeBase - 1));
}
static const MCExpr *forceExpAbs(MCStreamer &OS, const MCExpr* Expr) {

View File

@ -2204,65 +2204,65 @@ MachOObjectFile::getLinkOptHintsLoadCommand() const {
ArrayRef<uint8_t> MachOObjectFile::getDyldInfoRebaseOpcodes() const {
if (!DyldInfoLoadCmd)
return ArrayRef<uint8_t>();
return None;
MachO::dyld_info_command DyldInfo
= getStruct<MachO::dyld_info_command>(this, DyldInfoLoadCmd);
const uint8_t *Ptr = reinterpret_cast<const uint8_t*>(
getPtr(this, DyldInfo.rebase_off));
return ArrayRef<uint8_t>(Ptr, DyldInfo.rebase_size);
return makeArrayRef(Ptr, DyldInfo.rebase_size);
}
ArrayRef<uint8_t> MachOObjectFile::getDyldInfoBindOpcodes() const {
if (!DyldInfoLoadCmd)
return ArrayRef<uint8_t>();
return None;
MachO::dyld_info_command DyldInfo
= getStruct<MachO::dyld_info_command>(this, DyldInfoLoadCmd);
const uint8_t *Ptr = reinterpret_cast<const uint8_t*>(
getPtr(this, DyldInfo.bind_off));
return ArrayRef<uint8_t>(Ptr, DyldInfo.bind_size);
return makeArrayRef(Ptr, DyldInfo.bind_size);
}
ArrayRef<uint8_t> MachOObjectFile::getDyldInfoWeakBindOpcodes() const {
if (!DyldInfoLoadCmd)
return ArrayRef<uint8_t>();
return None;
MachO::dyld_info_command DyldInfo
= getStruct<MachO::dyld_info_command>(this, DyldInfoLoadCmd);
const uint8_t *Ptr = reinterpret_cast<const uint8_t*>(
getPtr(this, DyldInfo.weak_bind_off));
return ArrayRef<uint8_t>(Ptr, DyldInfo.weak_bind_size);
return makeArrayRef(Ptr, DyldInfo.weak_bind_size);
}
ArrayRef<uint8_t> MachOObjectFile::getDyldInfoLazyBindOpcodes() const {
if (!DyldInfoLoadCmd)
return ArrayRef<uint8_t>();
return None;
MachO::dyld_info_command DyldInfo
= getStruct<MachO::dyld_info_command>(this, DyldInfoLoadCmd);
const uint8_t *Ptr = reinterpret_cast<const uint8_t*>(
getPtr(this, DyldInfo.lazy_bind_off));
return ArrayRef<uint8_t>(Ptr, DyldInfo.lazy_bind_size);
return makeArrayRef(Ptr, DyldInfo.lazy_bind_size);
}
ArrayRef<uint8_t> MachOObjectFile::getDyldInfoExportsTrie() const {
if (!DyldInfoLoadCmd)
return ArrayRef<uint8_t>();
return None;
MachO::dyld_info_command DyldInfo
= getStruct<MachO::dyld_info_command>(this, DyldInfoLoadCmd);
const uint8_t *Ptr = reinterpret_cast<const uint8_t*>(
getPtr(this, DyldInfo.export_off));
return ArrayRef<uint8_t>(Ptr, DyldInfo.export_size);
return makeArrayRef(Ptr, DyldInfo.export_size);
}
ArrayRef<uint8_t> MachOObjectFile::getUuid() const {
if (!UuidLoadCmd)
return ArrayRef<uint8_t>();
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<uint8_t>(reinterpret_cast<const uint8_t *>(Ptr), 16);
return makeArrayRef(reinterpret_cast<const uint8_t *>(Ptr), 16);
}
StringRef MachOObjectFile::getStringTableData() const {

View File

@ -691,7 +691,7 @@ SDValue SITargetLowering::LowerFormalArguments(
}
if (Info->getShaderType() != ShaderType::COMPUTE) {
unsigned ScratchIdx = CCInfo.getFirstUnallocated(ArrayRef<MCPhysReg>(
unsigned ScratchIdx = CCInfo.getFirstUnallocated(makeArrayRef(
AMDGPU::SGPR_32RegClass.begin(), AMDGPU::SGPR_32RegClass.getNumRegs()));
Info->ScratchOffsetReg = AMDGPU::SGPR_32RegClass.getRegister(ScratchIdx);
}

View File

@ -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<little32_t>(
COL.Data = makeArrayRef(
reinterpret_cast<const little32_t *>(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<little32_t>(
CHD.Data = makeArrayRef(
reinterpret_cast<const little32_t *>(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<little32_t>(
BCD.Data = makeArrayRef(
reinterpret_cast<const little32_t *>(SymContents.data()) + 1, 5);
StringRef *I = std::begin(BCD.Symbols), *E = std::end(BCD.Symbols);
collectRelocatedSymbols(Obj, Sec, SecAddress, SymAddress, SymSize, I, E);

View File

@ -151,7 +151,7 @@ static void printAllUnwindCodes(ArrayRef<UnwindCode> UCs) {
<< " remaining in buffer";
return ;
}
printUnwindCode(ArrayRef<UnwindCode>(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<UnwindCode>(&UI->UnwindCodes[0], UI->NumCodes));
printAllUnwindCodes(makeArrayRef(&UI->UnwindCodes[0], UI->NumCodes));
outs() << "\n";
outs().flush();

View File

@ -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<uint8_t>(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<uint8_t>(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<uint8_t>(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<uint8_t>(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<uint8_t>(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<uint8_t>(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<uint8_t>(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<uint8_t>(Bytes.data() + Index, InstSize), outs());
dumpBytes(makeArrayRef(Bytes.data() + Index, InstSize), outs());
}
IP->printInst(&Inst, outs(), "", *STI);
outs() << "\n";

View File

@ -254,7 +254,7 @@ void Dumper::printUnwindInfo(const Context &Ctx, const coff_section *Section,
return;
}
printUnwindCode(UI, ArrayRef<UnwindCode>(UCI, UCE));
printUnwindCode(UI, makeArrayRef(UCI, UCE));
UCI = UCI + UsedSlots - 1;
}
}