Skip to content

Commit 0603737

Browse files
committed
[llvm-remarkutil] Fix issues after #66214 and its fixups
Don't use reserved identifier (_GroupBy) Fix GCC 7.4/7.5 builds (return Filter => return std::move(Filter)) Remove trailing spaces
1 parent 8dd3bc1 commit 0603737

14 files changed

+50
-51
lines changed

llvm/docs/CommandGuide/llvm-remarkutil.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ CSV format is as follows:
7575
Function,InstructionCount
7676
foo,123
7777

78-
if `--use-debug-loc` is passed then the CSV will include the source path, line number and column.
78+
if `--use-debug-loc` is passed then the CSV will include the source path, line number and column.
7979

8080
::
8181
Source,Function,InstructionCount
@@ -104,7 +104,7 @@ CSV format is as follows:
104104
Function,Count
105105
foo,123
106106

107-
if `--use-debug-loc` is passed then the CSV will include the source path, line number and column.
107+
if `--use-debug-loc` is passed then the CSV will include the source path, line number and column.
108108

109109
::
110110
Source,Function,Count
@@ -122,7 +122,7 @@ USAGE: :program:`llvm-remarkutil` count [*options*] <input file>
122122
Summary
123123
^^^^^^^
124124

125-
:program:`llvm-remarkutil count` counts `remarks <https://llvm.org/docs/Remarks.html>` based on specified properties.
125+
:program:`llvm-remarkutil count` counts `remarks <https://llvm.org/docs/Remarks.html>` based on specified properties.
126126
By default the tool counts remarks based on how many occour in a source file or function or total for the generated remark file.
127127
The tool also supports collecting count based on specific remark arguments. The specified arguments should have an integer value to be able to report a count.
128128

@@ -143,15 +143,15 @@ OPTIONS
143143

144144
.. option:: --group-by=<value>
145145
group count of remarks by property.
146-
* ``source``: Count will be collected per source path. Remarks with no debug location will not be counted.
146+
* ``source``: Count will be collected per source path. Remarks with no debug location will not be counted.
147147
* ``function``: Count is collected per function.
148-
* ``function-with-loc``: Count is collected per function per source. Remarks with no debug location will not be counted.
148+
* ``function-with-loc``: Count is collected per function per source. Remarks with no debug location will not be counted.
149149
* ``Total``: Report a count for the provided remark file.
150150

151151
.. option:: --args[=arguments]
152152
If `count-by` is set to `arg` this flag can be used to collect from specified remark arguments represented as a comma seperated string.
153153
The arguments must have a numeral value to be able to count remarks by
154-
154+
155155
.. option:: --rargs[=arguments]
156156
If `count-by` is set to `arg` this flag can be used to collect from specified remark arguments using regular expression.
157157
The arguments must have a numeral value to be able to count remarks by
@@ -177,12 +177,12 @@ OPTIONS
177177
.. option:: --remark-type=<value>
178178
Filter remarks by type with the following options.
179179
* ``unknown``
180-
* ``passed``
181-
* ``missed``
182-
* ``analysis``
180+
* ``passed``
181+
* ``missed``
182+
* ``analysis``
183183
* ``analysis-fp-commute``
184-
* ``analysis-aliasing``
185-
* ``failure``
184+
* ``analysis-aliasing``
185+
* ``failure``
186186

187187
.. _size-diff_subcommand:
188188

llvm/test/tools/llvm-remarkutil/Inputs/annotation-count-with-dbg-loc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Args:
1212
Pass: annotation-remarks
1313
Name: AnnotationSummary
1414
DebugLoc: { File: path/to/anno2.c, Line: 1, Column: 2 }
15-
Function: func2
15+
Function: func2
1616
Args:
1717
- String: 'Annotated '
1818
- count: '2'

llvm/test/tools/llvm-remarkutil/Inputs/annotation-count.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--- !Analysis
22
Pass: annotation-remarks
33
Name: AnnotationSummary
4-
Function: func1
4+
Function: func1
55
Args:
66
- String: 'Annotated '
77
- count: '1'
@@ -10,7 +10,7 @@ Args:
1010
--- !Analysis
1111
Pass: annotation-remarks
1212
Name: AnnotationSummary
13-
Function: func2
13+
Function: func2
1414
Args:
1515
- String: 'Annotated '
1616
- count: '2'

