Amr Hesham c017cdf071
[Clang][ASTMatcher] Improve matching isDerivedFrom base in case of multi aliases exists (#126793)
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
2025-03-05 21:32:24 +01:00
..