diff options
author | Daniel Jasper <djasper@google.com> | 2012-12-10 18:59:13 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2012-12-10 18:59:13 +0000 |
commit | a4396865d01f4bf544f22eefb14b87ca53ae8930 (patch) | |
tree | 26ae218e86fb46b92e6ad28f06579c67f5805020 /clang | |
parent | 66859ae0f64f1ead5579d9fb798927cd204f989b (diff) | |
download | bcm5719-llvm-a4396865d01f4bf544f22eefb14b87ca53ae8930.tar.gz bcm5719-llvm-a4396865d01f4bf544f22eefb14b87ca53ae8930.zip |
Addi formatting tests for pointer template parameters.
Fix spacing before ",".
llvm-svn: 169746
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Format/Format.cpp | 4 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 7f1131ca6f5..e8faa12a263 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -689,6 +689,8 @@ private: } bool spaceRequiredBetween(Token Left, Token Right) { + if (Right.is(tok::r_paren) || Right.is(tok::semi) || Right.is(tok::comma)) + return false; if (Left.is(tok::kw_template) && Right.is(tok::less)) return true; if (Left.is(tok::arrow) || Right.is(tok::arrow)) @@ -725,8 +727,6 @@ private: return false; if (Left.is(tok::hash)) return false; - if (Right.is(tok::r_paren) || Right.is(tok::semi) || Right.is(tok::comma)) - return false; if (Right.is(tok::l_paren)) { return !Left.isAnyIdentifier() || isIfForOrWhile(Left); } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 79cefc46637..d70442cebf5 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -478,7 +478,17 @@ TEST_F(FormatTest, UnderstandsUsesOfStar) { verifyFormat("int a = b * *c;"); verifyFormat("int main(int argc, char **argv) {\n}"); + // FIXME: Is this desired for LLVM? Fix if not. + verifyFormat("A<int *> a;"); + verifyFormat("A<int **> a;"); + verifyFormat("A<int *, int *> a;"); + verifyFormat("A<int **, int **> a;"); + verifyGoogleFormat("int main(int argc, char** argv) {\n}"); + verifyGoogleFormat("A<int*> a;"); + verifyGoogleFormat("A<int**> a;"); + verifyGoogleFormat("A<int*, int*> a;"); + verifyGoogleFormat("A<int**, int**> a;"); } TEST_F(FormatTest, LineStartsWithSpecialCharacter) { |