clang-tools 8.0.0

AbseilTidyModule.cpp
Go to the documentation of this file.
1 //===------- AbseilTidyModule.cpp - clang-tidy ----------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "../ClangTidy.h"
11 #include "../ClangTidyModule.h"
12 #include "../ClangTidyModuleRegistry.h"
13 #include "DurationComparisonCheck.h"
14 #include "DurationDivisionCheck.h"
15 #include "DurationFactoryFloatCheck.h"
16 #include "DurationFactoryScaleCheck.h"
17 #include "DurationSubtractionCheck.h"
18 #include "FasterStrsplitDelimiterCheck.h"
19 #include "NoInternalDependenciesCheck.h"
20 #include "NoNamespaceCheck.h"
21 #include "RedundantStrcatCallsCheck.h"
22 #include "StringFindStartswithCheck.h"
23 #include "StrCatAppendCheck.h"
24 #include "UpgradeDurationConversionsCheck.h"
25
26 namespace clang {
27 namespace tidy {
28 namespace abseil {
29
30 class AbseilModule : public ClangTidyModule {
31 public:
32 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
33 CheckFactories.registerCheck<DurationComparisonCheck>(
34 "abseil-duration-comparison");
35 CheckFactories.registerCheck<DurationDivisionCheck>(
36 "abseil-duration-division");
37 CheckFactories.registerCheck<DurationFactoryFloatCheck>(
38 "abseil-duration-factory-float");
39 CheckFactories.registerCheck<DurationFactoryScaleCheck>(
40 "abseil-duration-factory-scale");
41 CheckFactories.registerCheck<DurationSubtractionCheck>(
42 "abseil-duration-subtraction");
43 CheckFactories.registerCheck<FasterStrsplitDelimiterCheck>(
44 "abseil-faster-strsplit-delimiter");
45 CheckFactories.registerCheck<NoInternalDependenciesCheck>(
46 "abseil-no-internal-dependencies");
47 CheckFactories.registerCheck<NoNamespaceCheck>("abseil-no-namespace");
48 CheckFactories.registerCheck<RedundantStrcatCallsCheck>(
49 "abseil-redundant-strcat-calls");
50 CheckFactories.registerCheck<StrCatAppendCheck>(
51 "abseil-str-cat-append");
52 CheckFactories.registerCheck<StringFindStartswithCheck>(
53 "abseil-string-find-startswith");
54 CheckFactories.registerCheck<UpgradeDurationConversionsCheck>(
55 "abseil-upgrade-duration-conversions");
56 }
57 };
58
59 // Register the AbseilModule using this statically initialized variable.
60 static ClangTidyModuleRegistry::Add<AbseilModule> X("abseil-module",
61 "Add Abseil checks.");
62
63 } // namespace abseil
64
65 // This anchor is used to force the linker to link in the generated object file
66 // and thus register the AbseilModule.
67 volatile int AbseilModuleAnchorSource = 0;
68
69 } // namespace tidy
70 } // namespace clang
clang::tidy::abseil::StringFindStartswithCheck
Definition: StringFindStartswithCheck.h:28
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:24
clang::tidy::ClangTidyCheckFactories::registerCheck
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Definition: ClangTidyModule.h:59
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:27
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:26
clang::tidy::abseil::FasterStrsplitDelimiterCheck
Finds instances of absl::StrSplit() or absl::MaxSplits() where the delimiter is a single character st...
Definition: FasterStrsplitDelimiterCheck.h:24
clang::tidy::abseil::DurationFactoryFloatCheck
This check finds cases where Duration factories are being called with floating point arguments...
Definition: DurationFactoryFloatCheck.h:26
clang::tidy::ClangTidyModule
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Definition: ClangTidyModule.h:84
clang::tidy::abseil::AbseilModule
Definition: AbseilTidyModule.cpp:30
RedundantStrcatCallsCheck.h
clang::tidy::abseil::NoInternalDependenciesCheck
Finds instances where the user depends on internal details and warns them against doing so...
Definition: NoInternalDependenciesCheck.h:24
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:32
StringFindStartswithCheck.h
clang::tidy::abseil::DurationDivisionCheck
Definition: DurationDivisionCheck.h:24
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ChangeNamespace.cpp:18
clang::tidy::abseil::StrCatAppendCheck
Flags uses of absl::StrCat to append to a string.
Definition: StrCatAppendCheck.h:24
StrCatAppendCheck.h
clang::tidy::AbseilModuleAnchorSource
volatile int AbseilModuleAnchorSource
Definition: AbseilTidyModule.cpp:67
clang::tidy::abseil::UpgradeDurationConversionsCheck
Finds deprecated uses of absl::Duration arithmetic operators and factories.
Definition: UpgradeDurationConversionsCheck.h:25
clang::tidy::abseil::DurationSubtractionCheck
Checks for cases where subtraction should be performed in the absl::Duration domain.
Definition: DurationSubtractionCheck.h:24
clang::tidy::abseil::DurationComparisonCheck
Prefer comparison in the absl::Duration domain instead of the numeric domain.
Definition: DurationComparisonCheck.h:24
DurationSubtractionCheck.h