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/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);
+}