A constant reference to consecutive elements in memory.

Synopsis

Declared in <llvm/ADT/ArrayRef.h>

template<typename T>
class [[nodiscard]] ArrayRef;

Description

Represents a constant reference to an array (0 or more elements consecutively in memory), i.e. a start pointer and a length. It allows various APIs to take consecutive elements easily and conveniently.

This class does not own the underlying data; it is expected to be used in situations where the data resides in some other buffer whose lifetime extends past that of the ArrayRef. For this reason, it is not in general safe to store an ArrayRef.

This is intended to be trivially copyable, so it should be passed by value.

Type Aliases

Name

Description

const_iterator

Const iterator over the referenced array elements.

const_pointer

Pointer to a const element.

const_reference

Const reference to an element.

const_reverse_iterator

Const reverse iterator over the referenced array elements.

difference_type

Signed type used to express distances between iterators.

iterator

Iterator over the referenced array elements.

pointer

Mutable pointer to an element.

reference

Mutable reference to an element.

reverse_iterator

Reverse iterator over the referenced array elements.

size_type

Unsigned type used to express the size of the array.

value_type

Element type stored in the referenced array.

Member Functions

Name

Description

ArrayRef [constructor]

Constructors

operator=

Disallow accidental assignment from a temporary.

back

Get the last element.

begin

Return an iterator to the first element.

consume_back

consume_back() ‐ Returns the last element and drops it from ArrayRef.

consume_front

consume_front() ‐ Returns the first element and drops it from ArrayRef.

copy

Allocate a mutable copy in A and return a reference to it.

data

Return a pointer to the first element of the array.

drop_back

Drop the last N elements of the array.

drop_front

Drop the first N elements of the array.

drop_until

Return a copy of *this with the first N elements not satisfying the given predicate removed.

drop_while

Return a copy of *this with the first N elements satisfying the given predicate removed.

empty

Check if the array is empty.

end

Return an iterator past the last element.

equals

Check for element‐wise equality.

front

Get the first element.

operator[]

Return a const reference to the element at Index.

rbegin

Return a reverse iterator to the last element.

rend

Return a reverse iterator to the element before the first element.

size

Get the array size.

slice

slice overloads

take_back

Return a copy of *this with only the last N elements.

take_front

Return a copy of *this with only the first N elements.

take_until

Return the first N elements of this Array that don't satisfy the given predicate.

take_while

Return the first N elements of this Array that satisfy the given predicate.

vec

Copy the referenced elements into a new std::vector.

operator std::vector<T>

Convert this ArrayRef into a std::vector copy of its elements.

Deduction Guides

Name

Description

ArrayRef<T>

Deduction guide to construct an ArrayRef from an ArrayRef

ArrayRef<T>

