AndroidTidyModule.cpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //===--- AndroidTidyModule.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. #include "../ClangTidy.h"
  9. #include "../ClangTidyModule.h"
  10. #include "../ClangTidyModuleRegistry.h"
  11. #include "CloexecAccept4Check.h"
  12. #include "CloexecAcceptCheck.h"
  13. #include "CloexecCreatCheck.h"
  14. #include "CloexecDupCheck.h"
  15. #include "CloexecEpollCreate1Check.h"
  16. #include "CloexecEpollCreateCheck.h"
  17. #include "CloexecFopenCheck.h"
  18. #include "CloexecInotifyInit1Check.h"
  19. #include "CloexecInotifyInitCheck.h"
  20. #include "CloexecMemfdCreateCheck.h"
  21. #include "CloexecOpenCheck.h"
  22. #include "CloexecPipe2Check.h"
  23. #include "CloexecPipeCheck.h"
  24. #include "CloexecSocketCheck.h"
  25. #include "ComparisonInTempFailureRetryCheck.h"
  26. using namespace clang::ast_matchers;
  27. namespace clang::tidy {
  28. namespace android {
  29. /// This module is for Android specific checks.
  30. class AndroidModule : public ClangTidyModule {
  31. public:
  32. void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
  33. CheckFactories.registerCheck<CloexecAccept4Check>("android-cloexec-accept4");
  34. CheckFactories.registerCheck<CloexecAcceptCheck>("android-cloexec-accept");
  35. CheckFactories.registerCheck<CloexecCreatCheck>("android-cloexec-creat");
  36. CheckFactories.registerCheck<CloexecDupCheck>("android-cloexec-dup");
  37. CheckFactories.registerCheck<CloexecEpollCreate1Check>(
  38. "android-cloexec-epoll-create1");
  39. CheckFactories.registerCheck<CloexecEpollCreateCheck>(
  40. "android-cloexec-epoll-create");
  41. CheckFactories.registerCheck<CloexecFopenCheck>("android-cloexec-fopen");
  42. CheckFactories.registerCheck<CloexecInotifyInit1Check>(
  43. "android-cloexec-inotify-init1");
  44. CheckFactories.registerCheck<CloexecInotifyInitCheck>(
  45. "android-cloexec-inotify-init");
  46. CheckFactories.registerCheck<CloexecMemfdCreateCheck>(
  47. "android-cloexec-memfd-create");
  48. CheckFactories.registerCheck<CloexecOpenCheck>("android-cloexec-open");
  49. CheckFactories.registerCheck<CloexecPipeCheck>("android-cloexec-pipe");
  50. CheckFactories.registerCheck<CloexecPipe2Check>("android-cloexec-pipe2");
  51. CheckFactories.registerCheck<CloexecSocketCheck>("android-cloexec-socket");
  52. CheckFactories.registerCheck<ComparisonInTempFailureRetryCheck>(
  53. "android-comparison-in-temp-failure-retry");
  54. }
  55. };
  56. // Register the AndroidTidyModule using this statically initialized variable.
  57. static ClangTidyModuleRegistry::Add<AndroidModule>
  58. X("android-module", "Adds Android platform checks.");
  59. } // namespace android
  60. // This anchor is used to force the linker to link in the generated object file
  61. // and thus register the AndroidModule.
  62. volatile int AndroidModuleAnchorSource = 0;
  63. } // namespace clang::tidy