diff options
| author | Daniel Jasper <djasper@google.com> | 2015-05-08 15:36:30 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2015-05-08 15:36:30 +0000 |
| commit | e44e5665d4a38aa7da6b3b500e6fc8c68c73285a (patch) | |
| tree | 723442d855a43386472f693735111c93be8e9e4a | |
| parent | ec1fc97e5da00a4bfbb16ac74449b2e042dc37cb (diff) | |
| download | bcm5719-llvm-e44e5665d4a38aa7da6b3b500e6fc8c68c73285a.tar.gz bcm5719-llvm-e44e5665d4a38aa7da6b3b500e6fc8c68c73285a.zip | |
clang-format: Only output IncompleteFormat if -cursor is given.
This is only for editor integrations.
llvm-svn: 236867
| -rw-r--r-- | clang/test/Format/incomplete.cpp | 4 | ||||
| -rw-r--r-- | clang/tools/clang-format/ClangFormat.cpp | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/clang/test/Format/incomplete.cpp b/clang/test/Format/incomplete.cpp index ade38b66a39..b66d5f816ea 100644 --- a/clang/test/Format/incomplete.cpp +++ b/clang/test/Format/incomplete.cpp @@ -1,7 +1,7 @@ // RUN: grep -Ev "// *[A-Z-]+:" %s > %t2.cpp // RUN: clang-format -style=LLVM %t2.cpp > %t.cpp -// RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s -// CHECK: {{^\{ "IncompleteFormat": true }} +// RUN: FileCheck -strict-whitespace -cursor=0 -input-file=%t.cpp %s +// CHECK: {{"IncompleteFormat": true}} // CHECK: {{^int\ \i;$}} int i; // CHECK: {{^f \( g \(;$}} diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index ae2180c8370..5037e901f3b 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -226,7 +226,8 @@ static bool format(StringRef FileName) { FormatStyle FormatStyle = getStyle( Style, (FileName == "-") ? AssumeFilename : FileName, FallbackStyle); bool IncompleteFormat = false; - tooling::Replacements Replaces = reformat(FormatStyle, Sources, ID, Ranges, &IncompleteFormat); + tooling::Replacements Replaces = + reformat(FormatStyle, Sources, ID, Ranges, &IncompleteFormat); if (OutputXML) { llvm::outs() << "<?xml version='1.0'?>\n<replacements " "xml:space='preserve' incomplete_format='" @@ -255,12 +256,11 @@ static bool format(StringRef FileName) { else if (Rewrite.overwriteChangedFiles()) return true; } else { - outs() << "{"; if (Cursor.getNumOccurrences() != 0) - outs() << " \"Cursor\": " - << tooling::shiftedCodePosition(Replaces, Cursor) << ","; - outs() << " \"IncompleteFormat\": " - << (IncompleteFormat ? "true" : "false") << " }\n"; + outs() << "{ \"Cursor\": " + << tooling::shiftedCodePosition(Replaces, Cursor) + << ", \"IncompleteFormat\": " + << (IncompleteFormat ? "true" : "false") << " }\n"; Rewrite.getEditBuffer(ID).write(outs()); } } |

