[cfe-dev] ast-print-xml for C++ and templates
Douglas Gregor
dgregor at apple.com
Wed Feb 16 08:32:43 PST 2011
On Feb 16, 2011, at 2:46 AM, Michael Lehn wrote:
> Hi,
>
> I am working on a little documentation tool for C++. For this I need
> to parse C++ files to some degree. For this purpose I want to extract
> from source/header files what function signature gets defined/declared
> in what line.
>
> I figured out that all I need can be done perfectly with ast-print-xml as long
> as functions and classes are not templated.
>
> So for clang-developers this question might sound stupid: Is this technically
> not possible. I mean is the information I am looking for "not in the AST"? Or
> does the ast-print-xml just skip certain template-nodes?
>
> Just to make sure that I make clear what I am looking for. If I have a code like
>
> template <typename T>
> int
> dummy(const T a);
>
> // ....
>
> template <typename T>
> int
> dummy(const T a)
> {
> // ...
> }
>
> I merely would like to extract the information:
>
> 1) Funktion "template <typename T> int dummy(const T a)" declared in line ...
> 2) Funktion "template <typename T> int dummy(const T a)" defined in line ...
The AST has all of this information, but the XML printer isn't anywhere near complete and isn't kept up-to-date. Personally, I wouldn't use it: I think you're better off using libclang, writing a Clang plugin, or extending/customizing something like Synopsis.
- Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110216/8b320e6f/attachment.html>
More information about the cfe-dev
mailing list