Use clang tool to do template instantiation

Hi fe-dev,

Recently I am looking to use clang tool to do template instantiation based on some command line parameter.

E.g. given template

template
static int f(int a) { return a + N; }

by providing the name of function and the list of template parameter, i.e. f and 4 for the tool, the tool should generate the following cpp file:

template
static int f(int a) { return a + N; }

static int f_4(int a) { return a + 4; }

Is there any example in clang?
which part of clang I should look at?

Thanks
Hongbin