diff options
author | Eric Liu <ioeric@google.com> | 2016-08-01 10:16:37 +0000 |
---|---|---|
committer | Eric Liu <ioeric@google.com> | 2016-08-01 10:16:37 +0000 |
commit | 40ef2fb363bcd89cb4a88157f5fa97a38d795a1f (patch) | |
tree | 0817f1606ccb51b55370c8b10346d519be9aec97 /clang/tools/clang-format | |
parent | 5c9583981b5e73ac42d224ec97bd8470a384da26 (diff) | |
download | bcm5719-llvm-40ef2fb363bcd89cb4a88157f5fa97a38d795a1f.tar.gz bcm5719-llvm-40ef2fb363bcd89cb4a88157f5fa97a38d795a1f.zip |
Implement tooling::Replacements as a class.
Summary:
- Implement clang::tooling::Replacements as a class to provide interfaces to
control how replacements for a single file are combined and provide guarantee
on the order of replacements being applied.
- tooling::Replacements only contains replacements for the same file now.
Use std::map<std::string, tooling::Replacements> to represent multi-file
replacements.
- Error handling for the interface change will be improved in followup patches.
Reviewers: djasper, klimek
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D21748
llvm-svn: 277335
Diffstat (limited to 'clang/tools/clang-format')
-rw-r--r-- | clang/tools/clang-format/ClangFormat.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index 6dbb6479ea4..3b893e04b32 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -266,17 +266,17 @@ static bool format(StringRef FileName) { bool IncompleteFormat = false; Replacements FormatChanges = reformat(FormatStyle, *ChangedCode, Ranges, AssumedFileName, &IncompleteFormat); - Replaces = tooling::mergeReplacements(Replaces, FormatChanges); + Replaces = Replaces.merge(FormatChanges); if (OutputXML) { outs() << "<?xml version='1.0'?>\n<replacements " "xml:space='preserve' incomplete_format='" << (IncompleteFormat ? "true" : "false") << "'>\n"; if (Cursor.getNumOccurrences() != 0) outs() << "<cursor>" - << tooling::shiftedCodePosition(FormatChanges, CursorPosition) + << FormatChanges.getShiftedCodePosition(CursorPosition) << "</cursor>\n"; - outputReplacementsXML(Replaces); + outputReplacementsXML(Replaces); outs() << "</replacements>\n"; } else { IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem( @@ -298,7 +298,7 @@ static bool format(StringRef FileName) { } else { if (Cursor.getNumOccurrences() != 0) outs() << "{ \"Cursor\": " - << tooling::shiftedCodePosition(FormatChanges, CursorPosition) + << FormatChanges.getShiftedCodePosition(CursorPosition) << ", \"IncompleteFormat\": " << (IncompleteFormat ? "true" : "false") << " }\n"; Rewrite.getEditBuffer(ID).write(outs()); |