summaryrefslogtreecommitdiff
path: root/lib/Format/Format.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-04-09 12:21:48 +0000
committerDaniel Jasper <djasper@google.com>2014-04-09 12:21:48 +0000
commit8d475618089e8bb3d0e47605b236b445eaefab2d (patch)
tree808eadce4d2638fd9df5bc65dbdd98ba350abc2a /lib/Format/Format.cpp
parent94096ad523611aa4c139c88ac5ec8985b46d6b1b (diff)
downloadclang-8d475618089e8bb3d0e47605b236b445eaefab2d.tar.gz
clang-8d475618089e8bb3d0e47605b236b445eaefab2d.tar.bz2
clang-8d475618089e8bb3d0e47605b236b445eaefab2d.tar.xz
clang-format: Fix bug where clang-format would break the code.
Before, it would turn: SomeFunction([]() { // Cool function.. return 43; }); Into this: SomeFunction([]() { // Cool function.. return 43; }); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205849 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/Format.cpp')
-rw-r--r--lib/Format/Format.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index 5367106535..4075ccdc8c 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -1121,6 +1121,10 @@ private:
if (Previous.Children.size() > 1)
return false;
+ // Cannot merge into one line if this line ends on a comment.
+ if (Previous.is(tok::comment))
+ return false;
+
// We can't put the closing "}" on a line with a trailing comment.
if (Previous.Children[0]->Last->isTrailingComment())
return false;