Skip to content

Commit c0c5fdc

Browse files
committed
s/IsAllowedInCoroutines/IgnoreCoroutines/ and invert logic
1 parent c5b7dda commit c0c5fdc

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ UnnecessaryValueParamCheck::UnnecessaryValueParamCheck(
5151
areDiagsSelfContained()),
5252
AllowedTypes(
5353
utils::options::parseStringList(Options.get("AllowedTypes", ""))),
54-
IsAllowedInCoroutines(Options.get("IsAllowedInCoroutines", false)) {}
54+
IgnoreCoroutines(Options.get("IgnoreCoroutines", true)) {}
5555

5656
void UnnecessaryValueParamCheck::registerMatchers(MatchFinder *Finder) {
5757
const auto ExpensiveValueParamDecl = parmVarDecl(
@@ -64,9 +64,9 @@ void UnnecessaryValueParamCheck::registerMatchers(MatchFinder *Finder) {
6464
Finder->addMatcher(
6565
traverse(
6666
TK_AsIs,
67-
functionDecl(hasBody(IsAllowedInCoroutines
68-
? stmt()
69-
: stmt(unless(coroutineBodyStmt()))),
67+
functionDecl(hasBody(IgnoreCoroutines
68+
? stmt(unless(coroutineBodyStmt()))
69+
: stmt()),
7070
isDefinition(), unless(isImplicit()),
7171
unless(cxxMethodDecl(anyOf(isOverride(), isFinal()))),
7272
has(typeLoc(forEach(ExpensiveValueParamDecl))),
@@ -127,7 +127,7 @@ void UnnecessaryValueParamCheck::storeOptions(
127127
Options.store(Opts, "IncludeStyle", Inserter.getStyle());
128128
Options.store(Opts, "AllowedTypes",
129129
utils::options::serializeStringList(AllowedTypes));
130-
Options.store(Opts, "IsAllowedInCoroutines", IsAllowedInCoroutines);
130+
Options.store(Opts, "IgnoreCoroutines", IgnoreCoroutines);
131131
}
132132

133133
void UnnecessaryValueParamCheck::onEndOfTranslationUnit() {

clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class UnnecessaryValueParamCheck : public ClangTidyCheck {
4646
ExprMutationAnalyzer::Memoized MutationAnalyzerCache;
4747
utils::IncludeInserter Inserter;
4848
const std::vector<StringRef> AllowedTypes;
49-
bool IsAllowedInCoroutines;
49+
bool IgnoreCoroutines;
5050
};
5151

5252
} // namespace clang::tidy::performance

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ Changes in existing checks
265265
<clang-tidy/checks/performance/unnecessary-value-param>` check performance by
266266
tolerating fix-it breaking compilation when functions is used as pointers
267267
to avoid matching usage of functions within the current compilation unit.
268-
Added an option `IsAllowedInCoroutines` with the default value `false` to
268+
Added an option `IgnoreCoroutines` with the default value `true` to
269269
suppress this check for coroutines where passing by reference may be unsafe.
270270

271271
- Improved :doc:`readability-convert-member-functions-to-static

clang-tools-extra/docs/clang-tidy/checks/performance/unnecessary-value-param.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ Options
7575
matched against the qualified type name (i.e. ``namespace::Type``),
7676
otherwise it is matched against only the type name (i.e. ``Type``).
7777

78-
.. option:: IsAllowedInCoroutines
78+
.. option:: IgnoreCoroutines
7979

8080
A boolean specifying whether the check should suggest passing parameters by
8181
reference in coroutines. Passing parameters by reference in coroutines may
8282
not be safe, please see :doc:`cppcoreguidelines-avoid-reference-coroutine-parameters <../cppcoreguidelines/avoid-reference-coroutine-parameters>`
83-
for more information. Default is `false`.
83+
for more information. Default is `true`.

clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-value-param-coroutine.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// RUN: %check_clang_tidy -std=c++20-or-later %s performance-unnecessary-value-param %t -- -fix-errors
22
// RUN: %check_clang_tidy -std=c++20-or-later %s performance-unnecessary-value-param %t -- \
3-
// RUN: -config='{CheckOptions: {performance-unnecessary-value-param.IsAllowedInCoroutines: false}}' -fix-errors
3+
// RUN: -config='{CheckOptions: {performance-unnecessary-value-param.IgnoreCoroutines: true}}' -fix-errors
44
// RUN: %check_clang_tidy -check-suffix=ALLOWED -std=c++20-or-later %s performance-unnecessary-value-param %t -- \
5-
// RUN: -config='{CheckOptions: {performance-unnecessary-value-param.IsAllowedInCoroutines: true}}' -fix-errors
5+
// RUN: -config='{CheckOptions: {performance-unnecessary-value-param.IgnoreCoroutines: false}}' -fix-errors
66

77
namespace std {
88

0 commit comments

Comments
 (0)