llvm/test/tools/llvm-remarkutil/count/Inputs/remark-count-by.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- !Analysis
22
Pass: generic-remarks-pass
3-
Name: Remark
3+
Name: Remark
44
DebugLoc: { File: path/to/anno.c, Line: 1, Column: 2 }
55
Function: func1
66
Args:
@@ -23,7 +23,7 @@ Args:
2323
- type: remark
2424
--- !Analysis
2525
Pass: generic-remarks-pass
26-
Name: Remark3
26+
Name: Remark3
2727
DebugLoc: { File: path/to/anno.c, Line: 1, Column: 2 }
2828
Function: func1
2929
Args:
@@ -32,7 +32,7 @@ Args:
3232
- type: remark
3333
--- !Analysis
3434
Pass: generic-remarks-pass
35-
Name: Remark
35+
Name: Remark
3636
DebugLoc: { File: path/to/anno.c, Line: 1, Column: 2 }
3737
Function: func2
3838
Args:

llvm/test/tools/llvm-remarkutil/count/Inputs/remark-filter-by.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- !Analysis
22
Pass: generic-remarks-pass
3-
Name: Remark
3+
Name: Remark
44
DebugLoc: { File: path/to/anno2.c, Line: 1, Column: 2 }
55
Function: func1
66
Args:
@@ -20,7 +20,7 @@ Args:
2020
- type: remark
2121
--- !Missed
2222
Pass: generic-remarks-pass
23-
Name: Remark3
23+
Name: Remark3
2424
DebugLoc: { File: path/to/anno.c, Line: 1, Column: 2 }
2525
Function: func1
2626
Args:
@@ -29,7 +29,7 @@ Args:
2929
- type: remark
3030
--- !Passed
3131
Pass: generic-remarks-pass
32-
Name: Remark
32+
Name: Remark
3333
DebugLoc: { File: path/to/anno.c, Line: 1, Column: 2 }
3434
Function: func1
3535
Args:

llvm/test/tools/llvm-remarkutil/count/Inputs/remark-group-by.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- !Analysis
22
Pass: generic-remarks-pass
3-
Name: Remark
3+
Name: Remark
44
DebugLoc: { File: path/to/anno.c, Line: 1, Column: 2 }
55
Function: func1
66
Args:
@@ -9,7 +9,7 @@ Args:
99
- type: remark
1010
--- !Missed
1111
Pass: generic-remarks-pass
12-
Name: Remark
12+
Name: Remark
1313
DebugLoc: { File: path/to/anno.c, Line: 1, Column: 2 }
1414
Function: func1
1515
Args:
@@ -18,7 +18,7 @@ Args:
1818
- type: remark
1919
--- !Passed
2020
Pass: generic-remarks-pass
21-
Name: Remark
21+
Name: Remark
2222
DebugLoc: { File: path/to/anno.c, Line: 1, Column: 2 }
2323
Function: func2
2424
Args:
@@ -27,7 +27,7 @@ Args:
2727
- type: remark
2828
--- !Analysis
2929
Pass: generic-remarks-pass2
30-
Name: Remark
30+
Name: Remark
3131
DebugLoc: { File: path/to/anno3.c, Line: 1, Column: 2 }
3232
Function: func1
3333
Args:
@@ -36,7 +36,7 @@ Args:
3636
- type: remark
3737
--- !Analysis
3838
Pass: generic-remarks-pass3
39-
Name: Remark
39+
Name: Remark
4040
DebugLoc: { File: path/to/anno.c, Line: 1, Column: 2 }
4141
Function: func2
4242
Args:
@@ -45,7 +45,7 @@ Args:
4545
- type: remark
4646
--- !Analysis
4747
Pass: generic-remarks-pass4
48-
Name: Remark
48+
Name: Remark
4949
DebugLoc: { File: path/to/anno2.c, Line: 1, Column: 2 }
5050
Function: func3
5151
Args:

llvm/test/tools/llvm-remarkutil/count/count-by-keys.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
RUN: llvm-remarkutil count --parser=yaml --count-by=arg --group-by=source %p/Inputs/remark-count-by.yaml | FileCheck %s
22
RUN: llvm-remarkutil count --parser=yaml --count-by=arg --group-by=function %p/Inputs/remark-count-by.yaml | FileCheck %s --check-prefix=CHECKFUNC
33
RUN: llvm-remarkutil count --parser=yaml --count-by=arg --group-by=function-with-loc %p/Inputs/remark-count-by.yaml | FileCheck %s --check-prefix=CHECKFUNCLOC
4-
RUN: llvm-remarkutil count --parser=yaml --count-by=arg --group-by=total %p/Inputs/remark-count-by.yaml | FileCheck %s --check-prefix=CHECKTOTAL
4+
RUN: llvm-remarkutil count --parser=yaml --count-by=arg --group-by=total %p/Inputs/remark-count-by.yaml | FileCheck %s --check-prefix=CHECKTOTAL
55

66
; CHECK-LABEL: Source,count1,count2,count3,count4
77
; CHECK: path/to/anno.c,3,4,6,4

