BoolPointerImplicitConversionCheck.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //===--- BoolPointerImplicitConversionCheck.h - clang-tidy ------*- C++ -*-===//
  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. #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_BOOLPOINTERIMPLICITCONVERSIONCHECK_H
  9. #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_BOOLPOINTERIMPLICITCONVERSIONCHECK_H
  10. #include "../ClangTidyCheck.h"
  11. namespace clang::tidy::bugprone {
  12. /// Checks for conditions based on implicit conversion from a bool pointer to
  13. /// bool.
  14. ///
  15. /// Example:
  16. ///
  17. /// \code
  18. /// bool *p;
  19. /// if (p) {
  20. /// // Never used in a pointer-specific way.
  21. /// }
  22. /// \endcode
  23. class BoolPointerImplicitConversionCheck : public ClangTidyCheck {
  24. public:
  25. BoolPointerImplicitConversionCheck(StringRef Name, ClangTidyContext *Context)
  26. : ClangTidyCheck(Name, Context) {}
  27. void registerMatchers(ast_matchers::MatchFinder *Finder) override;
  28. void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
  29. };
  30. } // namespace clang::tidy::bugprone
  31. #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_BOOLPOINTERIMPLICITCONVERSIONCHECK_H