[all-commits] [llvm/llvm-project] c017cd: [Clang][ASTMatcher] Improve matching isDerivedFrom...
Amr Hesham via All-commits
all-commits at lists.llvm.org
Wed Mar 5 12:32:46 PST 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: c017cdf0714afcccca3338529134f3792d9287f6
https://github.com/llvm/llvm-project/commit/c017cdf0714afcccca3338529134f3792d9287f6
Author: Amr Hesham <amr96 at programmer.net>
Date: 2025-03-05 (Wed, 05 Mar 2025)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/lib/ASTMatchers/ASTMatchFinder.cpp
M clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
Log Message:
-----------
[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
https://github.com/llvm/llvm-project/blob/2cf6663d3c86b065edeb693815e6a4b325045cc2/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
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list