Diagnostics emitted while parsing main-file is easy, as they already
see new source locations. We just need to make sure the ones that can be
attributed to preamble section of the file is patched. That's achieved in two
ways:
- New include is actually patched with a #line-directive, so most clang features already point at the right line.
- Patching of main-file-includes inside the ParsedAST, which is used by replay preamble and include-cleaner analysis. This patch fixes/improve patching in this case.
The second problem is patching includes that were published when building the
preamble. Unfortunately because we don't have the full edit history in place,
it's hard to perform an exact translation. This patch tries to just preserve
diagnostics that are contained to lines containing #include or #define
directives and moves them around with the new file contents. It's granularity is
per-line, it doesn't handle column-wide changes.
Depends on D142890.