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) {
std::ostringstream output_stream;
Json::StyledStreamWriter writer(/* indentation */ " ");
writer.write(output_stream, obj);
return output_stream.str();
Json::StreamWriterBuilder factory;
factory["indentation"] = " ";
return Json::writeString(factory, obj);
}
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) {
Json::Value tu_json;
Json::Reader reader;
Json::CharReaderBuilder builder;
builder["collectComments"] = false;
std::ifstream input(dump_file);
if (!reader.parse(input, tu_json, /* collectComments */ false)) {
llvm::errs() << "Failed to parse JSON: "
<< reader.getFormattedErrorMessages() << "\n";
std::string errorMessage;
if (!Json::parseFromStream(builder, input, &tu_json, &errorMessage)) {
llvm::errs() << "Failed to parse JSON: " << errorMessage << "\n";
return false;
}
bool ok = true;