This patch fixes preamble skipping when the preamble region includes a byte order mark (BOM). Previously, parsing would fail if preamble PCH generation was enabled and a BOM was present.
This also fixes preamble invalidation when a BOM appears or disappears. This may seem to be an obscure edge case, but it happens regularly with IDEs that pass buffer overrides that never (or always) have a BOM, yet the underlying file from the initial parse that generated a PCH might (or might not) have a BOM.
I've included a test case for these scenarios.
Note: This depends on the test infrastructure introduced in D37474.
Let's leave this class's interface immutable. It is used concurrently in clangd and having a mutable method like this would break the code.
Passing new PreambleBounds to AddImplicitPreamble and setting the offsets accordingly would do the trick, leave the interface immutable and make the fact that offsets might change more evident.