CodeInjector.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- CodeInjector.h ------------------------------------------*- 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. /// \file
  15. /// Defines the clang::CodeInjector interface which is responsible for
  16. /// injecting AST of function definitions that may not be available in the
  17. /// original source.
  18. ///
  19. //===----------------------------------------------------------------------===//
  20. #ifndef LLVM_CLANG_ANALYSIS_CODEINJECTOR_H
  21. #define LLVM_CLANG_ANALYSIS_CODEINJECTOR_H
  22. namespace clang {
  23. class Stmt;
  24. class FunctionDecl;
  25. class ObjCMethodDecl;
  26. /// CodeInjector is an interface which is responsible for injecting AST
  27. /// of function definitions that may not be available in the original source.
  28. ///
  29. /// The getBody function will be called each time the static analyzer examines a
  30. /// function call that has no definition available in the current translation
  31. /// unit. If the returned statement is not a null pointer, it is assumed to be
  32. /// the body of a function which will be used for the analysis. The source of
  33. /// the body can be arbitrary, but it is advised to use memoization to avoid
  34. /// unnecessary reparsing of the external source that provides the body of the
  35. /// functions.
  36. class CodeInjector {
  37. public:
  38. CodeInjector();
  39. virtual ~CodeInjector();
  40. virtual Stmt *getBody(const FunctionDecl *D) = 0;
  41. virtual Stmt *getBody(const ObjCMethodDecl *D) = 0;
  42. };
  43. }
  44. #endif
  45. #ifdef __GNUC__
  46. #pragma GCC diagnostic pop
  47. #endif