Issue 126498
Summary AST Matcher binds wrong TypedefDecl object
Labels new issue
Assignees
Reporter StevenSchmidtADV
    I  have this code:

`struct AnInterface {};`

`typedef AnInterface ABase1;`
`class AClass1 : public ABase1 {};`

`typedef AnInterface ABase2;`
`class AClass2 : public ABase2 {};`

And this ASTMatcher:

`cxxRecordDecl(`
`  isDerivedFrom(`
` decl().bind("typedef")`
`  )`
`).bind("record")`

The second match wrongly binds `AClass2` and **`ABase1`**.
The same behavior occurs with
`using ABase1=AnInterface`

Output of clang-query:

> clang-query> m cxxRecordDecl( isDerivedFrom( decl().bind("typedef") ) ).bind("record")
> 
> Match #1:
> [... works as expected]
> 
> Match #2:
> 
> typedef_problem.cpp:9:1: note: "record" binds here
>     9 | class AClass2 : public ABase2 {};
>       | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> typedef_problem.cpp:9:1: note: "root" binds here
>     9 | class AClass2 : public ABase2 {};
>       | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> typedef_problem.cpp:5:1: note: "typedef" binds here
>     5 | typedef AnInterface **ABase1**;
>       | ^~~~~~~~~~~~~~~~~~~~~~~~~~
> 2 matches.

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to