diff options
author | Nico Weber <nicolasweber@gmx.de> | 2017-04-11 15:50:04 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2017-04-11 15:50:04 +0000 |
commit | 48c94a6164192b05c5c19d07c0fda4b38e8eed5a (patch) | |
tree | 66961b967d4b81e78f8a02c6be48ff97f4e42f65 /clang/unittests/Format/FormatTestJava.cpp | |
parent | 46103e0ede41cef3ddce5f5194c258f6de607acd (diff) | |
download | llvm-48c94a6164192b05c5c19d07c0fda4b38e8eed5a.zip llvm-48c94a6164192b05c5c19d07c0fda4b38e8eed5a.tar.gz llvm-48c94a6164192b05c5c19d07c0fda4b38e8eed5a.tar.bz2 |
[clang-format] Recognize Java logical shift assignment operator
At present, clang-format mangles Java containing logical right shift operators
('>>>=' or '>>>'), splitting them in two, resulting in invalid code:
public class Minimal {
public void func(String args) {
int i = 42;
- i >>>= 1;
+ i >> >= 1;
return i;
}
}
This adds both forms of logical right shift to the FormatTokenLexer, so
clang-format won't attempt to split them and insert bogus whitespace.
https://reviews.llvm.org/D31652
Patch from Richard Bradfield <bradfier@fstab.me>!
llvm-svn: 299952
Diffstat (limited to 'clang/unittests/Format/FormatTestJava.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTestJava.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestJava.cpp b/clang/unittests/Format/FormatTestJava.cpp index ee09ca9..6e685f6 100644 --- a/clang/unittests/Format/FormatTestJava.cpp +++ b/clang/unittests/Format/FormatTestJava.cpp @@ -522,5 +522,17 @@ TEST_F(FormatTestJava, AlignsBlockComments) { " void f() {}")); } +TEST_F(FormatTestJava, RetainsLogicalShifts) { + verifyFormat("void f() {\n" + " int a = 1;\n" + " a >>>= 1;\n" + "}"); + verifyFormat("void f() {\n" + " int a = 1;\n" + " a = a >>> 1;\n" + "}"); +} + + } // end namespace tooling } // end namespace clang |