Page MenuHomePhabricator

[clang-format] Do not emit replacements while regrouping if Cpp includes are OK

Authored by krasimir on Apr 3 2019, 7:00 AM.



Currently clang-format would always emit a replacement for multi-block #include
sections if IBS_Regroup, even if the sections are correct:

% cat ~/test.h
#include <a.h>

#include "b.h"
% bin/clang-format --output-replacements-xml -style=google ~/test.h
<?xml version='1.0'?>
<replacements xml:space='preserve' incomplete_format='false'>
<replacement offset='0' length='30'>#include &lt;a.h>&#10;&#10;#include "b.h"</replacement>

This change makes clang-format not emit replacements in this case.
The logic is similar to the one implemented for Java in r354452.

Diff Detail

rC Clang

Event Timeline

krasimir created this revision.Apr 3 2019, 7:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 3 2019, 7:00 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
ioeric added inline comments.Apr 3 2019, 7:39 AM

As most cases would pass 1, maybe it would make sense to make this a class member that defaults to 1? It can be explicitly set in specific tests when needed.

ioeric accepted this revision.Apr 3 2019, 7:40 AM
This revision is now accepted and ready to land.Apr 3 2019, 7:40 AM
krasimir updated this revision to Diff 193500.Apr 3 2019, 7:51 AM
  • Address review comments
krasimir marked an inline comment as done.Apr 3 2019, 7:51 AM
This revision was automatically updated to reflect the committed changes.
MyDeveloperDay added a project: Restricted Project.Sep 25 2019, 1:43 AM