[all-commits] [llvm/llvm-project] dea5a9: [clang-repl] Implement code undo.

Jun Zhang via All-commits all-commits at lists.llvm.org
Sun Jun 26 03:33:07 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: dea5a9cc929048be261a4c030407e4d7e1e70fec
  Author: Jun Zhang <jun at junz.org>
  Date:   2022-06-26 (Sun, 26 Jun 2022)

  Changed paths:
    M clang/include/clang/Interpreter/Interpreter.h
    M clang/lib/Interpreter/IncrementalExecutor.cpp
    M clang/lib/Interpreter/IncrementalExecutor.h
    M clang/lib/Interpreter/IncrementalParser.cpp
    M clang/lib/Interpreter/IncrementalParser.h
    M clang/lib/Interpreter/Interpreter.cpp
    A clang/test/Interpreter/code-undo.cpp
    M clang/test/Interpreter/execute.cpp
    M clang/test/Interpreter/plugins.cpp
    M clang/test/Interpreter/sanity.c
    M clang/tools/clang-repl/ClangRepl.cpp
    M clang/unittests/Interpreter/InterpreterTest.cpp

  Log Message:
  [clang-repl] Implement code undo.

In interactive C++ it is convenient to roll back to a previous state of the
compiler. For example:
clang-repl> int x = 42;
clang-repl> %undo
clang-repl> float x = 24 // not an error

To support this, the patch extends the functionality used to recover from
errors and adds functionality to recover the low-level execution infrastructure.

The current implementation is based on watermarks. It exploits the fact that
at each incremental input the underlying compiler infrastructure is in a valid
state. We can only go N incremental inputs back to a previous valid state. We do
not need and do not do any further dependency tracking.

This patch was co-developed with V. Vassilev, relies on the past work of Purva
Chaudhari in clang-repl and is inspired by the past work on the same feature
in the Cling interpreter.

Co-authored-by: Purva-Chaudhari <purva.chaudhari02 at gmail.com>
Co-authored-by: Vassil Vassilev <v.g.vassilev at gmail.com>
Signed-off-by: Jun Zhang <jun at junz.org>

More information about the All-commits mailing list