diff options
author | Daniel Jasper <djasper@google.com> | 2013-02-06 14:22:40 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-02-06 14:22:40 +0000 |
commit | 7fce3ab0f2aafde4f89ab286a55b0ce7aa70050c (patch) | |
tree | fae01218852983c81f22bee3d5caa6621324d13e /clang/unittests | |
parent | d1a665926399fc043bf48a69b9c36ba16bd133b1 (diff) | |
download | bcm5719-llvm-7fce3ab0f2aafde4f89ab286a55b0ce7aa70050c.tar.gz bcm5719-llvm-7fce3ab0f2aafde4f89ab286a55b0ce7aa70050c.zip |
Optionally derive formatting information from the input file.
With this patch, clang-format can analyze the input file for two
properties:
1. Is "int *a" or "int* a" more common.
2. Are non-C++03 constructs used, e.g. A<A<A>>.
With Google-style, clang-format will now use the more common style for
(1) and format C++03 compatible, unless it finds C++11 constructs in the
input.
llvm-svn: 174504
Diffstat (limited to 'clang/unittests')
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index f5250bc4df5..0f469836f5d 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1437,6 +1437,11 @@ TEST_F(FormatTest, UnderstandsTemplateParameters) { verifyGoogleFormat("A<A<int>> a;"); verifyGoogleFormat("A<A<A<int>>> a;"); verifyGoogleFormat("A<A<A<A<int>>>> a;"); + verifyGoogleFormat("A<A<int> > a;"); + verifyGoogleFormat("A<A<A<int> > > a;"); + verifyGoogleFormat("A<A<A<A<int> > > > a;"); + EXPECT_EQ("A<A<A<A>>> a;", format("A<A<A<A> >> a;", getGoogleStyle())); + EXPECT_EQ("A<A<A<A>>> a;", format("A<A<A<A>> > a;", getGoogleStyle())); verifyFormat("test >> a >> b;"); verifyFormat("test << a >> b;"); @@ -1597,6 +1602,22 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyIndependentOfContext("A = new SomeType *[Length]();"); verifyGoogleFormat("A = new SomeType* [Length]();"); + + EXPECT_EQ("int *a;\n" + "int *a;\n" + "int *a;", format("int *a;\n" + "int* a;\n" + "int *a;", getGoogleStyle())); + EXPECT_EQ("int* a;\n" + "int* a;\n" + "int* a;", format("int* a;\n" + "int* a;\n" + "int *a;", getGoogleStyle())); + EXPECT_EQ("int *a;\n" + "int *a;\n" + "int *a;", format("int *a;\n" + "int * a;\n" + "int * a;", getGoogleStyle())); } TEST_F(FormatTest, FormatsBinaryOperatorsPrecedingEquals) { |