llvm/test/tools/llvm-remarkutil/count/count-by-remark.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
RUN: llvm-remarkutil count --parser=yaml --count-by=remark-name --group-by=source %p/Inputs/remark-count-by.yaml | FileCheck %s
22
RUN: llvm-remarkutil count --parser=yaml --count-by=remark-name --group-by=function %p/Inputs/remark-count-by.yaml | FileCheck %s --check-prefix=CHECKFUNC
33
RUN: llvm-remarkutil count --parser=yaml --count-by=remark-name --group-by=function-with-loc %p/Inputs/remark-count-by.yaml | FileCheck %s --check-prefix=CHECKFUNCLOC
4-
RUN: llvm-remarkutil count --parser=yaml --count-by=remark-name --group-by=total %p/Inputs/remark-count-by.yaml | FileCheck %s --check-prefix=CHECKTOTAL
4+
RUN: llvm-remarkutil count --parser=yaml --count-by=remark-name --group-by=total %p/Inputs/remark-count-by.yaml | FileCheck %s --check-prefix=CHECKTOTAL
55

66
; CHECK-LABEL: Source,Count
77
; CHECK: path/to/anno.c,3

llvm/test/tools/llvm-remarkutil/count/filter-by-pass-name.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
RUN: llvm-remarkutil count --parser=yaml --pass-name=generic-remarks-pass %p/Inputs/remark-filter-by.yaml | FileCheck %s
2-
RUN: llvm-remarkutil count --parser=yaml --rpass-name=.* %p/Inputs/remark-filter-by.yaml | FileCheck %s --check-prefix=CHECKALL
1+
RUN: llvm-remarkutil count --parser=yaml --pass-name=generic-remarks-pass %p/Inputs/remark-filter-by.yaml | FileCheck %s
2+
RUN: llvm-remarkutil count --parser=yaml --rpass-name=.* %p/Inputs/remark-filter-by.yaml | FileCheck %s --check-prefix=CHECKALL
33

44
; CHECK-LABEL: Source,Count
55
; CHECK: path/to/anno.c,2

llvm/test/tools/llvm-remarkutil/count/filter-by-remark-name.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
RUN: llvm-remarkutil count --parser=yaml --remark-name=Remark %p/Inputs/remark-filter-by.yaml | FileCheck %s
2-
RUN: llvm-remarkutil count --parser=yaml --rremark-name=R.* %p/Inputs/remark-filter-by.yaml | FileCheck %s --check-prefix=CHECKALL
1+
RUN: llvm-remarkutil count --parser=yaml --remark-name=Remark %p/Inputs/remark-filter-by.yaml | FileCheck %s
2+
RUN: llvm-remarkutil count --parser=yaml --rremark-name=R.* %p/Inputs/remark-filter-by.yaml | FileCheck %s --check-prefix=CHECKALL
33

44
; CHECK-LABEL: Source,Count
55
; CHECK: path/to/anno.c,1

llvm/test/tools/llvm-remarkutil/count/filter-by-type.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ RUN: llvm-remarkutil count --parser=yaml --remark-type=unknown %p/Inputs/remark-
1313
; ANALYSIS: path/to/anno2.c,2
1414

1515
; UNKNOWN: Source,Count
16-
; UNKNOWN-EMPTY:
16+
; UNKNOWN-EMPTY:

llvm/test/tools/llvm-remarkutil/count/group-by-function.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ RUN: llvm-remarkutil count --parser=yaml --group-by=function %p/Inputs/remark-gr
44
; CHECK-LABEL: Function,Count
55
; CHECK: func1,3
66
; CHECK: func2,2
7-
; CHECK: func3,1
7+
; CHECK: func3,1

llvm/tools/llvm-remarkutil/RemarkCounter.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ Error ArgumentCounter::getAllMatchingArgumentsInRemark(
166166
}
167167

