How to get the code of an Expr with qualified types/names

Hi, all,

I'm quite new to Clang, but I'd thank for all your great work.

Assume I have below code,

struct Abc {
static const int A = 5;
void func(int a = A + 1); // note the default value

What I want to do is to use Clang to parse the code, and
when I find the default value "A + 1", I put the expression
to a tool generated C++ file, and use the expression there.

The generated C++ code may look like,

int defaultValue = Abc::A + 1; // this is in global namespace

But now I can only get the expression text from Expr's
source location, that results the generated code look like,

int defaultValue = A + 1; // Can't compile!

So my question is, how to get the expression text with all
values and types fully qualified? Travel through the expression tree
and reconstruct the text should work, but that may be too complicated.


That pretty much seems like the only approach I can think of, too...