mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 19:26:06 +00:00

Previously in case of multiable aliases exists for the same base we just
accept the first one
2cf6663d3c/clang/lib/ASTMatchers/ASTMatchFinder.cpp (L1290-L1297)
For example
```
struct AnInterface {};
typedef AnInterface UnusedTypedef;
typedef AnInterface Base;
class AClass : public Base {};
```
`cxxRecordDecl(isDerivedFrom(decl().bind("typedef")))` typedef will be
bonded to `UnusedTypedef`
But if we changed the order now it will point to the right one
```
struct AnInterface {};
typedef AnInterface Base;
typedef AnInterface UnusedTypedef;
class AClass : public Base {};
```
`cxxRecordDecl(isDerivedFrom(decl().bind("typedef")))` typedef will be
bonded to `Base`
This PR improve the matcher to prioritise the alias that has same
desugared name as the base, if not then just accept the first one.
Fixes: #126498