diff options
| author | Daniel Jasper <djasper@google.com> | 2015-06-12 07:15:33 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2015-06-12 07:15:33 +0000 |
| commit | 554e49fe84c56a483b7eaeaf111716cfc4d0b6c0 (patch) | |
| tree | 26b452fa8ca5319a7649e59d70caba3cf4f06771 | |
| parent | 26ceb0845ba0fef388fd322ce71f5a96c19e7fc9 (diff) | |
| download | bcm5719-llvm-554e49fe84c56a483b7eaeaf111716cfc4d0b6c0.tar.gz bcm5719-llvm-554e49fe84c56a483b7eaeaf111716cfc4d0b6c0.zip | |
clang-format: Understand C-style case in case label.
Before:
case (my_int) ONE:
After:
case (my_int)ONE:
This fixed llvm.org/PR23760
llvm-svn: 239597
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 2 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index e45ef603114..3e8659ef853 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1081,7 +1081,7 @@ private: // there is also an identifier before the (). else if (LeftOfParens && Tok.Next && (LeftOfParens->Tok.getIdentifierInfo() == nullptr || - LeftOfParens->is(tok::kw_return)) && + LeftOfParens->isOneOf(tok::kw_return, tok::kw_case)) && !LeftOfParens->isOneOf(TT_OverloadedOperator, tok::at, TT_TemplateCloser)) { if (Tok.Next->isOneOf(tok::identifier, tok::numeric_constant)) { diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 46be32bf4b1..e6df49d4590 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -5818,6 +5818,7 @@ TEST_F(FormatTest, FormatsCasts) { verifyFormat("my_int a = (const my_int *)-1;"); verifyFormat("my_int a = (my_int)(my_int)-1;"); verifyFormat("my_int a = (ns::my_int)-2;"); + verifyFormat("case (my_int)ONE:"); // FIXME: single value wrapped with paren will be treated as cast. verifyFormat("void f(int i = (kValue)*kMask) {}"); |

