diff options
| author | Krasimir Georgiev <krasimir@google.com> | 2017-04-21 14:35:20 +0000 |
|---|---|---|
| committer | Krasimir Georgiev <krasimir@google.com> | 2017-04-21 14:35:20 +0000 |
| commit | bcda54b69d4b6abe75c4c18f155433bfee216d72 (patch) | |
| tree | 0abb4eb7e03f4f26234516d45b715a70711896ec /clang/tools | |
| parent | d631b9e500e1cdfba439ea1b05ffbf2f44a11e1b (diff) | |
| download | bcm5719-llvm-bcda54b69d4b6abe75c4c18f155433bfee216d72.tar.gz bcm5719-llvm-bcda54b69d4b6abe75c4c18f155433bfee216d72.zip | |
[clang-format] Replace IncompleteFormat by a struct with Line
Summary: This patch replaces the boolean IncompleteFormat that is used to notify the client if an unrecoverable syntax error occurred by a struct that also contains a line number.
Reviewers: djasper
Reviewed By: djasper
Subscribers: cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D32298
llvm-svn: 300985
Diffstat (limited to 'clang/tools')
| -rw-r--r-- | clang/tools/clang-format/ClangFormat.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index ac0d0a8512f..14bff19a1a0 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -276,14 +276,17 @@ static bool format(StringRef FileName) { } // Get new affected ranges after sorting `#includes`. Ranges = tooling::calculateRangesAfterReplacements(Replaces, Ranges); - bool IncompleteFormat = false; + FormattingAttemptStatus Status; Replacements FormatChanges = reformat(*FormatStyle, *ChangedCode, Ranges, - AssumedFileName, &IncompleteFormat); + AssumedFileName, &Status); Replaces = Replaces.merge(FormatChanges); if (OutputXML) { outs() << "<?xml version='1.0'?>\n<replacements " "xml:space='preserve' incomplete_format='" - << (IncompleteFormat ? "true" : "false") << "'>\n"; + << (Status.FormatComplete ? "false" : "true") << "'"; + if (!Status.FormatComplete) + outs() << " line=" << Status.Line; + outs() << ">\n"; if (Cursor.getNumOccurrences() != 0) outs() << "<cursor>" << FormatChanges.getShiftedCodePosition(CursorPosition) @@ -307,11 +310,15 @@ static bool format(StringRef FileName) { if (Rewrite.overwriteChangedFiles()) return true; } else { - if (Cursor.getNumOccurrences() != 0) + if (Cursor.getNumOccurrences() != 0) { outs() << "{ \"Cursor\": " << FormatChanges.getShiftedCodePosition(CursorPosition) << ", \"IncompleteFormat\": " - << (IncompleteFormat ? "true" : "false") << " }\n"; + << (Status.FormatComplete ? "false" : "true"); + if (!Status.FormatComplete) + outs() << ", \"Line\": " << Status.Line; + outs() << " }\n"; + } Rewrite.getEditBuffer(ID).write(outs()); } } |

