[cfe-dev] Rewriter and AST nodes SourceRange's
Abramo Bagnara
abramo.bagnara at gmail.com
Thu Mar 10 14:36:11 PST 2011
To make the work of clang Rewriter feasible we need that node source
ranges are exact and congruent.
I propose to properly implement the following invariants (written here
for review and commenting):
1. Decl: the range is from first relevant for the declaration to the
last character. The range include the final ; *only* if the Decl derived
AST node can never be grouped with other declarations.
2. Stmt: the range include always the final ;
3. Expr: the range never includes the final ;
If there is no objection to the invariants definition above we'll like
to start ASAP to fix following deviations:
- all the declarations node that cannot be grouped currently violates 1
- AsmStmt, BreakStmt, ContinueStmt, DoStmt, GotoStmt, ReturnStmt
currently violates 2.
Once done that we will still have two further problems:
1) obtain final ; location of a declaration group
2) obtain final ; location for Exprs used as statements
For 2 I can propose to introduce an ExprStmt node (inheriting from Stmt)
to wrap an Expr used as a statement. I think this might also be nice
also under a conceptual point of view
For 1... I've to confess I've not yet a decent idea to propose ;-)
Of course any better idea is very welcome as well as opinions/criticisms
to the above design.
More information about the cfe-dev
mailing list