diff options
author | Nico Weber <nicolasweber@gmx.de> | 2013-01-08 19:40:21 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2013-01-08 19:40:21 +0000 |
commit | cb4d690820295d93c1cea6c13fb4409b8c1db2cf (patch) | |
tree | 5d1e8b68d0a2cd2ff576fd914a5758a56e23cdf5 | |
parent | f7fd7994a0c520d94e4dfd38848076e68da10a17 (diff) |
Formatter: Format @ literals better. Array and dictionary literals need more work.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171887 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Format/Format.cpp | 5 | ||||
-rw-r--r-- | unittests/Format/FormatTest.cpp | 14 |
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 120b54d831..1205c424b1 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -940,7 +940,10 @@ private: return false; if (Left.is(tok::exclaim) || Left.is(tok::tilde)) return false; - if (Left.is(tok::at) && Right.is(tok::identifier)) + if (Left.is(tok::at) && + (Right.is(tok::identifier) || Right.is(tok::string_literal) || + Right.is(tok::char_constant) || Right.is(tok::numeric_constant) || + Right.is(tok::l_paren) || Right.is(tok::l_brace))) return false; if (Left.is(tok::less) || Right.is(tok::greater) || Right.is(tok::less)) return false; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 2bd094bb83..d5f74d3daa 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -1137,6 +1137,20 @@ TEST_F(FormatTest, ObjCAt) { verifyFormat("@throw"); verifyFormat("@try"); + // FIXME: Make the uncommented lines below pass. + verifyFormat("@\"String\""); + verifyFormat("@1"); + //verifyFormat("@+4.8"); + //verifyFormat("@-4"); + verifyFormat("@1LL"); + verifyFormat("@.5"); + verifyFormat("@'c'"); + verifyFormat("@true"); + verifyFormat("NSNumber *smallestInt = @(-INT_MAX - 1);"); + verifyFormat("@["); + verifyFormat("@{"); + + EXPECT_EQ("@interface", format("@ interface")); // The precise formatting of this doesn't matter, nobody writes code like |