]> granicus.if.org Git - clang/commit
[ubsan] Diagnose invalid uses of builtins (clang)
authorVedant Kumar <vsk@apple.com>
Sat, 29 Jul 2017 00:19:51 +0000 (00:19 +0000)
committerVedant Kumar <vsk@apple.com>
Sat, 29 Jul 2017 00:19:51 +0000 (00:19 +0000)
commit081dca929f7dc72b99e53622bff71d21c9519ffb
tree5a28a96f2b28d6041a91b17ffeacf9255be72d07
parent8c94133f92df7c2e36e8ac0fa31011f2e54b5f3e
[ubsan] Diagnose invalid uses of builtins (clang)

On some targets, passing zero to the clz() or ctz() builtins has undefined
behavior. I ran into this issue while debugging UB in __hash_table from libcxx:
the bug I was seeing manifested itself differently under -O0 vs -Os, due to a
UB call to clz() (see: libcxx/r304617).

This patch introduces a check which can detect UB calls to builtins.

llvm.org/PR26979

Differential Revision: https://reviews.llvm.org/D34590

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309459 91177308-0d34-0410-b5e6-96231b3b80d8
docs/UndefinedBehaviorSanitizer.rst
include/clang/Basic/Sanitizers.def
lib/CodeGen/CGBuiltin.cpp
lib/CodeGen/CodeGenFunction.h
test/CodeGen/ubsan-builtin-checks.c [new file with mode: 0644]
test/Driver/fsanitize.c