@{ Deduction guide to construct an ArrayRef from a single element.

ArrayRef<T>

Deduction guide to construct an ArrayRef from an ArrayRef (const)

ArrayRef<T>

Deduction guide to construct an ArrayRef from a SmallVector

ArrayRef<T>

Deduction guide to construct an ArrayRef from a std::vector

ArrayRef<T>

Deduction guide to construct an ArrayRef from a SmallVector

ArrayRef<T>

Deduction guide to construct an ArrayRef from a std::array

ArrayRef<T>

Deduction guide to construct an ArrayRef from a C array.

ArrayRef<T>

Deduction guide to construct an ArrayRef from a pointer and length

ArrayRef<T>

Deduction guide to construct an ArrayRef from a range

Non-Member Functions

Name

Description

ComputeEditDistance

Determine the edit distance between two sequences.

ComputeMappedEditDistance

Determine the edit distance between two sequences.

ConvertCostTableLookup

Find in type conversion cost table.

CostTableLookup

Find in cost table.

DeleteDeadBlocks

Delete the specified blocks, which must have no live predecessors.

PrintError

Print an error diagnostic at source location(s) ErrorLoc.

PrintFatalError

Print an error at ErrorLoc and then exit the process.

PrintFatalNote

Print a note at ErrorLoc and then exit the process.

PrintNote

Print a note diagnostic at source location(s) NoteLoc.

PrintWarning

Print a warning diagnostic at source location(s) WarningLoc.

PromoteMemToReg

Promote the specified list of alloca instructions into scalar registers, inserting PHI nodes as appropriate.

StrCmpOptionPrefixes

Compare two option prefix sequences for sorting.

arrayRefFromStringRef

Construct an array ref of bytes from a string ref.

canConvertToMinOrMaxIntrinsic

Check if values in VL are selects convertible to a min/max intrinsic.

cleanUpTempFiles

Removes the temporary files named in FileName.

cloneAndAdaptNoAliasScopes

Clone noalias scopes and adapt instructions in a range.

cloneAndAdaptNoAliasScopes

Clone noalias scopes and adapt instructions in new blocks.

cloneNoAliasScopes

Duplicate the listed noalias declaration scopes.

collectGlobalObjectNameStrings

Serialize global‐object name strings into a profile‐ready blob.

collectPGOFuncNameStrings

Serialize referenced PGO function‐name variables into Result.

collectVTableStrings

Serialize vtable name strings into a profile‐ready blob.

computeExpressionSize

Compute a saturated expression‐size estimate from operand sizes.

computeMinimumValueSizes

Compute a map of integer instructions to their minimum legal type size.

convertUTF16ToUTF8String

Converts a UTF16 string into a UTF8 std::string.

convertUTF16ToUTF8String

Converts a stream of raw bytes assumed to be UTF16 into a UTF8 std::string.

convertUTF32ToUTF8String

Converts a stream of raw bytes assumed to be UTF32 into a UTF8 std::string.

convertUTF32ToUTF8String

Converts a UTF32 string into a UTF8 std::string.

convertUsersOfConstantsToInstructions

Replace constant expressions users of the given constants with instructions.

crc32

Compute the CRC‐32 of Data.

createMacroFusionDAGMutation

Create a DAG mutation that fuses instruction pairs matching the given predicates.

createPHIsForSplitLoopExit

Insert LCSSA PHI nodes required after splitting a loop exit edge.

createUnaryMask

Create a unary shuffle mask from a binary shuffle mask.

detachDeadBlocks

Replace every block in BBs with a single unreachable instruction.

dlltoolDriverMain

Entry point for the dlltool.exe‐compatible driver used by llvm‐dlltool.

downscaleWeights

downscale the given weights preserving the ratio. If the maximum value is not already known and not provided via

dumpBytes

Convert `Bytes' to a hex string and output to `OS'

dumpRegSetPressure

Dump non‐zero entries of SetPressure to the debug stream.

eraseInstrs

Erase a list of dead instructions, optionally notifying a debug observer.

fitWeights

Push the weights right to fit in uint32_t.

format_bytes

Format Bytes as a hex dump without an ASCII column.

format_bytes_with_ascii

Format Bytes as hex with an ASCII column.

fullyRecomputeLiveIns

Convenience function for recomputing live‐in's for a set of MBBs until the computation converges.

getContainedTypes

Returns the types contained in Ty. For struct types, it returns the elements, all other types are returned directly.

getShuffleMaskWithWidestElts

Repetitively apply widenShuffleMaskElts() for as long as it succeeds, to get the shuffle mask with widest possible elements.

getSipHash_2_4_128

Computes a SipHash‐2‐4 128‐bit result.

getSipHash_2_4_64

Computes a SipHash‐2‐4 64‐bit result.

getSplatIndex

Return the common non‐negative splat index in Mask, or ‐1.

hasUTF16ByteOrderMark

Returns true if a blob of text starts with a UTF‐16 big or little endian byte order mark.

hash_value

Compute a hash_code for an ArrayRef.

identifyNoAliasScopesToClone

Collect noalias scopes declared in the given basic blocks.

isMaskedSlidePair

Return true if Mask is one slide or a masked pair of slides.

libDriverMain

Entry point for the lib.exe‐compatible driver used by llvm‐lib and lld‐link /lib.

operator!=

Return true if LHS and RHS differ in length or element values.

operator<

Lexicographically compare two `ArrayRef`s.

operator<=

Return true if LHS is lexicographically less than or equal to RHS.

operator==

Return true if LHS and RHS contain equal elements.

operator>

Lexicographically compare two `ArrayRef`s.

operator>=

Return true if LHS is lexicographically greater than or equal to RHS.

processShuffleMasks

Split and process a shuffle mask across real input and output registers.

readWideAPInt

Decode a wide APInt from a sequence of 64‐bit words.

remapInstructionsInBlocks

Remaps instructions in Blocks using the mapping in VMap.

sortPtrAccesses

Attempt to sort the pointers in VL and return the sorted indices in SortedIndices, if reordering is required.

stable_hash_combine

Combine the hashes in Buffer into a single stable hash.

toHex

Convert buffer Input to its hexadecimal representation. The returned string is double the size of Input.

toHex

Convert the bytes in Input to a hexadecimal string.

toStringRef

Construct a string ref from an array ref of unsigned chars.

toStringRef

Construct a string ref from an array ref of chars.

widenShuffleMaskElts

Widen a shuffle mask with Scale=2, treating ‐1 as undef.

writeArchiveToBuffer

Write an archive into a memory buffer.

xxh3_128bits

Compute the XXH3 128‐bit hash of the bytes in data.

xxh3_64bits

Compute the XXH3 64‐bit hash of the bytes in data.

AArch64::getCpuSupportsMask

Compute the CPU‐supports bitmask for the given FMV feature names.

AArch64::getFMVPriority

Compute the FMV priority bitmask for the given feature names.

BBAddrMapYAML::encodePayload

Encodes the BBAddrMap payload into a contiguous blob.

CodeViewYAML::fromDebugH

Parse a .debug$H section blob into a YAML DebugHSection.

CodeViewYAML::fromDebugS

Parse a .debug$S section blob into YAML debug subsections.

CodeViewYAML::fromDebugT

Parse a .debug$T or .debug$P section blob into YAML leaf records.

CodeViewYAML::initializeStringsAndChecksums

Populate string and checksum tables from YAML debug subsections.

CodeViewYAML::toDebugH

Serialize a YAML DebugHSection into a .debug$H section blob.

CodeViewYAML::toDebugT

Serialize YAML leaf records into a .debug$T or .debug$P section blob.

ELFYAML::shouldAllocateFileSpace

Return whether SHT_NOBITS section S should allocate file space.

IntegerInclusiveIntervalUtils::contains

Check if a value is contained in any of the intervals.

IntegerInclusiveIntervalUtils::mergeAdjacentIntervals

Merge adjacent/consecutive intervals into single intervals. Example: [1‐3, 4‐6, 8‐10]‐> [1‐6, 8‐10].

Intrinsic::getIntrinsicInfoTableEntries

Fill the IIT table descriptors for an intrinsic into T.

MachO::mapToArchitectureSet

Map a list of targets to the set of architectures.

MachO::mapToPlatformSet

Map a list of targets to the set of platforms.

MachO::mapToPlatformSet

Map a list of target triples to the set of platforms they represent.

MachO::mapToPlatformVersionSet

Map a list of targets to the set of platform and version pairs.

PatternMatch::match

Match shuffle mask Mask against pattern P.

Win64EH::decodeUnwindInfoV3

Parse a V3 UNWIND_INFO from raw bytes. Returns an error on malformed data.

Win64EH::decodeWOD

Decode one WOD from the pool at the given byte offset. Returns an error on malformed data.

X86::getCpuSupportsMask

Build the 128‐bit feature mask for __builtin_cpu_supports from feature names.

cfg::LegalizeUpdates

Simplify a sequence of CFG edge updates by removing redundancy and cancels.

cgdata::mergeCodeGenData

Merge the codegen data from the scratch objects from the first codegen round.

cl::HideUnrelatedOptions

Mark all options not part of the categories as cl::ReallyHidden.

cl::getCompilerBuildConfig

Return enabled LLVM build‐configuration tags such as +assertions.

cl::list_init

Build a list_initializer modifier for default elements Vals.

codelayout::calcExtTspScore

Estimate the quality of a given node order in a CFG.

codelayout::calcExtTspScore

Estimate the quality of the current node order in a CFG.

codelayout::computeCacheDirectedLayout

Apply a Cache‐Directed Sort to a call graph of functions.

codelayout::computeExtTspLayout

Find a CFG node layout that optimizes jump locality.

codeview::discoverTypeIndices

Discover TypeIndex references in raw type‐record bytes.

codeview::discoverTypeIndices

Collect every TypeIndex referenced by raw type‐record bytes.

codeview::discoverTypeIndicesInSymbol

Discover TypeIndex references in raw symbol‐record bytes.

codeview::discoverTypeIndicesInSymbol

Collect every TypeIndex referenced by raw symbol‐record bytes.

codeview::fmt_guid

Adapt a GUID byte sequence for use with formatv.

codeview::forEachCodeViewRecord

Invoke F for each contiguous CodeView record in StreamBuffer.

codeview::getBytesAsCString

Reinterpret a byte array as a null‐terminated C string.

codeview::getBytesAsCharacters

Reinterpret a byte array as an array of characters. Does not interpret as a C string, as StringRef has several helpers (split) that make that easy.

codeview::serialize_array

Build an array serialization helper whose length comes from Func.

codeview::serialize_array_tail

Build a helper that deserializes the remaining stream as an array of T.

codeview::visitMemberRecordStream

Visit every member record in a field‐list byte stream.

dwarf::toBlock

Take an optional DWARFFormValue and try to extract block data.

irsymtab::build

Fills in Symtab and StrtabBuilder with a valid symbol and string table for Mods.

lto::generateModulesOrdering

Produces a container ordering for optimal multi‐threaded processing.

memprof::buildCallstackMetadata

Build callstack metadata from the provided list of call stack ids.

memprof::computeFullStackId

Generate a single hash id for a given callstack.

object::decodeCrel

Decode a CREL relocation blob, invoking handlers for the header and entries.

object::doesXCOFFTracebackTableBegin

True when Bytes begin with the XCOFF traceback‐table initial zeros.

object::writeUniversalBinary

Write a Mach‐O universal binary containing Slices to OutputFileName.

object::writeUniversalBinaryToStream

Write a Mach‐O universal binary containing Slices to Out.

omp::getCompoundConstruct

Return the compound directive formed by Parts, or OMPD_unknown.

omp::getLeafConstructs

Return the leaf constructs that make up compound directive D.

omp::getLeafConstructsOrSelf

Return the leaf constructs of D, or D itself if it is a leaf.

omp::getLeafOrCompositeConstructs

Append the leaf and composite constituents of D to Output.

omp::getOpenMPVersions

Return the OpenMP language versions supported by this frontend.

omp::getReservedLocatorNames

Return the reserved OpenMP locator names (lowercase).

orc::makeJITDylibSearchOrder

Convenience function for creating a search order from an ArrayRef of JITDylib*, all with the same flags.

pdb::hashBufferV8

Compute the PDB V8 buffer hash (CRC‐32) of raw bytes.

pdb::typesetItemList

Join strings into lines of at most GroupSize items each.

wholeprogramdevirt::findLowestOffset

Find the lowest offset at which a value of Size bits may be stored.

compression::zlib::compress

Compress Input with zlib into CompressedBuffer.

compression::zlib::decompress

Decompress zlib‐compressed Input into a caller‐provided buffer.

compression::zlib::decompress

Decompress zlib‐compressed Input into Output.

compression::zstd::compress

Compress Input with zstd into CompressedBuffer.

compression::zstd::decompress

Decompress zstd‐compressed Input into a caller‐provided buffer.

compression::zstd::decompress

Decompress zstd‐compressed Input into Output.

jitlink::loongarch::getGOTEntryBlockContent

Return null‐pointer bytes sized for a GOT entry in G.

jitlink::loongarch::getStubBlockContent

Return the pointer‐jump stub content for the architecture of G.

jitlink::systemz::getGOTEntryBlockContent

Return the content used to initialize a GOT entry block.

jitlink::systemz::getStubBlockContent

Return the instruction bytes for a pointer jump stub block.

offloading::sycl::writeSymbolTable

Serialize Names into Out.

orc::shared::runDeallocActions

Run deallocation actions. Dealloc actions will be run in reverse order (from last element of DAs to first).

Derived Classes

Name

Description

MutableArrayRef

A mutable reference to consecutive elements in memory.

Return Value

Note

The return value should not be discarded.

Template Parameters

Name

Description

T

Element type of the referenced array.

Created with MrDocs