是否可以设置clang-tidy来输出在.clang-format
文件中定义的源代码格式中发现的问题。基本上,告诉您如果在文件上运行clang格式会进行哪些更改。类似于:
Line 23: improper indentation, 4 spaces should be used
Line 47: opening brace for loops should be on the same line
如果没有,是否可以编写自定义检查,这对我有帮助?
答案 0 :(得分:0)
您无法用clang-tidy做到这一点,因为它会将代码解析为AST,并且不关心格式。
您可以将clang-format
与-output-replacements-xml
选项一起使用。
该xml输出将告诉您您想要什么(发生了什么变化以及在哪里进行更改),但是不会为人类读者带来很好的输出。
示例:
<?xml version='1.0'?>
<replacements xml:space='preserve' incomplete_format='false'>
<replacement offset='337' length='8'> </replacement>
</replacements>