Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / asan / TestCases / Linux / odr-vtable.cpp
blobaee5d2aacfc588c9595452190969888b4032b78b
1 // Fails with debug checks: https://bugs.llvm.org/show_bug.cgi?id=46862
2 // XFAIL: !compiler-rt-optimized && !target=riscv64{{.*}}
4 // REQUIRES: shared_cxxabi
6 /// Not using private alias or enabling ODR indicator can detect ODR issues.
7 // RUN: %clangxx_asan -fno-rtti -DBUILD_SO1 -fPIC -shared -mllvm -asan-use-private-alias=0 %s -o %dynamiclib1
8 // RUN: %clangxx_asan -fno-rtti -DBUILD_SO2 -fPIC -shared -mllvm -asan-use-private-alias=0 %s -o %dynamiclib2
9 // RUN: %clangxx_asan -fno-rtti %s %ld_flags_rpath_exe1 %ld_flags_rpath_exe2 -o %t
10 // RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2 not %run %t 2>&1 | FileCheck %s
12 // RUN: %clangxx_asan -fno-rtti -DBUILD_SO1 -fPIC -shared -mllvm -asan-use-odr-indicator=1 %s -o %dynamiclib1
13 // RUN: %clangxx_asan -fno-rtti -DBUILD_SO2 -fPIC -shared -mllvm -asan-use-odr-indicator=1 %s -o %dynamiclib2
14 // RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2 not %run %t 2>&1 | FileCheck %s
16 /// By default we can detect ODR issues in vtables.
17 // RUN: %clangxx_asan -fno-rtti -DBUILD_SO1 -fPIC -shared %s -o %dynamiclib1
18 // RUN: %clangxx_asan -fno-rtti -DBUILD_SO2 -fPIC -shared %s -o %dynamiclib2
19 // RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2 not %run %t 2>&1 | FileCheck %s
21 struct XYZ {
22 virtual void foo();
25 #if defined(BUILD_SO1)
27 void XYZ::foo() {}
29 #elif defined(BUILD_SO2)
31 void XYZ::foo() {}
33 #else
35 int main() {}
37 #endif
39 // CHECK: AddressSanitizer: odr-violation
40 // CHECK-NEXT: 'vtable for XYZ'
41 // CHECK-NEXT: 'vtable for XYZ'