vvuksanovic wrote:

> Thank you for your patience and for working on macro expansions for CTU. The 
> PR itself looks impressive, however there a couple of aspects that make me 
> nervous:
> 
> You had to change a couple of fundamental components, such as the Lexing and 
> Preprocessing. As the Static Analyzer subproject, we don't really have 
> authority to those parts and those parts need really great stability and 
> confidence.
> 
> Do you see a way to minimise touching those parts? Maybe I'm overthinking 
> this.

I really don't like that either. The implementation is more invasive than I 
would like, but some changes are definitely required outside the analyzer for 
this to work.

To support macro expansions from PCH files we have to serialize them either in 
the PCH itself or in a new file. Since the `MacroExpansion` class already 
exists I thought it was fitting to extend it with the expansion string. That 
data can also be accessed from the loaded `ASTUnit` when needed in 
`CrossTranslationUnit`. Its serialization is even guarded by a flag, so we 
don't increase the size of the PCH by default.

Whatever the implementation, at least `ASTReader` and `ASTWriter` will have to 
be modified to serialize the macro expansion strings. It might be possible to 
handle the collection of macro expansions there, but I don't think those 
classes should be responsible for that.

Maybe a custom `ModuleFileExtension` can be implemented to perform this 
(de)serialization, but I'm not sure how to access that information from 
`CrossTranslationUnit`.

Also, I didn't notice that only one token watcher can be registered at a time, 
and that seems to be the cause of the failed XRay test. So that would have to 
be another preprocessor modification.

I am open to suggestions if someone can think of a less intrusive solution. If 
we can't find one, I would at least like to keep the on-demand compilation part 
of the PR.

https://github.com/llvm/llvm-project/pull/176126
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to