[cfe-dev] Correlating clang::CFGs with LLVM-CFGs
daniel at zuster.org
Thu Jan 28 09:23:20 PST 2010
On Thu, Jan 28, 2010 at 2:49 AM, <philipp.legrum at daimler.com> wrote:
> Hello LLVM-Developers,
> I'd like to write a program slicer that operates on LLVM-CFGs. The result,
> however, should be displayed to code reviewers in a CFG that is close to
> the C source code. The Graphviz output of clang::CFG is already pretty close
> to what I intend to do.
> Obviously, debug-info helps me to determine the origin of LLVM-instructions
> within the source code.
> So I am wondering now, if there is an (more) elegant way to correlate
> unoptimized LLVM-basic blocks (and the instructions contained by them) with
> the nodes of clang::CFGs (and the statements contained by those). Initially
> it would be ok to run the slicer on unoptimized code because I suspect
> optimization to complicate the correlation.
Short answer is no. Your best bet is to use debug info to do this.
Once you have used debug info to map instructions to the source they
came from, it is always possible to use the clang APIs to map those
source locations to clang AST nodes (see the APIs vended via
clang/include/clang-c/Index.h for example).
> Thanks in advance for your support.
> Kind regards,
> Philipp Legrum
> If you are not the intended addressee, please inform us immediately that you
> have received this e-mail in error, and delete it. We thank you for your
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
More information about the cfe-dev