llvm-project
c017cdf0 - [Clang][ASTMatcher] Improve matching isDerivedFrom base in case of multi aliases exists (#126793)

Commit
1 year ago
[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
Author
Parents
Loading