[cfe-dev] [LLVMdev] clang code-completion question

Dmitry Frank dimon.frank at gmail.com
Tue Nov 27 23:10:50 PST 2012


Hello, Nick!

Thank you for your reply.

Regarding to pointers to functions: look at this code:

static void _some_func(int a, int b, int c)
{
   //-- do something
}

typedef void (*T_pMyFunc) (int a, int b, int c);

typedef struct {
   T_pMyFunc p_my_func;
} T_MyStruct;

int main(void)
{
   T_MyStruct my_struct = {
      .p_my_func = _some_func,
   };

   _some_func/*cursor is here. I see function signature: int a, int b, int
c. Everything is great*/

   my_struct./*cursor is here. I see only member T_pMyFunc p_my_func, but
there's no function signature. There would be even greater if clang could
handle this*/

}

Hope I explained this clear.

As to second one (completion inside structure initializer), thanks for the
suggestion, I filed it as you suggested:
http://llvm.org/bugs/show_bug.cgi?id=14446 <http://goo.gl/wYP0z>

--
Regards,
Dmitry


2012/11/28 Nick Lewycky <nicholas at mxc.ca>

> [bcc llvm-dev, +cfe-dev]
>
>
> Dmitry Frank wrote:
>
>> Dear developers,
>>
>> First of all, thank you for your job on clang, now I use clang as
>> autocompletion tool with my Vim, and it seems to work awesome. But I
>> have some questions:
>>
>>   1) Is it possible to make clang to complete pointers to functions as a
>> functions? I mean, I want to get function prototype, with returning
>> value type and all the parameters.
>>
>
> Clang certainly knows all the relevant information, but it's not clear how
> this would work in code completion. What do you expect to have in the
> buffer, and where would the cursor be for clang to complete?
>
> You'll need to have already typed something that makes it clear that the
> next thing clang ought to do is complete the type of function prototype.
> Usually completion looks forwards, and wouldn't you have already needed to
> type the return type to get to the function name? Maybe I'm just failing to
> visualize what we're doing here.
>
>
>  2) Is it possible to make completion work inside structure initializers?
>> I mean, like that:
>>
>> typedef  struct  {
>>     int  a;
>>     int  b;
>> } T_MyStruct;
>>
>> int  main(void)
>> {
>>     T_MyStruct my_struct = {
>>        .a =0,
>>        ./*cursor is here. I want to get list of struct members: [a, b]*/
>>     };
>> }
>>
>
> This sounds like a great missing-feature bug report. Please file it at
> llvm.org/bugs !
>
> Nick
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121128/3b6d2381/attachment.html>


More information about the cfe-dev mailing list