[cfe-commits] r43105 - in /cfe/trunk: AST/ExprCXX.cpp AST/Stmt.cpp AST/StmtIterator.cpp include/clang/AST/Decl.h include/clang/AST/Stmt.h include/clang/AST/StmtGraphTraits.h include/clang/AST/StmtIterator.h
Ted Kremenek
kremenek at apple.com
Wed Oct 17 17:46:10 PDT 2007
All good points. I'll get to this tomorrow.
On Oct 17, 2007, at 5:33 PM, Chris Lattner wrote:
>> Log:
>> 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.
>
>> +++ cfe/trunk/AST/ExprCXX.cpp Wed Oct 17 19:24:38 2007
>> @@ -25,7 +25,7 @@
>> }
>>
>> Stmt::child_iterator CXXCastExpr::child_end() {
>> - return child_begin()+1;
>> + return ++child_begin();
>> }
>
> These probably shouldn't call child_begin(), which is a virtual
> method call. They should do what child_begin() does inline.
>
>>
>> +void StmtIterator::PrevDecl() { assert(false); }
>> +
>> +Stmt*& StmtIterator::GetInitializer() const {
>> + assert (D && isa<VarDecl>(D));
>> + assert (cast<VarDecl>(D)->Init);
>
> cast<VarDecl> on the next line does these asserts internally, you
> can drop these two asserts.
>
>> + return reinterpret_cast<Stmt*&>(cast<VarDecl>(D)->Init);
>> +}
>
>
>
>
>> +
>> +class StmtIterator : public bidirectional_iterator<Stmt*,
>> ptrdiff_t> {
>
> Instead of largely duplicating StmtIterator into ConstStmtIterator,
> does it make sense to make this a template that is instantiated for
> both 'Stmt*' and 'const Stmt *'?
>
>
>> + Stmt** S;
>> + ScopedDecl* D;
>
> Should be merged :)
>
> -Chris
More information about the cfe-commits
mailing list