aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2012-12-07 09:52:15 +0000
committerDaniel Jasper <djasper@google.com>2012-12-07 09:52:15 +0000
commitc74e2794bebaab41213f23b27c09c21cb1e1f81b (patch)
tree9002493cec366836fdec32c87809cef5c6a0011a
parentbf25fb1e2eaea0eadb90d1a9ce91e7d510c8972a (diff)
Small tweaks to clang-format.
Now not joining keywords with '::' and not putting a space between a pointer pointer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169594 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Format/Format.cpp10
-rw-r--r--unittests/Format/FormatTest.cpp5
2 files changed, 12 insertions, 3 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index ebb49498da..7085aaf8b7 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -696,16 +696,20 @@ private:
return false;
if (Left.is(tok::less) || Right.is(tok::greater) || Right.is(tok::less))
return false;
+ if (Right.is(tok::amp) || Right.is(tok::star))
+ return Left.isLiteral() ||
+ (Left.isNot(tok::star) && Left.isNot(tok::amp) &&
+ !Style.PointerAndReferenceBindToType);
if (Left.is(tok::amp) || Left.is(tok::star))
return Right.isLiteral() || Style.PointerAndReferenceBindToType;
if (Right.is(tok::star) && Left.is(tok::l_paren))
return false;
- if (Right.is(tok::amp) || Right.is(tok::star))
- return Left.isLiteral() || !Style.PointerAndReferenceBindToType;
if (Left.is(tok::l_square) || Right.is(tok::l_square) ||
Right.is(tok::r_square))
return false;
- if (Left.is(tok::coloncolon) || Right.is(tok::coloncolon))
+ if (Left.is(tok::coloncolon) ||
+ (Right.is(tok::coloncolon) &&
+ (Left.is(tok::identifier) || Left.is(tok::greater))))
return false;
if (Left.is(tok::period) || Right.is(tok::period))
return false;
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index c8416cb352..d00da7ffee 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -277,6 +277,8 @@ TEST_F(FormatTest, UnderstandsAccessSpecifiers) {
TEST_F(FormatTest, FormatsDerivedClass) {
verifyFormat("class A : public B {\n"
"};");
+ verifyFormat("class A : public ::B {\n"
+ "};");
}
TEST_F(FormatTest, FormatsEnum) {
@@ -474,6 +476,9 @@ TEST_F(FormatTest, UnderstandsUsesOfStar) {
verifyFormat("int a = *b;");
verifyFormat("int a = *b * c;");
verifyFormat("int a = b * *c;");
+ verifyFormat("int main(int argc, char **argv) {\n}");
+
+ verifyGoogleFormat("int main(int argc, char** argv) {\n}");
}
TEST_F(FormatTest, LineStartsWithSpecialCharacter) {