[cfe-dev] Try-Throw-Catch handling in CFG
Ted Kremenek
kremenek at apple.com
Wed Nov 30 17:24:28 PST 2011
On Nov 30, 2011, at 2:52 PM, Jim Goodnow II wrote:
> So, if I have a simple program like:
>
> void foo()
> {
> try { throw( 5 ); }
> catch( int x ) {}
> catch( ... ) {}
> }
>
> This generates a CFG that looks like: (Excuse the ASCII graphics .)
>
> throw
> |
> v
> try
> | |
> v v
> catch(int) catch(...)
>
> where these are each blocks. How does the try block know the type of the
> throw argument? Should that be stored in the state on exit from the
> throw block or is there a better mechanism for passing that information?
Hi Jim,
I'm not certain I understand your question. What are you trying to accomplish? The CFG certainly doesn't retain any type information; that's up to the AST. If you are talking about the static analyzer, it's up to the static analyzer's value flow analysis to track the thrown value, including its type, so that the path analysis matches with the right 'catch' block.
Ted
More information about the cfe-dev
mailing list