Skip to content

Commit a9e2e26

Browse files
committed
Fix a misplaced ( and add more tests
1 parent 9eb81c8 commit a9e2e26

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

clang/test/Format/dry-run-warning.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,20 @@
33
// RUN: echo '}' >> %t.json
44

55
// RUN: clang-format -n -style=LLVM %t.json 2>&1 | FileCheck %s -allow-empty
6-
// CHECK-NOT: warning
76

87
// RUN: clang-format -n -style=LLVM < %t.json 2>&1 \
98
// RUN: | FileCheck %s -check-prefix=CHECK2 -strict-whitespace
10-
// CHECK2: warning: code should be clang-formatted
9+
10+
// RUN: echo '{' > %t.json
11+
// RUN: echo ' "married" : true' >> %t.json
12+
// RUN: echo '}' >> %t.json
13+
14+
// RUN: clang-format -n -style=LLVM < %t.json 2>&1 | FileCheck %s -allow-empty
15+
16+
// RUN: clang-format -n -style=LLVM %t.json 2>&1 \
17+
// RUN: | FileCheck %s -check-prefix=CHECK2 -strict-whitespace
1118

1219
// RUN: rm %t.json
20+
21+
// CHECK-NOT: warning
22+
// CHECK2: warning: code should be clang-formatted

clang/tools/clang-format/ClangFormat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ static bool format(StringRef FileName, bool ErrorOnIncompleteFormat = false) {
511511
Replaces = Replaces.merge(FormatChanges);
512512
if (OutputXML || DryRun) {
513513
if (DryRun) {
514-
return (Replaces.size() > IsJson ? 1 : 0) &&
514+
return Replaces.size() > (IsJson ? 1 : 0) &&
515515
emitReplacementWarnings(Replaces, AssumedFileName, Code);
516516
}
517517
outputXML(Replaces, FormatChanges, Status, Cursor, CursorPosition);

0 commit comments

Comments
 (0)