[cfe-dev] Fwd: -Wunreachable-code and templates
Chandler Carruth
chandlerc at google.com
Wed Nov 30 01:30:12 PST 2011
On Wed, Nov 30, 2011 at 12:45 AM, Ted Kremenek <kremenek at apple.com> wrote:
> The idea I had to tackle this was a bit simpler, although it could
> certainly be flawed. Looking at the results of -Wunreachable-code that you
> mentioned, the reason we report this code as unreachable is because the
> edges for the branch conditions in the CFG are intentionally pruned as
> being trivially satisfiable/unsatisfiable. Instead of just chopping off
> the edges completely, we can retain all edges, but mark them as being
> unreachable for various reasons, e.g. value dependent because of template
> instantiations or expanded from a macro.
I really like this idea for the reasons you mention.
Also, Richard Smith and I were discussing based on David's initial queries
in IRC how we might do this. Our specific idea was to retain just enough
information in the instantiated AST to figure out the dependence of the
templated expressions leading to that instantiation. He had a clever idea
that would re-use the bits already in the Expr node to indicate different
kinds of dependence to also indicate being instantiated *from* different
kinds of dependence. I'll let him fill in the details, but essentially this
(possibly combined with a side-table of more detailed information) seems
like it would allow the AST to indicate exactly what template construct it
came from, much the way source locations provide this information for
macros.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111130/10e9e8b9/attachment.html>
More information about the cfe-dev
mailing list