forked from OSchip/llvm-project
[C++11] Replacing CapturedStmt iterators capture_begin() and capture_end() with iterator_range captures(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203953
This commit is contained in:
parent
3c9a0d05cd
commit
c656303a2c
|
@ -2048,6 +2048,15 @@ public:
|
|||
/// \brief An iterator that walks over the captures.
|
||||
typedef Capture *capture_iterator;
|
||||
typedef const Capture *const_capture_iterator;
|
||||
typedef llvm::iterator_range<capture_iterator> capture_range;
|
||||
typedef llvm::iterator_range<const_capture_iterator> capture_const_range;
|
||||
|
||||
capture_range captures() {
|
||||
return capture_range(capture_begin(), capture_end());
|
||||
}
|
||||
capture_const_range captures() const {
|
||||
return capture_const_range(capture_begin(), capture_end());
|
||||
}
|
||||
|
||||
/// \brief Retrieve an iterator pointing to the first capture.
|
||||
capture_iterator capture_begin() { return getStoredCaptures(); }
|
||||
|
|
|
@ -1100,15 +1100,14 @@ Stmt::child_range CapturedStmt::children() {
|
|||
}
|
||||
|
||||
bool CapturedStmt::capturesVariable(const VarDecl *Var) const {
|
||||
for (const_capture_iterator I = capture_begin(),
|
||||
E = capture_end(); I != E; ++I) {
|
||||
if (!I->capturesVariable())
|
||||
for (const auto &I : captures()) {
|
||||
if (!I.capturesVariable())
|
||||
continue;
|
||||
|
||||
// This does not handle variable redeclarations. This should be
|
||||
// extended to capture variables with redeclarations, for example
|
||||
// a thread-private variable in OpenMP.
|
||||
if (I->getCapturedVar() == Var)
|
||||
if (I.getCapturedVar() == Var)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -399,13 +399,11 @@ void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
|
|||
S->getCapturedDecl()->setBody(S->getCapturedStmt());
|
||||
|
||||
// Captures
|
||||
for (CapturedStmt::capture_iterator I = S->capture_begin(),
|
||||
E = S->capture_end();
|
||||
I != E; ++I) {
|
||||
I->VarAndKind.setPointer(ReadDeclAs<VarDecl>(Record, Idx));
|
||||
I->VarAndKind
|
||||
for (auto &I : S->captures()) {
|
||||
I.VarAndKind.setPointer(ReadDeclAs<VarDecl>(Record, Idx));
|
||||
I.VarAndKind
|
||||
.setInt(static_cast<CapturedStmt::VariableCaptureKind>(Record[Idx++]));
|
||||
I->Loc = ReadSourceLocation(Record, Idx);
|
||||
I.Loc = ReadSourceLocation(Record, Idx);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -309,15 +309,13 @@ void ASTStmtWriter::VisitCapturedStmt(CapturedStmt *S) {
|
|||
Writer.AddStmt(S->getCapturedStmt());
|
||||
|
||||
// Captures
|
||||
for (CapturedStmt::capture_iterator I = S->capture_begin(),
|
||||
E = S->capture_end();
|
||||
I != E; ++I) {
|
||||
if (I->capturesThis())
|
||||
for (const auto &I : S->captures()) {
|
||||
if (I.capturesThis())
|
||||
Writer.AddDeclRef(0, Record);
|
||||
else
|
||||
Writer.AddDeclRef(I->getCapturedVar(), Record);
|
||||
Record.push_back(I->getCaptureKind());
|
||||
Writer.AddSourceLocation(I->getLocation(), Record);
|
||||
Writer.AddDeclRef(I.getCapturedVar(), Record);
|
||||
Record.push_back(I.getCaptureKind());
|
||||
Writer.AddSourceLocation(I.getLocation(), Record);
|
||||
}
|
||||
|
||||
Code = serialization::STMT_CAPTURED;
|
||||
|
|
Loading…
Reference in New Issue