Skip to content

Commit c84d5b5

Browse files
Kevin Freikevinfrei
Kevin Frei
authored andcommitted
Updated to use explicit JSON objects, renamed flag to --json-summary-file
1 parent 9e0ef03 commit c84d5b5

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

llvm/include/llvm/DebugInfo/DIContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ struct DIDumpOptions {
206206
bool IsEH = false;
207207
bool DumpNonSkeleton = false;
208208
bool ShowAggregateErrors = false;
209-
std::string AggregateErrJsonFile = "";
209+
std::string JsonSummaryFile = "";
210210
std::function<llvm::StringRef(uint64_t DwarfRegNum, bool IsEH)>
211211
GetNameForDWARFReg;
212212

llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "llvm/Support/ErrorHandling.h"
3333
#include "llvm/Support/FileSystem.h"
3434
#include "llvm/Support/FormatVariadic.h"
35+
#include "llvm/Support/JSON.h"
3536
#include "llvm/Support/WithColor.h"
3637
#include "llvm/Support/raw_ostream.h"
3738
#include <map>
@@ -2036,27 +2037,26 @@ void DWARFVerifier::summarize() {
20362037
error() << s << " occurred " << count << " time(s).\n";
20372038
});
20382039
}
2039-
if (!DumpOpts.AggregateErrJsonFile.empty()) {
2040+
if (!DumpOpts.JsonSummaryFile.empty()) {
20402041
std::error_code EC;
2041-
raw_fd_ostream JsonStream(DumpOpts.AggregateErrJsonFile, EC,
2042-
sys::fs::OF_Text);
2042+
raw_fd_ostream JsonStream(DumpOpts.JsonSummaryFile, EC, sys::fs::OF_Text);
20432043
if (EC) {
20442044
error() << "error opening aggregate error json file '"
2045-
<< DumpOpts.AggregateErrJsonFile
2046-
<< "' for writing: " << EC.message() << '\n';
2045+
<< DumpOpts.JsonSummaryFile << "' for writing: " << EC.message()
2046+
<< '\n';
20472047
return;
20482048
}
2049-
JsonStream << "{\"errors\":[\n";
2050-
bool prev = false;
2049+
2050+
llvm::json::Object Categories;
20512051
ErrorCategory.EnumerateResults([&](StringRef category, unsigned count) {
2052-
if (prev)
2053-
JsonStream << ",\n";
2054-
JsonStream << "{\"category\":\"";
2055-
llvm::printEscapedString(category, JsonStream);
2056-
JsonStream << "\",\"count\":" << count << "}";
2057-
prev = true;
2052+
llvm::json::Object Val;
2053+
Val.try_emplace("count", count);
2054+
Categories.try_emplace(category, std::move(Val));
20582055
});
2059-
JsonStream << "\n]}\n";
2056+
llvm::json::Object RootNode;
2057+
RootNode.try_emplace("error-categories", std::move(Categories));
2058+
2059+
JsonStream << llvm::json::Value(std::move(RootNode));
20602060
}
20612061
}
20622062

llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ static opt<ErrorDetailLevel> ErrorDetails(
295295
clEnumValN(BothDetailsAndSummary, "full",
296296
"Display each error as well as a summary. [default]")),
297297
cat(DwarfDumpCategory));
298-
static opt<std::string> AggregationJsonFile(
299-
"aggregate-output-file", cl::init(""),
298+
static opt<std::string> JsonSummaryFile(
299+
"json-summary-file", cl::init(""),
300300
cl::desc("When using --verify, output JSON-formatted error summary to the "
301301
"specified file."),
302302
cl::value_desc("filename.json"), cat(DwarfDumpCategory));
@@ -354,7 +354,7 @@ static DIDumpOptions getDumpOpts(DWARFContext &C) {
354354
ErrorDetails != NoDetailsOrSummary;
355355
DumpOpts.ShowAggregateErrors = ErrorDetails != OnlyDetailsNoSummary &&
356356
ErrorDetails != NoDetailsOnlySummary;
357-
DumpOpts.AggregateErrJsonFile = AggregationJsonFile;
357+
DumpOpts.JsonSummaryFile = JsonSummaryFile;
358358
return DumpOpts.noImplicitRecursion();
359359
}
360360
return DumpOpts;
@@ -842,9 +842,8 @@ int main(int argc, char **argv) {
842842
}
843843
if (!Verify && ErrorDetails != Unspecified)
844844
WithColor::warning() << "-error-detail has no affect without -verify";
845-
if (!Verify && !AggregationJsonFile.empty())
846-
WithColor::warning()
847-
<< "-aggregate-output-file has no affect without -verify";
845+
if (!Verify && !JsonSummaryFile.empty())
846+
WithColor::warning() << "-json-summary-file has no affect without -verify";
848847

849848
std::error_code EC;
850849
ToolOutputFile OutputFile(OutputFilename, EC, sys::fs::OF_TextWithCRLF);

0 commit comments

Comments
 (0)