Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 755668 | Differences between
and this patch

Collapse All | Expand All

(-)a/dev-libs/libclangformat-ide/Manifest (+3 lines)
Lines 1-6 Link Here
1
AUX clang-qtcreator-compat-11.0.0.patch 7551 BLAKE2B 3bba88d182fc9d0eac5145694777e7ac1b3c1baebfc8cb30104b720ccc66dbf5e8cecbab6ec252b9e5518edbe90802c425ad4365ba529e85b8099e14b31c0784 SHA512 aa7b48775994b7ecbbf6bec3a6746628b628b43762de1e28ce2dade8ccd485f4005900dc4cc11847d70bf88df17689f769c8198478c4846fb4c74ab364d8487c
1
AUX clang-qtcreator-compat.patch 7480 BLAKE2B aabe085093786be2733f50259be355596b8f35ddcf524aa9437f67462e48c22532e51b113a1e839e6f1bb22548229ee111c0587e58b62e3a145a6bdf43b9b347 SHA512 6e8d761dcd7bcdda476326fa8b2e3d5966f15959aefc500c04a57b6396a035fc822ad1a57184519de3ac7340c680a5f49f5fc9841d24210e20e949d6b28a57b4
2
AUX clang-qtcreator-compat.patch 7480 BLAKE2B aabe085093786be2733f50259be355596b8f35ddcf524aa9437f67462e48c22532e51b113a1e839e6f1bb22548229ee111c0587e58b62e3a145a6bdf43b9b347 SHA512 6e8d761dcd7bcdda476326fa8b2e3d5966f15959aefc500c04a57b6396a035fc822ad1a57184519de3ac7340c680a5f49f5fc9841d24210e20e949d6b28a57b4
2
DIST llvmorg-10.0.0.tar.gz 120804856 BLAKE2B 6b0254f5b913398cdcf2b2ec1ff219888706d2b79d5296590934714e42ac79f6a6547941ac2b1d2c4e6313dd18b6c7068e748aa6ac033e49fccbf5d355aa8191 SHA512 baa182d62fef1851836013ae8a1a00861ea89769778d67fb97b407a9de664e6c85da2af9c5b3f75d2bf34ff6b00004e531ca7e4b3115a26c0e61c575cf2303a0
3
DIST llvmorg-10.0.0.tar.gz 120804856 BLAKE2B 6b0254f5b913398cdcf2b2ec1ff219888706d2b79d5296590934714e42ac79f6a6547941ac2b1d2c4e6313dd18b6c7068e748aa6ac033e49fccbf5d355aa8191 SHA512 baa182d62fef1851836013ae8a1a00861ea89769778d67fb97b407a9de664e6c85da2af9c5b3f75d2bf34ff6b00004e531ca7e4b3115a26c0e61c575cf2303a0
4
DIST llvmorg-11.0.0.tar.gz 122743665 BLAKE2B 3f95570240789fd68ddb747df817f5c6cdc9da40911bbe9ee3531c15ada9165e5002b1c2f778cf8735858485ea05a8754e3d3a5f4b15bdd6cb33d64a14692984 SHA512 b6d38871ccce0e086e27d35e42887618d68e57d8274735c59e3eabc42dee352412489296293f8d5169fe0044936345915ee7da61ebdc64ec10f7737f6ecd90f2
3
DIST llvmorg-9.0.1.tar.gz 113193320 BLAKE2B b86e405f2b8e00436045fd409fe19cdde75c797b1192c62a22b5ec75e6b4dc8e874a0f33008dc31562445e4cbe53a992b6f48c684255a6a1ef261e595b8b161f SHA512 fa88beeaae94b6d0cd9b5ba38658d0ffed8004035d7d8a4f95c3d31a709b88b581ae9bd7761333c8e5375c44b8f6be01768b5a3be901163159d7e6c43b71da59
5
DIST llvmorg-9.0.1.tar.gz 113193320 BLAKE2B b86e405f2b8e00436045fd409fe19cdde75c797b1192c62a22b5ec75e6b4dc8e874a0f33008dc31562445e4cbe53a992b6f48c684255a6a1ef261e595b8b161f SHA512 fa88beeaae94b6d0cd9b5ba38658d0ffed8004035d7d8a4f95c3d31a709b88b581ae9bd7761333c8e5375c44b8f6be01768b5a3be901163159d7e6c43b71da59
4
EBUILD libclangformat-ide-10.0.0.ebuild 1724 BLAKE2B 4b7fc4a91fff065ef5b9687dbbab5e905d39a9ec6b7903b90c27e14e232522ba79ad928873a658c46c60eb5e7e596c798fccc9189844b5e002313fe02b95a9c0 SHA512 21d3e5d1960548bb04a5a57ccc40b3aaf4f1df69ed9ad650253b6f01b655a9fd7232e035c27a3b037b93f5e83930ce10ff995560429aa62e27cba99c238a539c
6
EBUILD libclangformat-ide-10.0.0.ebuild 1724 BLAKE2B 4b7fc4a91fff065ef5b9687dbbab5e905d39a9ec6b7903b90c27e14e232522ba79ad928873a658c46c60eb5e7e596c798fccc9189844b5e002313fe02b95a9c0 SHA512 21d3e5d1960548bb04a5a57ccc40b3aaf4f1df69ed9ad650253b6f01b655a9fd7232e035c27a3b037b93f5e83930ce10ff995560429aa62e27cba99c238a539c
7
EBUILD libclangformat-ide-11.0.0.ebuild 1730 BLAKE2B abb71ab942c5bf16428a5b3cc4d5e30c0b4b2191a75c5b61b7c8f1f54296878c7e8fb0cd6fe681f4956a91c7115dfbc5ca2591e8af8953c3890fcf9fe54ac5cb SHA512 4faa67304b3c8e9843f0012eebd888264dcc2f90df6dad2e90b80b89c17f2a239f1a7e671474bc7caaec28e3d679a2e03f2f7a9c15d36bbaa19b7b3cbea3845a
5
EBUILD libclangformat-ide-9.0.1.ebuild 1719 BLAKE2B af595842b8e1928f435a93bdc04935bbfac86c90ec40a87344b1023e1bcb855dbcf3517e63f1c0d9093e652aa12aa8ceef8cc0e48a831831f445185e6687125d SHA512 c345fed4ed94521ec51ae5b998db71f29efc5b927bd3471c754649c787373939a396f0dcd16bfa3a2516eb415cbc2457cd7616b17a404b70712c94f8b99335d7
8
EBUILD libclangformat-ide-9.0.1.ebuild 1719 BLAKE2B af595842b8e1928f435a93bdc04935bbfac86c90ec40a87344b1023e1bcb855dbcf3517e63f1c0d9093e652aa12aa8ceef8cc0e48a831831f445185e6687125d SHA512 c345fed4ed94521ec51ae5b998db71f29efc5b927bd3471c754649c787373939a396f0dcd16bfa3a2516eb415cbc2457cd7616b17a404b70712c94f8b99335d7
6
MISC metadata.xml 250 BLAKE2B 3c6a58190f2680dd7f7e4afd9e6abfedc7e36181b1a8d7fa9710e08c805ef85988e4a156221c61fc71c36f8e84113537b70a8f144e0764e7704f7dd074af8172 SHA512 d2115b154bf731eac11fd7b96a95baa2467cb660371f7a3dc7a7a77cf4a6cf992b97c5353f184010eac1d37cdfffa6c5d9ec35d82e171f0fad5086767d0173a5
9
MISC metadata.xml 250 BLAKE2B 3c6a58190f2680dd7f7e4afd9e6abfedc7e36181b1a8d7fa9710e08c805ef85988e4a156221c61fc71c36f8e84113537b70a8f144e0764e7704f7dd074af8172 SHA512 d2115b154bf731eac11fd7b96a95baa2467cb660371f7a3dc7a7a77cf4a6cf992b97c5353f184010eac1d37cdfffa6c5d9ec35d82e171f0fad5086767d0173a5
(-)a/dev-libs/libclangformat-ide/files/clang-qtcreator-compat-11.0.0.patch (+186 lines)
Line 0 Link Here
1
From 9b992a0f7f160dd6c75f20a4dcfcf7c60a4894df Mon Sep 17 00:00:00 2001
2
From: Ivan Donchevskii <ivan.donchevskii@qt.io>
3
Date: Fri, 12 Oct 2018 08:19:25 +0200
4
Subject: [clang-format] Introduce the flag which allows not to shrink lines
5
6
https://reviews.llvm.org/D53072
7
8
Currently there's no way to prevent to lines optimization even
9
if you have intentionally put <CR> to split the line.
10
11
In general case it's fine. So I would prefer to have such option
12
which you can enable in special cases (for me it's an IDE related use case).
13
14
Revert this change if upstream clang-format offers better solution.
15
16
Reviewed-by; Marco Bubke <marco.bubke@qt.io>
17
18
Cherry picked from commit
19
clang.git/fa1b9053729ec6a4425a44ec5502dd388928274a.
20
21
Change-Id: I92296dd177c811593ebba7d4b5c3c5f472af10a2
22
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
23
---
24
 clang/include/clang/Format/Format.h         | 13 +++++++++++++
25
 clang/lib/Format/Format.cpp                 |  4 ++++
26
 clang/lib/Format/UnwrappedLineFormatter.cpp |  9 +++++----
27
 clang/lib/Format/UnwrappedLineParser.cpp    |  2 ++
28
 clang/unittests/Format/FormatTest.cpp       | 16 ++++++++++++++++
29
 5 files changed, 40 insertions(+), 4 deletions(-)
30
31
NB! Line numbers adjusted manually to get perfect patch.
32
33
diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
34
index 3549ec9e..1e6a4869 100755
35
--- a/clang/include/clang/Format/Format.h
36
+++ b/clang/include/clang/Format/Format.h
37
@@ -21,6 +21,8 @@
38
 #include "llvm/Support/Regex.h"
39
 #include <system_error>
40
 
41
+#define KEEP_LINE_BREAKS_FOR_NON_EMPTY_LINES_BACKPORTED
42
+
43
 namespace llvm {
44
 namespace vfs {
45
 class FileSystem;
46
@@ -1666,6 +1668,16 @@ struct FormatStyle {
47
   bool JavaScriptWrapImports;
48
   // clang-format on
49
 
50
+  /// If true, no line breaks are optimized out (works only with ColumnLimit = 0)
51
+  /// \code
52
+  ///    true:                                  false:
53
+  ///    int foo(int a,                 vs.     int foo(int a, int b) {
54
+  ///            int b) {
55
+  ///      bar();                                 bar();
56
+  ///    }                                      }
57
+  /// \endcode
58
+  bool KeepLineBreaksForNonEmptyLines;
59
+
60
   /// If true, the empty line at the start of blocks is kept.
61
   /// \code
62
   ///    true:                                  false:
63
@@ -2358,6 +2370,7 @@ struct FormatStyle {
64
            JavaImportGroups == R.JavaImportGroups &&
65
            JavaScriptQuotes == R.JavaScriptQuotes &&
66
            JavaScriptWrapImports == R.JavaScriptWrapImports &&
67
+           KeepLineBreaksForNonEmptyLines == R.KeepLineBreaksForNonEmptyLines &&
68
            KeepEmptyLinesAtTheStartOfBlocks ==
69
                R.KeepEmptyLinesAtTheStartOfBlocks &&
70
            MacroBlockBegin == R.MacroBlockBegin &&
71
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
72
index 0d277a64..7875838b 100644
73
--- a/clang/lib/Format/Format.cpp
74
+++ b/clang/lib/Format/Format.cpp
75
@@ -532,6 +532,8 @@ template <> struct MappingTraits<FormatStyle> {
76
     IO.mapOptional("JavaImportGroups", Style.JavaImportGroups);
77
     IO.mapOptional("JavaScriptQuotes", Style.JavaScriptQuotes);
78
     IO.mapOptional("JavaScriptWrapImports", Style.JavaScriptWrapImports);
79
+    IO.mapOptional("KeepLineBreaksForNonEmptyLines",
80
+                   Style.KeepLineBreaksForNonEmptyLines);
81
     IO.mapOptional("KeepEmptyLinesAtTheStartOfBlocks",
82
                    Style.KeepEmptyLinesAtTheStartOfBlocks);
83
     IO.mapOptional("MacroBlockBegin", Style.MacroBlockBegin);
84
@@ -889,6 +891,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
85
   LLVMStyle.JavaScriptWrapImports = true;
86
   LLVMStyle.TabWidth = 8;
87
   LLVMStyle.MaxEmptyLinesToKeep = 1;
88
+  LLVMStyle.KeepLineBreaksForNonEmptyLines = false;
89
   LLVMStyle.KeepEmptyLinesAtTheStartOfBlocks = true;
90
   LLVMStyle.NamespaceIndentation = FormatStyle::NI_None;
91
   LLVMStyle.ObjCBinPackProtocolList = FormatStyle::BPS_Auto;
92
@@ -973,6 +976,7 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) {
93
   GoogleStyle.IncludeStyle.IncludeIsMainRegex = "([-_](test|unittest))?$";
94
   GoogleStyle.IncludeStyle.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup;
95
   GoogleStyle.IndentCaseLabels = true;
96
+  GoogleStyle.KeepLineBreaksForNonEmptyLines = false;
97
   GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false;
98
   GoogleStyle.ObjCBinPackProtocolList = FormatStyle::BPS_Never;
99
   GoogleStyle.ObjCSpaceAfterProperty = false;
100
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp
101
index 22f27a66..5060b04f 100644
102
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
103
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
104
@@ -732,7 +732,7 @@ public:
105
   LineFormatter(ContinuationIndenter *Indenter, WhitespaceManager *Whitespaces,
106
                 const FormatStyle &Style,
107
                 UnwrappedLineFormatter *BlockFormatter)
108
-      : Indenter(Indenter), Whitespaces(Whitespaces), Style(Style),
109
+      : Indenter(Indenter), Style(Style), Whitespaces(Whitespaces),
110
         BlockFormatter(BlockFormatter) {}
111
   virtual ~LineFormatter() {}
112
 
113
@@ -773,7 +773,8 @@ protected:
114
       // assert so that we can simply call this function for all tokens.
115
       return true;
116
 
117
-    if (NewLine) {
118
+    if (NewLine || (Previous.Children[0]->First->MustBreakBefore &&
119
+                    Style.KeepLineBreaksForNonEmptyLines)) {
120
       int AdditionalIndent = State.Stack.back().Indent -
121
                              Previous.Children[0]->Level * Style.IndentWidth;
122
 
123
@@ -819,10 +820,10 @@ protected:
124
   }
125
 
126
   ContinuationIndenter *Indenter;
127
+  const FormatStyle &Style;
128
 
129
 private:
130
   WhitespaceManager *Whitespaces;
131
-  const FormatStyle &Style;
132
   UnwrappedLineFormatter *BlockFormatter;
133
 };
134
 
135
@@ -845,7 +846,7 @@ public:
136
     while (State.NextToken) {
137
       bool Newline =
138
           Indenter->mustBreak(State) ||
139
-          (Indenter->canBreak(State) && State.NextToken->NewlinesBefore > 0);
140
+          (State.NextToken->NewlinesBefore > 0 && Indenter->canBreak(State));
141
       unsigned Penalty = 0;
142
       formatChildren(State, Newline, /*DryRun=*/false, Penalty);
143
       Indenter->addTokenToState(State, Newline, /*DryRun=*/false);
144
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
145
index a3738642..f80c1116 100644
146
--- a/clang/lib/Format/UnwrappedLineParser.cpp
147
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
148
@@ -2942,6 +2942,8 @@ void UnwrappedLineParser::nextToken(int LevelDifference) {
149
   else
150
     readTokenWithJavaScriptASI();
151
   FormatTok->Previous = Previous;
152
+  if (FormatTok->NewlinesBefore && Style.KeepLineBreaksForNonEmptyLines)
153
+    FormatTok->MustBreakBefore = true;
154
 }
155
 
156
 void UnwrappedLineParser::distributeComments(
157
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
158
index 17d302f0..48971623 100644
159
--- a/clang/unittests/Format/FormatTest.cpp
160
+++ b/clang/unittests/Format/FormatTest.cpp
161
@@ -393,6 +393,22 @@ TEST_F(FormatTest, RemovesEmptyLines) {
162
                    "  void funk() {}\n"
163
                    "};",
164
                    Style));
165
+
166
+  Style.KeepLineBreaksForNonEmptyLines = true;
167
+  Style.ColumnLimit = 0;
168
+  EXPECT_EQ("int foo(int a,\n"
169
+            "        int b)\n"
170
+            "{\n"
171
+            "}",
172
+            format("int foo(int a,\n"
173
+                   "int b) {}",
174
+                   Style));
175
+
176
+  EXPECT_EQ("[]() {\n"
177
+            "  foo(); }",
178
+            format("[]() {\n"
179
+                   "foo(); }",
180
+                   Style));
181
 }
182
 
183
 TEST_F(FormatTest, RecognizesBinaryOperatorKeywords) {
184
-- 
185
2.26.2
186
(-)a/dev-libs/libclangformat-ide/libclangformat-ide-11.0.0.ebuild (+72 lines)
Line 0 Link Here
1
# Copyright 1999-2020 Gentoo Authors
2
# Distributed under the terms of the GNU General Public License v2
3
4
EAPI=7
5
6
inherit cmake llvm llvm.org toolchain-funcs
7
8
DESCRIPTION="A static clangformat library patched for IDE use"
9
HOMEPAGE="https://www.qt.io/blog/2019/04/17/clangformat-plugin-qt-creator-4-9"
10
LLVM_COMPONENTS=( clang )
11
12
llvm.org_set_globals
13
14
LICENSE="Apache-2.0-with-LLVM-exceptions UoI-NCSA MIT"
15
SLOT="$(ver_cut 1)"
16
KEYWORDS="~amd64 ~arm ~x86"
17
IUSE="debug"
18
19
DEPEND="~sys-devel/llvm-${PV}:${SLOT}=[debug=]"
20
21
# least intrusive of all
22
CMAKE_BUILD_TYPE=RelWithDebInfo
23
24
PATCHES=( "${FILESDIR}/clang-qtcreator-compat-${PV}.patch" )
25
26
pkg_setup() {
27
	LLVM_MAX_SLOT=${SLOT} llvm_pkg_setup
28
}
29
30
src_unpack() {
31
	llvm.org_src_unpack
32
}
33
34
src_configure() {
35
	local mycmakeargs=(
36
		-DLLVM_CMAKE_PATH="${EPREFIX}/usr/lib/llvm/${SLOT}/$(get_libdir)/cmake/llvm"
37
		-DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${SLOT}"
38
		-DBUILD_SHARED_LIBS=OFF
39
		-DLLVM_ENABLE_EH=ON
40
		-DLLVM_ENABLE_RTTI=ON
41
	)
42
43
	if [[ -n ${EPREFIX} ]]; then
44
		mycmakeargs+=(
45
			-DGCC_INSTALL_PREFIX="${EPREFIX}/usr"
46
		)
47
	fi
48
49
	if tc-is-cross-compiler; then
50
		[[ -x "/usr/bin/clang-tblgen" ]] \
51
			|| die "/usr/bin/clang-tblgen not found or usable"
52
		mycmakeargs+=(
53
			-DCMAKE_CROSSCOMPILING=ON
54
			-DCLANG_TABLEGEN=/usr/bin/clang-tblgen
55
		)
56
	fi
57
58
	# LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844
59
	use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG"
60
	cmake_src_configure
61
}
62
63
src_compile() {
64
	cmake_src_compile libclangFormat.a
65
}
66
67
src_install() {
68
	into usr/lib/llvm/${SLOT}
69
	newlib.a "${BUILD_DIR}/$(get_libdir)/libclangFormat.a" libclangFormatIDE.a
70
	insinto usr/lib/llvm/${SLOT}/include/clang/Format
71
	newins "${S}/include/clang/Format/Format.h" FormatIDE.h
72
}

Return to bug 755668