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"
15 #include "DurationDivisionCheck.h"
22 #include "NoNamespaceCheck.h"
25 #include "StrCatAppendCheck.h"
26 #include "TimeComparisonCheck.h"
27 #include "TimeSubtractionCheck.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");
42  "abseil-duration-conversion-cast");
43  CheckFactories.registerCheck<DurationDivisionCheck>(
44  "abseil-duration-division");
46  "abseil-duration-factory-float");
48  "abseil-duration-factory-scale");
50  "abseil-duration-subtraction");
52  "abseil-duration-unnecessary-conversion");
54  "abseil-faster-strsplit-delimiter");
56  "abseil-no-internal-dependencies");
57  CheckFactories.registerCheck<NoNamespaceCheck>("abseil-no-namespace");
59  "abseil-redundant-strcat-calls");
60  CheckFactories.registerCheck<StrCatAppendCheck>(
61  "abseil-str-cat-append");
63  "abseil-string-find-startswith");
64  CheckFactories.registerCheck<TimeComparisonCheck>(
65  "abseil-time-comparison");
66  CheckFactories.registerCheck<TimeSubtractionCheck>(
67  "abseil-time-subtraction");
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
This check ensures users don&#39;t open namespace absl, as that violates Abseil&#39;s compatibility guideline...
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Prefer comparison in the absl::Time domain instead of the numeric domain.
Flags redundant calls to absl::StrCat when the result is being passed to another call of absl::StrCat...
A collection of ClangTidyCheckFactory instances.
static ClangTidyModuleRegistry::Add< AbseilModule > X("abseil-module", "Add Abseil checks.")
This check finds cases where the incorrect Duration factory function is being used by looking for sca...
Finds and fixes absl::Time subtraction expressions to do subtraction in the time domain instead of th...
Finds instances of absl::StrSplit() or absl::MaxSplits() where the delimiter is a single character st...
This check finds cases where Duration factories are being called with floating point arguments...
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Finds and fixes cases where absl::Duration values are being converted to numeric types and back again...
Finds instances where the user depends on internal details and warns them against doing so...
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
Checks for cases where addition should be performed in the absl::Time domain.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Flags uses of absl::StrCat to append to a string.
volatile int AbseilModuleAnchorSource
Finds deprecated uses of absl::Duration arithmetic operators and factories.
Checks for cases where subtraction should be performed in the absl::Duration domain.
Checks for casts of absl::Duration conversion functions, and recommends the right conversion function...
Prefer comparison in the absl::Duration domain instead of the numeric domain.