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"
14 #include "DurationDivisionCheck.h"
20 #include "NoNamespaceCheck.h"
23 #include "StrCatAppendCheck.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");
38  "abseil-duration-factory-float");
40  "abseil-duration-factory-scale");
42  "abseil-duration-subtraction");
44  "abseil-faster-strsplit-delimiter");
46  "abseil-no-internal-dependencies");
47  CheckFactories.registerCheck<NoNamespaceCheck>("abseil-no-namespace");
49  "abseil-redundant-strcat-calls");
50  CheckFactories.registerCheck<StrCatAppendCheck>(
51  "abseil-str-cat-append");
53  "abseil-string-find-startswith");
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
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.
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 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 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...
===– 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.
Prefer comparison in the absl::Duration domain instead of the numeric domain.