NoLintDirectiveHandler.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //===-- clang-tools-extra/clang-tidy/NoLintDirectiveHandler.h ----*- 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_NOLINTDIRECTIVEHANDLER_H
  9. #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_NOLINTDIRECTIVEHANDLER_H
  10. #include "clang/Basic/Diagnostic.h"
  11. #include "llvm/ADT/StringRef.h"
  12. #include <memory>
  13. namespace clang::tooling {
  14. struct Diagnostic;
  15. } // namespace clang::tooling
  16. namespace llvm {
  17. template <typename T> class SmallVectorImpl;
  18. } // namespace llvm
  19. namespace clang::tidy {
  20. /// This class is used to locate NOLINT comments in the file being analyzed, to
  21. /// decide whether a diagnostic should be suppressed.
  22. /// This class keeps a cache of every NOLINT comment found so that files do not
  23. /// have to be repeatedly parsed each time a new diagnostic is raised.
  24. class NoLintDirectiveHandler {
  25. public:
  26. NoLintDirectiveHandler();
  27. ~NoLintDirectiveHandler();
  28. bool shouldSuppress(DiagnosticsEngine::Level DiagLevel,
  29. const Diagnostic &Diag, llvm::StringRef DiagName,
  30. llvm::SmallVectorImpl<tooling::Diagnostic> &NoLintErrors,
  31. bool AllowIO, bool EnableNoLintBlocks);
  32. private:
  33. class Impl;
  34. std::unique_ptr<Impl> PImpl;
  35. };
  36. } // namespace clang::tidy
  37. #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_NOLINTDIRECTIVEHANDLER_H