Sanitize upcasts and conversion to virtual base.
authorAlexey Samsonov <vonosmas@gmail.com>
Mon, 13 Oct 2014 23:59:00 +0000 (23:59 +0000)
committerAlexey Samsonov <vonosmas@gmail.com>
Mon, 13 Oct 2014 23:59:00 +0000 (23:59 +0000)
commiteb47d8a2c880611d79a468d04f287e868b8e241a
treecba22a0d20aed83e80a543af4d842bd5e93cc560
parent0809b2ddc3a8661a55f818dbed8ea71a86e3802a
Sanitize upcasts and conversion to virtual base.

This change adds UBSan check to upcasts. Namely, when we
perform derived-to-base conversion, we:
1) check that the pointer-to-derived has suitable alignment
   and underlying storage, if this pointer is non-null.
2) if vptr-sanitizer is enabled, and we perform conversion to
   virtual base, we check that pointer-to-derived has a matching vptr.

llvm-svn: 219642
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/test/CodeGenCXX/catch-undef-behavior.cpp
compiler-rt/lib/ubsan/ubsan_handlers.cc
compiler-rt/test/ubsan/TestCases/TypeCheck/misaligned.cpp
compiler-rt/test/ubsan/TestCases/TypeCheck/vptr-virtual-base.cpp [new file with mode: 0644]