clang/test/Interpreter/code-undo.cpp
raw| 1 | // RUN: cat %s | clang-repl | FileCheck %s |
| 2 | extern "C" int printf(const char *, ...); |
| 3 | int x1 = 0; |
| 4 | int x2 = 42; |
| 5 | %undo |
| 6 | int x2 = 24; |
| 7 | auto r1 = printf("x1 = %d\n", x1); |
| 8 | // CHECK: x1 = 0 |
| 9 | auto r2 = printf("x2 = %d\n", x2); |
| 10 | // CHECK-NEXT: x2 = 24 |
| 11 | |
| 12 | int foo() { return 1; } |
| 13 | %undo |
| 14 | int foo() { return 2; } |
| 15 | auto r3 = printf("foo() = %d\n", foo()); |
| 16 | // CHECK-NEXT: foo() = 2 |
| 17 | |
| 18 | inline int bar() { return 42;} |
| 19 | auto r4 = bar(); |
| 20 | %undo |
| 21 | auto r5 = bar(); |
| 22 | |
| 23 | %quit |