summaryrefslogtreecommitdiffstats
path: root/clang/unittests
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-08-28 09:07:32 +0000
committerDaniel Jasper <djasper@google.com>2013-08-28 09:07:32 +0000
commita49393f54de2f9944972c7b52789ab4ac120353e (patch)
treea7c0d57e59b6b98435e67168d9b20ac8042e117c /clang/unittests
parentbe133a8757103c430a36f15d6210f99a0206921f (diff)
downloadbcm5719-llvm-a49393f54de2f9944972c7b52789ab4ac120353e.tar.gz
bcm5719-llvm-a49393f54de2f9944972c7b52789ab4ac120353e.zip
clang-format: Fix infinite loop in macro special case.
If escaped newlines are aligned right (FormatStyle.AlignEscapedNewlinesLeft == false), and a line contained too many characters to fit into the column limit, this would result in a (virtually) endless loop creating a negative number of spaces. Instead, allow the escaped newlines to be pushed past the column limit in this case. This fixes llvm.org/PR16515. llvm-svn: 189459
Diffstat (limited to 'clang/unittests')
-rw-r--r--clang/unittests/Format/FormatTest.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index f5afbd3d7c4..d80011ba175 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -1814,7 +1814,7 @@ TEST_F(FormatTest, IndentsPPDirectiveInReducedSpace) {
verifyFormat("#define A( \\\n BB)", getLLVMStyleWithColumns(12));
verifyFormat("#define A( \\\n A, B)", getLLVMStyleWithColumns(12));
// FIXME: We never break before the macro name.
- verifyFormat("#define AA(\\\n B)", getLLVMStyleWithColumns(12));
+ verifyFormat("#define AA( \\\n B)", getLLVMStyleWithColumns(12));
verifyFormat("#define A A\n#define A A");
verifyFormat("#define A(X) A\n#define A A");
@@ -1887,9 +1887,9 @@ TEST_F(FormatTest, MacroDefinitionInsideStatement) {
TEST_F(FormatTest, HashInMacroDefinition) {
verifyFormat("#define A \\\n b #c;", getLLVMStyleWithColumns(11));
- verifyFormat("#define A \\\n"
- " { \\\n"
- " f(#c);\\\n"
+ verifyFormat("#define A \\\n"
+ " { \\\n"
+ " f(#c); \\\n"
" }",
getLLVMStyleWithColumns(11));
@@ -4396,7 +4396,7 @@ TEST_F(FormatTest, BlockComments) {
EXPECT_EQ("/* */ /* */ /* */\n/* */ /* */ /* */",
format("/* *//* */ /* */\n/* *//* */ /* */"));
EXPECT_EQ("/* */ a /* */ b;", format(" /* */ a/* */ b;"));
- EXPECT_EQ("#define A /*123*/\\\n"
+ EXPECT_EQ("#define A /*123*/ \\\n"
" b\n"
"/* */\n"
"someCall(\n"
OpenPOWER on IntegriCloud