Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 661614 Details for
Bug 734732
dev-libs/libclangformat-ide-10.0.1 version bump
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Updated version of the patch
clang-qtcreator-compat.patch (text/plain), 6.38 KB, created by
Alessandro Di Federico
on 2020-09-20 10:35:25 UTC
(
hide
)
Description:
Updated version of the patch
Filename:
MIME Type:
Creator:
Alessandro Di Federico
Created:
2020-09-20 10:35:25 UTC
Size:
6.38 KB
patch
obsolete
>Author: Alessandro Di Federico <ale@clearmind.me> >Date: Sun Sep 20 12:29:44 2020 +0200 > > [PATCH] [clang-format] Introduce the flag which allows not to shrink lines > > Signed-off-by: Alessandro Di Federico <ale@clearmind.me> > >diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h >index add2937..08dc1a0 100644 >--- a/clang/include/clang/Format/Format.h >+++ b/clang/include/clang/Format/Format.h >@@ -21,6 +21,8 @@ > #include "llvm/Support/Regex.h" > #include <system_error> > >+#define KEEP_LINE_BREAKS_FOR_NON_EMPTY_LINES_BACKPORTED >+ > namespace llvm { > namespace vfs { > class FileSystem; >@@ -1476,6 +1478,16 @@ struct FormatStyle { > bool JavaScriptWrapImports; > // clang-format on > >+ /// If true, no line breaks are optimized out (works only with ColumnLimit = 0) >+ /// \code >+ /// true: false: >+ /// int foo(int a, vs. int foo(int a, int b) { >+ /// int b) { >+ /// bar(); bar(); >+ /// } } >+ /// \endcode >+ bool KeepLineBreaksForNonEmptyLines; >+ > /// If true, the empty line at the start of blocks is kept. > /// \code > /// true: false: >@@ -2126,6 +2138,7 @@ struct FormatStyle { > JavaImportGroups == R.JavaImportGroups && > JavaScriptQuotes == R.JavaScriptQuotes && > JavaScriptWrapImports == R.JavaScriptWrapImports && >+ KeepLineBreaksForNonEmptyLines == R.KeepLineBreaksForNonEmptyLines && > KeepEmptyLinesAtTheStartOfBlocks == > R.KeepEmptyLinesAtTheStartOfBlocks && > MacroBlockBegin == R.MacroBlockBegin && >diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp >index f12bca4..052095c 100644 >--- a/clang/lib/Format/Format.cpp >+++ b/clang/lib/Format/Format.cpp >@@ -488,6 +488,8 @@ template <> struct MappingTraits<FormatStyle> { > IO.mapOptional("JavaImportGroups", Style.JavaImportGroups); > IO.mapOptional("JavaScriptQuotes", Style.JavaScriptQuotes); > IO.mapOptional("JavaScriptWrapImports", Style.JavaScriptWrapImports); >+ IO.mapOptional("KeepLineBreaksForNonEmptyLines", >+ Style.KeepLineBreaksForNonEmptyLines); > IO.mapOptional("KeepEmptyLinesAtTheStartOfBlocks", > Style.KeepEmptyLinesAtTheStartOfBlocks); > IO.mapOptional("MacroBlockBegin", Style.MacroBlockBegin); >@@ -790,6 +792,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) { > LLVMStyle.JavaScriptWrapImports = true; > LLVMStyle.TabWidth = 8; > LLVMStyle.MaxEmptyLinesToKeep = 1; >+ LLVMStyle.KeepLineBreaksForNonEmptyLines = false; > LLVMStyle.KeepEmptyLinesAtTheStartOfBlocks = true; > LLVMStyle.NamespaceIndentation = FormatStyle::NI_None; > LLVMStyle.ObjCBinPackProtocolList = FormatStyle::BPS_Auto; >@@ -870,6 +873,7 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) { > GoogleStyle.IncludeStyle.IncludeIsMainRegex = "([-_](test|unittest))?$"; > GoogleStyle.IncludeStyle.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup; > GoogleStyle.IndentCaseLabels = true; >+ GoogleStyle.KeepLineBreaksForNonEmptyLines = false; > GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false; > GoogleStyle.ObjCBinPackProtocolList = FormatStyle::BPS_Never; > GoogleStyle.ObjCSpaceAfterProperty = false; >diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp >index fec85f1..85c1719 100644 >--- a/clang/lib/Format/UnwrappedLineFormatter.cpp >+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp >@@ -741,7 +741,7 @@ public: > LineFormatter(ContinuationIndenter *Indenter, WhitespaceManager *Whitespaces, > const FormatStyle &Style, > UnwrappedLineFormatter *BlockFormatter) >- : Indenter(Indenter), Whitespaces(Whitespaces), Style(Style), >+ : Indenter(Indenter), Style(Style), Whitespaces(Whitespaces), > BlockFormatter(BlockFormatter) {} > virtual ~LineFormatter() {} > >@@ -782,7 +782,8 @@ protected: > // assert so that we can simply call this function for all tokens. > return true; > >- if (NewLine) { >+ if (NewLine || (Previous.Children[0]->First->MustBreakBefore && >+ Style.KeepLineBreaksForNonEmptyLines)) { > int AdditionalIndent = State.Stack.back().Indent - > Previous.Children[0]->Level * Style.IndentWidth; > >@@ -827,10 +828,10 @@ protected: > } > > ContinuationIndenter *Indenter; >+ const FormatStyle &Style; > > private: > WhitespaceManager *Whitespaces; >- const FormatStyle &Style; > UnwrappedLineFormatter *BlockFormatter; > }; > >@@ -853,7 +854,7 @@ public: > while (State.NextToken) { > bool Newline = > Indenter->mustBreak(State) || >- (Indenter->canBreak(State) && State.NextToken->NewlinesBefore > 0); >+ (State.NextToken->NewlinesBefore > 0 && Indenter->canBreak(State)); > unsigned Penalty = 0; > formatChildren(State, Newline, /*DryRun=*/false, Penalty); > Indenter->addTokenToState(State, Newline, /*DryRun=*/false); >diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp >index ead6b47..6fd671d 100644 >--- a/clang/lib/Format/UnwrappedLineParser.cpp >+++ b/clang/lib/Format/UnwrappedLineParser.cpp >@@ -2640,6 +2640,8 @@ void UnwrappedLineParser::nextToken(int LevelDifference) { > else > readTokenWithJavaScriptASI(); > FormatTok->Previous = Previous; >+ if (FormatTok->NewlinesBefore && Style.KeepLineBreaksForNonEmptyLines) >+ FormatTok->MustBreakBefore = true; > } > > void UnwrappedLineParser::distributeComments( >diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp >index 7f8a379..a2d477b 100644 >--- a/clang/unittests/Format/FormatTest.cpp >+++ b/clang/unittests/Format/FormatTest.cpp >@@ -393,6 +393,22 @@ TEST_F(FormatTest, RemovesEmptyLines) { > " void funk() {}\n" > "};", > Style)); >+ >+ Style.KeepLineBreaksForNonEmptyLines = true; >+ Style.ColumnLimit = 0; >+ EXPECT_EQ("int foo(int a,\n" >+ " int b)\n" >+ "{\n" >+ "}", >+ format("int foo(int a,\n" >+ "int b) {}", >+ Style)); >+ >+ EXPECT_EQ("[]() {\n" >+ " foo(); }", >+ format("[]() {\n" >+ "foo(); }", >+ Style)); > } > > TEST_F(FormatTest, RecognizesBinaryOperatorKeywords) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 734732
:
652276
| 661614