[LLVMdev] Find template types of std::map
Sebastian Dreßler
dressler at zib.de
Tue Oct 16 04:17:42 PDT 2012
Hi,
for a current project I'm required to get the types of the template
arguments key and value for std::map<K,V>. I've noticed that the STL
implementation used by Clang defines the type of the map as
%"class.std::map" = type { %"class.std::_Rb_tree" }
which then is further defined and finally ends as
%"struct.std::_Rb_tree_node_base" = type {
i32,
%"struct.std::_Rb_tree_node_base"*,
%"struct.std::_Rb_tree_node_base"*,
%"struct.std::_Rb_tree_node_base"*
}
However, indifferent what K and V are and how many different maps are
instantiated, it always ends at this definition. But, I also noticed, that
%"struct.std::pair" = type { i32, double }
is defined, which then provides the information I need.
Now the problem arises to connect %"class.std::map" to
%"struct.std::pair" correctly. To solve this I looked at the IR and
noticed, that the std::pair's are always defined in the reverse order of
the definitions of std::map. So I think about using some index to find
the correct std::pair.
From this idea two issues arise:
1. I feel that this approach is not that stable as it should be, for
instance, I think that the ordering of instantiation I'm making use of
may change.
2. I'm unable to retrieve all defined named types from the module. I
know there is LLVMContextImpl but this class is a forward declaration
and therefore I'm not able to access LLVMContextImpl::NamedStructTypes.
Thanks for any suggestions.
Best regards,
Sebastian
--
Mit freundlichen Grüßen / Kind regards
Sebastian Dreßler
Zuse Institute Berlin (ZIB)
Takustraße 7
D-14195 Berlin-Dahlem
Germany
dressler at zib.de
Phone: +49 30 84185-261
http://www.zib.de/
More information about the llvm-dev
mailing list