diff options
author | Malcolm Parsons <malcolm.parsons@gmail.com> | 2016-10-20 14:58:45 +0000 |
---|---|---|
committer | Malcolm Parsons <malcolm.parsons@gmail.com> | 2016-10-20 14:58:45 +0000 |
commit | 5d8cdb83db58829bacc8d5478030b41a20acaf19 (patch) | |
tree | 56b891d82af1a5ef752bc404a74c781259259a3c /clang/unittests/Format/CleanupTest.cpp | |
parent | c1b73a1793b63a4cc67e6db9412a9c6cc85ef956 (diff) | |
download | bcm5719-llvm-5d8cdb83db58829bacc8d5478030b41a20acaf19.tar.gz bcm5719-llvm-5d8cdb83db58829bacc8d5478030b41a20acaf19.zip |
[Format] Cleanup after replacing constructor body with = default
Summary:
Remove colon and commas after replacing constructor body with = default.
Fix annotation of TT_CtorInitializerColon when preceded by a comment.
Reviewers: djasper
Subscribers: cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D25768
llvm-svn: 284732
Diffstat (limited to 'clang/unittests/Format/CleanupTest.cpp')
-rw-r--r-- | clang/unittests/Format/CleanupTest.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/unittests/Format/CleanupTest.cpp b/clang/unittests/Format/CleanupTest.cpp index 77c4d9be81a..ddd90487e56 100644 --- a/clang/unittests/Format/CleanupTest.cpp +++ b/clang/unittests/Format/CleanupTest.cpp @@ -151,6 +151,16 @@ TEST_F(CleanupTest, CtorInitializationSimpleRedundantComma) { EXPECT_EQ(Expected, cleanupAroundOffsets({15}, Code)); } +TEST_F(CleanupTest, CtorInitializationSimpleRedundantColon) { + std::string Code = "class A {\nA() : =default; };"; + std::string Expected = "class A {\nA() =default; };"; + EXPECT_EQ(Expected, cleanupAroundOffsets({15}, Code)); + + Code = "class A {\nA() : , =default; };"; + Expected = "class A {\nA() =default; };"; + EXPECT_EQ(Expected, cleanupAroundOffsets({15}, Code)); +} + TEST_F(CleanupTest, ListRedundantComma) { std::string Code = "void f() { std::vector<int> v = {1,2,,,3,{4,5}}; }"; std::string Expected = "void f() { std::vector<int> v = {1,2,3,{4,5}}; }"; @@ -239,6 +249,14 @@ TEST_F(CleanupTest, RemoveCommentsAroundDeleteCode) { Code = "class A {\nA() : , // comment\n y(1),{} };"; Expected = "class A {\nA() : // comment\n y(1){} };"; EXPECT_EQ(Expected, cleanupAroundOffsets({17}, Code)); + + Code = "class A {\nA() // comment\n : ,,{} };"; + Expected = "class A {\nA() // comment\n {} };"; + EXPECT_EQ(Expected, cleanupAroundOffsets({30}, Code)); + + Code = "class A {\nA() // comment\n : ,,=default; };"; + Expected = "class A {\nA() // comment\n =default; };"; + EXPECT_EQ(Expected, cleanupAroundOffsets({30}, Code)); } TEST_F(CleanupTest, CtorInitializerInNamespace) { |