clang-tools 10.0.0

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"
13 #include "DurationComparisonCheck.h"
14 #include "DurationConversionCastCheck.h"
15 #include "DurationDivisionCheck.h"
16 #include "DurationFactoryFloatCheck.h"
17 #include "DurationFactoryScaleCheck.h"
18 #include "DurationSubtractionCheck.h"
19 #include "DurationUnnecessaryConversionCheck.h"
20 #include "FasterStrsplitDelimiterCheck.h"
21 #include "NoInternalDependenciesCheck.h"
22 #include "NoNamespaceCheck.h"
23 #include "RedundantStrcatCallsCheck.h"
24 #include "StringFindStartswithCheck.h"
25 #include "StrCatAppendCheck.h"
26 #include "TimeComparisonCheck.h"
27 #include "TimeSubtractionCheck.h"
28 #include "UpgradeDurationConversionsCheck.h"
29
30 namespace clang {
31 namespace tidy {
32 namespace abseil {
33
34 class AbseilModule : public ClangTidyModule {
35 public:
36 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
37 CheckFactories.registerCheck<DurationAdditionCheck>(
38 "abseil-duration-addition");
39 CheckFactories.registerCheck<DurationComparisonCheck>(
40 "abseil-duration-comparison");
41 CheckFactories.registerCheck<DurationConversionCastCheck>(
42 "abseil-duration-conversion-cast");
43 CheckFactories.registerCheck<DurationDivisionCheck>(
44 "abseil-duration-division");
45 CheckFactories.registerCheck<DurationFactoryFloatCheck>(
46 "abseil-duration-factory-float");
47 CheckFactories.registerCheck<DurationFactoryScaleCheck>(
48 "abseil-duration-factory-scale");
49 CheckFactories.registerCheck<DurationSubtractionCheck>(
50 "abseil-duration-subtraction");
51 CheckFactories.registerCheck<DurationUnnecessaryConversionCheck>(
52 "abseil-duration-unnecessary-conversion");
53 CheckFactories.registerCheck<FasterStrsplitDelimiterCheck>(
54 "abseil-faster-strsplit-delimiter");
55 CheckFactories.registerCheck<NoInternalDependenciesCheck>(
56 "abseil-no-internal-dependencies");
57 CheckFactories.registerCheck<NoNamespaceCheck>("abseil-no-namespace");
58 CheckFactories.registerCheck<RedundantStrcatCallsCheck>(
59 "abseil-redundant-strcat-calls");
60 CheckFactories.registerCheck<StrCatAppendCheck>(
61 "abseil-str-cat-append");
62 CheckFactories.registerCheck<StringFindStartswithCheck>(
63 "abseil-string-find-startswith");
64 CheckFactories.registerCheck<TimeComparisonCheck>(
65 "abseil-time-comparison");
66 CheckFactories.registerCheck<TimeSubtractionCheck>(
67 "abseil-time-subtraction");
68 CheckFactories.registerCheck<UpgradeDurationConversionsCheck>(
69 "abseil-upgrade-duration-conversions");
70 }
71 };
72
73 // Register the AbseilModule using this statically initialized variable.
74 static ClangTidyModuleRegistry::Add<AbseilModule> X("abseil-module",
75 "Add Abseil checks.");
76
77 } // namespace abseil
78
79 // This anchor is used to force the linker to link in the generated object file
80 // and thus register the AbseilModule.
81 volatile int AbseilModuleAnchorSource = 0;
82
83 } // namespace tidy
84 } // namespace clang
clang::tidy::abseil::StringFindStartswithCheck
Definition: StringFindStartswithCheck.h:27
DurationComparisonCheck.h
clang::tidy::abseil::NoNamespaceCheck
This check ensures users don&#39;t open namespace absl, as that violates Abseil&#39;s compatibility guideline...
Definition: NoNamespaceCheck.h:23
clang::tidy::ClangTidyCheckFactories::registerCheck
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Definition: ClangTidyModule.h:58
clang::tidy::abseil::TimeComparisonCheck
Prefer comparison in the absl::Time domain instead of the numeric domain.
Definition: TimeComparisonCheck.h:23
TimeComparisonCheck.h
DurationDivisionCheck.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
DurationAdditionCheck.h
clang::tidy::ClangTidyCheckFactories
A collection of ClangTidyCheckFactory instances.
Definition: ClangTidyModule.h:27
DurationFactoryScaleCheck.h
NoNamespaceCheck.h
UpgradeDurationConversionsCheck.h
FasterStrsplitDelimiterCheck.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::TimeSubtractionCheck
Finds and fixes absl::Time subtraction expressions to do subtraction in the time domain instead of th...
Definition: TimeSubtractionCheck.h:23
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::DurationFactoryFloatCheck
This check finds cases where Duration factories are being called with floating point arguments...
Definition: DurationFactoryFloatCheck.h:25
clang::tidy::ClangTidyModule
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Definition: ClangTidyModule.h:80
clang::tidy::abseil::AbseilModule
Definition: AbseilTidyModule.cpp:34
RedundantStrcatCallsCheck.h
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
clang::tidy::abseil::NoInternalDependenciesCheck
Finds instances where the user depends on internal details and warns them against doing so...
Definition: NoInternalDependenciesCheck.h:23
DurationFactoryFloatCheck.h
NoInternalDependenciesCheck.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:36
clang::tidy::abseil::DurationAdditionCheck
Checks for cases where addition should be performed in the absl::Time domain.
Definition: DurationAdditionCheck.h:23
StringFindStartswithCheck.h
DurationUnnecessaryConversionCheck.h
clang::tidy::abseil::DurationDivisionCheck
Definition: DurationDivisionCheck.h:23
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
StrCatAppendCheck.h
clang::tidy::AbseilModuleAnchorSource
volatile int AbseilModuleAnchorSource
Definition: AbseilTidyModule.cpp:81
clang::tidy::abseil::UpgradeDurationConversionsCheck
Finds deprecated uses of absl::Duration arithmetic operators and factories.
Definition: UpgradeDurationConversionsCheck.h:24
clang::tidy::abseil::DurationSubtractionCheck
Checks for cases where subtraction should be performed in the absl::Duration domain.
Definition: DurationSubtractionCheck.h:23
TimeSubtractionCheck.h
DurationConversionCastCheck.h
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::DurationComparisonCheck
Prefer comparison in the absl::Duration domain instead of the numeric domain.
Definition: DurationComparisonCheck.h:23
DurationSubtractionCheck.h