[cfe-dev] from source location to token?
Roberto Bagnara
bagnara at cs.unipr.it
Mon Nov 24 07:53:30 PST 2008
steve naroff wrote:
> Hi Paolo,
>
> I'm not sure what you are trying to do, however here is some info...
>
> - The AST's don't currently store Tokens (they are transient), and we
> have no mechanism for associating an AST with a list/stream of Tokens.
> - The NamedDecl AST stores a DeclarationName (which is commonly an
> IdentifierInfo).
> - The DeclRefExpr AST stores a NamedDecl.
>
> You can, as you figured out, get a character stream from a
> SourceLocation (and lex/parse again).
>
> It would be interesting to know a little bit more about what you are
> doing. In general, re-lexing/re-parsing isn't very desirable (though
> it may be appropriate if it's uncommon).
Hi Steve,
there are program analyses that, for instance:
1) need to reason on an exact representation of floating-point literals
(any approximation may result into an unsound analysis);
2) need to reason on the textual representation that was used in the
program also for integer literals (for example, there are coding
rules that forbid the use of octal constants: the analyzer should
flag their use in the source program).
All the best,
Roberto
--
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it
More information about the cfe-dev
mailing list