How to add new labels to the AST?

HI all,

I try to add some new labels to the AST in my source to source transform.

In the function LabelStmt (SourceLocation IL, LabelDecl *D, Stmt *substmt), a LabelDecl is required.

So I come to the function static LabelDecl * Create (ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II).

But I don’t know where the DeclContext *DC comes from. What should I do now?

I notice Sema has a methond LabelDecl *Sema::LookupOrCreateLabel(IdentifierInfo *II, SourceLocation Loc, SourceLocation GnuLabelLoc). But I even don’t know how to use this to parse my code and store the infos in it… So everything in the object is empty and I got SEGMENT FAULT when I called this method. I used ParseAST(…) to the work before. Do I need to use Sema instead?

Thank you very much!

Best Regards,

wolf5x(Qingquan Zhang)