<div dir="ltr">Hi,<div><br></div><div>Here is an example of adding a function summary in the StdLibraryFunctionsChecker:</div><div><font face="monospace">    // ssize_t recv(int sockfd, void *buf, size_t len, int flags);<br>    addToFunctionSummaryMap(<br>        "recv",</font></div><div><font face="monospace">        Signature(</font>ArgTypes{IntTy, VoidPtrTy, SizeTy, IntTy}, RetType{Ssize_tTy}),<font face="monospace"><br>        Summary(NoEvalCall)<br>            .ArgConstraint(ArgumentCondition(0, WithinRange, Range(0, IntMax)))<br>            .ArgConstraint(BufferSize(/*Buffer=*/ArgNo(1),<br>                                      /*BufSize=*/ArgNo(2))));</font><br></div><div><br></div><div>Instead, I'd like to have the following in the future:</div><div><font face="monospace">    addToFunctionSummaryMap(</font></div><div><font face="monospace">        "recv"<br>        Signature("ssize_t recv(int sockfd, void *buf, size_t len, int flags);</font><span style="font-family:monospace">"),</span></div><div><font face="monospace">        Summary(NoEvalCall)<br>            .ArgConstraint(ArgumentCondition(0, WithinRange, Range(0, IntMax)))<br>            .ArgConstraint(BufferSize(/*Buffer=*/ArgNo(1),<br>                                      /*BufSize=*/ArgNo(2))));</font><br></div><div><font face="monospace"><br></font></div><div><font face="arial, sans-serif">Why? This could simplify the type matching code in the Checker extremely. Besides, whenever we reach up to a point where we can read up summaries from e.g. YAML files (maybe when we merge with the TaintChecker) then the user could specify the signatures as they would write that in C/C++, which seems to be an ultimate convenience.</font></div><div><font face="monospace"><br></font></div><div><font face="arial, sans-serif">To achieve this I have to parse the string given to the Signature in the ASTContext of the TU that is being analyzed. I am considering two options to develop this:</font></div><div><font face="arial, sans-serif">1) Seems like BodyFarm/ModelInjector does something similar (it reads function bodies from model files). However, I am not sure if that solution is flexible enough. Gabor, what do you think, would it make sense to extend into this direction, could we handle C++ declarations as well? What other weak points or difficulties do you see?</font></div><div><font face="arial, sans-serif">2) Maybe we could use the parser with a custom ExternalASTSource implementation that could do the job. Actually, this is how LLDB does it, the implementation of the </font>ExternalASTSource interface uses the ASTImporter under the hood. I am not sure if ASTImporter could be used for this, but maybe some parts of it, we could reuse.</div><div><br></div><div>Thanks,</div><div>Gabor</div></div>