[llvm] Gsymutil aggregation similar to DwarfDump --verify (PR #81154)
Greg Clayton via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 9 11:45:03 PST 2024
================
@@ -0,0 +1,107 @@
+//===- DwarfTransformer.h ---------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_GSYM_OUTPUTAGGREGATOR_H
+#define LLVM_DEBUGINFO_GSYM_OUTPUTAGGREGATOR_H
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/DebugInfo/GSYM/ExtractRanges.h"
+
+#include <map>
+#include <string>
+
+namespace llvm {
+
+class raw_ostream;
+
+namespace gsym {
+
+class OutputAggregator {
+protected:
+ // A std::map is preferable over an llvm::StringMap for presenting results
+ // in a predictable order.
+ std::map<std::string, unsigned> Aggregation;
+ raw_ostream *Out;
+ bool IncludeDetail;
+
+public:
+ OutputAggregator(raw_ostream *out, bool includeDetail = true)
+ : Out(out), IncludeDetail(includeDetail) {}
+
+ // Do I want a "detail level" thing? I think so, actually...
+ void ShowDetail(bool showDetail) { IncludeDetail = showDetail; }
+ bool IsShowingDetail() const { return IncludeDetail; }
+
+ size_t GetNumCategories() const { return Aggregation.size(); }
+
+ void Report(StringRef s, std::function<void(raw_ostream &o)> detailCallback) {
+ Aggregation[std::string(s)]++;
+ if (IncludeDetail && Out != nullptr)
+ detailCallback(*Out);
+ }
+
+ void Report(StringRef s, std::function<void()> detailCallback) {
+ Aggregation[std::string(s)]++;
+ if (IncludeDetail)
+ detailCallback();
+ }
+
+ void EnumerateResults(
+ std::function<void(StringRef, unsigned)> handleCounts) const {
+ for (auto &&[name, count] : Aggregation) {
+ handleCounts(name, count);
+ }
----------------
clayborg wrote:
remove braces from single line `for` or `if` statements per llvm coding guidelines
https://github.com/llvm/llvm-project/pull/81154
More information about the llvm-commits
mailing list