<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">Stephen you’ve raised a great point about how the user should be able to interface with Stmt nodes, and your clang-query idea is absolutely great, I love it.   </div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">But I don’t think your proposed solution is broad enough, even for your own use case.  Below I give an easy, general solution that would work for you and everyone else.  (This clarifies & applies to Stephen’s case the points I discussed with Richard earlier.)  Please point out where you see a problem with this; that would at least help clarify the discussion for others.</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">To summarize the issue, the now famous "B-42" example:</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">```</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">struct B { B(int); }</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">B func1() { return 42; }</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">```</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">This currently get matches for `hasReturnValue(exprWCleanups())`; you want it to match `hasReturnValue(integerLiteral())` under a new "beginner" setting.</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">But if we’re going to introduce a new, easier setting, why not go all out, and let it *also* match `hasReturnValue(cxxConstructExpr())` OR hasReturnValue(materializeTemporaryExpr()) OR, yes, even the original `hasReturnValue(exprWithCleanups())`?  I believe this is what Richard originally suggested.</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">We should call this setting "easy" mode — and I would probably agree with you that it *should* be made the default, for *everyone*’s sake, not just beginners - more on that later.  </div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">This is how it could be implemented, three steps:</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">1. Add Expr::isImplicit(), Expr::desalt(), and Expr::getAs<T>(), the latter two similar but, as Richard pointed out, anti-analogous to Type::desugar() and Type::getAs<T>().  (I support introducing these in the main AST nodes, rather than only in ASTMatchers, so that other users of the AST can inteface with nodes in the same way ASTMatchers do, thereby avoiding a bifurcation in how AST nodes are interpreted and used.)</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">```</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>class Expr : public Stmt {</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">               </span>//…</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">    </span>public:</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">          </span>bool isImplicit() const {</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">                        </span>//…Dispatch to the most derived type’s isImplicit(), and be sure they all define one.</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">              </span>/// Whereas Type::desugar peels off meaningless syntax ("sugar") to get at underlying semantics, this</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">          </span>/// peels off invisible semantics ("salt") to get at underlying syntax.  (Proposed name, open to suggestions.)</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">            </span>Expr * desalt() const {</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">                  </span>if (!this->isImplicit())</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">                              </span>return nullptr;</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">                  </span>assert(children.end() = children.begin() + 1 &&</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">                          </span>  "Expected implicit nodes to have exactly one child");</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">                   </span>return *children.begin();</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><p style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier; min-height: 12px;" class=""><span class="Apple-tab-span" style="white-space:pre">                </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">              </span>template<typename T></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">               </span>T *getAs() const {</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">                       </span>if (isa<T>(this)) </div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">                            </span>return cast<T>(this);</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">                      </span>return desalt()->getAs<T>();</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">            </span>}</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>};</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">```</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">2. In the ASTMatchers implem, define BoundNodes::getNodeAs<T>() in terms of Stmt::getAs<T>().  I think it would be as simple as this:</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">```</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">  <span class="Apple-tab-span" style="white-space:pre"> </span>class BoundNodes {</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">               </span>//… </div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">    <span class="Apple-tab-span" style="white-space:pre">                </span>template <typename T></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">    <span class="Apple-tab-span" style="white-space:pre">                </span>const T *getNodeAs(StringRef ID) const {</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">                 </span>if (std::is_base_of<Expr, T>::value) {</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">                             </span>if (Expr *E = MyBoundNodes.getNodeAs<Expr>(ID))</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">                                    </span>return E->getAs<T>();</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">                           </span>return nullptr;</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">                  </span>}</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">      <span class="Apple-tab-span" style="white-space:pre">                   </span>return MyBoundNodes.getNodeAs<T>(ID);</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><span class="Apple-tab-span" style="white-space:pre">              </span>}</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">    <span class="Apple-tab-span" style="white-space:pre">  </span>};</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">```</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">At this point, if on the B-42 example you call</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">`returnStmt(hasReturnValue(expr().bind("theReturnVal")))`</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">when in "easy" mode, for theReturnVal you should be able to getNodeAs<IntegerLiteral>(), getNodeAs<ExprWCleanups>(), getNodeAs<CXXConstructExpr>() etc — all would be nonnull, users can take their pick.  And btw, if you wanted to get the other CXXConstructExpr, since there are two, you would call firstConstructExpr->desalt()->getAs<CXXConstructExpr>()).  And, if you only wanted matches that were non-implicit, you'd use ignoreImplicit as usual — but you would have to specify this.  This would force the user to reckon with the existence of what I guess I’m calling "semantic salt" over their syntax, without forcing them to manually dust it all off to get to a simple IntegerLiteral underneath.  </div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">So the user retains maximum flexibility, but gains maximum tightness/expressiveness, in this new mode.</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">3. The last part of the puzzle: how to allow `hasReturnValue(integerLiteral())` to match the "return 42;" in the B-42 example.  From perusing ASTMatchersInternal.h, it seems you would just want to change any dyn_cast<SomeExpr>(E) to E->getAs<T>() when in "easy" mode.  If a generic template is used somewhere, specialize it for Exprs to do this, same as we did for getNodeAs<T>().</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">Then, it should be able to work as you suggested — correct me if I’m wrong.</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">What is more, as you suggested, this really isn’t just a beginner mode — the experts would benefit too:</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">Suppose in the future we find we need more than just ExprWCleanups — we need an extra implicit ExprWExtraCleanups that wraps the ExprWCleanups and everything else.  Or we need new inner implicit nodes.  If an expert used "easy" mode and getNodeAs<ExprWCleanups>(), and getAs<T>() whenever they sought to navigate to a child of an implicit node, he/she would not need to change her code at all.  Only if she required that each match was exact (call such a mode "directMatchOnly" perhaps) would she need to do a lot of maintenance whenever a new implicit node is introduced.  </div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">That’s why I would probably agree with Stephen that "easy" mode should probably be the default — the user should have to call "directMatchOnly" to opt out.  But I could see the other side of it too.</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">Bottom line: you’ve raised a great but subtle point, doggedly pursued it, but now, let’s just get rid of the half measures — let’s go all out with a solution that is easy and lifts all boats.</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">If there is some problem this way of doing things won’t solve, please point it out — that would at least clarify the discussion for others who perhaps can help better than I can.  Thanks again for your efforts,</div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 10px; line-height: normal; font-family: Courier;" class="">- Dave</div><div><br class=""><blockquote type="cite" class=""><div class="">On Jun 28, 2020, at 7:07 PM, Stephen Kelly via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
  
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" class="">
  
  <div bgcolor="#FFFFFF" text="#000000" class=""><p class=""><br class="">
    </p>
    <div class="moz-cite-prefix">On 24/06/2020 21:26, Yitzhak Mandelbaum
      wrote:<br class="">
    </div>
    <blockquote type="cite" cite="mid:CAKTLd7wqycd3uMXN2rkCHYr99=jo7JHemLE9jMQQAviJJ-8tgg@mail.gmail.com" class="">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8" class="">
      <div dir="ltr" class="">
        <div class="gmail_default" style="font-family:arial,helvetica,sans-serif">My 2cents: </div>
        <div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br class="">
        </div>
      </div>
    </blockquote><p class=""><br class="">
    </p><p class="">Thanks for responding about the matcher output from clang-query.<br class="">
    </p><p class=""><br class="">
    </p>
    <blockquote type="cite" cite="mid:CAKTLd7wqycd3uMXN2rkCHYr99=jo7JHemLE9jMQQAviJJ-8tgg@mail.gmail.com" class="">
      <div dir="ltr" class="">
        <div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I mostly agree
          with Richard and Sam. My only concern w/ Richard's proposal is
          that the hybrid model may be even more confusing to the
          beginner, since it may be harder to predict how a given
          matcher will match against an AST.  The system will be more
          forgiving, yet it becomes harder to build a mental model of
          how it works. <br class="">
        </div>
      </div>
    </blockquote><p class=""><br class="">
    </p><p class="">In addition to making clang-query output relatable information, I
      agree with what you wrote here about creating a mental model.<br class="">
    </p><p class=""><br class="">
    </p>
    <blockquote type="cite" cite="mid:CAKTLd7wqycd3uMXN2rkCHYr99=jo7JHemLE9jMQQAviJJ-8tgg@mail.gmail.com" class="">
      <div dir="ltr" class="">
        <div class="gmail_default" style="font-family:arial,helvetica,sans-serif"> I think we'd
          need to be sure we can concisely explain how this mode works,
          without having to reference any code/algorithms. For example,
          is there a deterministic elaboration from any unadorned
          matcher to a matcher with explicit `traverse` annotations?
          That would allow us to give some examples that illuminate
          what's happening. Otherwise, I'd prefer we just go back to the
          original default for the library. I'm fine if
          beginner-oriented tools want to start with "IgnoreUnless..."
          as their default. It sounds like Stephen is amenable to this
          approach as well from his last reply.</div>
        <div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br class="">
        </div>
      </div>
    </blockquote><p class=""><br class="">
    </p><p class="">I think reversing the change of default is a worse outcome, but I
      think it's better than the current state of unhappiness from
      people. <br class="">
    </p><p class="">Further development can't happen until this thread is resolved I
      think.</p><p class="">However, if the default is changed back, I think there is less
      reason to add the matcher output feature to clang-query, because
      it will either need to <br class="">
    </p><p class="">* not show ignoring*() matchers in its output<br class="">
    </p><p class="">* show output based on each of (and none of) the ignoring*()
      matchers being applied</p><p class="">I think that would be too noisy and I don't think it's a good
      thing to require newcomer users to immediately create a mental
      model which requires those matchers.<br class="">
    </p><p class=""><br class="">
    </p>
    <blockquote type="cite" cite="mid:CAKTLd7wqycd3uMXN2rkCHYr99=jo7JHemLE9jMQQAviJJ-8tgg@mail.gmail.com" class="">
      <div dir="ltr" class="">
        <div class="gmail_default" style="font-family:arial,helvetica,sans-serif">re:
          context-sensitive suggestions. </div>
        <div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Stephen, if you
          drop the need to suggest all possible matchers at that point
          and only provide (beginner) helpful suggestions, does your
          concern go away?  </div>
      </div>
    </blockquote><p class=""><br class="">
    </p><p class="">It doesn't change my concern. <br class="">
    </p><p class="">I don't know how you would determine what should be in the output
      and what shouldn't. Also, this content is not just for beginners.
      I use the feature still.</p><p class="">I don't think this is the thread for details such as your other
      question.</p><p class=""><br class="">
    </p>
    <blockquote type="cite" cite="mid:CAKTLd7wqycd3uMXN2rkCHYr99=jo7JHemLE9jMQQAviJJ-8tgg@mail.gmail.com" class="">
      <div dir="ltr" class=""><span class="gmail_default" style="font-family:arial,helvetica,sans-serif">Overall, </span>I'm<span class="gmail_default" style="font-family:arial,helvetica,sans-serif"> </span>pessimistic
        ab<span class="gmail_default" style="font-family:arial,helvetica,sans-serif"></span>out
        making the current matchers easier for users.</div>
    </blockquote><p class=""><br class="">
    </p><p class="">I think if AST Matchers are not going to be removed, we should
      make them easier for users.</p><p class=""><br class="">
    </p>
    <blockquote type="cite" cite="mid:CAKTLd7wqycd3uMXN2rkCHYr99=jo7JHemLE9jMQQAviJJ-8tgg@mail.gmail.com" class="">
      <div dir="ltr" class=""> I think the AST is challenging for beginners and
        band aids will not solve that and can often make it worse. If we
        want beginner-friendly tooling (and I do!) we need to admit its
        cost and then invest in it.<span style="font-family:arial,helvetica,sans-serif" class=""></span></div>
    </blockquote><p class=""><br class="">
    </p><p class="">Yes, I have started such tooling, but there is much more that can
      be done.<br class="">
    </p><p class="">But, as in this thread, I don't think this is fully a tooling
      issue. It's also about discoverability and that means making it
      easier for users to create a mental model that doesn't require
      them to put ignoringImplicit() everywhere.</p><p class=""><br class="">
    </p><p class="">Thanks Yitzhak for your input. I remain interested in
      feedback/input from others on the content I quote below.<br class="">
    </p><p class=""><br class="">
    </p><p class="">Thanks,</p><p class="">Stephen.<br class="">
    </p><p class=""><br class="">
    </p>
    <blockquote type="cite" cite="mid:CAKTLd7wqycd3uMXN2rkCHYr99=jo7JHemLE9jMQQAviJJ-8tgg@mail.gmail.com" class="">
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Mon, Jun 22, 2020 at 5:51
          PM Stephen Kelly via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" moz-do-not-send="true" class="">cfe-dev@lists.llvm.org</a>>
          wrote:<br class="">
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div bgcolor="#FFFFFF" class=""><br class=""><p class="">The main reason I'm not supportive of this idea is that I
              want to make clang-query tell the user what matchers they
              can use with the nodes in the binding list.<br class="">
            </p><p class="">For example, if I write<br class="">
            </p><p class=""> returnStmt()</p><p class="">in clang-query it should tell me that I can write <br class="">
            </p><p class=""> hasReturnValue(integerLiteral())<br class="">
            </p><p class="">inside the expr():</p><p class=""> <a href="http://ce.steveire.com/z/9EF8x0" target="_blank" moz-do-not-send="true" class="">http://ce.steveire.com/z/9EF8x0</a></p><p class="">That's how I as a newcomer quickly discover
              hasReturnValue() and integerLiteral().</p><p class="">You have no idea how overwhelming <br class="">
            </p><p class=""> <a href="http://clang.llvm.org/docs/LibASTMatchersReference.html" target="_blank" moz-do-not-send="true" class="">http://clang.llvm.org/docs/LibASTMatchersReference.html</a><br class="">
            </p><p class="">is to someone who has zero familiarity with the clang
              AST.</p><p class="">But the above link is interactive and it aids *discovery*
              which is what my talk was about and which is what I'm
              trying to make easier with AST Matchers. The above
              suggested clang-query feature (not upstream yet) tells me
              at every step which matchers I can use in the context of
              what I am trying to achieve.<br class="">
            </p><p class="">However, if all of the implicit nodes should also appear
              in that output, and if in<br class="">
            </p><p class="">`returnStmt(hasReturnValue(expr().bind("theReturnVal")))`</p><p class="">the expr() should match the exprWithCleanups(), then I
              don't know how to make that feature work. If the expr() is
              the exprWithCleanups() then the tool definitely shouldn't
              tell the user they can write integerLiteral() there. The
              output for implicit nodes would add lots of noise and
              would have to be neutral in terms of what it recommends.<br class="">
            </p><p class="">The entire point of what I'm trying to do is not present
              the user with exprWithCleanups() and let them achieve
              their goals without it. I don't know if that's possible
              with the ideas floating around at the moment about making
              AST Matchers present all of the implicit nodes.</p><p class="">But, if making IgnoreUnlessSpelledInSource non-default
              means that I can continue work toward that goal (and eg
              ignore template instantiations and other implicit nodes
              which are not skipped yet), then maybe that's a viable way
              forward. So, that's my preference now I think.<br class="">
            </p><p class="">That way, people who want expert mode get it by default,
              and newcomers (and anyone else who doesn't want to write
              ignoringImplicit() everywhere) can relatively easily get
              the easier mode, and can use the expert mode when wanting
              to match implicit nodes. <br class="">
            </p><p class="">That might be the best compromise.<br class="">
            </p><p class="">Thanks,</p><p class="">Stephen<br class="">
            </p><p class=""><br class="">
            </p>
          </div>
          _______________________________________________<br class="">
          cfe-dev mailing list<br class="">
          <a href="mailto:cfe-dev@lists.llvm.org" target="_blank" moz-do-not-send="true" class="">cfe-dev@lists.llvm.org</a><br class="">
          <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank" moz-do-not-send="true" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br class="">
        </blockquote>
      </div>
    </blockquote>
  </div>

_______________________________________________<br class="">cfe-dev mailing list<br class=""><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev<br class=""></div></blockquote></div><br class=""></body></html>