| 1 | //===--- AnalysisConsumer.h - Front-end Analysis Engine Hooks ---*- 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 | // |
| 9 | // This header contains the functions necessary for a front-end to run various |
| 10 | // analyses. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_CLANG_STATICANALYZER_FRONTEND_ANALYSISCONSUMER_H |
| 15 | #define LLVM_CLANG_STATICANALYZER_FRONTEND_ANALYSISCONSUMER_H |
| 16 | |
| 17 | #include "clang/AST/ASTConsumer.h" |
| 18 | #include "clang/Basic/LLVM.h" |
| 19 | #include <functional> |
| 20 | #include <memory> |
| 21 | |
| 22 | namespace clang { |
| 23 | |
| 24 | class Preprocessor; |
| 25 | class DiagnosticsEngine; |
| 26 | class CodeInjector; |
| 27 | class CompilerInstance; |
| 28 | |
| 29 | namespace ento { |
| 30 | class PathDiagnosticConsumer; |
| 31 | class CheckerManager; |
| 32 | class CheckerRegistry; |
| 33 | |
| 34 | class AnalysisASTConsumer : public ASTConsumer { |
| 35 | public: |
| 36 | virtual void AddDiagnosticConsumer(PathDiagnosticConsumer *Consumer) = 0; |
| 37 | |
| 38 | /// This method allows registering statically linked custom checkers that are |
| 39 | /// not a part of the Clang tree. It employs the same mechanism that is used |
| 40 | /// by plugins. |
| 41 | /// |
| 42 | /// Example: |
| 43 | /// |
| 44 | /// Consumer->AddCheckerRegistrationFn([] (CheckerRegistry& Registry) { |
| 45 | /// Registry.addChecker<MyCustomChecker>("example.MyCustomChecker", |
| 46 | /// "Description"); |
| 47 | /// }); |
| 48 | virtual void |
| 49 | AddCheckerRegistrationFn(std::function<void(CheckerRegistry &)> Fn) = 0; |
| 50 | }; |
| 51 | |
| 52 | /// CreateAnalysisConsumer - Creates an ASTConsumer to run various code |
| 53 | /// analysis passes. (The set of analyses run is controlled by command-line |
| 54 | /// options.) |
| 55 | std::unique_ptr<AnalysisASTConsumer> |
| 56 | CreateAnalysisConsumer(CompilerInstance &CI); |
| 57 | |
| 58 | } // end GR namespace |
| 59 | |
| 60 | } // end clang namespace |
| 61 | |
| 62 | #endif |
| 63 |