1145479Smp//===-- CodeInjector.h ------------------------------------------*- C++ -*-===//
259243Sobrien//
359243Sobrien// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
459243Sobrien// See https://llvm.org/LICENSE.txt for license information.
559243Sobrien// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
659243Sobrien//
759243Sobrien//===----------------------------------------------------------------------===//
859243Sobrien///
959243Sobrien/// \file
1059243Sobrien/// Defines the clang::CodeInjector interface which is responsible for
1159243Sobrien/// injecting AST of function definitions that may not be available in the
12145479Smp/// original source.
1359243Sobrien///
1459243Sobrien//===----------------------------------------------------------------------===//
1559243Sobrien
1659243Sobrien#ifndef LLVM_CLANG_ANALYSIS_CODEINJECTOR_H
1759243Sobrien#define LLVM_CLANG_ANALYSIS_CODEINJECTOR_H
1859243Sobrien
1959243Sobriennamespace clang {
2059243Sobrien
2159243Sobrienclass Stmt;
2259243Sobrienclass FunctionDecl;
2359243Sobrienclass ObjCMethodDecl;
2459243Sobrien
2559243Sobrien/// CodeInjector is an interface which is responsible for injecting AST
2659243Sobrien/// of function definitions that may not be available in the original source.
2759243Sobrien///
2859243Sobrien/// The getBody function will be called each time the static analyzer examines a
2959243Sobrien/// function call that has no definition available in the current translation
3059243Sobrien/// unit. If the returned statement is not a null pointer, it is assumed to be
3159243Sobrien/// the body of a function which will be used for the analysis. The source of
3259243Sobrien/// the body can be arbitrary, but it is advised to use memoization to avoid
3359243Sobrien/// unnecessary reparsing of the external source that provides the body of the
3459243Sobrien/// functions.
3559243Sobrienclass CodeInjector {
3659243Sobrienpublic:
37145479Smp  CodeInjector();
3859243Sobrien  virtual ~CodeInjector();
39145479Smp
4059243Sobrien  virtual Stmt *getBody(const FunctionDecl *D) = 0;
4159243Sobrien  virtual Stmt *getBody(const ObjCMethodDecl *D) = 0;
4259243Sobrien};
4359243Sobrien}
4459243Sobrien
4559243Sobrien#endif
4659243Sobrien