3

Is it possible to set up clang-tidy to output issues it has found with the formatting of the source code as defined by the .clang-format file. Basically, telling you what kind of changes clang-format would do if it ran on the file. Something along the lines of:

Line 23: improper indentation, 4 spaces should be used

Line 47: opening brace for loops should be on the same line

If not, would it be possible to write a custom check, which could do that for me?

1 Answers1

1

There is no way you can do this with clang-tidy since it parses the code to AST and doesn't care about formatting.

You can use clang-format with the -output-replacements-xml option.

The xml output will tell you what you want (what changes and where) but don't expect a nice output for human readers.

Sample:

<?xml version='1.0'?>
<replacements xml:space='preserve' incomplete_format='false'>
<replacement offset='337' length='8'>&#13;&#10;&#13;&#10;  </replacement>
</replacements>
pablo285
  • 2,460
  • 4
  • 14
  • 38