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 "StrCatAppendCheck.h" 25 #include "StringFindStartswithCheck.h" 26 #include "StringFindStrContainsCheck.h" 27 #include "TimeComparisonCheck.h" 28 #include "TimeSubtractionCheck.h" 29 #include "UpgradeDurationConversionsCheck.h" 30 31 namespace clang { 32 namespace tidy { 33 namespace abseil { 34 35 class AbseilModule : public ClangTidyModule { 36 public: addCheckFactories(ClangTidyCheckFactories & CheckFactories)37 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { 38 CheckFactories.registerCheck<DurationAdditionCheck>( 39 "abseil-duration-addition"); 40 CheckFactories.registerCheck<DurationComparisonCheck>( 41 "abseil-duration-comparison"); 42 CheckFactories.registerCheck<DurationConversionCastCheck>( 43 "abseil-duration-conversion-cast"); 44 CheckFactories.registerCheck<DurationDivisionCheck>( 45 "abseil-duration-division"); 46 CheckFactories.registerCheck<DurationFactoryFloatCheck>( 47 "abseil-duration-factory-float"); 48 CheckFactories.registerCheck<DurationFactoryScaleCheck>( 49 "abseil-duration-factory-scale"); 50 CheckFactories.registerCheck<DurationSubtractionCheck>( 51 "abseil-duration-subtraction"); 52 CheckFactories.registerCheck<DurationUnnecessaryConversionCheck>( 53 "abseil-duration-unnecessary-conversion"); 54 CheckFactories.registerCheck<FasterStrsplitDelimiterCheck>( 55 "abseil-faster-strsplit-delimiter"); 56 CheckFactories.registerCheck<NoInternalDependenciesCheck>( 57 "abseil-no-internal-dependencies"); 58 CheckFactories.registerCheck<NoNamespaceCheck>("abseil-no-namespace"); 59 CheckFactories.registerCheck<RedundantStrcatCallsCheck>( 60 "abseil-redundant-strcat-calls"); 61 CheckFactories.registerCheck<StrCatAppendCheck>( 62 "abseil-str-cat-append"); 63 CheckFactories.registerCheck<StringFindStartswithCheck>( 64 "abseil-string-find-startswith"); 65 CheckFactories.registerCheck<StringFindStrContainsCheck>( 66 "abseil-string-find-str-contains"); 67 CheckFactories.registerCheck<TimeComparisonCheck>( 68 "abseil-time-comparison"); 69 CheckFactories.registerCheck<TimeSubtractionCheck>( 70 "abseil-time-subtraction"); 71 CheckFactories.registerCheck<UpgradeDurationConversionsCheck>( 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 88