diff options
author | Kim Gräsman <kim.grasman@gmail.com> | 2022-08-28 12:26:03 +0200 |
---|---|---|
committer | Kim Gräsman <kim.grasman@gmail.com> | 2022-08-31 22:24:54 +0200 |
commit | ce63c68ed2f9534d2e9aaf37cd17bc5bfb387048 (patch) | |
tree | 0fd7765ff4357f99ad048db5f8974c5adb5c191b | |
parent | 18a331be381e4550d691e562d00db08da493403c (diff) |
[clang compat] Back up through sugar before parent type check
This is kind-of the inverse of desugaring -- walk up the ancestor chain until
we're at the most elaborated (should really be "sugared") ancestor. Then we can
make assumptions about parent types again.
Clang 15f3cd6bfc670ba6106184a903eb04be059e5977 made this necessary, because many
more type nodes are now wrapped in ElaboratedType, which breaks naive parent
type checking.
-rw-r--r-- | iwyu.cc | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -1586,7 +1586,8 @@ class IwyuBaseAstVisitor : public BaseAstVisitor<Derived> { // typedef (that is, 'typedef MyTypedef OtherTypdef'), then the // user -- the other typedef -- is never responsible for the // underlying type. Instead, users of that typedef are. - if (!current_ast_node()->template ParentIsA<TypedefNameDecl>()) { + const ASTNode* ast_node = MostElaboratedAncestor(current_ast_node()); + if (!ast_node->ParentIsA<TypedefNameDecl>()) { const set<const Type*>& underlying_types = GetCallerResponsibleTypesForTypedef(typedef_decl); if (!underlying_types.empty()) { |