summaryrefslogtreecommitdiffstats
path: root/tools/clang-format/ClangFormat.cpp
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2016-08-01 10:16:37 +0000
committerEric Liu <ioeric@google.com>2016-08-01 10:16:37 +0000
commit85c0fa18d965d4ed91e037a085e4c20bcea7e27f (patch)
treec01feb771ce1fadf36ee0e2473b001d3405458bd /tools/clang-format/ClangFormat.cpp
parent1505139f741e601408dc4aaddf8e352d28085f00 (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@277335 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/clang-format/ClangFormat.cpp')
-rw-r--r--tools/clang-format/ClangFormat.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/clang-format/ClangFormat.cpp b/tools/clang-format/ClangFormat.cpp
index 6dbb6479ea..3b893e04b3 100644
--- a/tools/clang-format/ClangFormat.cpp
+++ b/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());