[foreign] road to posix
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Thu May 31 13:58:16 UTC 2018
On 30/05/18 21:18, John Rose wrote:
> - We might be able to use the built-in cpp expression evaluator
> inside of clang.
On this point, few days ago I tried to do some experiments with the
clang API point:
https://clang.llvm.org/doxygen/group__CINDEX__MISC.html#ga6be809ca82538f4a610d9a5b18a10ccb
This appeared to be useful for evaluating a clang cursor but,
unfortunately it doesn't work on macros, not even if the
'detailedPreprocessingRecord' flag is enabled:
https://clang.llvm.org/doxygen/group__CINDEX__TRANSLATION__UNIT.html#ggab1e4965c1ebe8e41d71e90203a723fe9a9e1dd69c4a2ff7954dca8df41a63c0e6
The problem seems to be that, by the time we get to parse the AST, the
preprocessor has already ran, and the clang API sees just
annotation-like thingies that are placeholders for what once used to be
a compiler macro. So there seems to be no way to evaluate the value of a
macro constant, other than get at the macro definition tokens, and
defining the parsing logic manually (or jump to the C++ API, although I
don't see a clear way to do that).
Maurizio
More information about the panama-dev
mailing list