Merge "[header-checker] Use new jsoncpp API"

This commit is contained in:
Haibo Huang
2021-03-11 18:26:15 +00:00
committed by Gerrit Code Review
2 changed files with 8 additions and 8 deletions

View File

@@ -362,10 +362,9 @@ bool JsonIRDumper::AddElfSymbolMessageIR(const ElfSymbolIR *elf_symbol_ir) {
} }
static std::string DumpJson(const JsonObject &obj) { static std::string DumpJson(const JsonObject &obj) {
std::ostringstream output_stream; Json::StreamWriterBuilder factory;
Json::StyledStreamWriter writer(/* indentation */ " "); factory["indentation"] = " ";
writer.write(output_stream, obj); return Json::writeString(factory, obj);
return output_stream.str();
} }
static void WriteTailTrimmedLinesToFile(const std::string &path, static void WriteTailTrimmedLinesToFile(const std::string &path,

View File

@@ -154,12 +154,13 @@ GetElfSymbolBinding(const JsonObjectRef &elf_symbol) {
bool JsonIRReader::ReadDumpImpl(const std::string &dump_file) { bool JsonIRReader::ReadDumpImpl(const std::string &dump_file) {
Json::Value tu_json; Json::Value tu_json;
Json::Reader reader; Json::CharReaderBuilder builder;
builder["collectComments"] = false;
std::ifstream input(dump_file); std::ifstream input(dump_file);
if (!reader.parse(input, tu_json, /* collectComments */ false)) { std::string errorMessage;
llvm::errs() << "Failed to parse JSON: " if (!Json::parseFromStream(builder, input, &tu_json, &errorMessage)) {
<< reader.getFormattedErrorMessages() << "\n"; llvm::errs() << "Failed to parse JSON: " << errorMessage << "\n";
return false; return false;
} }
bool ok = true; bool ok = true;