From: Ted Kremenek Date: Mon, 6 Oct 2008 18:35:55 +0000 (+0000) Subject: Add const_decl_iterator to DecStmt. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8a0d2660b6890ed95d34f37d142c0c52ac490194;p=clang Add const_decl_iterator to DecStmt. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57186 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index d8cf087ea1..20b01cec55 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -180,6 +180,29 @@ public: virtual decl_iterator decl_begin() { return TheDecl; } virtual decl_iterator decl_end() { return 0; } + class const_decl_iterator { + decl_iterator Impl; + public: + const_decl_iterator(const ScopedDecl *d) + : Impl(const_cast(d)) {} + + bool operator==(const const_decl_iterator& I) const { + return Impl == I.Impl; + } + bool operator!=(const const_decl_iterator& I) const { + return Impl != I.Impl; + } + const ScopedDecl* operator*() const { + return *Impl; + } + const_decl_iterator& operator++() { + ++Impl; return *this; + } + }; + + const_decl_iterator decl_begin() const { return TheDecl; } + const_decl_iterator decl_end() const { return 0; } + // Serialization. virtual void EmitImpl(llvm::Serializer& S) const; static DeclStmt* CreateImpl(llvm::Deserializer& D, ASTContext& C);