//===- RemarkCounter.h ----------------------------------------------------===// // // 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 // //===----------------------------------------------------------------------===// // // Generic tool to count remarks based on properties // //===----------------------------------------------------------------------===// #ifndef TOOLS_LLVM_REMARKCOUNTER_H #define TOOLS_LLVM_REMARKCOUNTER_H #include "RemarkUtilHelpers.h" #include "llvm/ADT/MapVector.h" #include "llvm/Support/Regex.h" namespace llvm { namespace remarks { /// Collect remarks by counting the existance of a remark or by looking through /// the keys and summing through the total count. enum class CountBy { … }; /// Summarize the count by either emitting one count for the remark file, or /// grouping the count by source file or by function name. enum class GroupBy { … }; /// Convert \p GroupBy to a std::string. inline std::string groupByToStr(GroupBy GroupBy) { … } /// Filter object which can be either a string or a regex to match with the /// remark properties. struct FilterMatcher { … }; /// Filter out remarks based on remark properties based on name, pass name, /// argument and type. struct Filters { … }; /// Convert Regex string error to an error object. inline Error checkRegex(const Regex &Regex) { … } /// Abstract counter class used to define the general required methods for /// counting a remark. struct Counter { … }; /// Count remarks based on the provided \p Keys argument and summing up the /// value for each matching key organized by source, function or reporting a /// total for the specified remark file. /// Reporting count grouped by source: /// /// | source | key1 | key2 | key3 | /// |---------------|------|------|------| /// | path/to/file1 | 0 | 1 | 3 | /// | path/to/file2 | 1 | 0 | 2 | /// | path/to/file3 | 2 | 3 | 1 | /// /// Reporting count grouped by function: /// /// | Function | key1 | key2 | key3 | /// |---------------|------|------|------| /// | function1 | 0 | 1 | 3 | /// | function2 | 1 | 0 | 2 | /// | function3 | 2 | 3 | 1 | struct ArgumentCounter : Counter { … }; /// Collect remarks based by counting the existance of individual remarks. The /// reported table will be structured based on the provided \p Group argument /// by reporting count for functions, source or total count for the provided /// remark file. struct RemarkCounter : Counter { … }; } // namespace remarks } // namespace llvm #endif // TOOLS_LLVM_REMARKCOUNTER_H