class ModelInjector

Declaration

class ModelInjector : public CodeInjector { /* full declaration omitted */ };

Description

CodeInjector is an interface which is responsible for injecting AST of function definitions that may not be available in the original source. The getBody function will be called each time the static analyzer examines a function call that has no definition available in the current translation unit. If the returned statement is not a null pointer, it is assumed to be the body of a function which will be used for the analysis. The source of the body can be arbitrary, but it is advised to use memoization to avoid unnecessary reparsing of the external source that provides the body of the functions.

Declared at: clang/lib/StaticAnalyzer/Frontend/ModelInjector.h:35

Inherits from: CodeInjector

Member Variables

private clang::CompilerInstance& CI
private llvm::StringMap<Stmt*> Bodies

Method Overview

  • public ModelInjector(clang::CompilerInstance & CI)
  • public clang::Stmt * getBody(const clang::FunctionDecl * D)
  • public clang::Stmt * getBody(const clang::ObjCMethodDecl * D)
  • private void onBodySynthesis(const clang::NamedDecl * D)

Inherited from CodeInjector:

Methods

ModelInjector(clang::CompilerInstance& CI)

Declared at: clang/lib/StaticAnalyzer/Frontend/ModelInjector.h:37

Parameters

clang::CompilerInstance& CI

clang::Stmt* getBody(const clang::FunctionDecl* D)

Declared at: clang/lib/StaticAnalyzer/Frontend/ModelInjector.h:38

Parameters

const clang::FunctionDecl* D

clang::Stmt* getBody(
    const clang::ObjCMethodDecl* D)

Declared at: clang/lib/StaticAnalyzer/Frontend/ModelInjector.h:39

Parameters

const clang::ObjCMethodDecl* D

void onBodySynthesis(const clang::NamedDecl* D)

Description

Synthesize a body for a declaration This method first looks up the appropriate model file based on the model-path configuration option and the name of the declaration that is looked up. If no model were synthesized yet for a function with that name it will create a new compiler instance to parse the model file using the ASTContext, Preprocessor, SourceManager of the original compiler instance. The former resources are shared between the two compiler instance, so the newly created instance have to "leak" these objects, since they are owned by the original instance. The model-path should be either an absolute path or relative to the working directory of the compiler.

Declared at: clang/lib/StaticAnalyzer/Frontend/ModelInjector.h:55

Parameters

const clang::NamedDecl* D