[PATCH] D151047: [clang-format] Fix indentation for selective formatting.
Björn Schäpers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 7 12:19:16 PDT 2023
HazardyKnusperkeks added inline comments.
================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:80
+ // directive, since these do not terminate a code block.
+ if (!Line.InPPDirective && Line.Level < IndentForLevel.size())
+ IndentForLevel.resize(Line.Level + 1, -1);
----------------
Do we need this check? I assume `resize` has a check if it has to grow or shrink, so we would check twice when the size is to be changed and once if not.
================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:169-170
/// The indent in characters for each level.
+ /// It remembers the indent of previous lines (that are not PP directives) of
+ /// equal or lower levels. This is used to align formatted lines to the indent
----------------
And then reformat the comment.
================
Comment at: clang/unittests/Format/FormatTestSelective.cpp:663
+ "#define some\n" // Formatted line
+ "#endif\n" // That this line is also formatted might be a bug.
+ " }};", // Dito: Bug?
----------------
Have you tried to see what is causing this?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151047/new/
https://reviews.llvm.org/D151047
More information about the cfe-commits
mailing list