<div class="gmail_quote">On Wed, Nov 30, 2011 at 12:45 AM, Ted Kremenek <span dir="ltr"><<a href="mailto:kremenek@apple.com">kremenek@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
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.</blockquote>
</div><br><div>I really like this idea for the reasons you mention.</div><div><br></div><div>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.</div>