]> granicus.if.org Git - clang/commitdiff
In my tests, I'm finding that declaring iterators in terms of ranges can sometimes...
authorAaron Ballman <aaron@aaronballman.com>
Fri, 7 Mar 2014 22:17:20 +0000 (22:17 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Fri, 7 Mar 2014 22:17:20 +0000 (22:17 +0000)
This changes the iterators so that they are no longer implemented in terms of ranges (so it's a very partial revert of the existing rangification efforts).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203299 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Decl.h
include/clang/AST/DeclBase.h
include/clang/AST/DeclObjC.h
include/clang/AST/Redeclarable.h
lib/AST/DeclBase.cpp

index 081101520fee502a86377c46d7c348391eb34889..c4451e73cdc7ff34d9688f8e7ba66e524d22e880 100644 (file)
@@ -1846,14 +1846,20 @@ public:
   typedef llvm::iterator_range<param_iterator> param_range;
   typedef llvm::iterator_range<param_const_iterator> param_const_range;
 
-  param_iterator param_begin() { return params().begin(); }
-  param_iterator param_end()   { return params().end(); }
+  param_iterator param_begin() { return param_iterator(ParamInfo); }
+  param_iterator param_end() {
+    return param_iterator(ParamInfo + param_size());
+  }
   param_range params() {
     return param_range(ParamInfo, ParamInfo + param_size());
   }
 
-  param_const_iterator param_begin() const { return params().begin(); }
-  param_const_iterator param_end() const   { return params().end(); }
+  param_const_iterator param_begin() const {
+    return param_const_iterator(ParamInfo);
+  }
+  param_const_iterator param_end() const {
+    return param_const_iterator(ParamInfo + param_size());
+  }
   param_const_range params() const {
     return param_const_range(ParamInfo, ParamInfo + param_size());
   }
index 47a3600e9ca2edfe866f47208db85f4b6c73b428..4139e28afef44d9882753c6663b407b68e35b54b 100644 (file)
@@ -780,8 +780,10 @@ public:
                         redecl_iterator());
   }
 
-  redecl_iterator redecls_begin() const { return redecls().begin(); }
-  redecl_iterator redecls_end() const { return redecls().end(); }
+  redecl_iterator redecls_begin() const {
+    return redecl_iterator(const_cast<Decl *>(this));
+  }
+  redecl_iterator redecls_end() const { return redecl_iterator(); }
 
   /// \brief Retrieve the previous declaration that declares the same entity
   /// as this declaration, or NULL if there is no previous declaration.
@@ -1311,16 +1313,16 @@ public:
   /// decls_begin/decls_end - Iterate over the declarations stored in
   /// this context.
   decl_range decls() const;
-  decl_iterator decls_begin() const { return decls().begin(); }
-  decl_iterator decls_end() const { return decls().end(); }
+  decl_iterator decls_begin() const;
+  decl_iterator decls_end() const { return decl_iterator(); }
   bool decls_empty() const;
 
   /// noload_decls_begin/end - Iterate over the declarations stored in this
   /// context that are currently loaded; don't attempt to retrieve anything
   /// from an external source.
   decl_range noload_decls() const;
-  decl_iterator noload_decls_begin() const { return noload_decls().begin(); }
-  decl_iterator noload_decls_end() const { return noload_decls().end(); }
+  decl_iterator noload_decls_begin() const;
+  decl_iterator noload_decls_end() const { return decl_iterator(); }
 
   /// specific_decl_iterator - Iterates over a subrange of
   /// declarations stored in a DeclContext, providing only those that
index 309bb12609023c3f6645f255664a58d1308fa743..6948443d8d3179cd59e96d69746834c12c41f652 100644 (file)
@@ -352,10 +352,14 @@ public:
     return param_const_range(getParams(), getParams() + NumParams);
   }
 
-  param_const_iterator param_begin() const { return params().begin(); }
-  param_const_iterator param_end() const { return params().end(); }
-  param_iterator param_begin() { return params().begin(); }
-  param_iterator param_end() { return params().end(); }
+  param_const_iterator param_begin() const {
+    return param_const_iterator(getParams());
+  }
+  param_const_iterator param_end() const {
+    return param_const_iterator(getParams() + NumParams);
+  }
+  param_iterator param_begin() { return param_iterator(getParams()); }
+  param_iterator param_end() { return param_iterator(getParams() + NumParams); }
 
   // This method returns and of the parameters which are part of the selector
   // name mangling requirements.
index 1170eda819c2caa3e295f8dbc4afd3c7e593cb46..25b81c2a807b6e5413bd3b2b56fc7d905bc5601e 100644 (file)
@@ -171,8 +171,11 @@ public:
                         redecl_iterator());
   }
 
-  redecl_iterator redecls_begin() const { return redecls().begin(); }
-  redecl_iterator redecls_end() const { return redecls().end(); }
+  redecl_iterator redecls_begin() const {
+    return redecl_iterator(
+        const_cast<decl_type *>(static_cast<const decl_type *>(this)));
+  }
+  redecl_iterator redecls_end() const { return redecl_iterator(); }
 
   friend class ASTDeclReader;
   friend class ASTDeclWriter;
index 711946ea0092b6d6a1243a2112be5f24ab2067cc..5797e554a3ca9697fd6b5b75a4a3d60217ee7f93 100644 (file)
@@ -1080,12 +1080,22 @@ DeclContext::decl_range DeclContext::noload_decls() const {
   return decl_range(decl_iterator(FirstDecl), decl_iterator());
 }
 
+DeclContext::decl_iterator DeclContext::noload_decls_begin() const {
+  return decl_iterator(FirstDecl);
+}
+
 DeclContext::decl_range DeclContext::decls() const {
   if (hasExternalLexicalStorage())
     LoadLexicalDeclsFromExternalStorage();
   return decl_range(decl_iterator(FirstDecl), decl_iterator());
 }
 
+DeclContext::decl_iterator DeclContext::decls_begin() const {
+  if (hasExternalLexicalStorage())
+    LoadLexicalDeclsFromExternalStorage();
+  return decl_iterator(FirstDecl);
+}
+
 bool DeclContext::decls_empty() const {
   if (hasExternalLexicalStorage())
     LoadLexicalDeclsFromExternalStorage();