#include "RemarkCounter.h"
#include "RemarkUtilRegistry.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Regex.h"
usingnamespacellvm;
usingnamespaceremarks;
usingnamespacellvm::remarkutil;
static cl::SubCommand CountSub("count",
"Collect remarks based on specified criteria.");
INPUT_FORMAT_COMMAND_LINE_OPTIONS(…)
INPUT_OUTPUT_COMMAND_LINE_OPTIONS(…)
static cl::list<std::string>
Keys("args", cl::desc("Specify remark argument/s to count by."),
cl::value_desc("arguments"), cl::sub(CountSub), cl::ValueOptional);
static cl::list<std::string> RKeys(
"rargs",
cl::desc(
"Specify remark argument/s to count (accepts regular expressions)."),
cl::value_desc("arguments"), cl::sub(CountSub), cl::ValueOptional);
static cl::opt<std::string>
RemarkNameOpt("remark-name",
cl::desc("Optional remark name to filter collection by."),
cl::ValueOptional, cl::sub(CountSub));
static cl::opt<std::string>
PassNameOpt("pass-name", cl::ValueOptional,
cl::desc("Optional remark pass name to filter collection by."),
cl::sub(CountSub));
static cl::opt<std::string> RemarkFilterArgByOpt(
"filter-arg-by", cl::desc("Optional remark arg to filter collection by."),
cl::ValueOptional, cl::sub(CountSub));
static cl::opt<std::string>
RemarkNameOptRE("rremark-name",
cl::desc("Optional remark name to filter collection by "
"(accepts regular expressions)."),
cl::ValueOptional, cl::sub(CountSub));
static cl::opt<std::string>
RemarkArgFilterOptRE("rfilter-arg-by",
cl::desc("Optional remark arg to filter collection by "
"(accepts regular expressions)."),
cl::sub(CountSub), cl::ValueOptional);
static cl::opt<std::string>
PassNameOptRE("rpass-name", cl::ValueOptional,
cl::desc("Optional remark pass name to filter collection "
"by (accepts regular expressions)."),
cl::sub(CountSub));
static cl::opt<Type> RemarkTypeOpt(
"remark-type", cl::desc("Optional remark type to filter collection by."),
cl::values(clEnumValN(Type::Unknown, "unknown", "UNKOWN"),
clEnumValN(Type::Passed, "passed", "PASSED"),
clEnumValN(Type::Missed, "missed", "MISSED"),
clEnumValN(Type::Analysis, "analysis", "ANALYSIS"),
clEnumValN(Type::AnalysisFPCommute, "analysis-fp-commute",
"ANALYSIS_FP_COMMUTE"),
clEnumValN(Type::AnalysisAliasing, "analysis-aliasing",
"ANALYSIS_ALIASING"),
clEnumValN(Type::Failure, "failure", "FAILURE")),
cl::init(Type::Failure), cl::sub(CountSub));
static cl::opt<CountBy> CountByOpt(
"count-by", cl::desc("Specify the property to collect remarks by."),
cl::values(
clEnumValN(CountBy::REMARK, "remark-name",
"Counts individual remarks based on how many of the remark "
"exists."),
clEnumValN(CountBy::ARGUMENT, "arg",
"Counts based on the value each specified argument has. The "
"argument has to have a number value to be considered.")),
cl::init(CountBy::REMARK), cl::sub(CountSub));
static cl::opt<GroupBy> GroupByOpt(
"group-by", cl::desc("Specify the property to group remarks by."),
cl::values(
clEnumValN(
GroupBy::PER_SOURCE, "source",
"Display the count broken down by the filepath of each remark "
"emitted. Requires remarks to have DebugLoc information."),
clEnumValN(GroupBy::PER_FUNCTION, "function",
"Breakdown the count by function name."),
clEnumValN(
GroupBy::PER_FUNCTION_WITH_DEBUG_LOC, "function-with-loc",
"Breakdown the count by function name taking into consideration "
"the filepath info from the DebugLoc of the remark."),
clEnumValN(GroupBy::TOTAL, "total",
"Output the total number corresponding to the count for the "
"provided input file.")),
cl::init(GroupBy::PER_SOURCE), cl::sub(CountSub));
static unsigned getValForKey(StringRef Key, const Remark &Remark) { … }
Error Filters::regexArgumentsValid() { … }
bool Filters::filterRemark(const Remark &Remark) { … }
Error ArgumentCounter::getAllMatchingArgumentsInRemark(
StringRef Buffer, ArrayRef<FilterMatcher> Arguments, Filters &Filter) { … }
std::optional<std::string> Counter::getGroupByKey(const Remark &Remark) { … }
void ArgumentCounter::collect(const Remark &Remark) { … }
void RemarkCounter::collect(const Remark &Remark) { … }
Error ArgumentCounter::print(StringRef OutputFileName) { … }
Error RemarkCounter::print(StringRef OutputFileName) { … }
Expected<Filters> getRemarkFilter() { … }
Error useCollectRemark(StringRef Buffer, Counter &Counter, Filters &Filter) { … }
static Error collectRemarks() { … }
static CommandRegistration CountReg(&CountSub, collectRemarks);