Skip to main content

Module output

Module output 

Source
Expand description

-output-replacements-xml: the formatter’s answer as clang-format’s replacement list.

<?xml version='1.0'?>
<replacements xml:space='preserve' incomplete_format='false'>
<replacement offset='3' length='2'> </replacement>
</replacements>

The format is clang-format’s (measured against 22.1.3): a header, then one <replacement> per edit, each with a byte offset into the input, a length to remove, and the text to put there as escaped content (a newline is &#10;).

§One replacement, not many

clang-format emits one replacement per whitespace run. This emits one per file — the changed middle between the longest common prefix and suffix — because the library’s job is “these bytes produce that text”, and a client that applies a single edit gets the same answer with less to get wrong. A caller that needs the fine-grained list can diff further; layout_audit and spacing_audit already do.

Functions§

replacement
The single edit that turns source into formatted: the middle between the common prefix and suffix, in bytes.
replacements_xml
The replacement list for formatted against source, as clang-format’s XML.