On Tue, Apr 11, 2017 at 10:27 AM Aaron Ballman via Phabricator < revi...@reviews.llvm.org> wrote:
> aaron.ballman added inline comments. > > > ================ > Comment at: include/clang/AST/Expr.h:4025 > child_range children() { > + const_child_range CCR = const_cast<const InitListExpr > *>(this)->children(); > + return child_range(cast_away_const(CCR.begin()), > ---------------- > dblaikie wrote: > > If this is adding const, can you use a weaker cast? (I guess what would > be ideal here would be implicit_cast - if you're interested you could add > that - otherwise... yeah, I guess static_cast could do other nasty things, > etc, so there's nothing good) > I'm not certain what you mean. This is adding the const qualifier so that > we call the proper overload. I'm not certain of what a weaker cast would be. > Oh, I meant something like tihs: http://www.boost.org/doc/libs/1_39_0/boost/implicit_cast.hp <http://www.boost.org/doc/libs/1_39_0/boost/implicit_cast.hpp>p The thing about using a const_cast to add const is it can be a bit hard to read/be sure about. I don't know if it's removing some const while it adds other const. > > > ================ > Comment at: include/clang/AST/StmtIterator.h:148-150 > +inline StmtIterator cast_away_const(const ConstStmtIterator &RHS) { > + return RHS; > +} > ---------------- > dblaikie wrote: > > Maybe I'm missing something - what stops code from doing this conversion > implicitly/accidentally all over the place? (I would've expecetd > cast_away_const to be a friend or something, to only allow the conversion > through this explicit call/operation) > Good catch, I've corrected this. > > > https://reviews.llvm.org/D31153 > > > >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits