Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform.h =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform.h +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform.h @@ -162,4 +162,10 @@ # define MSC_PREREQ(version) 0 #endif +#if defined(__arm64__) && SANITIZER_IOS +# define SANITIZER_NON_UNIQUE_TYPEINFO 1 +#else +# define SANITIZER_NON_UNIQUE_TYPEINFO 0 +#endif + #endif // SANITIZER_PLATFORM_H Index: compiler-rt/trunk/lib/ubsan/ubsan_type_hash_itanium.cc =================================================================== --- compiler-rt/trunk/lib/ubsan/ubsan_type_hash_itanium.cc +++ compiler-rt/trunk/lib/ubsan/ubsan_type_hash_itanium.cc @@ -115,7 +115,9 @@ static bool isDerivedFromAtOffset(const abi::__class_type_info *Derived, const abi::__class_type_info *Base, sptr Offset) { - if (Derived->__type_name == Base->__type_name) + if (Derived->__type_name == Base->__type_name || + (SANITIZER_NON_UNIQUE_TYPEINFO && + !internal_strcmp(Derived->__type_name, Base->__type_name))) return Offset == 0; if (const abi::__si_class_type_info *SI = Index: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Helpers/lit.local.cfg =================================================================== --- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Helpers/lit.local.cfg +++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Helpers/lit.local.cfg @@ -0,0 +1,3 @@ +# Sources in this directory are helper files for tests which test functionality +# involving multiple translation units. +config.suffixes = [] Index: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Helpers/vptr-non-unique-typeinfo-lib.h =================================================================== --- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Helpers/vptr-non-unique-typeinfo-lib.h +++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Helpers/vptr-non-unique-typeinfo-lib.h @@ -0,0 +1,4 @@ +struct X { + virtual ~X() {} +}; +X *libCall(); Index: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Helpers/vptr-non-unique-typeinfo-lib.cpp =================================================================== --- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Helpers/vptr-non-unique-typeinfo-lib.cpp +++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/Helpers/vptr-non-unique-typeinfo-lib.cpp @@ -0,0 +1,5 @@ +#include "vptr-non-unique-typeinfo-lib.h" + +X *libCall() { + return new X; +} Index: compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr-non-unique-typeinfo.cpp =================================================================== --- compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr-non-unique-typeinfo.cpp +++ compiler-rt/trunk/test/ubsan/TestCases/TypeCheck/vptr-non-unique-typeinfo.cpp @@ -0,0 +1,10 @@ +// RUN: %clangxx -frtti -fsanitize=vptr -fno-sanitize-recover=vptr -I%p/Helpers %p/Helpers/vptr-non-unique-typeinfo-lib.cpp -fPIC -shared -o %t-lib.so +// RUN: %clangxx -frtti -fsanitize=vptr -fno-sanitize-recover=vptr -I%p/Helpers -g %s -O3 -o %t %t-lib.so +// RUN: %run %t + +#include "vptr-non-unique-typeinfo-lib.h" + +int main() { + X *px = libCall(); + delete px; +}