]> granicus.if.org Git - clang/commitdiff
[C++11] Replacing ObjCProtocolDecl iterators protocol_loc_begin() and protocol_loc_en...
authorAaron Ballman <aaron@aaronballman.com>
Fri, 14 Mar 2014 12:38:50 +0000 (12:38 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Fri, 14 Mar 2014 12:38:50 +0000 (12:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203919 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclObjC.h
lib/Serialization/ASTWriterDecl.cpp

index da4a4ee7f6adc163687f5c094df70d981a568ff1..f27b4420769ad2b4a043810ea55a271ab1ab9ced 100644 (file)
@@ -1571,6 +1571,11 @@ public:
     return data().ReferencedProtocols.end(); 
   }
   typedef ObjCProtocolList::loc_iterator protocol_loc_iterator;
+  typedef llvm::iterator_range<protocol_loc_iterator> protocol_loc_range;
+
+  protocol_loc_range protocol_locs() const {
+    return protocol_loc_range(protocol_loc_begin(), protocol_loc_end());
+  }
   protocol_loc_iterator protocol_loc_begin() const {
     if (!hasDefinition())
       return protocol_loc_iterator();
index 66155b7153028a85f21eccbede0bb3a3c0bf21af..a667a1785720d83bf8b90a935eed6ba9e31f5efe 100644 (file)
@@ -547,10 +547,8 @@ void ASTDeclWriter::VisitObjCProtocolDecl(ObjCProtocolDecl *D) {
     Record.push_back(D->protocol_size());
     for (const auto *I : D->protocols())
       Writer.AddDeclRef(I, Record);
-    for (ObjCProtocolDecl::protocol_loc_iterator PL = D->protocol_loc_begin(),
-           PLEnd = D->protocol_loc_end();
-         PL != PLEnd; ++PL)
-      Writer.AddSourceLocation(*PL, Record);
+    for (const auto &PL : D->protocol_locs())
+      Writer.AddSourceLocation(PL, Record);
   }
   
   Code = serialization::DECL_OBJC_PROTOCOL;