Page MenuHomePhabricator

[clang-format] Align preprocessor comments with #
ClosedPublic

Authored by mzeren-vmw on Jan 22 2018, 10:26 PM.

Details

Summary

r312125, which introduced preprocessor indentation, shipped with a known
issue where "indentation of comments immediately before indented
preprocessor lines is toggled on each run". For example these two forms
toggle:

#ifndef HEADER_H
#define HEADER_H
#if 1
// comment
#   define A 0
#endif
#endif

#ifndef HEADER_H
#define HEADER_H
#if 1
   // comment
#   define A 0
#endif
#endif

This happens because we check vertical alignment against the '#' yet
indent to the level of the 'define'. This patch resolves this issue by
aligning against the '#'.

Diff Detail

Repository
rL LLVM

Event Timeline

mzeren-vmw created this revision.Jan 22 2018, 10:26 PM
krasimir added inline comments.Jan 29 2018, 11:44 AM
unittests/Format/FormatTest.cpp
2613 ↗(On Diff #131003)

s/indnet/indent

krasimir accepted this revision.Jan 29 2018, 11:44 AM
This revision is now accepted and ready to land.Jan 29 2018, 11:44 AM
This revision was automatically updated to reflect the committed changes.