clang-tools  14.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 "DurationAdditionCheck.h"
15 #include "DurationDivisionCheck.h"
22 #include "NoNamespaceCheck.h"
24 #include "StrCatAppendCheck.h"
27 #include "TimeComparisonCheck.h"
28 #include "TimeSubtractionCheck.h"
30 
31 namespace clang {
32 namespace tidy {
33 namespace abseil {
34 
35 class AbseilModule : public ClangTidyModule {
36 public:
37  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
38  CheckFactories.registerCheck<DurationAdditionCheck>(
39  "abseil-duration-addition");
40  CheckFactories.registerCheck<DurationComparisonCheck>(
41  "abseil-duration-comparison");
43  "abseil-duration-conversion-cast");
44  CheckFactories.registerCheck<DurationDivisionCheck>(
45  "abseil-duration-division");
47  "abseil-duration-factory-float");
49  "abseil-duration-factory-scale");
51  "abseil-duration-subtraction");
53  "abseil-duration-unnecessary-conversion");
55  "abseil-faster-strsplit-delimiter");
57  "abseil-no-internal-dependencies");
58  CheckFactories.registerCheck<NoNamespaceCheck>("abseil-no-namespace");
60  "abseil-redundant-strcat-calls");
61  CheckFactories.registerCheck<StrCatAppendCheck>(
62  "abseil-str-cat-append");
64  "abseil-string-find-startswith");
66  "abseil-string-find-str-contains");
67  CheckFactories.registerCheck<TimeComparisonCheck>(
68  "abseil-time-comparison");
69  CheckFactories.registerCheck<TimeSubtractionCheck>(
70  "abseil-time-subtraction");
72  "abseil-upgrade-duration-conversions");
73  }
74 };
75 
76 // Register the AbseilModule using this statically initialized variable.
77 static ClangTidyModuleRegistry::Add<AbseilModule> X("abseil-module",
78  "Add Abseil checks.");
79 
80 } // namespace abseil
81 
82 // This anchor is used to force the linker to link in the generated object file
83 // and thus register the AbseilModule.
84 volatile int AbseilModuleAnchorSource = 0;
85 
86 } // namespace tidy
87 } // namespace clang
DurationComparisonCheck.h
clang::tidy::abseil::StringFindStrContainsCheck
Finds s.find(...) == string::npos comparisons (for various string-like types) and suggests replacing ...
Definition: StringFindStrContainsCheck.h:24
clang::tidy::abseil::NoNamespaceCheck
This check ensures users don't open namespace absl, as that violates Abseil's compatibility guideline...
Definition: NoNamespaceCheck.h:23
DurationUnnecessaryConversionCheck.h
DurationDivisionCheck.h
TimeComparisonCheck.h
StringFindStartswithCheck.h
DurationFactoryScaleCheck.h
DurationFactoryFloatCheck.h
RedundantStrcatCallsCheck.h
clang::tidy::abseil::RedundantStrcatCallsCheck
Flags redundant calls to absl::StrCat when the result is being passed to another call of absl::StrCat...
Definition: RedundantStrcatCallsCheck.h:26
clang::tidy::abseil::DurationAdditionCheck
Checks for cases where addition should be performed in the absl::Time domain.
Definition: DurationAdditionCheck.h:23
clang::tidy::ClangTidyCheckFactories
A collection of ClangTidyCheckFactory instances.
Definition: ClangTidyModule.h:28
StringFindStrContainsCheck.h
clang::tidy::abseil::AbseilModule
Definition: AbseilTidyModule.cpp:35
clang::tidy::abseil::FasterStrsplitDelimiterCheck
Finds instances of absl::StrSplit() or absl::MaxSplits() where the delimiter is a single character st...
Definition: FasterStrsplitDelimiterCheck.h:23
clang::tidy::abseil::DurationDivisionCheck
Definition: DurationDivisionCheck.h:23
clang::tidy::abseil::NoInternalDependenciesCheck
Finds instances where the user depends on internal details and warns them against doing so.
Definition: NoInternalDependenciesCheck.h:23
clang::tidy::abseil::TimeComparisonCheck
Prefer comparison in the absl::Time domain instead of the numeric domain.
Definition: TimeComparisonCheck.h:23
clang::tidy::abseil::DurationConversionCastCheck
Checks for casts of absl::Duration conversion functions, and recommends the right conversion function...
Definition: DurationConversionCastCheck.h:23
clang::tidy::abseil::UpgradeDurationConversionsCheck
Finds deprecated uses of absl::Duration arithmetic operators and factories.
Definition: UpgradeDurationConversionsCheck.h:25
DurationAdditionCheck.h
clang::tidy::abseil::X
static ClangTidyModuleRegistry::Add< AbseilModule > X("abseil-module", "Add Abseil checks.")
clang::tidy::abseil::DurationFactoryScaleCheck
This check finds cases where the incorrect Duration factory function is being used by looking for sca...
Definition: DurationFactoryScaleCheck.h:25
clang::tidy::abseil::DurationUnnecessaryConversionCheck
Finds and fixes cases where absl::Duration values are being converted to numeric types and back again...
Definition: DurationUnnecessaryConversionCheck.h:23
StrCatAppendCheck.h
clang::tidy::abseil::StringFindStartswithCheck
Definition: StringFindStartswithCheck.h:27
DurationConversionCastCheck.h
NoInternalDependenciesCheck.h
DurationSubtractionCheck.h
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::tidy::abseil::StrCatAppendCheck
Flags uses of absl::StrCat to append to a string.
Definition: StrCatAppendCheck.h:23
FasterStrsplitDelimiterCheck.h
clang::tidy::abseil::DurationComparisonCheck
Prefer comparison in the absl::Duration domain instead of the numeric domain.
Definition: DurationComparisonCheck.h:23
NoNamespaceCheck.h
clang::tidy::abseil::AbseilModule::addCheckFactories
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module.
Definition: AbseilTidyModule.cpp:37
clang::tidy::abseil::TimeSubtractionCheck
Finds and fixes absl::Time subtraction expressions to do subtraction in the time domain instead of th...
Definition: TimeSubtractionCheck.h:23
UpgradeDurationConversionsCheck.h
TimeSubtractionCheck.h
clang::tidy::ClangTidyModule
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Definition: ClangTidyModule.h:81
clang::tidy::abseil::DurationFactoryFloatCheck
This check finds cases where Duration factories are being called with floating point arguments,...
Definition: DurationFactoryFloatCheck.h:25
clang::tidy::abseil::DurationSubtractionCheck
Checks for cases where subtraction should be performed in the absl::Duration domain.
Definition: DurationSubtractionCheck.h:23
clang::tidy::ClangTidyCheckFactories::registerCheck
void registerCheck(llvm::StringRef CheckName)
Registers the CheckType with the name Name.
Definition: ClangTidyModule.h:59
clang::tidy::AbseilModuleAnchorSource
volatile int AbseilModuleAnchorSource
Definition: AbseilTidyModule.cpp:84