[cfe-dev] How to add new labels to the AST?

wolf5x wolf5x1016 at gmail.com
Tue Sep 11 03:32:22 PDT 2012


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)

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120911/5ebe544a/attachment.html>


More information about the cfe-dev mailing list