[cfe-dev] Tool to match defined and used method signatures

Madhura Ganesh via cfe-dev cfe-dev at lists.llvm.org
Fri Mar 20 11:26:42 PDT 2020


Hi All,

I am trying to solve a build contract problem where frequently my
dependencies break the contract and my product fails to build.
To prevent this, i wanted to give a contract to my dependencies saying that
hey you should not break these methods. Now, you may ask why not simply ask
your dependencies to build my package and check, but it takes a long time
to build my package, and hence wanted an easy check.

Let's suppose I establish a contract like this,

int Calculator::add(int, int) is an agreement and my dependency will should
not change it,
if he changes this to say,
int Calculator::add(int, int), then my build contract test should fail.

To do that, I should parse the AST of both the packages and extract all the
defined and used methods. Once, i have them i can check whether all the
methods that i have used has a definition in the dependency AST or not.

Do we have a tooling already on this? wanted to know the right library to
use on this as if i had to write this AST comparison from scratch, I should
handle inheritance, typedefines and all of such cases.

Not sure if ast matcher would be right here, because I should understand
the ast of consumer and create an ast matcher query from the used method
and check if it exists in the producer which is round about, than doing a
direct check on the method signatures as per the ast of producer and
consumer.

Thanks in advance for your help!

Thanks,
Madhura Ganesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200320/e98267b8/attachment.html>


More information about the cfe-dev mailing list