<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Wed, Jun 10, 2015 at 3:57 AM Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jun 9, 2015 at 3:01 PM, Kevin Funk <span dir="ltr"><<a href="mailto:kfunk@kde.org" target="_blank">kfunk@kde.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On Tuesday 09 June 2015 13:31:40 Richard Smith wrote:<br>
> On Tue, Jun 9, 2015 at 3:52 AM, Manuel Klimek <<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>> wrote:<br>
> > Yea, this is really hard currently in clang's design: the only place at<br>
> > which the lookup information is available is during semantic analysis on<br>
> > clang's stack :(<br>
> ><br>
> > This has been one of the most requested features though, so perhaps we can<br>
> > find a way to allow re-querying some flows of sema (or being able to<br>
> > optionally store some info) for this.<br>
> ><br>
> > cc'ing Richard for ideas.<br>
><br>
> It seems relatively straightforward to walk the AST and rebuild the Scope<br>
> information that Sema would need to perform an unqualified name lookup from<br>
> a specified context. A starting point of a clang::Expr is not sufficient,<br>
> however, because that doesn't identify a unique place in the AST; we'd need<br>
> to know the path taken to get there. (I'd imagine your AST visitor could<br>
> easily accumulate this information when it's looking for places to<br>
> transform.)<br>
<br>
</span>That means I cannot use AST matchers but have to walk the AST myself and<br>
accumulate information from contexts while walking it? This doesn't sound<br>
straight forward.<br></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>It's probably reasonable to use the parents map to reconstruct the path in this case; if you're planning on making a code transformation, you want to check (for instance) all template instantiations that used that Expr anyway.</div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Could you point me to code which implements something like this? Or some code<br>
snippet doing so?<br></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>I don't know of any existing code that does anything like this, sorry. As Manuel says this is something we've had requests for but never actually provided before.</div></div></div></div></blockquote><div><br></div><div>Note that when Richard says "straight forward" it usually still means "> 1 week to implement for a mortal being". It's not trivial.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks a lot,<br>
Greets<br>
<div><div><br>
> > On Tue, Jun 9, 2015 at 10:05 AM Kevin Funk <<a href="mailto:kfunk@kde.org" target="_blank">kfunk@kde.org</a>> wrote:<br>
> >> On Tuesday 09 June 2015 06:27:02 Wilhelm wrote:<br>
> >> > (snip)<br>
> >> ><br>
> >> > Am 08.06.2015 um 13:54 schrieb Kevin Funk:<br>
> >> > (snip)<br>
> >> ><br>
> >> > > Now the part I'm struggling with is how to make sure the "member<br>
> >> > > name"<br>
> >> > > is a non-ambiguous identifier from the current context so I can just<br>
> >> > > strip "this->". How can I find out the accessible declarations (or<br>
> >><br>
> >> just<br>
> >><br>
> >> > > the ids) from the context of the expression referencing `this`? I'm<br>
> >> > > missing API to get the clang::DeclContext, plus looking up<br>
> >><br>
> >> declarations<br>
> >><br>
> >> > > accessible from within this context.<br>
> >><br>
> >> I didn't get a lot of replies to my actual question, so let's maybe<br>
> >> simplify<br>
> >> it a bit.<br>
> >><br>
> >> My root problem:<br>
> >> Given an instance of clang::Expr: how can I deduce the context of this<br>
> >> expression and get a list of declarations which are accessible from this<br>
> >> context. What API can I use for this?<br>
> >><br>
> >> This sounds trivial, but I didn't figure it out yet. Apparently I'm<br>
> >> missing<br>
> >> something obvious here.<br>
> >><br>
> >> Thanks.<br>
> >><br>
> >> --<br>
> >> Kevin Funk | <a href="mailto:kfunk@kde.org" target="_blank">kfunk@kde.org</a> | <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__kfunk.org&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=M0M5rZxpJXCf6I0KrOa198WubHFxH_cqj9y6_zJoUfM&s=eGVhn0z1ZYs1MVuRQNUEIcrSv9Pef9I39by3yP-ttOU&e=" target="_blank">http://kfunk.org</a><br>
> >> _______________________________________________<br>
> >> cfe-dev mailing list<br>
> >> <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
> >> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br>
--<br>
Kevin Funk | <a href="mailto:kfunk@kde.org" target="_blank">kfunk@kde.org</a> | <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__kfunk.org&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=M0M5rZxpJXCf6I0KrOa198WubHFxH_cqj9y6_zJoUfM&s=eGVhn0z1ZYs1MVuRQNUEIcrSv9Pef9I39by3yP-ttOU&e=" target="_blank">http://kfunk.org</a></div></div></blockquote></div></div></div></blockquote></div></div>