]> granicus.if.org Git - clang/commitdiff
[C++11] Replacing CXXRecordDecl iterators capture_begin() and capture_end() with...
authorAaron Ballman <aaron@aaronballman.com>
Thu, 13 Mar 2014 17:08:33 +0000 (17:08 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Thu, 13 Mar 2014 17:08:33 +0000 (17:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203817 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclCXX.h
lib/Sema/SemaDecl.cpp

index c6bc7411f4fc7cf3113ca509e646cff1b21b2f40..3a410123074e134c412c08e7abd567ca4d2a9ab3 100644 (file)
@@ -1019,6 +1019,11 @@ public:
                         FieldDecl *&ThisCapture) const;
 
   typedef const LambdaExpr::Capture* capture_const_iterator;
+  typedef llvm::iterator_range<capture_const_iterator> 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;
   }
index 258914343cb61d56fc8b6b51d830234803da0033..876b0785c1d65f8b11fbb7f1f983c52ed44cc28f 100644 (file)
@@ -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);
     }
   }