[PATCH] D124036: [clang-format] Don't skip PP lines if original line was a PP line when trying to merge lines
Arthur Eubanks via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 20 08:42:52 PDT 2022
aeubanks updated this revision to Diff 423923.
aeubanks added a comment.
take suggestion
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124036/new/
https://reviews.llvm.org/D124036
Files:
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13393,6 +13393,12 @@
" return 1; \\\n"
" return 2;",
ShortMergedIf);
+
+ verifyFormat("//\n"
+ "#define a \\\n"
+ " if \\\n"
+ " 0",
+ getChromiumStyle(FormatStyle::LK_Cpp));
}
TEST_F(FormatTest, FormatStarDependingOnContext) {
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -307,9 +307,13 @@
// TODO: Use IndentTracker to avoid loop?
// Find the last line with lower level.
auto J = I - 1;
- for (; J != AnnotatedLines.begin(); --J)
- if (!(*J)->InPPDirective && (*J)->Level < TheLine->Level)
- break;
+ if (!TheLine->InPPDirective) {
+ for (; J != AnnotatedLines.begin(); --J) {
+ if (!(*J)->InPPDirective && (*J)->Level < TheLine->Level)
+ break;
+ }
+ }
+
if ((*J)->Level >= TheLine->Level)
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124036.423923.patch
Type: text/x-patch
Size: 1372 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220420/5572619e/attachment-0001.bin>
More information about the cfe-commits
mailing list