<div style="font-family: arial, helvetica, sans-serif; font-size: 10pt"><br><br><div class="gmail_quote">On Wed, Nov 14, 2012 at 8:39 AM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Wed, Nov 14, 2012 at 6:01 AM, Daniel Cheng <<a href="mailto:dcheng@google.com">dcheng@google.com</a>> wrote:<br>

> I recently wrote a small tool to do some automated refactoring. During<br>
> that work, I ended up writing some helper functions to "simplify"<br>
> fully qualified names, i.e. if you're already in namespace a::b, you<br>
> can refer to a::b::C as "C" rather than using the fully qualified<br>
> name. I'm wondering if there'd be interest in upstreaming this<br>
> functionality into Clang, as I believe this would be a generally<br>
> useful utility.<br>
><br>
> Currently, I have the following signature:<br>
><br>
> // Attempts to find the most concise way to refer to 'symbol' in the given<br>
> // context. 'symbol' should be a fully qualified name.<br>
> string SimplifySymbol(<br>
>     const clang::ASTContext& ast_context,<br>
>     const clang::DeclContext* context,<br>
>     const string& symbol);  // I think this should probably be a<br>
> NamedDecl* to prevent ambiguities<br>
><br>
> Do other people feel this sort of thing would be helpful, and if so,<br>
> where would it belong? It seems like it ought to be a member of<br>
> NamedDecl or DeclContext, but I'm new to Clang development, so I'm<br>
> interested in feedback and comments. Thanks!<br>
<br>
</div>I haven't looked closely but would this be applicable to Clang's typo<br>
correction logic & improve the quality of the typo correction by<br>
offering minimally qualified names?<br></blockquote><div><br></div><div>The typo correction code already has logic to try to build a minimal nested name specifier for a potential correction by taking the chain of NamespaceDecls for the current context/symbol and for the potential correction and eliminating common elements. (see NamespaceSpecifierSet::AddNamespace in lib/Sema/SemaLookup.cpp). It could probably use a bit more refinement--particularly in the presence of "using namespace ..." directives--though I've not yet seen cases where it gives extraneous specifiers for a potential correction (it also uses the number of added specifiers as part of the overall edit distance for the correction candidate).</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
If that's the case that might be a good angle of attack to get this<br>
upstream with a solid use case.<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">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>
</div></div></blockquote></div><br></div>