[cfe-dev] Comparing a canonical type to a type with a known name

Gábor Kozár kozargabor at gmail.com
Mon Sep 9 04:38:12 PDT 2013


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<int>':'struct
std::_Rb_tree_const_iterator<int>' 'void (const struct
std::_Rb_tree_const_iterator<int> &) noexcept'

`-ImplicitCastExpr 0xc09a488 'const struct
std::_Rb_tree_const_iterator<int>' lvalue <NoOp>

  `-DeclRefExpr 0xc09a344 'struct
std::_Rb_tree_const_iterator<int>':'struct
std::_Rb_tree_const_iterator<int>' lvalue Var 0xc09a1b0 'it' 'struct
std::_Rb_tree_const_iterator<int>':'struct
std::_Rb_tree_const_iterator<int>'



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!



--
Gábor Kozár -- ShdNx
kozargabor at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130909/7cc7bbf8/attachment.html>


More information about the cfe-dev mailing list