[cfe-dev] HOWTO: access function (template) names from CXCursor

Douglas Gregor dgregor at apple.com
Mon Jan 24 07:29:16 PST 2011


On Jan 23, 2011, at 7:21 AM, Stefan Seefeld wrote:

> When parsing a function declaration "void foo(int)" using libclang, how 
> can I access the function name "foo" from a cursor ? 
> clang_getCursorDisplayName() would return the function name together 
> with its signature.
> 
> Similarly, when parsing a class or function template, 
> clang_getCursorDisplayName() would report the template-id, not the 
> (template-)name.
> 
> Is that an oversight ?

This is the intended behavior of clang_getCursorDisplayName(). Use clang_getCursorSpelling() to get just the name itself, without the arguments.

	- Doug



More information about the cfe-dev mailing list