<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Apr 11, 2017 at 10:27 AM Aaron Ballman via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">aaron.ballman added inline comments.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
================<br class="gmail_msg">
Comment at: include/clang/AST/Expr.h:4025<br class="gmail_msg">
   child_range children() {<br class="gmail_msg">
+    const_child_range CCR = const_cast<const InitListExpr *>(this)->children();<br class="gmail_msg">
+    return child_range(cast_away_const(CCR.begin()),<br class="gmail_msg">
----------------<br class="gmail_msg">
dblaikie wrote:<br class="gmail_msg">
> 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)<br class="gmail_msg">
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.<br class="gmail_msg"></blockquote><div><br>Oh, I meant something like tihs: <a href="http://www.boost.org/doc/libs/1_39_0/boost/implicit_cast.hpp">http://www.boost.org/doc/libs/1_39_0/boost/implicit_cast.hp</a>p<br><br>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.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br class="gmail_msg">
<br class="gmail_msg">
================<br class="gmail_msg">
Comment at: include/clang/AST/StmtIterator.h:148-150<br class="gmail_msg">
+inline StmtIterator cast_away_const(const ConstStmtIterator &RHS) {<br class="gmail_msg">
+  return RHS;<br class="gmail_msg">
+}<br class="gmail_msg">
----------------<br class="gmail_msg">
dblaikie wrote:<br class="gmail_msg">
> 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)<br class="gmail_msg">
Good catch, I've corrected this.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<a href="https://reviews.llvm.org/D31153" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D31153</a><br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
</blockquote></div></div>