[cfe-dev] How ubsan inserts checking code to detect undefined behaviors?

Richard Smith richard at metafoo.co.uk
Wed Oct 15 19:27:47 PDT 2014

On Wed, Oct 15, 2014 at 2:44 PM, Dingbao Xie <xiedingbao at gmail.com> wrote:

> Dear list,
> I know that unsan can detect certain number of undefined behaviors at
> runtime.
> When compiling the program with option -fsanitize=undefined, some checking
> code
> will be inserted into the necessary position. I looked at the source code
> of ubsan,

I assume you mean the ubsan runtime in compiler_rt?

> but failed to find the code that performs the instrumentation.
> I'm trying to understand how ubsan works by looking at its source code.
> Does anybody know where is the corresponding source code located?

The code that inserts the instrumentation is spread throughout Clang's
lib/CodeGen. Search for calls to EmitCheck.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141015/df8ecc61/attachment.html>

More information about the cfe-dev mailing list