[PATCH] D137181: [clang-format] Don't use 'PPIndentWidth' inside multi-line macros
Noah Goldstein via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 13 21:55:54 PST 2022
goldstein.w.n marked 2 inline comments as done.
goldstein.w.n added inline comments.
================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:69
(Style.PPIndentWidth >= 0) ? Style.PPIndentWidth : Style.IndentWidth;
- Indent = Line.Level * IndentWidth + AdditionalIndent;
+ if (Line.InMacroBody && Line.PPLevel != 0 &&
+ static_cast<unsigned>(Line.PPLevel) < Line.Level) {
----------------
sstwcw wrote:
> What is this test for?
>
> ```
> clang-format -style='{IndentPPDirective: BeforeHash, PPIndentWidth: 2, IndentWidth: 4, ColumnLimit: 40}'
>
> actual:
> #define X \
> { \
> x; \
> x; \
> }
>
> expected:
> #define X \
> { \
> x; \
> x; \
> }
> ```
You're right, unneeded. Fixed and added test for it.
================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:73
+ Indent += (Line.Level - Line.PPLevel - 1) * Style.IndentWidth;
+ if (PPIndentWidth < Style.IndentWidth)
+ Indent += Style.IndentWidth - PPIndentWidth;
----------------
sstwcw wrote:
> What is this for?
>
> ```
> clang-format -style='{IndentPPDirective: BeforeHash, PPIndentWidth: 4, IndentWidth: 1, ColumnLimit: 40}'
>
> actual:
> #if X
> #define X \
> { \
> x; \
> x; \
> }
> #endif
>
> expected:
> #if X
> #define X \
> { \
> x; \
> x; \
> }
> #endif
> ```
You're right, unneeded. Fixed and added test for it.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137181/new/
https://reviews.llvm.org/D137181
More information about the cfe-commits
mailing list