HazardyKnusperkeks created this revision. HazardyKnusperkeks added reviewers: MyDeveloperDay, curdeius, baramin. HazardyKnusperkeks added a project: clang-format. HazardyKnusperkeks requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
This amends c5243c63cda3c740d6e9c7e501f6518c21688da3 <https://reviews.llvm.org/rGc5243c63cda3c740d6e9c7e501f6518c21688da3> to fix formatting continued function calls with BinPacking = false. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D106773 Files: clang/lib/Format/WhitespaceManager.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -16411,6 +16411,37 @@ "}", Style); // clang-format on + + Style = getLLVMStyleWithColumns(120); + Style.AlignConsecutiveAssignments = FormatStyle::ACS_Consecutive; + Style.ContinuationIndentWidth = 4; + Style.IndentWidth = 4; + + // clang-format off + verifyFormat("void SomeFunc() {\n" + " newWatcher.maxAgeUsec = ToLegacyTimestamp(GetMaxAge(FromLegacyTimestamp<milliseconds>(monitorFrequencyUsec),\n" + " seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));\n" + " newWatcher.maxAge = ToLegacyTimestamp(GetMaxAge(FromLegacyTimestamp<milliseconds>(monitorFrequencyUsec),\n" + " seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));\n" + " newWatcher.max = ToLegacyTimestamp(GetMaxAge(FromLegacyTimestamp<milliseconds>(monitorFrequencyUsec),\n" + " seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));\n" + "}", + Style); + // clang-format on + + Style.BinPackArguments = false; + + // clang-format off + verifyFormat("void SomeFunc() {\n" + " newWatcher.maxAgeUsec = ToLegacyTimestamp(GetMaxAge(\n" + " FromLegacyTimestamp<milliseconds>(monitorFrequencyUsec), seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));\n" + " newWatcher.maxAge = ToLegacyTimestamp(GetMaxAge(\n" + " FromLegacyTimestamp<milliseconds>(monitorFrequencyUsec), seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));\n" + " newWatcher.max = ToLegacyTimestamp(GetMaxAge(\n" + " FromLegacyTimestamp<milliseconds>(monitorFrequencyUsec), seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));\n" + "}", + Style); + // clang-format on } TEST_F(FormatTest, AlignWithInitializerPeriods) { Index: clang/lib/Format/WhitespaceManager.cpp =================================================================== --- clang/lib/Format/WhitespaceManager.cpp +++ clang/lib/Format/WhitespaceManager.cpp @@ -347,7 +347,7 @@ if (ScopeStart > Start + 1 && Changes[ScopeStart - 2].Tok->is(tok::identifier) && Changes[ScopeStart - 1].Tok->is(tok::l_paren)) - return true; + return Style.BinPackArguments; // Ternary operator if (Changes[i].Tok->is(TT_ConditionalExpr))
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -16411,6 +16411,37 @@ "}", Style); // clang-format on + + Style = getLLVMStyleWithColumns(120); + Style.AlignConsecutiveAssignments = FormatStyle::ACS_Consecutive; + Style.ContinuationIndentWidth = 4; + Style.IndentWidth = 4; + + // clang-format off + verifyFormat("void SomeFunc() {\n" + " newWatcher.maxAgeUsec = ToLegacyTimestamp(GetMaxAge(FromLegacyTimestamp<milliseconds>(monitorFrequencyUsec),\n" + " seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));\n" + " newWatcher.maxAge = ToLegacyTimestamp(GetMaxAge(FromLegacyTimestamp<milliseconds>(monitorFrequencyUsec),\n" + " seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));\n" + " newWatcher.max = ToLegacyTimestamp(GetMaxAge(FromLegacyTimestamp<milliseconds>(monitorFrequencyUsec),\n" + " seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));\n" + "}", + Style); + // clang-format on + + Style.BinPackArguments = false; + + // clang-format off + verifyFormat("void SomeFunc() {\n" + " newWatcher.maxAgeUsec = ToLegacyTimestamp(GetMaxAge(\n" + " FromLegacyTimestamp<milliseconds>(monitorFrequencyUsec), seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));\n" + " newWatcher.maxAge = ToLegacyTimestamp(GetMaxAge(\n" + " FromLegacyTimestamp<milliseconds>(monitorFrequencyUsec), seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));\n" + " newWatcher.max = ToLegacyTimestamp(GetMaxAge(\n" + " FromLegacyTimestamp<milliseconds>(monitorFrequencyUsec), seconds(std::uint64_t(maxSampleAge)), maxKeepSamples));\n" + "}", + Style); + // clang-format on } TEST_F(FormatTest, AlignWithInitializerPeriods) { Index: clang/lib/Format/WhitespaceManager.cpp =================================================================== --- clang/lib/Format/WhitespaceManager.cpp +++ clang/lib/Format/WhitespaceManager.cpp @@ -347,7 +347,7 @@ if (ScopeStart > Start + 1 && Changes[ScopeStart - 2].Tok->is(tok::identifier) && Changes[ScopeStart - 1].Tok->is(tok::l_paren)) - return true; + return Style.BinPackArguments; // Ternary operator if (Changes[i].Tok->is(TT_ConditionalExpr))
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits