Question

Does anyone have a regular expression for matching function calls in C programs ?

Was it helpful?

Solution 2

After a bit more searching I decided to let the compiler do the hard work.

Get the compiler to produce a Register Transfer Language (RTL) file using the -dr options of gcc.

The produced RTL file has the suffix .rtl or .expand.

This file is far easier to parse as the functions calls are already identified.

OTHER TIPS

Since C isn't a regular language and C function calls can contain arbitrary argument expressions, I fear the answer to your question is “no.”

I doubt you can find a regex that matches all (and only) the function calls in some source code. But maybe you could use a tool like Understand, or your IDE, to browse your code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top