From ea237c0eeec89549f9ed288cc83b4c3d06ac872e Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Thu, 13 Mar 2014 17:08:33 +0000 Subject: [PATCH] [C++11] Replacing CXXRecordDecl iterators capture_begin() and capture_end() with iterator_range captures(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203817 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/DeclCXX.h | 5 +++++ lib/Sema/SemaDecl.cpp | 19 +++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index c6bc7411f4..3a41012307 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -1019,6 +1019,11 @@ public: FieldDecl *&ThisCapture) const; typedef const LambdaExpr::Capture* capture_const_iterator; + typedef llvm::iterator_range capture_const_range; + + capture_const_range captures() const { + return capture_const_range(captures_begin(), captures_end()); + } capture_const_iterator captures_begin() const { return isLambda() ? getLambdaData().Captures : NULL; } diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 258914343c..876b0785c1 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -9470,22 +9470,21 @@ static void RebuildLambdaScopeInfo(CXXMethodDecl *CallOperator, // Add the captures to the LSI so they can be noted as already // captured within tryCaptureVar. - for (LambdaExpr::capture_iterator C = LambdaClass->captures_begin(), - CEnd = LambdaClass->captures_end(); C != CEnd; ++C) { - if (C->capturesVariable()) { - VarDecl *VD = C->getCapturedVar(); + for (const auto &C : LambdaClass->captures()) { + if (C.capturesVariable()) { + VarDecl *VD = C.getCapturedVar(); if (VD->isInitCapture()) S.CurrentInstantiationScope->InstantiatedLocal(VD, VD); QualType CaptureType = VD->getType(); - const bool ByRef = C->getCaptureKind() == LCK_ByRef; + const bool ByRef = C.getCaptureKind() == LCK_ByRef; LSI->addCapture(VD, /*IsBlock*/false, ByRef, - /*RefersToEnclosingLocal*/true, C->getLocation(), - /*EllipsisLoc*/C->isPackExpansion() - ? C->getEllipsisLoc() : SourceLocation(), + /*RefersToEnclosingLocal*/true, C.getLocation(), + /*EllipsisLoc*/C.isPackExpansion() + ? C.getEllipsisLoc() : SourceLocation(), CaptureType, /*Expr*/ 0); - } else if (C->capturesThis()) { - LSI->addThisCapture(/*Nested*/ false, C->getLocation(), + } else if (C.capturesThis()) { + LSI->addThisCapture(/*Nested*/ false, C.getLocation(), S.getCurrentThisType(), /*Expr*/ 0); } } -- 2.40.0