File indexing completed on 2026-05-10 08:43:42
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_DEBUGINFO_GSYM_OUTPUTAGGREGATOR_H
0010 #define LLVM_DEBUGINFO_GSYM_OUTPUTAGGREGATOR_H
0011
0012 #include "llvm/ADT/StringRef.h"
0013 #include "llvm/DebugInfo/GSYM/ExtractRanges.h"
0014
0015 #include <map>
0016 #include <string>
0017
0018 namespace llvm {
0019
0020 class raw_ostream;
0021
0022 namespace gsym {
0023
0024 class OutputAggregator {
0025 protected:
0026
0027
0028 std::map<std::string, unsigned> Aggregation;
0029 raw_ostream *Out;
0030
0031 public:
0032 OutputAggregator(raw_ostream *out) : Out(out) {}
0033
0034 size_t GetNumCategories() const { return Aggregation.size(); }
0035
0036 void Report(StringRef s, std::function<void(raw_ostream &o)> detailCallback) {
0037 Aggregation[std::string(s)]++;
0038 if (GetOS())
0039 detailCallback(*Out);
0040 }
0041
0042 void EnumerateResults(
0043 std::function<void(StringRef, unsigned)> handleCounts) const {
0044 for (auto &&[name, count] : Aggregation)
0045 handleCounts(name, count);
0046 }
0047
0048 raw_ostream *GetOS() const { return Out; }
0049
0050
0051
0052
0053 template <typename T> OutputAggregator &operator<<(T &&value) {
0054 if (Out != nullptr)
0055 *Out << value;
0056 return *this;
0057 }
0058
0059
0060
0061
0062 void Merge(const OutputAggregator &other) {
0063 for (auto &&[name, count] : other.Aggregation)
0064 Aggregation[name] += count;
0065 }
0066 };
0067
0068 }
0069 }
0070
0071 #endif