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;
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;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits