summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/sanitize-dtor-tail-call.cpp
blob: bfbf04dcbd584ff9c9f6917c5adf68e4d05f08c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Test -fsanitize-memory-use-after-dtor
// RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s

struct Simple {
  int x_;
  Simple() {
    x_ = 5;
  }
  ~Simple() {
    x_ += 1;
  }
};

Simple s;
// Simple internal member is poisoned by compiler-generated dtor
// CHECK-LABEL: define {{.*}}SimpleD2Ev
// CHECK: {{^ *}}call void @__sanitizer_dtor_callback
// CHECK-NOT: tail call void @__sanitizer_dtor_callback
// CHECK: ret void

// Destructor does not emit any tail calls
// CHECK: attributes #1 = {{.*("disable-tail-calls"="true").*}}
// CHECK: }{{$}}
OpenPOWER on IntegriCloud