diff --git a/clang-tools-extra/clang-format/ClangFormat.cpp b/clang-tools-extra/clang-format/ClangFormat.cpp index 7b3da2d1e5aa..d34f533cbf50 100644 --- a/clang-tools-extra/clang-format/ClangFormat.cpp +++ b/clang-tools-extra/clang-format/ClangFormat.cpp @@ -38,8 +38,8 @@ static cl::opt Style( static cl::opt Inplace("i", cl::desc("Inplace edit , if specified.")); -static cl::opt OutputReplacements( - "output-replacements", cl::desc("Output replacements as JSON.")); +static cl::opt OutputXML( + "output-replacements-xml", cl::desc("Output replacements as XML.")); // FIXME: Remove this when styles are configurable through files. static cl::opt InvertPointerBinding( @@ -107,22 +107,17 @@ static void format() { Ranges.push_back(CharSourceRange::getCharRange(Start, End)); } tooling::Replacements Replaces = reformat(getStyle(), Lex, Sources, Ranges); - if (OutputReplacements) { - llvm::outs() << "[\n"; + if (OutputXML) { + llvm::outs() << "\n\n"; for (tooling::Replacements::const_iterator I = Replaces.begin(), E = Replaces.end(); I != E; ++I) { - if (I != Replaces.begin()) { - llvm::outs() << ",\n"; - } - llvm::outs() << " {\n" - << " \"offset\": " << I->getOffset() << ",\n" - << " \"length\": " << I->getLength() << ",\n" - << " \"replacement_text\": \"" << I->getReplacementText() - << "\"\n" - << " }"; + llvm::outs() << "" + << I->getReplacementText() << "\n"; } - llvm::outs() << "\n]\n"; + llvm::outs() << "\n"; } else { Rewriter Rewrite(Sources, LangOptions()); tooling::applyAllReplacements(Replaces, Rewrite);