llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Make (interpreted) model code visible to analyses

Open ymand opened this issue 4 years ago • 0 comments

Context: We are currently building support for modeling function definitions with interpreted code. This approach is intended to replace writing the function interpretations by hand against the framework's APIs, as is currently done, for example, in the std::optional model.

Our new approach requires a way to make the model code visible to the analysis. We propose to extend the DataflowAnalysisContext with a map from function ~decls to clang::FunctionDecl *. Ideally, we'd key on clang::FunctionDecl * from the main TU, but collecting those eagerly could be costly. Instead, we'll start with keying on the name of the function, and then map to a pair of the full declaration name and the target function decl. Once this is implemented, we can investigate the performance implications and consider whether to add a cache.

struct FunctionEntry {
  // Qualifiying components of the full name. Does not include the name of the function itself, which is the key in the map.
  std::vector<std::string> Qualifiers;
  FunctionDecl *FunDecl;
};
map<std::string, FunctionEntry> FunctionModels;

@Xazax-hun @sgatev @gribozavr @samestep

ymand avatar Aug 02 '22 14:08 ymand