Comparing a canonical type to a type with a known name

I’m trying to write a checker to determine when the std::find is passed an argument of type e.g. std::set::iterator. Unfortunately, in the AST, I cannot find the original type of the argument of std::find. This is what the AST dump shows:

CXXConstructExpr 0xc09a530 ‘struct std::_Rb_tree_const_iterator’:‘struct std::_Rb_tree_const_iterator’ ‘void (const struct std::_Rb_tree_const_iterator &) noexcept’

`-ImplicitCastExpr 0xc09a488 ‘const struct std::_Rb_tree_const_iterator’ lvalue

`-DeclRefExpr 0xc09a344 ‘struct std::_Rb_tree_const_iterator’:‘struct std::_Rb_tree_const_iterator’ lvalue Var 0xc09a1b0 ‘it’ ‘struct std::_Rb_tree_const_iterator’:‘struct std::_Rb_tree_const_iterator’

For:

auto it = s.begin();

auto itEnd = s.end();

std::find(it, itEnd, 45); // dumping argument 0

I would need to compare the type of argument 0 to std::set::iterator. However, I do not know how to get the Type representation of the latter only by the name. I tried using the IdentifierTable, but dumping it (iterating through it) just gives me a lot garbage keys, and it doesn’t seem to recognize neither “set” or “std::set”.

So how should I go about doing this?

Thanks!

Huh. You'll have to do this building up from the bottom, starting from the TU and looking up "iterator" inside "set" inside "std". (Bailing out, of course, if any of those are not defined or not the kind of decl you expect.) Take a look at DeclContext::lookup.

Jordan