<div dir="ltr">This might be a bit of a strange take, but as an outside user of LLVM, my personal request would be that uses of `auto` be loosely predicated on not breaking doxygen too badly/frequently. (I surmise this essentially means discouraging `auto` when there are member functions being called from it later to do interesting work, but I leave that for others to debate and decide).<div><br><div><div>I know doxygen already has many other similar failure modes (such as templates and auto-generated content, macros), but I thought offering this view might provide some objectivity to the "more readable" question, as it attempts to connect the definition of readability to a specific tooling question ("is the type available to a locally-syntactic tool with a particular purpose?") instead of subjective aesthetics (such as whether auto in lambda is more or less pretty).</div><br class="inbox-inbox-Apple-interchange-newline"></div><div>Of course, that still leaves many edge cases: for example, I found</div><div><a href="http://llvm.org/doxygen/IRBuilder_8h_source.html#l02247">http://llvm.org/doxygen/IRBuilder_8h_source.html#l02247</a> while searching for an example for this email:</div><div><div class="inbox-inbox-line" style="font-stretch:normal;font-size:13px;line-height:1;font-family:monospace,fixed;min-height:13px;white-space:pre-wrap;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px;background-color:rgb(251,252,253)"><span class="inbox-inbox-lineno" style="padding-right:4px;text-align:right;border-right-width:2px;border-right-style:solid;border-right-color:rgb(0,255,0);background-color:rgb(232,232,232);white-space:pre"> 2247</span>       <span class="inbox-inbox-keywordflow" style="color:rgb(224,128,0)">if</span> (<span class="inbox-inbox-keyword" style="color:rgb(0,128,0)">const</span> <span class="inbox-inbox-keyword" style="color:rgb(0,128,0)">auto</span> *CI = dyn_cast<ConstantInt>(OffsetValue))<br></div><div class="inbox-inbox-line" style="font-stretch:normal;font-size:13px;line-height:1;font-family:monospace,fixed;min-height:13px;white-space:pre-wrap;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px;background-color:rgb(251,252,253)"><a style="color:rgb(61,87,140)"></a><span class="inbox-inbox-lineno" style="padding-right:4px;text-align:right;border-right-width:2px;border-right-style:solid;border-right-color:rgb(0,255,0);background-color:rgb(232,232,232);white-space:pre"> 2248</span>         IsOffsetZero = CI->isZero();</div><div class="inbox-inbox-line" style="font-stretch:normal;font-size:13px;line-height:1;font-family:monospace,fixed;min-height:13px;white-space:pre-wrap;word-wrap:break-word;padding-left:53px;padding-bottom:0px;margin:0px;background-color:rgb(251,252,253)"><a style="color:rgb(61,87,140)"></a><span class="inbox-inbox-lineno" style="padding-right:4px;text-align:right;border-right-width:2px;border-right-style:solid;border-right-color:rgb(0,255,0);background-color:rgb(232,232,232);white-space:pre"> 2249</span></div><br class="inbox-inbox-Apple-interchange-newline" style="font-family:-webkit-standard">This is a case where auto is generally accepted (because the type is obvious in the dyn_cast), but since doxygen doesn't know about that convention, it is unable to find the documentation for the `isZero` call.</div><div><br></div><div>Anyways, my 2¢, from a lurker.</div><div><br class="inbox-inbox-Apple-interchange-newline"><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Feb 3, 2019 at 1:31 PM Stephen Kelly via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">
    <p><br>
    </p>
    <div class="m_-5351493160336335539moz-cite-prefix">On 03/02/2019 17:59, Mehdi AMINI wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">
        <div dir="ltr">
          <div dir="ltr">
            <div dir="ltr"><br>
            </div>
            <br>
            <div class="gmail_quote">
              <div dir="ltr" class="gmail_attr">On Sun, Feb 3, 2019 at
                6:50 AM Stephen Kelly via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>
                wrote:<br>
              </div>
              <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">On
                31/12/2018 04:54, Chris Lattner via llvm-dev wrote:<br>
                >> Do those uses conform to the guide? If they
                don't, then should the guide be updated? Are the types
                there 'obvious’?<br>
                > <br>
                > If/when we revise the policy, then it would make
                sense for non-conforming uses of auto to be changed. 
                However, I don’t think that actually making a widespread
                change would be high priority...<br>
                > <br>
                >> How did all of those uses get into the
                codebase? Does it indicate that the guide is not
                followed, or does it indicate that the guide is too
                subjective, or that maybe the 'the type must be obvios'
                guide does not reflect the 'reality at the coalface'
                anymore? Should those uses of auto be changed?<br>
                > <br>
                > My understanding is that there has been no widely
                understood or accepted policy, so different coders and
                reviewers are doing different things.<br>
                <br>
                One of the things which has no consensus here is whether
                'auto' may be<br>
                used in lambdas (using c++-14). </blockquote>
              <div><br>
              </div>
              <div>Under the current guidelines, my understanding is
                that nothing prevents to use auto in lambda in order to
                "make the code more readable" when "the type is already
                obvious from the context" or "when the type would have
                been abstracted away anyways, often behind a container’s
                typedef such as std::vector<T>::iterator".</div>
              <div><br>
              </div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <p><br>
    </p>
    </div><div bgcolor="#FFFFFF" text="#000000"><p>Some people seem to have objections to use of auto with range-for
      loops too.</p>
    There doesn't seem to be consensus on what is 'readable'. Some
    people claim <br>
    strongly that 'the type must be obvious. There even seems to be
    consensus on <br>
    that phrase, though it doesn't seem to actually apply - We have lots
    of uses of<br>
    auto with AST Matchers for example, and the type of the matcher is
    not obvious<br>
    in that code. We have lots of similar 'the type is not "obvious"'
    code using auto.
    <p>And yet, <br>
    </p></div><div bgcolor="#FFFFFF" text="#000000">
    <p> if (const auto *TSI = D->getTypeSourceInfo())</p>
    </div><div bgcolor="#FFFFFF" text="#000000"><p>draws review comments that it must be changed.<br>
    </p></div><div bgcolor="#FFFFFF" text="#000000">
    <p><br>
    </p>
    <blockquote type="cite">
      <div dir="ltr">
        <div dir="ltr">
          <div dir="ltr">
            <div class="gmail_quote">
              <div>We don't need to update the guideline on auto to be
                able to use auto in lambda as soon as c++14 is
                available.</div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <p><br>
    </p>
    </div><div bgcolor="#FFFFFF" text="#000000"><p>That seems to depend on the reviewer, which means the code and
      the reviews will be inconsistent.<br>
    </p></div><div bgcolor="#FFFFFF" text="#000000">
    <p><br>
    </p>
    <blockquote type="cite">
      <div dir="ltr">
        <div dir="ltr">
          <div dir="ltr">
            <div class="gmail_quote">
              <div><br>
              </div>
              <div> <br>
              </div>
              <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">This
                feature was celebrated as a big<br>
                feature which gets unlocked by migrating to toolchains
                which provide<br>
                that feature:<br>
                <br>
                  <a href="https://groups.google.com/forum/#!msg/llvm-dev/0VkIuhn10nE/QZ5FwYEmHAAJ" rel="noreferrer" target="_blank">https://groups.google.com/forum/#!msg/llvm-dev/0VkIuhn10nE/QZ5FwYEmHAAJ</a><br>
                <br>
                So, does this need a guideline update?<br>
                <br>
                Is there consistency in celbrating that but writing
                'remove all use of<br>
                auto from this file' in reviews?<br>
                <br>
                If there's no consensus and no consistency, what does
                that mean for the<br>
                code?<br>
                <br>
                Is<br>
                <br>
                   if (const auto *TSI = D->getTypeSourceInfo())<br>
                <br>
                ok?<br>
                <br>
                Some reviewers say 'no'. What is the consensus and how
                is that expressed<br>
                in the guidelines?<br>
                <br>
                Does anyone have any interest in making the guidelines
                more clear on<br>
                this?<br>
                <br>
                I have made several proposals, and at least Chris agreed
                that something<br>
                should be improved, but then he left the discussion.<br>
                <br>
                Does anyone else think that something can be improved?
                Is anyone willing<br>
                to read and comment on my proposal and get a change to
                the guidelines<br>
                committed?<br>
              </blockquote>
              <div><br>
              </div>
              <div>I think that multiple people read your proposal and
                gave feedback on Phabricator that mandates a revision
                (for instance for-range loop). Also in this topic I
                believe some feedback was given that rewording in order
                to remove ambiguity is always good, as long as the
                "spirit" of the current rule as it is written is
                preserved.</div>
              <div>So my take on the subject is that we're waiting on a
                new revision of your patch?</div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <p><br>
    </p></div><div bgcolor="#FFFFFF" text="#000000">
    We deliberately took the discussion off Phab and onto the mailing
    list <br>
    to try to get more-fruitful discussion. For example in <br>
    <p><br>
    </p>
    <p> <a class="m_-5351493160336335539moz-txt-link-freetext" href="http://clang-developers.42468.n3.nabble.com/Re-llvm-dev-RFC-Modernizing-our-use-of-auto-td4063365.html#a4063424" target="_blank">http://clang-developers.42468.n3.nabble.com/Re-llvm-dev-RFC-Modernizing-our-use-of-auto-td4063365.html#a4063424</a></p>
    <p><br>
    </p>
    I suggested that 'New guidelines should...' and then wrote some<br>
    content. If we don't agree on 'what new guidelines should do', then<br>
    perhaps it is not time for a Phab patch yet?
    <p><br>
    </p>
    Thanks for responding to that mail! :) I responded to you, but the <br>
    discussion again did not progress. Is there just not enough interest<br>
    in this? I'm getting the impression the topic should be dropped, but
    <br>
    maybe I'm missing something?
    <p><br>
    </p>
    <p>Thanks,</p>
    <p>Stephen.<br>
    </p>
    <p><br>
    </p>
  </div>

_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div></div></div>