diff --git a/clang-tools-extra/clang-tidy/CMakeLists.txt b/clang-tools-extra/clang-tidy/CMakeLists.txt index 1644ca82aa457d..2a469c592383f8 100644 --- a/clang-tools-extra/clang-tidy/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/CMakeLists.txt @@ -50,6 +50,7 @@ add_subdirectory(darwin) add_subdirectory(fuchsia) add_subdirectory(google) add_subdirectory(hicpp) +add_subdirectory(kokkos) add_subdirectory(linuxkernel) add_subdirectory(llvm) add_subdirectory(llvmlibc) @@ -75,6 +76,7 @@ set(ALL_CLANG_TIDY_CHECKS clangTidyFuchsiaModule clangTidyGoogleModule clangTidyHICPPModule + clangTidyKokkosModule clangTidyLinuxKernelModule clangTidyLLVMModule clangTidyLLVMLibcModule diff --git a/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h b/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h index 1d6bd2a4fd6214..f2e90b7025d518 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h +++ b/clang-tools-extra/clang-tidy/ClangTidyForceLinker.h @@ -1,5 +1,9 @@ //===- ClangTidyForceLinker.h - clang-tidy --------------------------------===// // +// Copyright 2020 National Technology & Engineering Solutions of Sandia, LLC +// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. +// Government retains certain rights in this software. +// // 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 @@ -65,6 +69,11 @@ extern volatile int HICPPModuleAnchorSource; static int LLVM_ATTRIBUTE_UNUSED HICPPModuleAnchorDestination = HICPPModuleAnchorSource; +// This anchor is used to force the linker to link the KokkosModule. +extern volatile int KokkosModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED KokkosModuleAnchorDestination = + KokkosModuleAnchorSource; + // This anchor is used to force the linker to link the LinuxKernelModule. extern volatile int LinuxKernelModuleAnchorSource; static int LLVM_ATTRIBUTE_UNUSED LinuxKernelModuleAnchorDestination = diff --git a/clang-tools-extra/clang-tidy/add_new_check.py b/clang-tools-extra/clang-tidy/add_new_check.py index 454d128a5dcb35..15df3131aa536d 100755 --- a/clang-tools-extra/clang-tidy/add_new_check.py +++ b/clang-tools-extra/clang-tidy/add_new_check.py @@ -61,6 +61,10 @@ def write_header(module_path, module, namespace, check_name, check_name_camel): f.write('*- C++ -*-===//') f.write(""" // +// Copyright 2020 National Technology & Engineering Solutions of Sandia, +// LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. +// Government retains certain rights in this software. +// // 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 diff --git a/clang-tools-extra/clang-tidy/kokkos/CMakeLists.txt b/clang-tools-extra/clang-tidy/kokkos/CMakeLists.txt new file mode 100644 index 00000000000000..4716e61815043c --- /dev/null +++ b/clang-tools-extra/clang-tidy/kokkos/CMakeLists.txt @@ -0,0 +1,16 @@ +set(LLVM_LINK_COMPONENTS support) + +add_clang_library(clangTidyKokkosModule + ImplicitThisCaptureCheck.cpp + KokkosMatchers.cpp + KokkosTidyModule.cpp + + LINK_LIBS + clangAnalysis + clangAST + clangASTMatchers + clangBasic + clangLex + clangTidy + clangTidyUtils + ) diff --git a/clang-tools-extra/clang-tidy/kokkos/ImplicitThisCaptureCheck.cpp b/clang-tools-extra/clang-tidy/kokkos/ImplicitThisCaptureCheck.cpp new file mode 100644 index 00000000000000..94b9fba623f263 --- /dev/null +++ b/clang-tools-extra/clang-tidy/kokkos/ImplicitThisCaptureCheck.cpp @@ -0,0 +1,94 @@ +//===--- ImplicitThisCaptureCheck.cpp - clang-tidy ------------------------===// +// +// Copyright 2020 National Technology & Engineering Solutions of Sandia, LLC +// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. +// Government retains certain rights in this software. +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "ImplicitThisCaptureCheck.h" +#include "KokkosMatchers.h" +#include "clang/AST/ASTContext.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "llvm/ADT/Optional.h" + +using namespace clang::ast_matchers; + +namespace clang { +namespace tidy { +namespace kokkos { + +namespace { +llvm::Optional capturesThis(CXXRecordDecl const *CRD) { + if (!CRD->isLambda()) { + return llvm::None; + } + + for (auto const &Capture : CRD->captures()) { + if (Capture.capturesThis()) { + return llvm::Optional(Capture.getLocation()); + } + } + + return llvm::None; +} + +} // namespace + +ImplicitThisCaptureCheck::ImplicitThisCaptureCheck( + StringRef Name, ClangTidyContext *Context) + : ClangTidyCheck(Name, Context) { + CheckIfExplicitHost = std::stoi(Options.get("CheckIfExplicitHost", "0")); + HostTypeDefRegex = + Options.get("HostTypeDefRegex", "Kokkos::DefaultHostExecutionSpace"); +} + +void ImplicitThisCaptureCheck::storeOptions( + ClangTidyOptions::OptionMap &Opts) { + Options.store(Opts, "CheckIfExplicitHost", + std::to_string(CheckIfExplicitHost)); + Options.store(Opts, "HostTypeDefRegex", HostTypeDefRegex); +} + +void ImplicitThisCaptureCheck::registerMatchers(MatchFinder *Finder) { + auto isAllowedPolicy = expr(hasType( + cxxRecordDecl(matchesName("::Impl::ThreadVectorRangeBoundariesStruct.*|::" + "Impl::TeamThreadRangeBoundariesStruct.*")))); + + auto Lambda = expr(hasType(cxxRecordDecl(isLambda()).bind("Lambda"))); + + Finder->addMatcher( + callExpr(isKokkosParallelCall(), + hasAnyArgument(Lambda), unless(hasAnyArgument(isAllowedPolicy))) + .bind("x"), + this); +} + +void ImplicitThisCaptureCheck::check( + const MatchFinder::MatchResult &Result) { + auto const *CE = Result.Nodes.getNodeAs("x"); + + if (CheckIfExplicitHost) { + if (explicitlyUsingHostExecutionSpace(CE, HostTypeDefRegex)) { + return; + } + } + + auto const *Lambda = Result.Nodes.getNodeAs("Lambda"); + auto CaptureLocation = capturesThis(Lambda); + if (CaptureLocation) { + diag(Lambda->getBeginLoc(), "Lambda passed to %0 implicitly captures this.") + << CE->getDirectCallee()->getName(); + diag(CaptureLocation.getValue(), "the captured variable is used here.", + DiagnosticIDs::Note); + diag(CE->getBeginLoc(), "Kokkos call here.", DiagnosticIDs::Note); + } +} + +} // namespace kokkos +} // namespace tidy +} // namespace clang diff --git a/clang-tools-extra/clang-tidy/kokkos/ImplicitThisCaptureCheck.h b/clang-tools-extra/clang-tidy/kokkos/ImplicitThisCaptureCheck.h new file mode 100644 index 00000000000000..072b5f10eecd46 --- /dev/null +++ b/clang-tools-extra/clang-tidy/kokkos/ImplicitThisCaptureCheck.h @@ -0,0 +1,41 @@ +//===--- ImplicitThisCaptureCheck.h - clang-tidy ----------------*- C++ -*-===// +// +// Copyright 2020 National Technology & Engineering Solutions of Sandia, LLC +// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. +// Government retains certain rights in this software. +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_KOKKOS_IMPLICITTHISCAPTURECHECK_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_KOKKOS_IMPLICITTHISCAPTURECHECK_H + +#include "../ClangTidyCheck.h" + +#include + +namespace clang { +namespace tidy { +namespace kokkos { + +/// Check to detect when a lambda passed to a ::Kokkos::parallel_* implicitly +/// captures the this pointer +class ImplicitThisCaptureCheck : public ClangTidyCheck { +public: + ImplicitThisCaptureCheck(StringRef Name, ClangTidyContext *Context); + void registerMatchers(ast_matchers::MatchFinder *Finder) override; + void storeOptions(ClangTidyOptions::OptionMap &Opts) override; + void check(const ast_matchers::MatchFinder::MatchResult &Result) override; +private: + int CheckIfExplicitHost; + std::string HostTypeDefRegex; +}; + +} // namespace kokkos +} // namespace tidy +} // namespace clang + +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_KOKKOS_IMPLICITTHISCAPTURECHECK_H diff --git a/clang-tools-extra/clang-tidy/kokkos/KokkosMatchers.cpp b/clang-tools-extra/clang-tidy/kokkos/KokkosMatchers.cpp new file mode 100644 index 00000000000000..67721ac70b7347 --- /dev/null +++ b/clang-tools-extra/clang-tidy/kokkos/KokkosMatchers.cpp @@ -0,0 +1,54 @@ +//===--- KokkosMatchers.cpp - clang-tidy ------------------------===// +// +// Copyright 2020 National Technology & Engineering Solutions of Sandia, LLC +// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. +// Government retains certain rights in this software. +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "KokkosMatchers.h" + +namespace clang { +namespace tidy { +namespace kokkos { + +bool explicitlyUsingHostExecutionSpace(CallExpr const *CE, + std::string const &RegexString) { + using namespace clang::ast_matchers; + auto &Ctx = CE->getCalleeDecl()->getASTContext(); + + // We will assume that any policy where the user might explicitly ask for the + // host space inherits from Impl::PolicyTraits + auto FilterArgs = + hasAnyArgument(expr(hasType(cxxRecordDecl(isDerivedFrom(cxxRecordDecl( + matchesName("Impl::PolicyTraits")))))) + .bind("expr")); + + // We have to jump through some hoops to find this, if we just looked at the + // template type of the Policy constructor we lose the sugar and instead of + // Kokkos::DefaultHostExecutionSpace we get what the ever the typedef was set + // to such as Kokkos::Serial, preventing us from figuring out if the user + // actually asked for a host space specifically or just happens to have a + // host space as the default space. + llvm::Regex Reg(RegexString); + auto BNs = match(callExpr(FilterArgs).bind("CE"), *CE, Ctx); + for (auto &BN : BNs) { + if (auto const *E = BN.getNodeAs("expr")) { + if (auto const *TST = E->getType()->getAs()) { + if (Reg.match(TST->getArg(0).getAsType().getAsString())) { + return true; + } + } + } + } + + return false; +} + +} // namespace kokkos +} // namespace tidy +} // namespace clang diff --git a/clang-tools-extra/clang-tidy/kokkos/KokkosMatchers.h b/clang-tools-extra/clang-tidy/kokkos/KokkosMatchers.h new file mode 100644 index 00000000000000..167a60be60f436 --- /dev/null +++ b/clang-tools-extra/clang-tidy/kokkos/KokkosMatchers.h @@ -0,0 +1,52 @@ +//===--- KokkosMatchers.h - clang-tidy ------------------------===// +// +// Copyright 2020 National Technology & Engineering Solutions of Sandia, LLC +// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. +// Government retains certain rights in this software. +// +// 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_KOKKOS_KOKKOSMATCHERS_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_KOKKOS_KOKKOSMATCHERS_H + +#include "clang/AST/ASTContext.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/ASTMatchers/ASTMatchers.h" +#include + +namespace clang { +namespace tidy { +namespace kokkos { + +AST_MATCHER_FUNCTION(ast_matchers::internal::Matcher, + kokkosParallelXFunctionDecl) { + using namespace clang::ast_matchers; + return functionDecl(matchesName("::Kokkos::parallel_.*")); +} + +AST_MATCHER(CallExpr, isKokkosParallelCall) { + using namespace clang::ast_matchers; + if (auto const *FD = Node.getDirectCallee()) { + std::string Name = FD->getQualifiedNameAsString(); + StringRef SR(Name); + if (SR.startswith("::Kokkos::parallel_")) { + return true; + } + } + + return false; +} + +bool explicitlyUsingHostExecutionSpace(CallExpr const *CE, + std::string const &RegexString); + + +} // namespace kokkos +} // namespace tidy +} // namespace clang + +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_KOKKOS_KOKKOSMATCHERS_H diff --git a/clang-tools-extra/clang-tidy/kokkos/KokkosTidyModule.cpp b/clang-tools-extra/clang-tidy/kokkos/KokkosTidyModule.cpp new file mode 100644 index 00000000000000..2a7a2606603762 --- /dev/null +++ b/clang-tools-extra/clang-tidy/kokkos/KokkosTidyModule.cpp @@ -0,0 +1,41 @@ +//===--- KokkosTidyModule.cpp - clang-tidy ----------------------------------===// +// +// Copyright 2020 National Technology & Engineering Solutions of Sandia, LLC +// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. +// Government retains certain rights in this software. +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "../ClangTidy.h" +#include "../ClangTidyModule.h" +#include "../ClangTidyModuleRegistry.h" +#include "ImplicitThisCaptureCheck.h" + +namespace clang { +namespace tidy { +namespace kokkos { + +class KokkosModule : public ClangTidyModule { +public: + void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { + CheckFactories.registerCheck( + "kokkos-implicit-this-capture"); + } +}; + +} // namespace kokkos + +// Register the DarwinTidyModule using this statically initialized variable. +static ClangTidyModuleRegistry::Add + X("kokkos-module", "Adds Kokkos specific linting checks."); + +// This anchor is used to force the linker to link in the generated object file +// and thus register the KokkosModule. +volatile int KokkosModuleAnchorSource = 0; + +} // namespace tidy +} // namespace clang diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index bd898de446b9d4..f5123de755cf93 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -120,6 +120,11 @@ New checks Flags use of the `C` standard library functions ``memset``, ``memcpy`` and ``memcmp`` and similar derivatives on non-trivial types. +- New :doc:`kokkos-implicit-this-capture + ` check. + + New check for implicit this capture detection + - New :doc:`llvmlibc-callee-namespace ` check. diff --git a/clang-tools-extra/docs/clang-tidy/checks/kokkos-implicit-this-capture.rst b/clang-tools-extra/docs/clang-tidy/checks/kokkos-implicit-this-capture.rst new file mode 100644 index 00000000000000..b153d525fab590 --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/kokkos-implicit-this-capture.rst @@ -0,0 +1,19 @@ +.. title:: clang-tidy - kokkos-implicit-this-capture + +kokkos-implicit-this-capture +============================ + +The implicit-this-capture check checks if a lambda passed to any of +parallel_reduce, parallel_for, or parallel_scan functions captures the this +pointer. + +Example of a class that should trigger the check +.. code-block:: c++ + + class Foo { + int x = 0; + + void operator()(){ + Kokkos::parallel_for(10, KOKKOS_LAMBDA(int y){ printf("%d", x+y)}); + } + }; diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst index 17331605aa64e1..2e679b041f3198 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/list.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst @@ -12,28 +12,28 @@ Clang-Tidy Checks .. csv-table:: :header: "Name", "Offers fixes" - `abseil-duration-addition `_, "Yes" - `abseil-duration-comparison `_, "Yes" - `abseil-duration-conversion-cast `_, "Yes" - `abseil-duration-division `_, "Yes" - `abseil-duration-factory-float `_, "Yes" - `abseil-duration-factory-scale `_, "Yes" - `abseil-duration-subtraction `_, "Yes" - `abseil-duration-unnecessary-conversion `_, "Yes" - `abseil-faster-strsplit-delimiter `_, "Yes" + `abseil-duration-addition `_, + `abseil-duration-comparison `_, + `abseil-duration-conversion-cast `_, + `abseil-duration-division `_, + `abseil-duration-factory-float `_, + `abseil-duration-factory-scale `_, + `abseil-duration-subtraction `_, + `abseil-duration-unnecessary-conversion `_, + `abseil-faster-strsplit-delimiter `_, `abseil-no-internal-dependencies `_, `abseil-no-namespace `_, - `abseil-redundant-strcat-calls `_, "Yes" - `abseil-str-cat-append `_, "Yes" - `abseil-string-find-startswith `_, "Yes" - `abseil-string-find-str-contains `_, "Yes" - `abseil-time-comparison `_, "Yes" - `abseil-time-subtraction `_, "Yes" - `abseil-upgrade-duration-conversions `_, "Yes" - `android-cloexec-accept `_, "Yes" + `abseil-redundant-strcat-calls `_, + `abseil-str-cat-append `_, + `abseil-string-find-startswith `_, + `abseil-string-find-str-contains `_, + `abseil-time-comparison `_, + `abseil-time-subtraction `_, + `abseil-upgrade-duration-conversions `_, + `android-cloexec-accept `_, `android-cloexec-accept4 `_, - `android-cloexec-creat `_, "Yes" - `android-cloexec-dup `_, "Yes" + `android-cloexec-creat `_, + `android-cloexec-dup `_, `android-cloexec-epoll-create `_, `android-cloexec-epoll-create1 `_, `android-cloexec-fopen `_, @@ -41,63 +41,63 @@ Clang-Tidy Checks `android-cloexec-inotify-init1 `_, `android-cloexec-memfd-create `_, `android-cloexec-open `_, - `android-cloexec-pipe `_, "Yes" + `android-cloexec-pipe `_, `android-cloexec-pipe2 `_, `android-cloexec-socket `_, `android-comparison-in-temp-failure-retry `_, - `boost-use-to-string `_, "Yes" - `bugprone-argument-comment `_, "Yes" + `boost-use-to-string `_, + `bugprone-argument-comment `_, `bugprone-assert-side-effect `_, `bugprone-bad-signal-to-kill-thread `_, - `bugprone-bool-pointer-implicit-conversion `_, "Yes" + `bugprone-bool-pointer-implicit-conversion `_, `bugprone-branch-clone `_, - `bugprone-copy-constructor-init `_, "Yes" + `bugprone-copy-constructor-init `_, `bugprone-dangling-handle `_, `bugprone-dynamic-static-initializers `_, `bugprone-exception-escape `_, `bugprone-fold-init-type `_, `bugprone-forward-declaration-namespace `_, `bugprone-forwarding-reference-overload `_, - `bugprone-inaccurate-erase `_, "Yes" + `bugprone-inaccurate-erase `_, `bugprone-incorrect-roundings `_, `bugprone-infinite-loop `_, `bugprone-integer-division `_, `bugprone-lambda-function-name `_, - `bugprone-macro-parentheses `_, "Yes" + `bugprone-macro-parentheses `_, `bugprone-macro-repeated-side-effects `_, - `bugprone-misplaced-operator-in-strlen-in-alloc `_, "Yes" - `bugprone-misplaced-pointer-arithmetic-in-alloc `_, "Yes" + `bugprone-misplaced-operator-in-strlen-in-alloc `_, + `bugprone-misplaced-pointer-arithmetic-in-alloc `_, `bugprone-misplaced-widening-cast `_, - `bugprone-move-forwarding-reference `_, "Yes" + `bugprone-move-forwarding-reference `_, `bugprone-multiple-statement-macro `_, - `bugprone-not-null-terminated-result `_, "Yes" - `bugprone-parent-virtual-call `_, "Yes" - `bugprone-posix-return `_, "Yes" - `bugprone-reserved-identifier `_, "Yes" + `bugprone-not-null-terminated-result `_, + `bugprone-parent-virtual-call `_, + `bugprone-posix-return `_, + `bugprone-reserved-identifier `_, `bugprone-signed-char-misuse `_, `bugprone-sizeof-container `_, `bugprone-sizeof-expression `_, `bugprone-spuriously-wake-up-functions `_, - `bugprone-string-constructor `_, "Yes" - `bugprone-string-integer-assignment `_, "Yes" + `bugprone-string-constructor `_, + `bugprone-string-integer-assignment `_, `bugprone-string-literal-with-embedded-nul `_, `bugprone-suspicious-enum-usage `_, `bugprone-suspicious-include `_, - `bugprone-suspicious-memset-usage `_, "Yes" + `bugprone-suspicious-memset-usage `_, `bugprone-suspicious-missing-comma `_, - `bugprone-suspicious-semicolon `_, "Yes" - `bugprone-suspicious-string-compare `_, "Yes" - `bugprone-swapped-arguments `_, "Yes" - `bugprone-terminating-continue `_, "Yes" + `bugprone-suspicious-semicolon `_, + `bugprone-suspicious-string-compare `_, + `bugprone-swapped-arguments `_, + `bugprone-terminating-continue `_, `bugprone-throw-keyword-missing `_, `bugprone-too-small-loop-variable `_, `bugprone-undefined-memory-manipulation `_, `bugprone-undelegated-constructor `_, `bugprone-unhandled-self-assignment `_, - `bugprone-unused-raii `_, "Yes" + `bugprone-unused-raii `_, `bugprone-unused-return-value `_, `bugprone-use-after-move `_, - `bugprone-virtual-near-miss `_, "Yes" + `bugprone-virtual-near-miss `_, `cert-dcl21-cpp `_, `cert-dcl50-cpp `_, `cert-dcl58-cpp `_, @@ -133,28 +133,29 @@ Clang-Tidy Checks `clang-analyzer-valist.Uninitialized `_, `clang-analyzer-valist.Unterminated `_, `cppcoreguidelines-avoid-goto `_, - `cppcoreguidelines-init-variables `_, "Yes" + `cppcoreguidelines-avoid-non-const-global-variables `_, + `cppcoreguidelines-init-variables `_, `cppcoreguidelines-interfaces-global-init `_, `cppcoreguidelines-macro-usage `_, `cppcoreguidelines-narrowing-conversions `_, `cppcoreguidelines-no-malloc `_, `cppcoreguidelines-owning-memory `_, `cppcoreguidelines-pro-bounds-array-to-pointer-decay `_, - `cppcoreguidelines-pro-bounds-constant-array-index `_, "Yes" + `cppcoreguidelines-pro-bounds-constant-array-index `_, `cppcoreguidelines-pro-bounds-pointer-arithmetic `_, `cppcoreguidelines-pro-type-const-cast `_, - `cppcoreguidelines-pro-type-cstyle-cast `_, "Yes" - `cppcoreguidelines-pro-type-member-init `_, "Yes" + `cppcoreguidelines-pro-type-cstyle-cast `_, + `cppcoreguidelines-pro-type-member-init `_, `cppcoreguidelines-pro-type-reinterpret-cast `_, - `cppcoreguidelines-pro-type-static-cast-downcast `_, "Yes" + `cppcoreguidelines-pro-type-static-cast-downcast `_, `cppcoreguidelines-pro-type-union-access `_, `cppcoreguidelines-pro-type-vararg `_, `cppcoreguidelines-slicing `_, `cppcoreguidelines-special-member-functions `_, `darwin-avoid-spinlock `_, - `darwin-dispatch-once-nonstatic `_, "Yes" + `darwin-dispatch-once-nonstatic `_, `fuchsia-default-arguments-calls `_, - `fuchsia-default-arguments-declarations `_, "Yes" + `fuchsia-default-arguments-declarations `_, `fuchsia-multiple-inheritance `_, `fuchsia-overloaded-operator `_, `fuchsia-statically-constructed-objects `_, @@ -164,7 +165,7 @@ Clang-Tidy Checks `google-build-namespaces `_, `google-build-using-namespace `_, `google-default-arguments `_, - `google-explicit-constructor `_, "Yes" + `google-explicit-constructor `_, `google-global-names-in-headers `_, `google-objc-avoid-nsobject-new `_, `google-objc-avoid-throwing-exception `_, @@ -176,131 +177,132 @@ Clang-Tidy Checks `google-runtime-int `_, `google-runtime-operator `_, `google-runtime-references `_, - `google-upgrade-googletest-case `_, "Yes" + `google-upgrade-googletest-case `_, `hicpp-avoid-goto `_, `hicpp-exception-baseclass `_, `hicpp-multiway-paths-covered `_, `hicpp-no-assembler `_, `hicpp-signed-bitwise `_, + `kokkos-implicit-this-capture `_, `linuxkernel-must-use-errs `_, `llvm-header-guard `_, - `llvm-include-order `_, "Yes" + `llvm-include-order `_, `llvm-namespace-comment `_, - `llvm-prefer-isa-or-dyn-cast-in-conditionals `_, "Yes" - `llvm-prefer-register-over-unsigned `_, "Yes" - `llvm-twine-local `_, "Yes" - `llvmlibc-callee-namespace `_, + `llvm-prefer-isa-or-dyn-cast-in-conditionals `_, + `llvm-prefer-register-over-unsigned `_, + `llvm-twine-local `_, + `llvmlibc-callee-namespace `_, `llvmlibc-implementation-in-namespace `_, - `llvmlibc-restrict-system-libc-headers `_, "Yes" - `misc-definitions-in-headers `_, "Yes" + `llvmlibc-restrict-system-libc-headers `_, + `misc-definitions-in-headers `_, `misc-misplaced-const `_, `misc-new-delete-overloads `_, `misc-no-recursion `_, `misc-non-copyable-objects `_, `misc-non-private-member-variables-in-classes `_, - `misc-redundant-expression `_, "Yes" - `misc-static-assert `_, "Yes" + `misc-redundant-expression `_, + `misc-static-assert `_, `misc-throw-by-value-catch-by-reference `_, `misc-unconventional-assign-operator `_, - `misc-uniqueptr-reset-release `_, "Yes" - `misc-unused-alias-decls `_, "Yes" - `misc-unused-parameters `_, "Yes" - `misc-unused-using-decls `_, "Yes" - `modernize-avoid-bind `_, "Yes" + `misc-uniqueptr-reset-release `_, + `misc-unused-alias-decls `_, + `misc-unused-parameters `_, + `misc-unused-using-decls `_, + `modernize-avoid-bind `_, `modernize-avoid-c-arrays `_, - `modernize-concat-nested-namespaces `_, "Yes" - `modernize-deprecated-headers `_, "Yes" - `modernize-deprecated-ios-base-aliases `_, "Yes" - `modernize-loop-convert `_, "Yes" - `modernize-make-shared `_, "Yes" - `modernize-make-unique `_, "Yes" - `modernize-pass-by-value `_, "Yes" - `modernize-raw-string-literal `_, "Yes" - `modernize-redundant-void-arg `_, "Yes" - `modernize-replace-auto-ptr `_, "Yes" - `modernize-replace-disallow-copy-and-assign-macro `_, "Yes" - `modernize-replace-random-shuffle `_, "Yes" - `modernize-return-braced-init-list `_, "Yes" - `modernize-shrink-to-fit `_, "Yes" - `modernize-unary-static-assert `_, "Yes" - `modernize-use-auto `_, "Yes" - `modernize-use-bool-literals `_, "Yes" - `modernize-use-default-member-init `_, "Yes" - `modernize-use-emplace `_, "Yes" - `modernize-use-equals-default `_, "Yes" - `modernize-use-equals-delete `_, "Yes" - `modernize-use-nodiscard `_, "Yes" - `modernize-use-noexcept `_, "Yes" - `modernize-use-nullptr `_, "Yes" - `modernize-use-override `_, "Yes" - `modernize-use-trailing-return-type `_, "Yes" - `modernize-use-transparent-functors `_, "Yes" - `modernize-use-uncaught-exceptions `_, "Yes" - `modernize-use-using `_, "Yes" - `mpi-buffer-deref `_, "Yes" - `mpi-type-mismatch `_, "Yes" + `modernize-concat-nested-namespaces `_, + `modernize-deprecated-headers `_, + `modernize-deprecated-ios-base-aliases `_, + `modernize-loop-convert `_, + `modernize-make-shared `_, + `modernize-make-unique `_, + `modernize-pass-by-value `_, + `modernize-raw-string-literal `_, + `modernize-redundant-void-arg `_, + `modernize-replace-auto-ptr `_, + `modernize-replace-disallow-copy-and-assign-macro `_, + `modernize-replace-random-shuffle `_, + `modernize-return-braced-init-list `_, + `modernize-shrink-to-fit `_, + `modernize-unary-static-assert `_, + `modernize-use-auto `_, + `modernize-use-bool-literals `_, + `modernize-use-default-member-init `_, + `modernize-use-emplace `_, + `modernize-use-equals-default `_, + `modernize-use-equals-delete `_, + `modernize-use-nodiscard `_, + `modernize-use-noexcept `_, + `modernize-use-nullptr `_, + `modernize-use-override `_, + `modernize-use-trailing-return-type `_, + `modernize-use-transparent-functors `_, + `modernize-use-uncaught-exceptions `_, + `modernize-use-using `_, + `mpi-buffer-deref `_, + `mpi-type-mismatch `_, `objc-avoid-nserror-init `_, `objc-dealloc-in-category `_, `objc-forbidden-subclassing `_, `objc-missing-hash `_, - `objc-nsinvocation-argument-lifetime `_, "Yes" - `objc-property-declaration `_, "Yes" - `objc-super-self `_, "Yes" + `objc-nsinvocation-argument-lifetime `_, + `objc-property-declaration `_, + `objc-super-self `_, `openmp-exception-escape `_, `openmp-use-default-none `_, - `performance-faster-string-find `_, "Yes" - `performance-for-range-copy `_, "Yes" + `performance-faster-string-find `_, + `performance-for-range-copy `_, `performance-implicit-conversion-in-loop `_, - `performance-inefficient-algorithm `_, "Yes" + `performance-inefficient-algorithm `_, `performance-inefficient-string-concatenation `_, - `performance-inefficient-vector-operation `_, "Yes" - `performance-move-const-arg `_, "Yes" - `performance-move-constructor-init `_, "Yes" + `performance-inefficient-vector-operation `_, + `performance-move-const-arg `_, + `performance-move-constructor-init `_, `performance-no-automatic-move `_, - `performance-noexcept-move-constructor `_, "Yes" - `performance-trivially-destructible `_, "Yes" - `performance-type-promotion-in-math-fn `_, "Yes" + `performance-noexcept-move-constructor `_, + `performance-trivially-destructible `_, + `performance-type-promotion-in-math-fn `_, `performance-unnecessary-copy-initialization `_, - `performance-unnecessary-value-param `_, "Yes" - `portability-restrict-system-includes `_, "Yes" + `performance-unnecessary-value-param `_, + `portability-restrict-system-includes `_, `portability-simd-intrinsics `_, `readability-avoid-const-params-in-decls `_, - `readability-braces-around-statements `_, "Yes" - `readability-const-return-type `_, "Yes" - `readability-container-size-empty `_, "Yes" + `readability-braces-around-statements `_, + `readability-const-return-type `_, + `readability-container-size-empty `_, `readability-convert-member-functions-to-static `_, - `readability-delete-null-pointer `_, "Yes" + `readability-delete-null-pointer `_, `readability-deleted-default `_, - `readability-else-after-return `_, "Yes" + `readability-else-after-return `_, `readability-function-size `_, - `readability-identifier-naming `_, "Yes" - `readability-implicit-bool-conversion `_, "Yes" - `readability-inconsistent-declaration-parameter-name `_, "Yes" - `readability-isolate-declaration `_, "Yes" + `readability-identifier-naming `_, + `readability-implicit-bool-conversion `_, + `readability-inconsistent-declaration-parameter-name `_, + `readability-isolate-declaration `_, `readability-magic-numbers `_, - `readability-make-member-function-const `_, "Yes" + `readability-make-member-function-const `_, `readability-misleading-indentation `_, - `readability-misplaced-array-index `_, "Yes" - `readability-named-parameter `_, "Yes" - `readability-non-const-parameter `_, "Yes" - `readability-qualified-auto `_, "Yes" - `readability-redundant-access-specifiers `_, "Yes" - `readability-redundant-control-flow `_, "Yes" - `readability-redundant-declaration `_, "Yes" - `readability-redundant-function-ptr-dereference `_, "Yes" - `readability-redundant-member-init `_, "Yes" + `readability-misplaced-array-index `_, + `readability-named-parameter `_, + `readability-non-const-parameter `_, + `readability-qualified-auto `_, + `readability-redundant-access-specifiers `_, + `readability-redundant-control-flow `_, + `readability-redundant-declaration `_, + `readability-redundant-function-ptr-dereference `_, + `readability-redundant-member-init `_, `readability-redundant-preprocessor `_, - `readability-redundant-smartptr-get `_, "Yes" + `readability-redundant-smartptr-get `_, `readability-redundant-string-cstr `_, - `readability-redundant-string-init `_, "Yes" - `readability-simplify-boolean-expr `_, "Yes" - `readability-simplify-subscript-expr `_, "Yes" - `readability-static-accessed-through-instance `_, "Yes" - `readability-static-definition-in-anonymous-namespace `_, "Yes" - `readability-string-compare `_, "Yes" - `readability-uniqueptr-delete-release `_, "Yes" - `readability-uppercase-literal-suffix `_, "Yes" - `readability-use-anyofallof`_, "No" + `readability-redundant-string-init `_, + `readability-simplify-boolean-expr `_, + `readability-simplify-subscript-expr `_, + `readability-static-accessed-through-instance `_, + `readability-static-definition-in-anonymous-namespace `_, + `readability-string-compare `_, + `readability-uniqueptr-delete-release `_, + `readability-uppercase-literal-suffix `_, + `readability-use-anyofallof `_, `zircon-temporary-objects `_, @@ -309,10 +311,10 @@ Clang-Tidy Checks `cert-con36-c `_, `bugprone-spuriously-wake-up-functions `_, `cert-con54-cpp `_, `bugprone-spuriously-wake-up-functions `_, - `cert-dcl03-c `_, `misc-static-assert `_, "Yes" - `cert-dcl16-c `_, `readability-uppercase-literal-suffix `_, "Yes" - `cert-dcl37-c `_, `bugprone-reserved-identifier `_, "Yes" - `cert-dcl51-cpp `_, `bugprone-reserved-identifier `_, "Yes" + `cert-dcl03-c `_, `misc-static-assert `_, + `cert-dcl16-c `_, `readability-uppercase-literal-suffix `_, + `cert-dcl37-c `_, `bugprone-reserved-identifier `_, + `cert-dcl51-cpp `_, `bugprone-reserved-identifier `_, `cert-dcl54-cpp `_, `misc-new-delete-overloads `_, `cert-dcl59-cpp `_, `google-build-namespaces `_, `cert-err09-cpp `_, `misc-throw-by-value-catch-by-reference `_, @@ -320,7 +322,7 @@ Clang-Tidy Checks `cert-fio38-c `_, `misc-non-copyable-objects `_, `cert-msc30-c `_, `cert-msc50-cpp `_, `cert-msc32-c `_, `cert-msc51-cpp `_, - `cert-oop11-cpp `_, `performance-move-constructor-init `_, "Yes" + `cert-oop11-cpp `_, `performance-move-constructor-init `_, `cert-oop54-cpp `_, `bugprone-unhandled-self-assignment `_, `cert-pos44-c `_, `bugprone-bad-signal-to-kill-thread `_, `cert-str34-c `_, `bugprone-signed-char-misuse `_, @@ -390,38 +392,36 @@ Clang-Tidy Checks `clang-analyzer-unix.cstring.NullArg `_, `Clang Static Analyzer `_, `cppcoreguidelines-avoid-c-arrays `_, `modernize-avoid-c-arrays `_, `cppcoreguidelines-avoid-magic-numbers `_, `readability-magic-numbers `_, - `cppcoreguidelines-avoid-non-const-global-variables `_, , , "" `cppcoreguidelines-c-copy-assignment-signature `_, `misc-unconventional-assign-operator `_, - `cppcoreguidelines-explicit-virtual-functions `_, `modernize-use-override `_, "Yes" + `cppcoreguidelines-explicit-virtual-functions `_, `modernize-use-override `_, `cppcoreguidelines-non-private-member-variables-in-classes `_, `misc-non-private-member-variables-in-classes `_, `fuchsia-header-anon-namespaces `_, `google-build-namespaces `_, - `google-readability-braces-around-statements `_, `readability-braces-around-statements `_, "Yes" + `google-readability-braces-around-statements `_, `readability-braces-around-statements `_, `google-readability-function-size `_, `readability-function-size `_, `google-readability-namespace-comments `_, `llvm-namespace-comment `_, `hicpp-avoid-c-arrays `_, `modernize-avoid-c-arrays `_, - `hicpp-braces-around-statements `_, `readability-braces-around-statements `_, "Yes" - `hicpp-deprecated-headers `_, `modernize-deprecated-headers `_, "Yes" - `hicpp-explicit-conversions `_, `google-explicit-constructor `_, "Yes" + `hicpp-braces-around-statements `_, `readability-braces-around-statements `_, + `hicpp-deprecated-headers `_, `modernize-deprecated-headers `_, + `hicpp-explicit-conversions `_, `google-explicit-constructor `_, `hicpp-function-size `_, `readability-function-size `_, `hicpp-invalid-access-moved `_, `bugprone-use-after-move `_, - `hicpp-member-init `_, `cppcoreguidelines-pro-type-member-init `_, "Yes" - `hicpp-move-const-arg `_, `performance-move-const-arg `_, "Yes" - `hicpp-named-parameter `_, `readability-named-parameter `_, "Yes" + `hicpp-member-init `_, `cppcoreguidelines-pro-type-member-init `_, + `hicpp-move-const-arg `_, `performance-move-const-arg `_, + `hicpp-named-parameter `_, `readability-named-parameter `_, `hicpp-new-delete-operators `_, `misc-new-delete-overloads `_, `hicpp-no-array-decay `_, `cppcoreguidelines-pro-bounds-array-to-pointer-decay `_, `hicpp-no-malloc `_, `cppcoreguidelines-no-malloc `_, `hicpp-noexcept-move `_, `performance-noexcept-move-constructor `_, `hicpp-special-member-functions `_, `cppcoreguidelines-special-member-functions `_, - `hicpp-static-assert `_, `misc-static-assert `_, "Yes" + `hicpp-static-assert `_, `misc-static-assert `_, `hicpp-undelegated-constructor `_, `bugprone-undelegated-constructor `_, - `hicpp-uppercase-literal-suffix `_, `readability-uppercase-literal-suffix `_, "Yes" - `hicpp-use-auto `_, `modernize-use-auto `_, "Yes" - `hicpp-use-emplace `_, `modernize-use-emplace `_, "Yes" - `hicpp-use-equals-default `_, `modernize-use-equals-default `_, "Yes" - `hicpp-use-equals-delete `_, `modernize-use-equals-delete `_, "Yes" - `hicpp-use-noexcept `_, `modernize-use-noexcept `_, "Yes" - `hicpp-use-nullptr `_, `modernize-use-nullptr `_, "Yes" - `hicpp-use-override `_, `modernize-use-override `_, "Yes" + `hicpp-uppercase-literal-suffix `_, `readability-uppercase-literal-suffix `_, + `hicpp-use-auto `_, `modernize-use-auto `_, + `hicpp-use-emplace `_, `modernize-use-emplace `_, + `hicpp-use-equals-default `_, `modernize-use-equals-default `_, + `hicpp-use-equals-delete `_, `modernize-use-equals-delete `_, + `hicpp-use-noexcept `_, `modernize-use-noexcept `_, + `hicpp-use-nullptr `_, `modernize-use-nullptr `_, + `hicpp-use-override `_, `modernize-use-override `_, `hicpp-vararg `_, `cppcoreguidelines-pro-type-vararg `_, - `llvm-qualified-auto `_, `readability-qualified-auto `_, "Yes" - + `llvm-qualified-auto `_, `readability-qualified-auto `_, diff --git a/clang-tools-extra/test/clang-tidy/checkers/kokkos-implicit-this-capture.cpp b/clang-tools-extra/test/clang-tidy/checkers/kokkos-implicit-this-capture.cpp new file mode 100644 index 00000000000000..f1ab05e07024f6 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/kokkos-implicit-this-capture.cpp @@ -0,0 +1,15 @@ +// RUN: %check_clang_tidy %s kokkos-implicit-this-capture %t + +// TODO Need to mock Kokkos +// FIXME: Add something that triggers the check here. +// void f(); +// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'f' is insufficiently awesome [kokkos-implicit-this-capture] + +// FIXME: Verify the applied fix. +// * Make the CHECK patterns specific enough and try to make verified lines +// unique to avoid incorrect matches. +// * Use {{}} for regular expressions. +// CHECK-FIXES: {{^}}void awesome_f();{{$}} + +// FIXME: Add something that doesn't trigger the check here. +// void awesome_f2();