[clang-tidy][NFC] Add missing "Check" suffix to filenames in clang-tidy checks (#166889)

This is part of the codebase cleanup described in
[#166753](https://github.com/llvm/llvm-project/issues/166753).
This commit is contained in:
mitchell 2025-11-08 18:02:24 +08:00 committed by GitHub
parent af456dfa11
commit 8d950d27d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
30 changed files with 124 additions and 94 deletions

View File

@ -31,7 +31,7 @@
#include "../concurrency/ThreadCanceltypeAsynchronousCheck.h"
#include "../google/UnnamedNamespaceInHeaderCheck.h"
#include "../misc/NewDeleteOverloadsCheck.h"
#include "../misc/NonCopyableObjects.h"
#include "../misc/NonCopyableObjectsCheck.h"
#include "../misc/StaticAssertCheck.h"
#include "../misc/ThrowByValueCatchByReferenceCheck.h"
#include "../modernize/AvoidSetjmpLongjmpCheck.h"

View File

@ -21,7 +21,7 @@ add_clang_library(clangTidyCppCoreGuidelinesModule STATIC
OwningMemoryCheck.cpp
PreferMemberInitializerCheck.cpp
ProBoundsArrayToPointerDecayCheck.cpp
ProBoundsAvoidUncheckedContainerAccess.cpp
ProBoundsAvoidUncheckedContainerAccessCheck.cpp
ProBoundsConstantArrayIndexCheck.cpp
ProBoundsPointerArithmeticCheck.cpp
ProTypeConstCastCheck.cpp

View File

@ -36,7 +36,7 @@
#include "OwningMemoryCheck.h"
#include "PreferMemberInitializerCheck.h"
#include "ProBoundsArrayToPointerDecayCheck.h"
#include "ProBoundsAvoidUncheckedContainerAccess.h"
#include "ProBoundsAvoidUncheckedContainerAccessCheck.h"
#include "ProBoundsConstantArrayIndexCheck.h"
#include "ProBoundsPointerArithmeticCheck.h"
#include "ProTypeConstCastCheck.h"
@ -108,7 +108,7 @@ public:
"cppcoreguidelines-prefer-member-initializer");
CheckFactories.registerCheck<ProBoundsArrayToPointerDecayCheck>(
"cppcoreguidelines-pro-bounds-array-to-pointer-decay");
CheckFactories.registerCheck<ProBoundsAvoidUncheckedContainerAccess>(
CheckFactories.registerCheck<ProBoundsAvoidUncheckedContainerAccessCheck>(
"cppcoreguidelines-pro-bounds-avoid-unchecked-container-access");
CheckFactories.registerCheck<ProBoundsConstantArrayIndexCheck>(
"cppcoreguidelines-pro-bounds-constant-array-index");

View File

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "ProBoundsAvoidUncheckedContainerAccess.h"
#include "ProBoundsAvoidUncheckedContainerAccessCheck.h"
#include "../utils/Matchers.h"
#include "../utils/OptionsUtils.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
@ -19,8 +19,9 @@ namespace clang::tidy::cppcoreguidelines {
static constexpr llvm::StringRef DefaultExclusionStr =
"::std::map;::std::unordered_map;::std::flat_map";
ProBoundsAvoidUncheckedContainerAccess::ProBoundsAvoidUncheckedContainerAccess(
StringRef Name, ClangTidyContext *Context)
ProBoundsAvoidUncheckedContainerAccessCheck::
ProBoundsAvoidUncheckedContainerAccessCheck(StringRef Name,
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
ExcludedClasses(utils::options::parseStringList(
Options.get("ExcludeClasses", DefaultExclusionStr))),
@ -28,7 +29,7 @@ ProBoundsAvoidUncheckedContainerAccess::ProBoundsAvoidUncheckedContainerAccess(
FixFunction(Options.get("FixFunction", "gsl::at")),
FixFunctionEmptyArgs(Options.get("FixFunctionEmptyArgs", FixFunction)) {}
void ProBoundsAvoidUncheckedContainerAccess::storeOptions(
void ProBoundsAvoidUncheckedContainerAccessCheck::storeOptions(
ClangTidyOptions::OptionMap &Opts) {
Options.store(Opts, "ExcludeClasses",
utils::options::serializeStringList(ExcludedClasses));
@ -86,7 +87,7 @@ findAlternativeAt(const CXXMethodDecl *MatchedOperator) {
return nullptr;
}
void ProBoundsAvoidUncheckedContainerAccess::registerMatchers(
void ProBoundsAvoidUncheckedContainerAccessCheck::registerMatchers(
MatchFinder *Finder) {
Finder->addMatcher(
mapAnyOf(cxxOperatorCallExpr, cxxMemberCallExpr)
@ -100,7 +101,7 @@ void ProBoundsAvoidUncheckedContainerAccess::registerMatchers(
this);
}
void ProBoundsAvoidUncheckedContainerAccess::check(
void ProBoundsAvoidUncheckedContainerAccessCheck::check(
const MatchFinder::MatchResult &Result) {
const auto *MatchedExpr = Result.Nodes.getNodeAs<CallExpr>("caller");
@ -251,7 +252,7 @@ void ProBoundsAvoidUncheckedContainerAccess::check(
} // namespace clang::tidy::cppcoreguidelines
namespace clang::tidy {
using P = cppcoreguidelines::ProBoundsAvoidUncheckedContainerAccess;
using P = cppcoreguidelines::ProBoundsAvoidUncheckedContainerAccessCheck;
llvm::ArrayRef<std::pair<P::FixModes, StringRef>>
OptionEnumMapping<P::FixModes>::getEnumMapping() {

View File

@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PROBOUNDSAVOIDUNCHECKEDCONTAINERACCESS_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PROBOUNDSAVOIDUNCHECKEDCONTAINERACCESS_H
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PROBOUNDSAVOIDUNCHECKEDCONTAINERACCESSCHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PROBOUNDSAVOIDUNCHECKEDCONTAINERACCESSCHECK_H
#include "../ClangTidyCheck.h"
@ -20,10 +20,10 @@ namespace clang::tidy::cppcoreguidelines {
/// https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#slcon3-avoid-bounds-errors
/// For the user-facing documentation see:
/// https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/pro-bounds-avoid-unchecked-container-access.html
class ProBoundsAvoidUncheckedContainerAccess : public ClangTidyCheck {
class ProBoundsAvoidUncheckedContainerAccessCheck : public ClangTidyCheck {
public:
ProBoundsAvoidUncheckedContainerAccess(StringRef Name,
ClangTidyContext *Context);
ProBoundsAvoidUncheckedContainerAccessCheck(StringRef Name,
ClangTidyContext *Context);
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
return LangOpts.CPlusPlus;
}
@ -46,11 +46,11 @@ private:
namespace clang::tidy {
template <>
struct OptionEnumMapping<
cppcoreguidelines::ProBoundsAvoidUncheckedContainerAccess::FixModes> {
cppcoreguidelines::ProBoundsAvoidUncheckedContainerAccessCheck::FixModes> {
static ArrayRef<std::pair<
cppcoreguidelines::ProBoundsAvoidUncheckedContainerAccess::FixModes,
cppcoreguidelines::ProBoundsAvoidUncheckedContainerAccessCheck::FixModes,
StringRef>>
getEnumMapping();
};
} // namespace clang::tidy
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PROBOUNDSAVOIDUNCHECKEDCONTAINERACCESS_H
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PROBOUNDSAVOIDUNCHECKEDCONTAINERACCESSCHECK_H

View File

@ -25,12 +25,12 @@ add_clang_library(clangTidyMiscModule STATIC
HeaderIncludeCycleCheck.cpp
IncludeCleanerCheck.cpp
MiscTidyModule.cpp
MisleadingBidirectional.cpp
MisleadingIdentifier.cpp
MisleadingBidirectionalCheck.cpp
MisleadingIdentifierCheck.cpp
MisplacedConstCheck.cpp
NewDeleteOverloadsCheck.cpp
NoRecursionCheck.cpp
NonCopyableObjects.cpp
NonCopyableObjectsCheck.cpp
NonPrivateMemberVariablesInClassesCheck.cpp
OverrideWithDifferentVisibilityCheck.cpp
RedundantExpressionCheck.cpp

View File

@ -15,12 +15,12 @@
#include "DefinitionsInHeadersCheck.h"
#include "HeaderIncludeCycleCheck.h"
#include "IncludeCleanerCheck.h"
#include "MisleadingBidirectional.h"
#include "MisleadingIdentifier.h"
#include "MisleadingBidirectionalCheck.h"
#include "MisleadingIdentifierCheck.h"
#include "MisplacedConstCheck.h"
#include "NewDeleteOverloadsCheck.h"
#include "NoRecursionCheck.h"
#include "NonCopyableObjects.h"
#include "NonCopyableObjectsCheck.h"
#include "NonPrivateMemberVariablesInClassesCheck.h"
#include "OverrideWithDifferentVisibilityCheck.h"
#include "RedundantExpressionCheck.h"

View File

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "MisleadingBidirectional.h"
#include "MisleadingBidirectionalCheck.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Lex/Preprocessor.h"

View File

@ -6,13 +6,17 @@
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGBIDIRECTIONAL_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGBIDIRECTIONAL_H
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGBIDIRECTIONALCHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGBIDIRECTIONALCHECK_H
#include "../ClangTidyCheck.h"
namespace clang::tidy::misc {
/// Warns about unterminated bidirectional unicode sequence.
///
/// For the user-facing documentation see:
/// https://clang.llvm.org/extra/clang-tidy/checks/misc/misleading-bidirectional.html
class MisleadingBidirectionalCheck : public ClangTidyCheck {
public:
MisleadingBidirectionalCheck(StringRef Name, ClangTidyContext *Context);
@ -31,4 +35,4 @@ private:
} // namespace clang::tidy::misc
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGBIDIRECTIONAL_H
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGBIDIRECTIONALCHECK_H

View File

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "MisleadingIdentifier.h"
#include "MisleadingIdentifierCheck.h"
#include "llvm/Support/ConvertUTF.h"

View File

@ -6,13 +6,19 @@
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGIDENTIFIER_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGIDENTIFIER_H
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGIDENTIFIERCHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGIDENTIFIERCHECK_H
#include "../ClangTidyCheck.h"
namespace clang::tidy::misc {
/// Finds identifiers that contain Unicode characters with right-to-left
/// direction, which can be confusing as they may change the understanding of a
/// whole statement line.
///
/// For the user-facing documentation see:
/// https://clang.llvm.org/extra/clang-tidy/checks/misc/misleading-identifier.html
class MisleadingIdentifierCheck : public ClangTidyCheck {
public:
MisleadingIdentifierCheck(StringRef Name, ClangTidyContext *Context);
@ -24,4 +30,4 @@ public:
} // namespace clang::tidy::misc
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGIDENTIFIER_H
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGIDENTIFIERCHECK_H

View File

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "NonCopyableObjects.h"
#include "NonCopyableObjectsCheck.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"

View File

@ -6,15 +6,18 @@
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONCOPYABLEOBJECTS_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONCOPYABLEOBJECTS_H
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONCOPYABLEOBJECTSCHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONCOPYABLEOBJECTSCHECK_H
#include "../ClangTidyCheck.h"
namespace clang::tidy::misc {
/// The check flags dereferences and non-pointer declarations of objects that
/// Flags dereferences and non-pointer declarations of objects that
/// are not meant to be passed by value, such as C FILE objects.
///
/// For the user-facing documentation see:
/// https://clang.llvm.org/extra/clang-tidy/checks/misc/non-copyable-objects.html
class NonCopyableObjectsCheck : public ClangTidyCheck {
public:
NonCopyableObjectsCheck(StringRef Name, ClangTidyContext *Context)
@ -25,4 +28,4 @@ public:
} // namespace clang::tidy::misc
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONCOPYABLEOBJECTS_H
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONCOPYABLEOBJECTSCHECK_H

View File

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "AssertEquals.h"
#include "AssertEqualsCheck.h"
#include "llvm/ADT/StringMap.h"
#include <string>
@ -21,7 +21,7 @@ static const llvm::StringMap<StringRef> NameMap{
{"XCTAssertNotEqual", "XCTAssertNotEqualObjects"},
};
void AssertEquals::registerMatchers(MatchFinder *Finder) {
void AssertEqualsCheck::registerMatchers(MatchFinder *Finder) {
for (const auto &[CurrName, _] : NameMap) {
Finder->addMatcher(
binaryOperator(anyOf(hasOperatorName("!="), hasOperatorName("==")),
@ -35,7 +35,8 @@ void AssertEquals::registerMatchers(MatchFinder *Finder) {
}
}
void AssertEquals::check(const ast_matchers::MatchFinder::MatchResult &Result) {
void AssertEqualsCheck::check(
const ast_matchers::MatchFinder::MatchResult &Result) {
for (const auto &[CurrName, TargetName] : NameMap) {
if (const auto *Root = Result.Nodes.getNodeAs<BinaryOperator>(CurrName)) {
const SourceManager *Sm = Result.SourceManager;

View File

@ -6,22 +6,22 @@
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_ASSERTEQUALS_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_ASSERTEQUALS_H
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_ASSERTEQUALSCHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_ASSERTEQUALSCHECK_H
#include "../ClangTidyCheck.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
namespace clang::tidy::objc {
/// Warn if XCTAssertEqual() or XCTAssertNotEqual() is used with at least one
/// Warns if XCTAssertEqual() or XCTAssertNotEqual() is used with at least one
/// operands of type NSString*.
///
/// For the user-facing documentation see:
/// https://clang.llvm.org/extra/clang-tidy/checks/objc/assert-equals.html
class AssertEquals final : public ClangTidyCheck {
class AssertEqualsCheck final : public ClangTidyCheck {
public:
AssertEquals(StringRef Name, ClangTidyContext *Context)
AssertEqualsCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context) {}
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
return LangOpts.ObjC;
@ -32,4 +32,4 @@ public:
} // namespace clang::tidy::objc
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_ASSERTEQUALS_H
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_ASSERTEQUALSCHECK_H

View File

@ -4,7 +4,7 @@ set(LLVM_LINK_COMPONENTS
)
add_clang_library(clangTidyObjCModule STATIC
AssertEquals.cpp
AssertEqualsCheck.cpp
AvoidNSErrorInitCheck.cpp
DeallocInCategoryCheck.cpp
ForbiddenSubclassingCheck.cpp

View File

@ -9,7 +9,7 @@
#include "../ClangTidy.h"
#include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h"
#include "AssertEquals.h"
#include "AssertEqualsCheck.h"
#include "AvoidNSErrorInitCheck.h"
#include "DeallocInCategoryCheck.h"
#include "ForbiddenSubclassingCheck.h"
@ -29,7 +29,7 @@ public:
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
CheckFactories.registerCheck<AvoidNSErrorInitCheck>(
"objc-avoid-nserror-init");
CheckFactories.registerCheck<AssertEquals>("objc-assert-equals");
CheckFactories.registerCheck<AssertEqualsCheck>("objc-assert-equals");
CheckFactories.registerCheck<DeallocInCategoryCheck>(
"objc-dealloc-in-category");

View File

@ -23,7 +23,7 @@ add_clang_library(clangTidyPerformanceModule STATIC
PerformanceTidyModule.cpp
TriviallyDestructibleCheck.cpp
TypePromotionInMathFnCheck.cpp
UnnecessaryCopyInitialization.cpp
UnnecessaryCopyInitializationCheck.cpp
UnnecessaryValueParamCheck.cpp
LINK_LIBS

View File

@ -26,7 +26,7 @@
#include "NoexceptSwapCheck.h"
#include "TriviallyDestructibleCheck.h"
#include "TypePromotionInMathFnCheck.h"
#include "UnnecessaryCopyInitialization.h"
#include "UnnecessaryCopyInitializationCheck.h"
#include "UnnecessaryValueParamCheck.h"
namespace clang::tidy {
@ -66,7 +66,7 @@ public:
"performance-trivially-destructible");
CheckFactories.registerCheck<TypePromotionInMathFnCheck>(
"performance-type-promotion-in-math-fn");
CheckFactories.registerCheck<UnnecessaryCopyInitialization>(
CheckFactories.registerCheck<UnnecessaryCopyInitializationCheck>(
"performance-unnecessary-copy-initialization");
CheckFactories.registerCheck<UnnecessaryValueParamCheck>(
"performance-unnecessary-value-param");

View File

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "UnnecessaryCopyInitialization.h"
#include "UnnecessaryCopyInitializationCheck.h"
#include "../utils/DeclRefExprUtils.h"
#include "../utils/FixItHintUtils.h"
#include "../utils/LexerUtils.h"
@ -227,7 +227,7 @@ static QualType constructorArgumentType(const VarDecl *OldVar,
return MethodDecl->getReturnType();
}
UnnecessaryCopyInitialization::UnnecessaryCopyInitialization(
UnnecessaryCopyInitializationCheck::UnnecessaryCopyInitializationCheck(
StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
AllowedTypes(
@ -235,7 +235,7 @@ UnnecessaryCopyInitialization::UnnecessaryCopyInitialization(
ExcludedContainerTypes(utils::options::parseStringList(
Options.get("ExcludedContainerTypes", ""))) {}
void UnnecessaryCopyInitialization::registerMatchers(MatchFinder *Finder) {
void UnnecessaryCopyInitializationCheck::registerMatchers(MatchFinder *Finder) {
auto LocalVarCopiedFrom =
[this](const ast_matchers::internal::Matcher<Expr> &CopyCtorArg) {
return compoundStmt(
@ -276,7 +276,7 @@ void UnnecessaryCopyInitialization::registerMatchers(MatchFinder *Finder) {
this);
}
void UnnecessaryCopyInitialization::check(
void UnnecessaryCopyInitializationCheck::check(
const MatchFinder::MatchResult &Result) {
const auto &NewVar = *Result.Nodes.getNodeAs<VarDecl>("newVarDecl");
const auto &BlockStmt = *Result.Nodes.getNodeAs<Stmt>("blockStmt");
@ -325,7 +325,7 @@ void UnnecessaryCopyInitialization::check(
}
}
void UnnecessaryCopyInitialization::handleCopyFromMethodReturn(
void UnnecessaryCopyInitializationCheck::handleCopyFromMethodReturn(
const CheckContext &Ctx, const VarDecl *ObjectArg) {
const bool IsConstQualified = Ctx.Var.getType().isConstQualified();
if (!IsConstQualified && !Ctx.IsVarOnlyUsedAsConst)
@ -337,7 +337,7 @@ void UnnecessaryCopyInitialization::handleCopyFromMethodReturn(
diagnoseCopyFromMethodReturn(Ctx);
}
void UnnecessaryCopyInitialization::handleCopyFromLocalVar(
void UnnecessaryCopyInitializationCheck::handleCopyFromLocalVar(
const CheckContext &Ctx, const VarDecl &OldVar) {
if (!Ctx.IsVarOnlyUsedAsConst ||
!isInitializingVariableImmutable(OldVar, Ctx.BlockStmt, Ctx.ASTCtx,
@ -346,7 +346,7 @@ void UnnecessaryCopyInitialization::handleCopyFromLocalVar(
diagnoseCopyFromLocalVar(Ctx, OldVar);
}
void UnnecessaryCopyInitialization::diagnoseCopyFromMethodReturn(
void UnnecessaryCopyInitializationCheck::diagnoseCopyFromMethodReturn(
const CheckContext &Ctx) {
auto Diagnostic =
diag(Ctx.Var.getLocation(),
@ -360,7 +360,7 @@ void UnnecessaryCopyInitialization::diagnoseCopyFromMethodReturn(
maybeIssueFixes(Ctx, Diagnostic);
}
void UnnecessaryCopyInitialization::diagnoseCopyFromLocalVar(
void UnnecessaryCopyInitializationCheck::diagnoseCopyFromLocalVar(
const CheckContext &Ctx, const VarDecl &OldVar) {
auto Diagnostic =
diag(Ctx.Var.getLocation(),
@ -372,7 +372,7 @@ void UnnecessaryCopyInitialization::diagnoseCopyFromLocalVar(
maybeIssueFixes(Ctx, Diagnostic);
}
void UnnecessaryCopyInitialization::maybeIssueFixes(
void UnnecessaryCopyInitializationCheck::maybeIssueFixes(
const CheckContext &Ctx, DiagnosticBuilder &Diagnostic) {
if (Ctx.IssueFix) {
if (Ctx.IsVarUnused)
@ -382,7 +382,7 @@ void UnnecessaryCopyInitialization::maybeIssueFixes(
}
}
void UnnecessaryCopyInitialization::storeOptions(
void UnnecessaryCopyInitializationCheck::storeOptions(
ClangTidyOptions::OptionMap &Opts) {
Options.store(Opts, "AllowedTypes",
utils::options::serializeStringList(AllowedTypes));

View File

@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_UNNECESSARYCOPYINITIALIZATION_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_UNNECESSARYCOPYINITIALIZATION_H
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_UNNECESSARYCOPYINITIALIZATIONCHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_UNNECESSARYCOPYINITIALIZATIONCHECK_H
#include "../ClangTidyCheck.h"
#include "clang/AST/Decl.h"
@ -22,9 +22,12 @@ namespace clang::tidy::performance {
// The check currently only understands a subset of variables that are
// guaranteed to outlive the const reference returned, namely: const variables,
// const references, and const pointers to const.
class UnnecessaryCopyInitialization : public ClangTidyCheck {
//
// For the user-facing documentation see:
// https://clang.llvm.org/extra/clang-tidy/checks/performance/unnecessary-copy-initialization.html
class UnnecessaryCopyInitializationCheck : public ClangTidyCheck {
public:
UnnecessaryCopyInitialization(StringRef Name, ClangTidyContext *Context);
UnnecessaryCopyInitializationCheck(StringRef Name, ClangTidyContext *Context);
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
return LangOpts.CPlusPlus;
}
@ -64,4 +67,4 @@ private:
} // namespace clang::tidy::performance
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_UNNECESSARYCOPYINITIALIZATION_H
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_UNNECESSARYCOPYINITIALIZATIONCHECK_H

View File

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "AvoidConstParamsInDecls.h"
#include "AvoidConstParamsInDeclsCheck.h"
#include "../utils/LexerUtils.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/ASTMatchers/ASTMatchers.h"
@ -38,11 +38,12 @@ findConstToRemove(const ParmVarDecl &Param,
tok::kw_const, FileRange, *Result.Context, *Result.SourceManager);
}
void AvoidConstParamsInDecls::storeOptions(ClangTidyOptions::OptionMap &Opts) {
void AvoidConstParamsInDeclsCheck::storeOptions(
ClangTidyOptions::OptionMap &Opts) {
Options.store(Opts, "IgnoreMacros", IgnoreMacros);
}
void AvoidConstParamsInDecls::registerMatchers(MatchFinder *Finder) {
void AvoidConstParamsInDeclsCheck::registerMatchers(MatchFinder *Finder) {
const auto ConstParamDecl =
parmVarDecl(hasType(qualType(isConstQualified()))).bind("param");
Finder->addMatcher(functionDecl(unless(isDefinition()),
@ -51,7 +52,8 @@ void AvoidConstParamsInDecls::registerMatchers(MatchFinder *Finder) {
this);
}
void AvoidConstParamsInDecls::check(const MatchFinder::MatchResult &Result) {
void AvoidConstParamsInDeclsCheck::check(
const MatchFinder::MatchResult &Result) {
const auto *Func = Result.Nodes.getNodeAs<FunctionDecl>("func");
const auto *Param = Result.Nodes.getNodeAs<ParmVarDecl>("param");

View File

@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDCONSTPARAMSINDECLS_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDCONSTPARAMSINDECLS_H
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDCONSTPARAMSINDECLSCHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDCONSTPARAMSINDECLSCHECK_H
#include "../ClangTidyCheck.h"
@ -15,9 +15,12 @@ namespace clang::tidy::readability {
// Detect function declarations that have const value parameters and discourage
// them.
class AvoidConstParamsInDecls : public ClangTidyCheck {
//
// For the user-facing documentation see:
// https://clang.llvm.org/extra/clang-tidy/checks/readability/avoid-const-params-in-decls.html
class AvoidConstParamsInDeclsCheck : public ClangTidyCheck {
public:
AvoidConstParamsInDecls(StringRef Name, ClangTidyContext *Context)
AvoidConstParamsInDeclsCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
IgnoreMacros(Options.get("IgnoreMacros", true)) {}
@ -34,4 +37,4 @@ private:
} // namespace clang::tidy::readability
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDCONSTPARAMSINDECLS_H
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDCONSTPARAMSINDECLSCHECK_H

View File

@ -5,7 +5,7 @@ set(LLVM_LINK_COMPONENTS
add_clang_library(clangTidyReadabilityModule STATIC
AmbiguousSmartptrResetCallCheck.cpp
AvoidConstParamsInDecls.cpp
AvoidConstParamsInDeclsCheck.cpp
AvoidNestedConditionalOperatorCheck.cpp
AvoidReturnWithVoidValueCheck.cpp
AvoidUnconditionalPreprocessorIfCheck.cpp
@ -14,7 +14,7 @@ add_clang_library(clangTidyReadabilityModule STATIC
ContainerContainsCheck.cpp
ContainerDataPointerCheck.cpp
ContainerSizeEmptyCheck.cpp
ConvertMemberFunctionsToStatic.cpp
ConvertMemberFunctionsToStaticCheck.cpp
DeleteNullPointerCheck.cpp
DuplicateIncludeCheck.cpp
ElseAfterReturnCheck.cpp

View File

@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
#include "ConvertMemberFunctionsToStatic.h"
#include "ConvertMemberFunctionsToStaticCheck.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/RecursiveASTVisitor.h"
@ -78,7 +78,8 @@ AST_MATCHER(CXXMethodDecl, usesThis) {
} // namespace
void ConvertMemberFunctionsToStatic::registerMatchers(MatchFinder *Finder) {
void ConvertMemberFunctionsToStaticCheck::registerMatchers(
MatchFinder *Finder) {
Finder->addMatcher(
cxxMethodDecl(
isDefinition(), isUserProvided(),
@ -131,7 +132,7 @@ static SourceRange getLocationOfConst(const TypeSourceInfo *TSI,
return {Start, Start.getLocWithOffset(strlen("const") - 1)};
}
void ConvertMemberFunctionsToStatic::check(
void ConvertMemberFunctionsToStaticCheck::check(
const MatchFinder::MatchResult &Result) {
const auto *Definition = Result.Nodes.getNodeAs<CXXMethodDecl>("x");

View File

@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_CONVERTMEMBERFUNCTIONSTOSTATIC_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_CONVERTMEMBERFUNCTIONSTOSTATIC_H
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_CONVERTMEMBERFUNCTIONSTOSTATICCHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_CONVERTMEMBERFUNCTIONSTOSTATICCHECK_H
#include "../ClangTidyCheck.h"
@ -18,10 +18,10 @@ namespace clang::tidy::readability {
///
/// For the user-facing documentation see:
/// https://clang.llvm.org/extra/clang-tidy/checks/
/// readability-convert-member-functions-to-static.html
class ConvertMemberFunctionsToStatic : public ClangTidyCheck {
/// readability/convert-member-functions-to-static.html
class ConvertMemberFunctionsToStaticCheck : public ClangTidyCheck {
public:
ConvertMemberFunctionsToStatic(StringRef Name, ClangTidyContext *Context)
ConvertMemberFunctionsToStaticCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context) {}
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
return LangOpts.CPlusPlus;
@ -32,4 +32,4 @@ public:
} // namespace clang::tidy::readability
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_CONVERTMEMBERFUNCTIONSTOSTATIC_H
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_CONVERTMEMBERFUNCTIONSTOSTATICCHECK_H

View File

@ -10,7 +10,7 @@
#include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h"
#include "AmbiguousSmartptrResetCallCheck.h"
#include "AvoidConstParamsInDecls.h"
#include "AvoidConstParamsInDeclsCheck.h"
#include "AvoidNestedConditionalOperatorCheck.h"
#include "AvoidReturnWithVoidValueCheck.h"
#include "AvoidUnconditionalPreprocessorIfCheck.h"
@ -19,7 +19,7 @@
#include "ContainerContainsCheck.h"
#include "ContainerDataPointerCheck.h"
#include "ContainerSizeEmptyCheck.h"
#include "ConvertMemberFunctionsToStatic.h"
#include "ConvertMemberFunctionsToStaticCheck.h"
#include "DeleteNullPointerCheck.h"
#include "DuplicateIncludeCheck.h"
#include "ElseAfterReturnCheck.h"
@ -74,7 +74,7 @@ public:
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
CheckFactories.registerCheck<AmbiguousSmartptrResetCallCheck>(
"readability-ambiguous-smartptr-reset-call");
CheckFactories.registerCheck<AvoidConstParamsInDecls>(
CheckFactories.registerCheck<AvoidConstParamsInDeclsCheck>(
"readability-avoid-const-params-in-decls");
CheckFactories.registerCheck<AvoidNestedConditionalOperatorCheck>(
"readability-avoid-nested-conditional-operator");
@ -92,7 +92,7 @@ public:
"readability-container-data-pointer");
CheckFactories.registerCheck<ContainerSizeEmptyCheck>(
"readability-container-size-empty");
CheckFactories.registerCheck<ConvertMemberFunctionsToStatic>(
CheckFactories.registerCheck<ConvertMemberFunctionsToStaticCheck>(
"readability-convert-member-functions-to-static");
CheckFactories.registerCheck<DeleteNullPointerCheck>(
"readability-delete-null-pointer");

View File

@ -8,3 +8,6 @@ cert-fio38-c
The `cert-fio38-c` check is an alias, please see
:doc:`misc-non-copyable-objects <../misc/non-copyable-objects>` for more
information.
This check corresponds to CERT C++ Coding Standard rule `FIO38-C. Do not copy a FILE object
<https://www.securecoding.cert.org/confluence/display/c/FIO38-C.+Do+not+copy+a+FILE+object>`_.

View File

@ -3,7 +3,7 @@
misc-misleading-bidirectional
=============================
Warn about unterminated bidirectional unicode sequence, detecting potential attack
Warns about unterminated bidirectional unicode sequence, detecting potential attack
as described in the `Trojan Source <https://www.trojansource.codes>`_ attack.
Example:

View File

@ -5,9 +5,12 @@ misc-non-copyable-objects
`cert-fio38-c` redirects here as an alias for this check.
The check flags dereferences and non-pointer declarations of objects that are
Flags dereferences and non-pointer declarations of objects that are
not meant to be passed by value, such as C FILE objects or POSIX
``pthread_mutex_t`` objects.
References
----------
This check corresponds to CERT C++ Coding Standard rule `FIO38-C. Do not copy a FILE object
<https://www.securecoding.cert.org/confluence/display/c/FIO38-C.+Do+not+copy+a+FILE+object>`_.