| 1 |
// Purpose: |
| 2 |
// This ensures that DW_OP_deref is inserted when necessary, such as when |
| 3 |
// NRVO of a string object occurs in C++. |
| 4 |
// |
| 5 |
// REQUIRES: !asan, compiler-rt, lldb |
| 6 |
// UNSUPPORTED: system-windows |
| 7 |
// Zorg configures the ASAN stage2 bots to not build the asan |
| 8 |
// compiler-rt. Only run this test on non-asanified configurations. |
| 9 |
// |
| 10 |
// RUN: %clang++ -std=gnu++11 -O0 -glldb -fno-exceptions %s -o %t |
| 11 |
// RUN: %dexter --fail-lt 1.0 -w \ |
| 12 |
// RUN: --binary %t %dexter_lldb_args -- %s |
| 13 |
// |
| 14 |
// RUN: %clang++ -std=gnu++11 -O1 -glldb -fno-exceptions %s -o %t |
| 15 |
// RUN: %dexter --fail-lt 1.0 -w \ |
| 16 |
// RUN: --binary %t %dexter_lldb_args -- %s |
| 17 |
// |
| 18 |
// PR34513 |
| 19 |
volatile int sideeffect = 0; |
| 20 |
void __attribute__((noinline)) stop() { sideeffect++; } |
| 21 |
|
| 22 |
struct string { |
| 23 |
string() {} |
| 24 |
string(int i) : i(i) {} |
| 25 |
~string() {} |
| 26 |
int i = 0; |
| 27 |
}; |
| 28 |
string __attribute__((noinline)) get_string() { |
| 29 |
string unused; |
| 30 |
string output = 3; |
| 31 |
stop(); // DexLabel('string-nrvo') |
| 32 |
return output; |
| 33 |
} |
| 34 |
void some_function(int) {} |
| 35 |
struct string2 { |
| 36 |
string2() = default; |
| 37 |
string2(string2 &&other) { i = other.i; } |
| 38 |
int i; |
| 39 |
}; |
| 40 |
string2 __attribute__((noinline)) get_string2() { |
| 41 |
string2 output; |
| 42 |
output.i = 5; |
| 43 |
some_function(output.i); |
| 44 |
// Test that the debugger can get the value of output after another |
| 45 |
// function is called. |
| 46 |
stop(); // DexLabel('string2-nrvo') |
| 47 |
return output; |
| 48 |
} |
| 49 |
int main() { |
| 50 |
get_string(); |
| 51 |
get_string2(); |
| 52 |
} |
| 53 |
|
| 54 |
// DexExpectWatchValue('output.i', 3, on_line=ref('string-nrvo')) |
| 55 |
// DexExpectWatchValue('output.i', 5, on_line=ref('string2-nrvo')) |
| 56 |
|