[cfe-dev] Question about templates and functions with auto arguments

Anders Bakken via cfe-dev cfe-dev at lists.llvm.org
Sun Oct 9 11:17:45 PDT 2016


Consider the following example:

```
struct Thing
{
    int foobar {0};
};

template<typename T>
void g(T& obj)
{
    obj.foobar += 1;
}

int main() {
    auto f = [&](auto& obj) {
        obj.foobar += 2;
    };

    Thing thing;
    f(thing);
    g(thing);
    return 0;
}
```

I've been unable to find anything in clang-c that gives me information
about the invocations of f and g being the struct Thing.

E.g. I want to be able to put the cursor on:

obj.foobar += 1;

and

obj.foobar += 2;

and know which types the functions (f and g) were invoked on.

I can see the information being available using clang-check -ast-dump but I
can't find any way to get the information using clang-c.

I've attached the little example program I use (clangtest.c, cc clangtest.c
`llvm-config-3.8 --cflags` -lclang `llvm-config-3.8 --ldflags` -o clangtest)

and the output from clang-check and clangtest

Any hints?

I need the information for my indexer http://rtags.net

regards

Anders
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161009/45e599e9/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clangtest.c
Type: text/x-csrc
Size: 3665 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161009/45e599e9/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clangtest
Type: application/octet-stream
Size: 6808 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161009/45e599e9/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clangcheck
Type: application/octet-stream
Size: 17018 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161009/45e599e9/attachment-0001.obj>


More information about the cfe-dev mailing list