AnalysisConsumer.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===--- AnalysisConsumer.h - Front-end Analysis Engine Hooks ---*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This header contains the functions necessary for a front-end to run various
  15. // analyses.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CLANG_STATICANALYZER_FRONTEND_ANALYSISCONSUMER_H
  19. #define LLVM_CLANG_STATICANALYZER_FRONTEND_ANALYSISCONSUMER_H
  20. #include "clang/AST/ASTConsumer.h"
  21. #include "clang/Basic/LLVM.h"
  22. #include <functional>
  23. #include <memory>
  24. namespace clang {
  25. class CompilerInstance;
  26. namespace ento {
  27. class PathDiagnosticConsumer;
  28. class CheckerRegistry;
  29. class AnalysisASTConsumer : public ASTConsumer {
  30. public:
  31. virtual void AddDiagnosticConsumer(PathDiagnosticConsumer *Consumer) = 0;
  32. /// This method allows registering statically linked custom checkers that are
  33. /// not a part of the Clang tree. It employs the same mechanism that is used
  34. /// by plugins.
  35. ///
  36. /// Example:
  37. ///
  38. /// Consumer->AddCheckerRegistrationFn([] (CheckerRegistry& Registry) {
  39. /// Registry.addChecker<MyCustomChecker>("example.MyCustomChecker",
  40. /// "Description");
  41. /// });
  42. virtual void
  43. AddCheckerRegistrationFn(std::function<void(CheckerRegistry &)> Fn) = 0;
  44. };
  45. /// CreateAnalysisConsumer - Creates an ASTConsumer to run various code
  46. /// analysis passes. (The set of analyses run is controlled by command-line
  47. /// options.)
  48. std::unique_ptr<AnalysisASTConsumer>
  49. CreateAnalysisConsumer(CompilerInstance &CI);
  50. } // namespace ento
  51. } // end clang namespace
  52. #endif
  53. #ifdef __GNUC__
  54. #pragma GCC diagnostic pop
  55. #endif