clang-tools 20.0.0git
AbseilTidyModule.cpp
Go to the documentation of this file.
1//===------- AbseilTidyModule.cpp - clang-tidy ----------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "../ClangTidy.h"
10#include "../ClangTidyModule.h"
11#include "../ClangTidyModuleRegistry.h"
12#include "CleanupCtadCheck.h"
23#include "NoNamespaceCheck.h"
25#include "StrCatAppendCheck.h"
28#include "TimeComparisonCheck.h"
31
32namespace clang::tidy {
33namespace abseil {
34
36public:
37 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
38 CheckFactories.registerCheck<CleanupCtadCheck>("abseil-cleanup-ctad");
40 "abseil-duration-addition");
42 "abseil-duration-comparison");
44 "abseil-duration-conversion-cast");
46 "abseil-duration-division");
48 "abseil-duration-factory-float");
50 "abseil-duration-factory-scale");
52 "abseil-duration-subtraction");
54 "abseil-duration-unnecessary-conversion");
56 "abseil-faster-strsplit-delimiter");
58 "abseil-no-internal-dependencies");
59 CheckFactories.registerCheck<NoNamespaceCheck>("abseil-no-namespace");
61 "abseil-redundant-strcat-calls");
62 CheckFactories.registerCheck<StrCatAppendCheck>(
63 "abseil-str-cat-append");
65 "abseil-string-find-startswith");
67 "abseil-string-find-str-contains");
68 CheckFactories.registerCheck<TimeComparisonCheck>(
69 "abseil-time-comparison");
70 CheckFactories.registerCheck<TimeSubtractionCheck>(
71 "abseil-time-subtraction");
73 "abseil-upgrade-duration-conversions");
74 }
75};
76
77// Register the AbseilModule using this statically initialized variable.
78static ClangTidyModuleRegistry::Add<AbseilModule> X("abseil-module",
79 "Add Abseil checks.");
80
81} // namespace abseil
82
83// This anchor is used to force the linker to link in the generated object file
84// and thus register the AbseilModule.
85volatile int AbseilModuleAnchorSource = 0;
86
87} // namespace clang::tidy
int X
A collection of ClangTidyCheckFactory instances.
void registerCheck(llvm::StringRef CheckName)
Registers the CheckType with the name Name.
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module.
Suggests switching the initialization pattern of absl::Cleanup instances from the factory function to...
Checks for cases where addition should be performed in the absl::Time domain.
Prefer comparison in the absl::Duration domain instead of the numeric domain.
Checks for casts of absl::Duration conversion functions, and recommends the right conversion function...
This check finds cases where Duration factories are being called with floating point arguments,...
This check finds cases where the incorrect Duration factory function is being used by looking for sca...
Checks for cases where subtraction should be performed in the absl::Duration domain.
Finds and fixes cases where absl::Duration values are being converted to numeric types and back again...
Finds instances of absl::StrSplit() or absl::MaxSplits() where the delimiter is a single character st...
Finds instances where the user depends on internal details and warns them against doing so.
This check ensures users don't open namespace absl, as that violates Abseil's compatibility guideline...
Flags redundant calls to absl::StrCat when the result is being passed to another call of absl::StrCat...
Flags uses of absl::StrCat to append to a string.
Finds s.find(...) == string::npos comparisons (for various string-like types) and suggests replacing ...
Prefer comparison in the absl::Time domain instead of the numeric domain.
Finds and fixes absl::Time subtraction expressions to do subtraction in the time domain instead of th...
Finds deprecated uses of absl::Duration arithmetic operators and factories.
volatile int AbseilModuleAnchorSource