diff options
author | Daniel Jasper <djasper@google.com> | 2013-02-28 11:05:57 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-02-28 11:05:57 +0000 |
commit | a4d4621b206f941cc58d9d0bc7c67a8e705c9d49 (patch) | |
tree | 2f2f871f636f3daee81fc92ee550483d7d218f9e /unittests/Format/FormatTest.cpp | |
parent | b6f02f3bcb5ddcd7c7f1a3571d554fe55c72968f (diff) |
Improve formatting of #defines.
Two improvements:
1) Always leave at least one space before "\". Otherwise is can look bad
and there is a risk of unwillingly joining to characters to a different
token.
2) Use the full column limit for single-line #defines.
Fixes llvm.org/PR15148
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176245 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format/FormatTest.cpp')
-rw-r--r-- | unittests/Format/FormatTest.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index cc68bcb947..98e035a598 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -857,29 +857,24 @@ TEST_F(FormatTest, EndOfFileEndsPPDirective) { } TEST_F(FormatTest, IndentsPPDirectiveInReducedSpace) { - // If the macro fits in one line, we still do not get the full - // line, as only the next line decides whether we need an escaped newline and - // thus use the last column. - verifyFormat("#define A(B)", getLLVMStyleWithColumns(13)); - - verifyFormat("#define A( \\\n B)", getLLVMStyleWithColumns(12)); - verifyFormat("#define AA(\\\n B)", getLLVMStyleWithColumns(12)); + verifyFormat("#define A(BB)", getLLVMStyleWithColumns(13)); + 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 A A\n#define A A"); verifyFormat("#define A(X) A\n#define A A"); - verifyFormat("#define Something Other", getLLVMStyleWithColumns(24)); - verifyFormat("#define Something \\\n" - " Other", - getLLVMStyleWithColumns(23)); + verifyFormat("#define Something Other", getLLVMStyleWithColumns(23)); + verifyFormat("#define Something \\\n Other", getLLVMStyleWithColumns(22)); } TEST_F(FormatTest, HandlePreprocessorDirectiveContext) { EXPECT_EQ("// some comment\n" "#include \"a.h\"\n" - "#define A(A,\\\n" - " B)\n" + "#define A( \\\n" + " A, B)\n" "#include \"b.h\"\n" "// some comment\n", format(" // some comment\n" |