1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[AsmPrinter] Use range-based for loops (NFC)

This commit is contained in:
Kazu Hirata 2021-02-10 20:01:21 -08:00
parent be876e8742
commit 296ee17661
5 changed files with 21 additions and 28 deletions

View File

@ -327,9 +327,9 @@ void AppleAccelTableWriter::emitBuckets() const {
void AppleAccelTableWriter::emitData() const {
const auto &Buckets = Contents.getBuckets();
for (size_t i = 0, e = Buckets.size(); i < e; ++i) {
for (const AccelTableBase::HashList &Bucket : Buckets) {
uint64_t PrevHash = std::numeric_limits<uint64_t>::max();
for (auto &Hash : Buckets[i]) {
for (auto &Hash : Bucket) {
// Terminate the previous entry if there is no hash collision with the
// current one.
if (PrevHash != std::numeric_limits<uint64_t>::max() &&
@ -346,7 +346,7 @@ void AppleAccelTableWriter::emitData() const {
PrevHash = Hash->HashValue;
}
// Emit the final end marker for the bucket.
if (!Buckets[i].empty())
if (!Bucket.empty())
Asm->emitInt32(0);
}
}

View File

@ -814,8 +814,8 @@ void CodeViewDebug::emitCompilerInformation() {
StringRef CompilerVersion = CU->getProducer();
Version FrontVer = parseVersion(CompilerVersion);
OS.AddComment("Frontend version");
for (int N = 0; N < 4; ++N)
OS.emitInt16(FrontVer.Part[N]);
for (int N : FrontVer.Part)
OS.emitInt16(N);
// Some Microsoft tools, like Binscope, expect a backend version number of at
// least 8.something, so we'll coerce the LLVM version into a form that
@ -827,8 +827,8 @@ void CodeViewDebug::emitCompilerInformation() {
Major = std::min<int>(Major, std::numeric_limits<uint16_t>::max());
Version BackVer = {{ Major, 0, 0, 0 }};
OS.AddComment("Backend version");
for (int N = 0; N < 4; ++N)
OS.emitInt16(BackVer.Part[N]);
for (int N : BackVer.Part)
OS.emitInt16(N);
OS.AddComment("Null-terminated compiler version string");
emitNullTerminatedSymbolName(OS, CompilerVersion);

View File

@ -100,10 +100,10 @@ DwarfTypeUnit::DwarfTypeUnit(DwarfCompileUnit &CU, AsmPrinter *A,
}
DwarfUnit::~DwarfUnit() {
for (unsigned j = 0, M = DIEBlocks.size(); j < M; ++j)
DIEBlocks[j]->~DIEBlock();
for (unsigned j = 0, M = DIELocs.size(); j < M; ++j)
DIELocs[j]->~DIELoc();
for (DIEBlock *B : DIEBlocks)
B->~DIEBlock();
for (DIELoc *L : DIELocs)
L->~DIELoc();
}
int64_t DwarfUnit::getDefaultLowerBound() const {
@ -1489,9 +1489,9 @@ void DwarfUnit::constructArrayTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
// Add subranges to array type.
DINodeArray Elements = CTy->getElements();
for (unsigned i = 0, N = Elements.size(); i < N; ++i) {
for (DINode *E : Elements) {
// FIXME: Should this really be such a loose cast?
if (auto *Element = dyn_cast_or_null<DINode>(Elements[i])) {
if (auto *Element = dyn_cast_or_null<DINode>(E)) {
if (Element->getTag() == dwarf::DW_TAG_subrange_type)
constructSubrangeDIE(Buffer, cast<DISubrange>(Element), IdxTy);
else if (Element->getTag() == dwarf::DW_TAG_generic_subrange)
@ -1517,8 +1517,8 @@ void DwarfUnit::constructEnumTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
DINodeArray Elements = CTy->getElements();
// Add enumerators to enumeration type.
for (unsigned i = 0, N = Elements.size(); i < N; ++i) {
auto *Enum = dyn_cast_or_null<DIEnumerator>(Elements[i]);
for (const DINode *E : Elements) {
auto *Enum = dyn_cast_or_null<DIEnumerator>(E);
if (Enum) {
DIE &Enumerator = createAndAddDIE(dwarf::DW_TAG_enumerator, Buffer);
StringRef Name = Enum->getName();

View File

@ -83,10 +83,9 @@ void EHStreamer::computeActionsTable(
FilterOffsets.reserve(FilterIds.size());
int Offset = -1;
for (std::vector<unsigned>::const_iterator
I = FilterIds.begin(), E = FilterIds.end(); I != E; ++I) {
for (unsigned FilterId : FilterIds) {
FilterOffsets.push_back(Offset);
Offset -= getULEB128Size(*I);
Offset -= getULEB128Size(FilterId);
}
FirstActions.reserve(LandingPads.size());
@ -95,9 +94,7 @@ void EHStreamer::computeActionsTable(
unsigned SizeActions = 0; // Total size of all action entries for a function
const LandingPadInfo *PrevLPI = nullptr;
for (SmallVectorImpl<const LandingPadInfo *>::const_iterator
I = LandingPads.begin(), E = LandingPads.end(); I != E; ++I) {
const LandingPadInfo *LPI = *I;
for (const LandingPadInfo *LPI : LandingPads) {
const std::vector<int> &TypeIds = LPI->TypeIds;
unsigned NumShared = PrevLPI ? sharedTypeIDs(LPI, PrevLPI) : 0;
unsigned SizeSiteActions = 0; // Total size of all entries for a landingpad
@ -757,10 +754,7 @@ MCSymbol *EHStreamer::emitExceptionTable() {
// Emit the Action Table.
int Entry = 0;
for (SmallVectorImpl<ActionEntry>::const_iterator
I = Actions.begin(), E = Actions.end(); I != E; ++I) {
const ActionEntry &Action = *I;
for (const ActionEntry &Action : Actions) {
if (VerboseAsm) {
// Emit comments that decode the action table.
Asm->OutStreamer->AddComment(">> Action Record " + Twine(++Entry) + " <<");

View File

@ -79,11 +79,10 @@ void ErlangGCPrinter::finishAssembly(Module &M, GCModuleInfo &Info,
AP.emitInt16(MD.size());
// And each safe point...
for (GCFunctionInfo::iterator PI = MD.begin(), PE = MD.end(); PI != PE;
++PI) {
for (const GCPoint &P : MD) {
// Emit the address of the safe point.
OS.AddComment("safe point address");
MCSymbol *Label = PI->Label;
MCSymbol *Label = P.Label;
AP.emitLabelPlusOffset(Label /*Hi*/, 0 /*Offset*/, 4 /*Size*/);
}