Implemented 90% functionality of new child_iterator for Stmt objects
that will (soon) allow iteration over the initializers in
declarations.  This new iterator mechanism is implemented by the
classes StmtIterator and ConstStmtIterator.

Patched a few files to use "operator++" instead of "operator+" on
child_iterators.

Friendship added in VarDecl to StmtIterator to allow returning a
reference to the initializer within the VarDecl.  We may not wish this
as a permanent solution.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43105 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/ExprCXX.cpp b/AST/ExprCXX.cpp
index 093c37e..74d471e 100644
--- a/AST/ExprCXX.cpp
+++ b/AST/ExprCXX.cpp
@@ -25,7 +25,7 @@
 }
 
 Stmt::child_iterator CXXCastExpr::child_end() {
-  return child_begin()+1;
+  return ++child_begin();
 }
 
 // CXXBoolLiteralExpr
diff --git a/AST/Stmt.cpp b/AST/Stmt.cpp
index 6768705..c9a86ed 100644
--- a/AST/Stmt.cpp
+++ b/AST/Stmt.cpp
@@ -168,7 +168,7 @@
   return reinterpret_cast<Stmt**>(&Target); 
 }
 
-Stmt::child_iterator IndirectGotoStmt::child_end() { return child_begin()+1; }
+Stmt::child_iterator IndirectGotoStmt::child_end() { return ++child_begin(); }
 
 // ContinueStmt
 Stmt::child_iterator ContinueStmt::child_begin() { return NULL; }
diff --git a/AST/StmtIterator.cpp b/AST/StmtIterator.cpp
new file mode 100644
index 0000000..aca1f81
--- /dev/null
+++ b/AST/StmtIterator.cpp
@@ -0,0 +1,27 @@
+//===--- StmtIterator.cpp - Iterators for Statements ------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by Ted Kremenek and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines internal methods for StmtIterator.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/AST/StmtIterator.h"
+#include "clang/AST/Stmt.h"
+#include "clang/AST/Decl.h"
+
+using namespace clang;
+
+void StmtIterator::NextDecl() { assert(false); }
+void StmtIterator::PrevDecl() { assert(false); }
+
+Stmt*& StmtIterator::GetInitializer() const {
+  assert (D && isa<VarDecl>(D));
+  assert (cast<VarDecl>(D)->Init);
+  return reinterpret_cast<Stmt*&>(cast<VarDecl>(D)->Init);
+}