[cfe-dev] Cross Translation Unit Support in Clang
Noah L via cfe-dev
cfe-dev at lists.llvm.org
Wed Jun 28 10:48:23 PDT 2017
I think this post refers to the subject of the recent "Cross Translation
Unit Support in Clang" thread, but I'm not entirely sure I understand the
issue, so I'll start a new thread rather than potentially pollute that one.
So I've been working on a tool[1], based on libTooling, that automatically
translates C code to SaferCPlusPlus (essentially, a memory-safe subset of
C++). The problem I have, if I'm understanding it correctly, is that it can
only convert one source file (which corresponds to a "translation unit"
right?) at a time, due to libTooling's limitation. Right? Does that make
sense?
Ok, so converting a source file (potentially) modifies the file itself and
any included header files as well. The problem is when multiple source
files include the same header file, because conversion of a source file
requires the included header files to be in their original form. They can't
have been modified by a previous conversion of another source file. So
after (individually) converting all the source files in a project, you can
end up with multiple versions of a header file that were modified in
different ways by the conversions of different source files. Right? (An
example[2].)
So this means to get the final converted version of the header file you
have to merge the modifications made by each conversion operation. And
sometimes the modifications are made on the same line so the merge tool
can't do the merge automatically. (At least meld doesn't.) This is really
annoying.
Now, if libTooling were able to operate on the AST of the entire project at
once this problem would go away. Or if you think the AST of the whole
project would often be too big, then at least multiple specified
translation units at a time would help.
I'm not sure if this is what's being offered in the "Cross Translation Unit
Support in Clang" thread? I would want the
Rewriter::overwriteChangedFiles() function to apply to all the source
translation units of the AST as well.
Am I making make sense? Feel free to set me straight.
Noah
[1] https://github.com/duneroadrunner/SaferCPlusPlus-AutoTranslation
[2]
https://github.com/duneroadrunner/SaferCPlusPlus-AutoTranslation/tree/master/examples/lodepng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170628/7f90df64/attachment.html>
More information about the cfe-dev
mailing list