[llvm-bugs] [Bug 25132] New: BraceWrapping: AfterFunction flag interferes with formatting of empty class body
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Oct 9 17:23:37 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=25132
Bug ID: 25132
Summary: BraceWrapping: AfterFunction flag interferes with
formatting of empty class body
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: mattipee at yahoo.co.uk
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
Classification: Unclassified
$ clang-format -version
clang-format version 3.8.0 (http://llvm.org/git/clang.git
47928a9602f4bc13c065bad2f7f940bee2711e63) (http://llvm.org/git/llvm.git
0425965d3ddad80c886b6795361c1902f7e1dd78)
$ cat asdf.h
class A {};
$ cat .clang-format
---
BraceWrapping:
AfterClass: true
#AfterFunction: true
BreakBeforeBraces: Custom
...
$ clang-format --style=file asdf.h
class A
{};
Enable AfterFunction
====================
$ cat .clang-format
---
BraceWrapping:
AfterClass: true
AfterFunction: true
BreakBeforeBraces: Custom
...
$ clang-format --style=file asdf.h
class A
{
};
After recompilation (see below)
===================
$ clang-format --style=file asdf.h
class A
{};
I suspect the following change may be incorrect for reasons I am unable to
test...
diff --git a/lib/Format/UnwrappedLineFormatter.cpp
b/lib/Format/UnwrappedLineFormatter.cpp
index 6d9b1da..67567be 100644
--- a/lib/Format/UnwrappedLineFormatter.cpp
+++ b/lib/Format/UnwrappedLineFormatter.cpp
@@ -199,7 +199,8 @@ private:
return MergeShortFunctions ? tryMergeSimpleBlock(I, E, Limit) : 0;
}
if (TheLine->Last->is(tok::l_brace)) {
- return !Style.BraceWrapping.AfterFunction
+ return !(TheLine->Last->is(TT_FunctionLBrace) &&
+ Style.BraceWrapping.AfterFunction)
? tryMergeSimpleBlock(I, E, Limit)
: 0;
}
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20151010/066b4f23/attachment-0001.html>
More information about the llvm-bugs
mailing list