[cfe-dev] Displaying prototype tooltips in an IDE

Jared Low jared.low at ni.com
Tue Aug 23 16:43:02 PDT 2011


We are using Clang as our compiler, and I want to display prototype 
tooltips in the IDE. I'm using libclang to get various source code 
browsing information.

In order to get the prototype information, I create the translation unit 
with clang_createTranslationUnit. Then I traverse the translation unit 
with clang_visitChildren. Whenever I come upon a cursor of kind 
CXCursor_FunctionDecl, I remember the cursor and then add any cursors of 
kind CXCursor_ParmDecl that follow to a parameter list. Then when I want 
to display the function prototype, I go thru the parameter cursor list, 
getting each parameter's type and name.

This seems to work fine, except for variable argument functions. For 
example, for the function

void VarArgFunc(int p1, ...)
{
        va_list parmInfo;
        va_start(parmInfo, p1);
        va_end(parmInfo);
}

when traversing the translation unit with clang_visitChildren, the 
CXCursorVisitor callback is not called for the '...' variable argument 
parameter. This means that I can't tell that the function has a variable 
argument parameter, and when I show the prototype tooltip, it just shows 
"void VarArgFunc(int p1)".

How can I detect that the function has a variable argument parameter? Is 
there some other better way to get this information?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110823/86a11d62/attachment.html>


More information about the cfe-dev mailing list