Skip to content

Commit

Permalink
Use drop_begin (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata committed Jul 16, 2022
1 parent f382dfc commit 246bf08
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 29 deletions.
6 changes: 3 additions & 3 deletions clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
Expand Up @@ -308,14 +308,14 @@ bool conflictInNamespace(const ASTContext &AST, llvm::StringRef QualifiedSymbol,
// symbol name would have been shortened.
const NamedDecl *Scope =
LookupDecl(*AST.getTranslationUnitDecl(), NsSplitted.front());
for (auto I = NsSplitted.begin() + 1, E = NsSplitted.end(); I != E; ++I) {
if (*I == SymbolTopNs) // Handles "::ny" in "::nx::ny" case.
for (const auto &I : llvm::drop_begin(NsSplitted)) {
if (I == SymbolTopNs) // Handles "::ny" in "::nx::ny" case.
return true;
// Handles "::util" and "::nx::util" conflicts.
if (Scope) {
if (LookupDecl(*Scope, SymbolTopNs))
return true;
Scope = LookupDecl(*Scope, *I);
Scope = LookupDecl(*Scope, I);
}
}
if (Scope && LookupDecl(*Scope, SymbolTopNs))
Expand Down
33 changes: 11 additions & 22 deletions llvm/lib/MC/MCParser/MasmParser.cpp
Expand Up @@ -4238,11 +4238,8 @@ bool MasmParser::parseStructInitializer(const StructInfo &Structure,
}
}
// Default-initialize all remaining fields.
for (auto It = Structure.Fields.begin() + FieldIndex;
It != Structure.Fields.end(); ++It) {
const FieldInfo &Field = *It;
for (const FieldInfo &Field : llvm::drop_begin(Structure.Fields, FieldIndex))
FieldInitializers.push_back(Field.Contents);
}

if (EndToken) {
if (EndToken.value() == AsmToken::Greater)
Expand Down Expand Up @@ -4350,9 +4347,8 @@ bool MasmParser::emitFieldInitializer(const FieldInfo &Field,
return true;
}
// Default-initialize all remaining values.
for (auto it = Contents.Values.begin() + Initializer.Values.size();
it != Contents.Values.end(); ++it) {
const auto &Value = *it;
for (const auto &Value :
llvm::drop_begin(Contents.Values, Initializer.Values.size())) {
if (emitIntValue(Value, Field.Type))
return true;
}
Expand All @@ -4367,9 +4363,8 @@ bool MasmParser::emitFieldInitializer(const FieldInfo &Field,
AsInt.getBitWidth() / 8);
}
// Default-initialize all remaining values.
for (auto It = Contents.AsIntValues.begin() + Initializer.AsIntValues.size();
It != Contents.AsIntValues.end(); ++It) {
const auto &AsInt = *It;
for (const auto &AsInt :
llvm::drop_begin(Contents.AsIntValues, Initializer.AsIntValues.size())) {
getStreamer().emitIntValue(AsInt.getLimitedValue(),
AsInt.getBitWidth() / 8);
}
Expand All @@ -4384,10 +4379,8 @@ bool MasmParser::emitFieldInitializer(const FieldInfo &Field,
return true;
}
// Default-initialize all remaining values.
for (auto It =
Contents.Initializers.begin() + Initializer.Initializers.size();
It != Contents.Initializers.end(); ++It) {
const auto &Init = *It;
for (const auto &Init : llvm::drop_begin(Contents.Initializers,
Initializer.Initializers.size())) {
if (emitStructInitializer(Contents.Structure, Init))
return true;
}
Expand Down Expand Up @@ -4425,10 +4418,8 @@ bool MasmParser::emitStructInitializer(const StructInfo &Structure,
return true;
}
// Default-initialize all remaining fields.
for (auto It =
Structure.Fields.begin() + Initializer.FieldInitializers.size();
It != Structure.Fields.end(); ++It) {
const auto &Field = *It;
for (const auto &Field : llvm::drop_begin(
Structure.Fields, Initializer.FieldInitializers.size())) {
getStreamer().emitZeros(Field.Offset - Offset);
Offset = Field.Offset + Field.SizeOf;
if (emitFieldValue(Field))
Expand Down Expand Up @@ -4649,10 +4640,8 @@ bool MasmParser::parseDirectiveNestedEnds() {
if (ParentStruct.IsUnion) {
ParentStruct.Size = std::max(ParentStruct.Size, Structure.Size);
} else {
for (auto FieldIter = ParentStruct.Fields.begin() + OldFields;
FieldIter != ParentStruct.Fields.end(); ++FieldIter) {
FieldIter->Offset += FirstFieldOffset;
}
for (auto &Field : llvm::drop_begin(ParentStruct.Fields, OldFields))
Field.Offset += FirstFieldOffset;

const unsigned StructureEnd = FirstFieldOffset + Structure.Size;
if (!ParentStruct.IsUnion) {
Expand Down
7 changes: 3 additions & 4 deletions mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
Expand Up @@ -196,10 +196,9 @@ static AffineForOp generateShiftedLoop(
BlockAndValueMapping operandMap;

auto bodyBuilder = OpBuilder::atBlockTerminator(loopChunk.getBody());
for (auto it = opGroupQueue.begin() + offset, e = opGroupQueue.end(); it != e;
++it) {
uint64_t shift = it->first;
auto ops = it->second;
for (const auto &it : llvm::drop_begin(opGroupQueue, offset)) {
uint64_t shift = it.first;
auto ops = it.second;
// All 'same shift' operations get added with their operands being
// remapped to results of cloned operations, and their IV used remapped.
// Generate the remapping if the shift is not zero: remappedIV = newIV -
Expand Down

0 comments on commit 246bf08

Please sign in to comment.