diff options
author | David Majnemer <david.majnemer@gmail.com> | 2016-06-23 00:15:04 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2016-06-23 00:15:04 +0000 |
commit | f7e3609f77936044893fc2a69981d6ba212e3728 (patch) | |
tree | 9c00ae8b3cf60810afa33e3957c2e7e27135fd61 /clang/lib/Serialization | |
parent | d1fbf48566ae0ff14ea2b935cbf3cbbba40a6d28 (diff) | |
download | bcm5719-llvm-f7e3609f77936044893fc2a69981d6ba212e3728.tar.gz bcm5719-llvm-f7e3609f77936044893fc2a69981d6ba212e3728.zip |
Use ranges to concisely express iteration
No functional change is intended, this should just clean things up a
little.
llvm-svn: 273522
Diffstat (limited to 'clang/lib/Serialization')
-rw-r--r-- | clang/lib/Serialization/ASTWriterStmt.cpp | 32 | ||||
-rw-r--r-- | clang/lib/Serialization/ModuleManager.cpp | 8 |
2 files changed, 19 insertions, 21 deletions
diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp index 911ac478b81..cc6f3409962 100644 --- a/clang/lib/Serialization/ASTWriterStmt.cpp +++ b/clang/lib/Serialization/ASTWriterStmt.cpp @@ -749,31 +749,29 @@ void ASTStmtWriter::VisitDesignatedInitExpr(DesignatedInitExpr *E) { Record.AddStmt(E->getSubExpr(I)); Record.AddSourceLocation(E->getEqualOrColonLoc()); Record.push_back(E->usesGNUSyntax()); - for (DesignatedInitExpr::designators_iterator D = E->designators_begin(), - DEnd = E->designators_end(); - D != DEnd; ++D) { - if (D->isFieldDesignator()) { - if (FieldDecl *Field = D->getField()) { + for (const DesignatedInitExpr::Designator &D : E->designators()) { + if (D.isFieldDesignator()) { + if (FieldDecl *Field = D.getField()) { Record.push_back(serialization::DESIG_FIELD_DECL); Record.AddDeclRef(Field); } else { Record.push_back(serialization::DESIG_FIELD_NAME); - Record.AddIdentifierRef(D->getFieldName()); + Record.AddIdentifierRef(D.getFieldName()); } - Record.AddSourceLocation(D->getDotLoc()); - Record.AddSourceLocation(D->getFieldLoc()); - } else if (D->isArrayDesignator()) { + Record.AddSourceLocation(D.getDotLoc()); + Record.AddSourceLocation(D.getFieldLoc()); + } else if (D.isArrayDesignator()) { Record.push_back(serialization::DESIG_ARRAY); - Record.push_back(D->getFirstExprIndex()); - Record.AddSourceLocation(D->getLBracketLoc()); - Record.AddSourceLocation(D->getRBracketLoc()); + Record.push_back(D.getFirstExprIndex()); + Record.AddSourceLocation(D.getLBracketLoc()); + Record.AddSourceLocation(D.getRBracketLoc()); } else { - assert(D->isArrayRangeDesignator() && "Unknown designator"); + assert(D.isArrayRangeDesignator() && "Unknown designator"); Record.push_back(serialization::DESIG_ARRAY_RANGE); - Record.push_back(D->getFirstExprIndex()); - Record.AddSourceLocation(D->getLBracketLoc()); - Record.AddSourceLocation(D->getEllipsisLoc()); - Record.AddSourceLocation(D->getRBracketLoc()); + Record.push_back(D.getFirstExprIndex()); + Record.AddSourceLocation(D.getLBracketLoc()); + Record.AddSourceLocation(D.getEllipsisLoc()); + Record.AddSourceLocation(D.getRBracketLoc()); } } Code = serialization::EXPR_DESIGNATED_INIT; diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp index 74f75a103f7..292f36dfeb2 100644 --- a/clang/lib/Serialization/ModuleManager.cpp +++ b/clang/lib/Serialization/ModuleManager.cpp @@ -320,11 +320,11 @@ void ModuleManager::visit(llvm::function_ref<bool(ModuleFile &M)> Visitor, Queue.reserve(N); llvm::SmallVector<unsigned, 4> UnusedIncomingEdges; UnusedIncomingEdges.resize(size()); - for (auto M = rbegin(), MEnd = rend(); M != MEnd; ++M) { - unsigned Size = (*M)->ImportedBy.size(); - UnusedIncomingEdges[(*M)->Index] = Size; + for (ModuleFile *M : llvm::reverse(*this)) { + unsigned Size = M->ImportedBy.size(); + UnusedIncomingEdges[M->Index] = Size; if (!Size) - Queue.push_back(*M); + Queue.push_back(M); } // Traverse the graph, making sure to visit a module before visiting any |