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

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

index 2723aeda6e069b04d84db9105ca8e138396886f8..aad5d7222915d50ce6f679caedc0cedca1e12eb7 100644 (file)
@@ -1774,6 +1774,11 @@ public:
   protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
   unsigned protocol_size() const { return ReferencedProtocols.size(); }
   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 {
     return ReferencedProtocols.loc_begin();
   }
index 7a94cdaff63ccf9200c336bcd6cac72616924038..0d679802edd6bf3201fc558a51c818c9bbd03f2e 100644 (file)
@@ -568,10 +568,8 @@ void ASTDeclWriter::VisitObjCCategoryDecl(ObjCCategoryDecl *D) {
   Record.push_back(D->protocol_size());
   for (const auto *I : D->protocols())
     Writer.AddDeclRef(I, Record);
-  for (ObjCCategoryDecl::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_CATEGORY;
 }