[cfe-users] Missing AST Node for parsing code with std::vector<unsigned int>::data()

David Blaikie via cfe-users cfe-users at lists.llvm.org
Thu Dec 3 09:39:27 PST 2020


You might need to provide more details - at least a cursory example shows
the function call in the ast dump: https://godbolt.org/z/zvqTa3

On Thu, Dec 3, 2020 at 4:02 AM Владимир Фролов via cfe-users <
cfe-users at lists.llvm.org> wrote:

> Greetings! I'm using clang for source-to-source translation.
>
> Recently I got a problem with parsing code which use templates.
> First, here is the working example:
>
> struct MyTestVector2
> {
>  unsigned int _data[6];
>  unsigned int * data() { return &_data[0]; }
> };
> ...
> MyTestVector2 testData2;
> kernel_TestColor(&hit,
>                 testData2.data(), tidX, tidY);
> This code processed normally and i gon correct "CXXMemberCallExpr" node
> for kernel_TestColor which i actually need.
> Then i changed MyTestVector2 to template:
>
> template<class T>
> struct MyTestVector2
> {
>  T _data[6];
>  T * data() { return &_data[0]; }
> };
>
> ...
> MyTestVector2<unsigned int> testData2;
> kernel_TestColor(&hit,
>                 testData2.data(), tidX, tidY);
>
> This time i got
>
> `-DeclStmt 0x55555816e128 <line:59:3, col:40>
>   `-VarDecl 0x55555816e0c0 <col:3, col:31> col:31 invalid testData2
> 'MyTestVector2<unsigned int>':'MyTestVector2<unsigned int>'
>
> This time, The AST node for kernel_TestColor is just missed!
> The code is absolutely correct itself, it can be build and run.
>
> I'm using AST processing for code generation, so it is important for me to
> get  AST node for kernel_TestColor and then analyze its arguments.
> I understand that this seems to be not a bug, but ... may be, there is a
> way to make parser more tolerant to data types ... because what i actually
> need is just a strings of all parameters, so, just having "
> testData2.data()" at some level of AST for the second parameter of kernel_TestColor
> would be enough for me.
>
> I would be appretiate for help or advice.
> Currently i use llvm 10.
> Thanks!
> --
> Best Regards,
>  Frolov V.A.
>
> _______________________________________________
> cfe-users mailing list
> cfe-users at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20201203/145fedf7/attachment.html>


More information about the cfe-users mailing list