168168
std::optional<std::string> Counter::getGroupByKey(const Remark &Remark) {
169-
170-
switch (_GroupBy) {
169+
switch (Group) {
171170
case GroupBy::PER_FUNCTION:
172171
return Remark.FunctionName.str();
173172
case GroupBy::TOTAL:
@@ -177,7 +176,7 @@ std::optional<std::string> Counter::getGroupByKey(const Remark &Remark) {
177176
if (!Remark.Loc.has_value())
178177
return std::nullopt;
179178

180-
if (_GroupBy == GroupBy::PER_FUNCTION_WITH_DEBUG_LOC)
179+
if (Group == GroupBy::PER_FUNCTION_WITH_DEBUG_LOC)
181180
return Remark.Loc->SourceFilePath.str() + ":" + Remark.FunctionName.str();
182181
return Remark.Loc->SourceFilePath.str();
183182
}
@@ -214,7 +213,7 @@ Error ArgumentCounter::print(StringRef OutputFileName) {
214213
return MaybeOF.takeError();
215214

216215
auto OF = std::move(*MaybeOF);
217-
OF->os() << groupByToStr(_GroupBy) << ",";
216+
OF->os() << groupByToStr(Group) << ",";
218217
unsigned Idx = 0;
219218
for (auto [Key, _] : ArgumentSetIdxMap) {
220219
OF->os() << Key;
@@ -244,7 +243,7 @@ Error RemarkCounter::print(StringRef OutputFileName) {
244243
return MaybeOF.takeError();
245244

246245
auto OF = std::move(*MaybeOF);
247-
OF->os() << groupByToStr(_GroupBy) << ","
246+
OF->os() << groupByToStr(Group) << ","
248247
<< "Count\n";
249248
for (auto [Key, Count] : CountedByRemarksMap)
250249
OF->os() << Key << "," << Count << "\n";

llvm/tools/llvm-remarkutil/RemarkCounter.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct Filters {
8888
Filter.RemarkTypeFilter = std::move(RemarkTypeFilter);
8989
if (auto E = Filter.regexArgumentsValid())
9090
return std::move(E);
91-
return Filter;
91+
return std::move(Filter);
9292
}
9393
/// Returns true if \p Remark satisfies all the provided filters.
9494
bool filterRemark(const Remark &Remark);
@@ -110,15 +110,15 @@ inline Error checkRegex(const Regex &Regex) {
110110
/// Abstract counter class used to define the general required methods for
111111
/// counting a remark.
112112
struct Counter {
113-
GroupBy _GroupBy;
114-
Counter(){};
115-
Counter(enum GroupBy GroupBy) : _GroupBy(GroupBy) {}
113+
GroupBy Group = GroupBy::TOTAL;
114+
Counter() = default;
115+
Counter(enum GroupBy GroupBy) : Group(GroupBy) {}
116116
/// Obtain the field for collecting remark info based on how we are
117117
/// collecting. Remarks are grouped by FunctionName, Source, Source and
118118
/// Function or collect by file.
119119
std::optional<std::string> getGroupByKey(const Remark &Remark);
120120

121-
/// Collect count information from \p Remark organized based on \p GroupBy
121+
/// Collect count information from \p Remark organized based on \p Group
122122
/// property.
123123
virtual void collect(const Remark &) = 0;
124124
/// Output the final count to the file \p OutputFileName
@@ -158,10 +158,10 @@ struct ArgumentCounter : Counter {
158158
/// vector then we need to check that the provided regular expressions are
159159
/// valid if not we return an Error.
160160
static Expected<ArgumentCounter>
161-
createArgumentCounter(enum GroupBy GroupBy, ArrayRef<FilterMatcher> Arguments,
161+
createArgumentCounter(GroupBy Group, ArrayRef<FilterMatcher> Arguments,
162162
StringRef Buffer, Filters &Filter) {
163163
ArgumentCounter AC;
164-
AC._GroupBy = GroupBy;
164+
AC.Group = Group;
165165
for (auto &Arg : Arguments) {
166166
if (Arg.IsRegex) {
167167
if (auto E = checkRegex(Arg.FilterRE))
@@ -178,7 +178,7 @@ struct ArgumentCounter : Counter {
178178
void collect(const Remark &) override;
179179

180180
/// Print a CSV table consisting of an index which is specified by \p
181-
/// `GroupBy` and can be a function name, source file name or function name
181+
/// `Group` and can be a function name, source file name or function name
182182
/// with the full source path and columns of user specified remark arguments
183183
/// to collect the count for.
184184
Error print(StringRef OutputFileName) override;
@@ -194,19 +194,19 @@ struct ArgumentCounter : Counter {
194194
};
195195

196196
/// Collect remarks based by counting the existance of individual remarks. The
197-
/// reported table will be structured based on the provided \p GroupBy argument
197+
/// reported table will be structured based on the provided \p Group argument
198198
/// by reporting count for functions, source or total count for the provided
199199
/// remark file.
200200
struct RemarkCounter : Counter {
201201
std::map<std::string, unsigned> CountedByRemarksMap;
202-
RemarkCounter(enum GroupBy GroupBy) : Counter(GroupBy) {}
202+
RemarkCounter(GroupBy Group) : Counter(Group) {}
203203

204-
/// Advance the internal map count broken by \p GroupBy when
204+
/// Advance the internal map count broken by \p Group when
205205
/// seeing \p Remark.
206206
void collect(const Remark &) override;
207207

208208
/// Print a CSV table consisting of an index which is specified by \p
209-
/// `GroupBy` and can be a function name, source file name or function name
209+
/// `Group` and can be a function name, source file name or function name
210210
/// with the full source path and a counts column corresponding to the count
211211
/// of each individual remark at th index.
212212
Error print(StringRef OutputFileName) override;

0 commit comments

Comments
 (0)