[cfe-dev] [Clang Tools] Source-to-source transformations
Marcos Horro Varela via cfe-dev
cfe-dev at lists.llvm.org
Thu Dec 5 13:38:37 PST 2019
If you need semantic analysis such as name lookup, overload
resolution, etc. for your changed code. For instance, you want to
replace a type, which might transitively require to change types of
other variables, function result- and parameter types. However, the
AST was not designed with such a use case in mind and you will need to
write a lot of code to handle special situations (e.g. re-do overload
resolution with the new type; however the overload set depends on
clang::Scope which is only available during parsing). I strongly
suggest to pursue the parse-and-replace approach if possible.
I see, in my case I think is crystal clear that I do not have to perform modifications in the AST so my life will be easier.
Thanks for the clarification and prompt response.
Bests,
Horro, M.
http://gac.udc.es/~horro<https://link.getmailspring.com/link/19D0AF02-E364-4894-BF8F-1536153EAFCC@getmailspring.com/0?redirect=http%3A%2F%2Fgac.udc.es%2F~horro&recipient=Y2ZlLWRldkBsaXN0cy5sbHZtLm9yZw%3D%3D>
On Dec 5 2019, at 2:03 pm, Michael Kruse <cfe-dev at meinersbur.de> wrote:
Am Di., 3. Dez. 2019 um 14:54 Uhr schrieb Marcos Horro Varela
<marcos.horro at udc.es>:
Thank you so much for your comments. I think I will go with the ASTFrontendAction in detriment of clang-tidy in order to have more "freedom" when writing the tool. Nonetheless, I am quite concerned regarding my decision of not modifying the AST. Maybe using the TreeTransform helper would be a better decision. On the other hand, I do not see the utility of performing modifications in the AST; could you provide me an example where it is useful rather than "just parsing and replacing code"?
If you need semantic analysis such as name lookup, overload
resolution, etc. for your changed code. For instance, you want to
replace a type, which might transitively require to change types of
other variables, function result- and parameter types. However, the
AST was not designed with such a use case in mind and you will need to
write a lot of code to handle special situations (e.g. re-do overload
resolution with the new type; however the overload set depends on
clang::Scope which is only available during parsing). I strongly
suggest to pursue the parse-and-replace approach if possible.
Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20191205/3e01d2ef/attachment.html>
More information about the cfe-dev
mailing list