[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision. aaron.ballman added a comment. Commit in r299981. https://reviews.llvm.org/D31153 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Re: [PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-04-11 Thread David Blaikie via cfe-commits
Ah - perhaps it'd be worth having a standalone forward declaration for clarity? I don't think I've seen this construct anywhere else in LLVM? But I could be wrong. On Tue, Apr 11, 2017 at 10:51 AM Aaron Ballman via Phabricator < revi...@reviews.llvm.org> wrote: > aaron.ballman added inline commen

[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: include/clang/AST/StmtIterator.h:137 + inline friend StmtIterator + cast_away_const(const struct ConstStmtIterator &RHS); }; dblaikie wrote: > the "struct" here is a bit atypical/should be removed The forward re

Re: [PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-04-11 Thread David Blaikie via cfe-commits
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 *>(this)->children();

[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-04-11 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision. dblaikie added a comment. This revision is now accepted and ready to land. Looks good to me - thanks! Comment at: include/clang/AST/StmtIterator.h:137 + inline friend StmtIterator + cast_away_const(const struct ConstStmtIterator &RHS); }; ---

[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 94852. aaron.ballman added a comment. Addressing review comments. https://reviews.llvm.org/D31153 Files: include/clang/AST/Expr.h include/clang/AST/StmtIterator.h lib/AST/Expr.cpp Index: lib/AST/Expr.cpp

[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: include/clang/AST/Expr.h:4025 child_range children() { +const_child_range CCR = const_cast(this)->children(); +return child_range(cast_away_const(CCR.begin()), dblaikie wrote: > If this is adding const,

[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-04-11 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments. Comment at: include/clang/AST/Expr.h:4025 child_range children() { +const_child_range CCR = const_cast(this)->children(); +return child_range(cast_away_const(CCR.begin()), If this is adding const, can you use a weaker ca

[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 94809. aaron.ballman added a comment. Addressing David's review feedback. https://reviews.llvm.org/D31153 Files: include/clang/AST/Expr.h include/clang/AST/StmtIterator.h lib/AST/Expr.cpp Index: lib/AST/Expr.cpp

Re: [PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-03-27 Thread David Blaikie via cfe-commits
On Mon, Mar 27, 2017 at 10:20 AM Aaron Ballman via Phabricator < revi...@reviews.llvm.org> wrote: > aaron.ballman added a comment. > > In https://reviews.llvm.org/D31153#711287, @dblaikie wrote: > > > As I mentioned to Craig Topper recently on another review, generally > when implementing const an

[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-03-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In https://reviews.llvm.org/D31153#711287, @dblaikie wrote: > As I mentioned to Craig Topper recently on another review, generally when > implementing const and non-const overloads the non-const is implemented in > terms of the const overload (& const_casts away c

[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-03-27 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment. As I mentioned to Craig Topper recently on another review, generally when implementing const and non-const overloads the non-const is implemented in terms of the const overload (& const_casts away const on the result). This ensures no UB if the const overload is called

[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-03-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. Ping. Because I expect this to be fairly uncontroversial, I'll give it a week in case folks have comments, then commit (and will handle anything in post-commit review). https://reviews.llvm.org/D31153 ___ cfe-commit

[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-03-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 92522. aaron.ballman added a comment. Missed a case for `UnaryExprOrTypeTraitExpr`. https://reviews.llvm.org/D31153 Files: include/clang/AST/Expr.h include/clang/AST/StmtIterator.h lib/AST/Expr.cpp Index: lib/AST/Expr.cpp ==

[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-03-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision. We already have children() but not children() const, which is causing some problems for me on an out of tree project. Most of the changes here are mechanical, except for the work done to `ConstStmtIterator`, which cheats and uses a `const_cast`. Since none o