<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Yes, the purpose of this plugin is to
      cut apart C++ code for testing.  What it does is clip out the
      requested functions, find all the referenced
      types/templates/classes/macros/functions/etc, and generates a web
      of stubs and google mocks for the code to exist in.  The desired
      outcome is that you can select one or more functions in a compile
      unit and can easily perform isolated testing on them.</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">This represented a place where the end
      user had to add extra code (the "using X::Y;") to make the
      extracted code (and stubs/mocks) functional.  Not a huge gap, so I
      think we can live with it for now... but in the long run I always
      try to remove the need for the user to reimplement/redefine
      anything.</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">Worst case we can emit all of them that
      exist or can be seen by the context of the function, and that
      reference types we're already emitting.  That said this would be
      the only exception to a general rule of only emitting what was
      actually used, so I'm not entirely keen on that.<br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">   -Eric<br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">On 10/28/2019 1:57 PM, Robinson, Paul
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:BYAPR13MB24215FD5933EE6FBFD4EF47692660@BYAPR13MB2421.namprd13.prod.outlook.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        color:black;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoNormal"><span style="color:windowtext">Properly
            tracking which `using` directives actually get used has been
            on my wishlist for a long time, so that we can suppress the
            unused ones from DWARF.  But it sounds like you want more
            than just used-or-not, but actually where it was used.  That
            would be more ambitious.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:windowtext">--paulr<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:windowtext"><o:p> </o:p></span></p>
        <div>
          <div style="border:none;border-top:solid #E1E1E1
            1.0pt;padding:3.0pt 0in 0in 0in">
            <p class="MsoNormal"><b><span style="color:windowtext">From:</span></b><span
                style="color:windowtext"> cfe-dev
                <a class="moz-txt-link-rfc2396E" href="mailto:cfe-dev-bounces@lists.llvm.org"><cfe-dev-bounces@lists.llvm.org></a>
                <b>On Behalf Of </b>Eric Bayer via cfe-dev<br>
                <b>Sent:</b> Monday, October 28, 2019 4:52 PM<br>
                <b>To:</b> David Blaikie <a class="moz-txt-link-rfc2396E" href="mailto:dblaikie@gmail.com"><dblaikie@gmail.com></a><br>
                <b>Cc:</b> cfe-dev <a class="moz-txt-link-rfc2396E" href="mailto:cfe-dev@lists.llvm.org"><cfe-dev@lists.llvm.org></a><br>
                <b>Subject:</b> Re: [cfe-dev] Determining if a
                UsingDecl/UsingShadowDecl was used in the instantiation
                of a variable.<o:p></o:p></span></p>
          </div>
        </div>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p>Thanks for the answer.  Damn.  Yeah, that is the conclusion I
          was coming to as well.  We had a similar problem capturing
          pre-processor macros as they really are not part of the AST. 
          Eventually I figured out a way to do it because I could
          capture data during the expansions and maintain a data
          structure on the side.  Unfortunately for name resolution
          there seems to be no similar callback/hook.<o:p></o:p></p>
        <p>I also had wondered if there was some stage when maybe they'd
          be unresolved and I could build a data structure for later
          reference, but I've still not explored that avenue.<o:p></o:p></p>
        <div>
          <p class="MsoNormal">   -Eric<o:p></o:p></p>
        </div>
        <div>
          <p class="MsoNormal"><o:p> </o:p></p>
        </div>
        <div>
          <p class="MsoNormal">On 10/28/2019 1:08 PM, David Blaikie
            wrote:<o:p></o:p></p>
        </div>
        <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
          <div>
            <p class="MsoNormal">I don't believe that information is
              preserved in Clang's AST (if it was, we'd probably want to
              use it from the DWARF emission (GCC judiciously emits only
              referenced alias directives, whereas clang just emits them
              all, unfortunately) - and also to power a -Wunused... hmm,
              I thought GCC had a warning for unused using directives,
              but I can't seem to reproduce that now, so maybe I
              hallucinated).<o:p></o:p></p>
          </div>
          <p class="MsoNormal"><o:p> </o:p></p>
          <div>
            <div>
              <p class="MsoNormal">On Tue, Oct 22, 2019 at 2:02 PM Eric
                Bayer via cfe-dev <<a
                  href="mailto:cfe-dev@lists.llvm.org"
                  moz-do-not-send="true">cfe-dev@lists.llvm.org</a>>
                wrote:<o:p></o:p></p>
            </div>
            <blockquote style="border:none;border-left:solid #CCCCCC
              1.0pt;padding:0in 0in 0in
              6.0pt;margin-left:4.8pt;margin-right:0in">
              <div>
                <p>Hi,<o:p></o:p></p>
                <p>I have a plugin I'm working on a clang plugin where
                  we need to determine all the things used in the
                  creation of a piece of code.  Right now we have a
                  situation as follows:<o:p></o:p></p>
                <pre>namespace X { class Y { enum Z { A=0, B, C }; }; };<o:p></o:p></pre>
                <pre>using X::Y;<o:p></o:p></pre>
                <pre><o:p> </o:p></pre>
                <pre>void MyFunc() {<o:p></o:p></pre>
                <pre>       Y::Z q;<o:p></o:p></pre>
                <pre>        ...<o:p></o:p></pre>
                <pre>}<o:p></o:p></pre>
                <p>What we currently do is traverse the whole of MyFunc
                  looking for referenced elements using VisitStmt(). 
                  The problem I have is that I can't find any way to
                  determine that "using X::Y;" was used and that it was
                  involved in resolving "Y::Z" to "X::Y::Z" in the
                  creation of "q".   This has not been a problem for all
                  sorts of sugar (like typedefs, type aliases, etc), but
                  I am beside myself to find a way in this case.  Is
                  there any way to do this?  I'm even interested if it's
                  a sort of "long way around" solution.  It's surprising
                  to me that this has been this hard... there have been
                  breadcrumbs for every other piece of syntactic sugar.<o:p></o:p></p>
                <p>Thanks in advance,<o:p></o:p></p>
                <p>    -Eric<o:p></o:p></p>
                <p>PS - I thought I had found some clues, but they only
                  seemed to work for functions in one case
                  (DeclRefExpr), and templates in another
                  (getInstantiatedFromUsingDecl()).<o:p></o:p></p>
              </div>
              <p class="MsoNormal">_______________________________________________<br>
                cfe-dev mailing list<br>
                <a href="mailto:cfe-dev@lists.llvm.org" target="_blank"
                  moz-do-not-send="true">cfe-dev@lists.llvm.org</a><br>
                <a
href="https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fcfe-dev&data=02%7C01%7Cebayer%40vmware.com%7C38bb48c5025e401c2e4308d75be9792c%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C637078930645115931&sdata=KFJdCbEZHfVHYUImlsOwRM2%2BpL%2F11DKQq2REqSfUZCQ%3D&reserved=0"
originalsrc="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev"
shash="xXk8BvUeV2eEfyjqqj7M9qSFVlkz9T8nWZCdTqdnoBY+RwF52fzgEcoW37AaHlkkNV2+/aMrxMAoraTNzXAEuJaAa5F0GHhnO/pmYCuDkPdBAQmboPoh+CgqXXntLiVzDpNhxy1JQ6EmiPXW7U/PJA6ZW/sOxFNTOXTrPHyt+4k="
                  target="_blank" moz-do-not-send="true">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><o:p></o:p></p>
            </blockquote>
          </div>
        </blockquote>
        <p><o:p> </o:p></p>
      </div>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>