C sequence-point analyzer

Hi all,

I'm trying to write a tool for detecting undefined behavior in C
regarding sequence points and side effects.

I'm not sure whether it should be a Clang plugin or LLVM run or
something completely different (I'm really new to both Clang and LLVM)
and that's what I need advice with.

For my work, I need to use both AST and alias analysis

Clang plugin:
  +relatively easy to use
  +access to AST with all the needed info EXCEPT alias analysis (right?)
  -no alias analysis, I'd need to write one myself

LLVM run:
  +built-in alias analysis (I'd like to use it, writing my own alias
analysis is not really what my work is all about)
  -I do NOT have access to AST
  -I don't know it at all (but I'm ready to learn it if it shows up to be
the best option)

The big PROBLEM is: a behavior that is undefined in C (and which Clang
has access to) might be (and in my case WILL be) well defined in LLVM
(for example, i=i++; is undefined in C but in LLVM code it will be
already well defined and the result will depend on Clang behavior).

So I thought I could use both, in Clang create a list of rules, for
example "On line L, there is an undefined behavior if X aliases with Y"
and then SOMEHOW dig this info from LLVM run.

Is this a good idea? Is there a way (other than output to file from
Clang and then read it in LLVM) to give this set of rules to LLVM? I'd
also be glad for any other idea, not necessarily including LLVM and
Clang, to solve this problem.

Thanks in advance!

Hi Lukas,
I don't fully understand what you're working on, but you might consider
looking at how the -fcatch-undefined-behavior flag is implemented as a
starting point. This flag enables various run-time checks for undefined

I would also email the cfe-dev list as I'm guessing this is something
you'll want to implement on the clang side.

You might also consider looking at these:
http://clang.llvm.org/docs/index.html (Specifically, the Sanitizers) and

Hope this helps,