]> granicus.if.org Git - clang/commitdiff
[C++11] Replacing ObjCInterfaceDecl iterators protocol_loc_begin() and protocol_loc_e...
authorAaron Ballman <aaron@aaronballman.com>
Thu, 13 Mar 2014 20:34:24 +0000 (20:34 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Thu, 13 Mar 2014 20:34:24 +0000 (20:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203847 91177308-0d34-0410-b5e6-96231b3b80d8

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

index f6b71c8f6899bdd9af61b185d7084f526f868f1c..c1a419817e822d2ac6c7ac7384db6ab217b756b8 100644 (file)
@@ -850,7 +850,11 @@ public:
   }
 
   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 {
     // FIXME: Should make sure no callers ever do this.
     if (!hasDefinition())
index 96cf0e1dc11b410bc0898047c73e18faafa7a0d8..9ad55f5f634360f64dd148ffa8bd1e962a7706d5 100644 (file)
@@ -493,10 +493,8 @@ void ASTDeclWriter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
     Record.push_back(Data.ReferencedProtocols.size());
     for (const auto *P : D->protocols())
       Writer.AddDeclRef(P, Record);
-    for (ObjCInterfaceDecl::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);
     
     // Write out the protocols that are transitively referenced.
     Record.push_back(Data.AllReferencedProtocols.size());