aboutsummaryrefslogtreecommitdiff
path: root/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-01-15 14:27:39 +0000
committerDaniel Jasper <djasper@google.com>2013-01-15 14:27:39 +0000
commitb369c2cb31358f749b9ced97440a6c457f38eaae (patch)
treed9ddaae2938d116c0ca0e49ea4f981c62a119f20 /unittests/Format/FormatTest.cpp
parent47ea7f64108163491ed74dc746c8d94e10764704 (diff)
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; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172533 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format/FormatTest.cpp')
-rw-r--r--unittests/Format/FormatTest.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index e9fa666f90..c6f1c8e4ec 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/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) {