To parse templates you need to use the IDAClang plugin that comes with Ida Pro (I think it's not available with IDA Free).
To add a single class/structure definition you can use IDAPython:
import ida_srclang
code = """
template <typename T, typename U>
struct S;
template<>
struct S<int, void *>
{
int x;
void *y;
};
"""
ida_srclang.set_parser_argv("clang", "-x c++")
ida_srclang.parse_decls_with_parser("clang", None, code, False)
If you want to parse whole header files, you need to:
- Set clang as your parser in
Options > Compiler > Source parser
- Ensure you set the correct include directories
- Ensure you added the
-x c++
argument
You should then be able to parse whole files with Load file > Parse C header file
Sadly you cannot later edit such structures because the Edit dialog in Local Types
will not be able to parse them correctly. If you want to modify such a structure, you will need to re-parse it with clang using one of the two ways above.
See the IDAClang tutorial on Hex-Rays website for more information.