diff options
author | Daniel Jasper <djasper@google.com> | 2013-01-15 14:27:39 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-01-15 14:27:39 +0000 |
commit | 7194527d9f5f3c17a51484a7d6f5001ad4280ba7 (patch) | |
tree | 1abe82296ec80260c7e100a08790c18a492e2fce /clang/unittests/Format/FormatTest.cpp | |
parent | d8b1f782961e8492268df3e46b8090365dbe1279 (diff) | |
download | bcm5719-llvm-7194527d9f5f3c17a51484a7d6f5001ad4280ba7.tar.gz bcm5719-llvm-7194527d9f5f3c17a51484a7d6f5001ad4280ba7.zip |
Improve operator kind detection in presence of comments.
We used to incorrectly identify some operators (*, &, +, -, etc.) if
there were comments around them.
Example:
Before: int a = /**/ - 1;
After: int a = /**/ -1;
llvm-svn: 172533
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index e9fa666f907..c6f1c8e4ec7 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1037,6 +1037,10 @@ TEST_F(FormatTest, UnderstandsUnaryOperators) { verifyFormat("const NSPoint kBrowserFrameViewPatternOffset = { -5, +3 };"); verifyFormat("const NSPoint kBrowserFrameViewPatternOffset = { +5, -3 };"); + + verifyFormat("int a = /* confusing comment */ -1;"); + // FIXME: The space after 'i' is wrong, but hopefully, this is a rare case. + verifyFormat("int a = i /* confusing comment */++;"); } TEST_F(FormatTest, UndestandsOverloadedOperators) { @@ -1123,6 +1127,13 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyFormat("*(x + y).call();"); verifyFormat("&(x + y)->call();"); verifyFormat("&(*I).first"); + + verifyFormat("f(b * /* confusing comment */ ++c);"); + verifyFormat( + "int *MyValues = {\n" + " *A, // Operator detection might be confused by the '{'\n" + " *BB // Operator detection might be confused by previous comment\n" + "};"); } TEST_F(FormatTest, FormatsCasts) { |