[PATCH] D140793: [clang-tidy] Implement CppCoreGuideline CP.53
Chris Cotter via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 1 15:43:00 PST 2023
ccotter updated this revision to Diff 485824.
ccotter added a comment.
- Cleanups
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140793/new/
https://reviews.llvm.org/D140793
Files:
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidReferenceCoroutineParametersCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidReferenceCoroutineParametersCheck.h
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-reference-coroutine-parameters.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===================================================================
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -182,7 +182,7 @@
`cppcoreguidelines-avoid-do-while <cppcoreguidelines/avoid-do-while.html>`_,
`cppcoreguidelines-avoid-goto <cppcoreguidelines/avoid-goto.html>`_,
`cppcoreguidelines-avoid-non-const-global-variables <cppcoreguidelines/avoid-non-const-global-variables.html>`_,
- `cppcoreguidelines-avoid-reference-coroutine-parameters <cppcoreguidelines/avoid-reference-coroutine-parameters.html>`_, "Yes"
+ `cppcoreguidelines-avoid-reference-coroutine-parameters <cppcoreguidelines/avoid-reference-coroutine-parameters.html>`_,
`cppcoreguidelines-init-variables <cppcoreguidelines/init-variables.html>`_, "Yes"
`cppcoreguidelines-interfaces-global-init <cppcoreguidelines/interfaces-global-init.html>`_,
`cppcoreguidelines-macro-usage <cppcoreguidelines/macro-usage.html>`_,
Index: clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-reference-coroutine-parameters.rst
===================================================================
--- clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-reference-coroutine-parameters.rst
+++ clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-reference-coroutine-parameters.rst
@@ -17,4 +17,4 @@
}
This check implements
-`CppCoreGuideline CP.53 <http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines>`_.
+`CppCoreGuideline CP.53 <https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rcoro-reference-parameters>`_.
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidReferenceCoroutineParametersCheck.h
===================================================================
--- clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidReferenceCoroutineParametersCheck.h
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidReferenceCoroutineParametersCheck.h
@@ -23,11 +23,12 @@
/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/avoid-reference-coroutine-parameters.html
class AvoidReferenceCoroutineParametersCheck : public ClangTidyCheck {
public:
- AvoidReferenceCoroutineParametersCheck(StringRef Name, ClangTidyContext *Context)
+ AvoidReferenceCoroutineParametersCheck(StringRef Name,
+ ClangTidyContext *Context)
: ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
- bool isLanguageVersionSupported(const LangOptions &LO) const override {
+ bool isLanguageVersionSupported(const LangOpts &LO) const override {
return LO.CPlusPlus20;
}
};
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidReferenceCoroutineParametersCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidReferenceCoroutineParametersCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidReferenceCoroutineParametersCheck.cpp
@@ -28,9 +28,9 @@
void AvoidReferenceCoroutineParametersCheck::check(
const MatchFinder::MatchResult &Result) {
- const auto *Param = Result.Nodes.getNodeAs<ParmVarDecl>("param");
-
- diag(Param->getBeginLoc(), "coroutine parameters should not be references");
+ if (const auto *Param = Result.Nodes.getNodeAs<ParmVarDecl>("param")) {
+ diag(Param->getBeginLoc(), "coroutine parameters should not be references");
+ }
}
} // namespace cppcoreguidelines
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140793.485824.patch
Type: text/x-patch
Size: 3648 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230101/dc560da6/attachment.bin>
More information about the cfe-commits
mailing list