From aa3576911cf31fd21c1321f42b2d51d7f59d3f92 Mon Sep 17 00:00:00 2001 From: Gnimuc Date: Sun, 23 Jun 2024 19:39:24 +0900 Subject: [PATCH] Add wrapper for `Undo` and fix prototype --- include/clang-c/CXCppInterOp.h | 7 ++++++- lib/Interpreter/CXCppInterOp.cpp | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/clang-c/CXCppInterOp.h b/include/clang-c/CXCppInterOp.h index c1231dfbc..a775cd41d 100644 --- a/include/clang-c/CXCppInterOp.h +++ b/include/clang-c/CXCppInterOp.h @@ -56,6 +56,11 @@ TInterp_t clang_interpreter_getInterpreterAsPtr(CXInterpreter I); */ TInterp_t clang_interpreter_takeInterpreterAsPtr(CXInterpreter I); +/** + * Undo N previous incremental inputs. + */ +CXErrorCode clang_interpreter_Undo(CXInterpreter I, unsigned int N); + /** * Dispose of the given interpreter context. */ @@ -144,7 +149,7 @@ typedef void* CXValue; * * \returns a \c CXValue. */ -CXValue clang_createValue(); +CXValue clang_createValue(void); /** * Dispose of the given CXValue. diff --git a/lib/Interpreter/CXCppInterOp.cpp b/lib/Interpreter/CXCppInterOp.cpp index 28a91c667..4868f7581 100644 --- a/lib/Interpreter/CXCppInterOp.cpp +++ b/lib/Interpreter/CXCppInterOp.cpp @@ -70,6 +70,10 @@ TInterp_t clang_interpreter_takeInterpreterAsPtr(CXInterpreter I) { return static_cast(I)->Interp.release(); } +CXErrorCode clang_interpreter_Undo(CXInterpreter I, unsigned int N) { + return getInterpreter(I)->Undo(N) ? CXError_Failure : CXError_Success; +} + void clang_interpreter_dispose(CXInterpreter I) { delete I; // NOLINT(*-owning-memory) } @@ -113,7 +117,7 @@ enum CXErrorCode clang_interpreter_process(CXInterpreter I, const char* code) { return CXError_Success; } -CXValue clang_createValue() { +CXValue clang_createValue(void) { #ifdef USE_CLING auto val = std::make_unique(); #else