<br><br><div class="gmail_quote">On Tue, Sep 25, 2012 at 12:55 AM, "C. Bergström" <span dir="ltr"><<a href="mailto:cbergstrom@pathscale.com" target="_blank">cbergstrom@pathscale.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
We've hit a couple issues while using clang for refactoring/auto-completion tools<br>
<br>
1. clang code completion -  There are two virtual methods within clang::CodeCompletionConsumer class. First is 'ProcessCodeCompleteResults'. This methods is working quite well. But second - 'ProcessOverloadCandidates', which is providing functions overload candidates within function call context, is working very strange. This method is called /only /within context of calling free function. Example:\<br>

<br>
void Foo();<br>
<br>
void Bar()<br>
{<br>
   Foo(>|<); // Overload candidates are successfully provided and contain one item ('Foo()')<br>
}<br>
<br>
But:<br>
class Clazz<br>
{<br>
public:<br>
   Clazz(int, int);<br>
   void Foo();<br>
   void TestFn();<br>
};<br>
<br>
void Bar(Clazz& cls)<br>
{<br>
   cls.Foo(>|<); // Overload candidates aren't provided<br>
   Class other(>|<); // The same.<br>
}<br>
<br>
void TestFn()<br>
{<br>
   Foo(>|<); // The same. Overload candidates aren't provided<br>
}<br>
<br>
Here ">|<" mark shows a current text caret position for which code completion is requested.<br>
Is there missing functionality here?  (If so anyone interested to help us with this?)<br>
<br>
2.   Here is a sample class:<br>
<br>
class BaseClass : public SuperBaseClass<br>
{<br>
public:<br>
    BaseClass(int a);<br>
    BaseClass(int a, int b);<br>
    void SomeVirtualMethod(int a, int b = 10);<br>
    void foo(int a, int b);<br>
    void foo(double a);<br>
    void foo(BaseClass *cls);<br>
};<br>
<br>
BaseClass::>|<<br>
<br>
In the point marked with ">|<" suggestion list doesn't contain constructors of the 'BaseClass'. It's very strange.<br>
<br></blockquote><div><br>It might have to do with the fact that one cannot invoke the constructor of a class with a qualifier in front of it: BaseClass::StaticMethod is a valid method call but BaseClass::BaseClass is not. The C++ syntax is slightly ambiguous since providing an out of line definition and calling the method have the same form, it could probably be disambiguated (more or less) by looking up the context: at namespace level and outside an expression, it's obviously a method definition for example; however I don't know if differentiating between the two is always so clear cut (I guess there are some weird cases).<br>
<br>-- Matthieu<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
3. AST building. We're looking to implement:<br>
 - Create method declaration from usage<br>
 - Create method declaration from definition<br>
<br>
Both this features assume what source code (in initial state) contains an error and feature implementation fix this error in the corresponded way.  The problem is clang can't help us to analyze the line with such error.<br>

<br>
For example:<br>
<br>
void Bar()<br>
{<br>
   int a, b;<br>
   Foo(a, b); // There is no 'Foo' function within code yet<br>
}<br>
<br>
clang parser throws out the line with 'Foo' call from AST.  So we can't analyze nor type of symbol or type of arguments within this context.<br>
My primary question is: can we add some special AST nodes into clang parser in order to handle such cases? In normal situation AST consumers/visitors will ignore such nodes but in case of refactoring we could extract some additional info from source code and have special handling for it.<br>

<br>
-----------<br>
Thoughts/suggestions?<br>
<br>
Thanks<br>
<br>
./C<br>
<br>
______________________________<u></u>_________________<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/<u></u>mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br>