<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/56879>56879</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Make (interpreted) model code visible to analyses
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:dataflow
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ymand
      </td>
    </tr>
</table>

<pre>
    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 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyFVF-P2jgQ_zTJy6hRCLDAQx7osiv1oWor9dS-TuxJ4ltj52wHln76GzsBdqurTorA9tgz8_tjN1Ze6kdrAr2GbLmHHwToCMToHJmgL9CMSktlOvDjMFgXoLUOjlaSjovtaERQ1oCkVhkVhx7OKvSgOKUbHAWSIHh7Ad975QGHwVkUHPdpi5EcDxYcDRoFwdlxEk4ceronv-XCqUBzgR6NBOxQGR-mzQ6PdLbuJas2HvZfP_msegT0sdAdjbSG4noEQa94HHSaKpNyZA-lD5Jp4M8OsRZqXpvgFpCVh6zcT79fRgeGznc8jv4ZlSNGCGe8REhHfKGUNh1PJMBJedVoiuEYQS5w8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