https://github.com/aadanen updated https://github.com/llvm/llvm-project/pull/149396
>From f3fbebdd6d940d36561ccf5177510095ba05077e Mon Sep 17 00:00:00 2001 From: Aaron Danen <aaron.da...@gmail.com> Date: Wed, 16 Jul 2025 19:44:58 -0700 Subject: [PATCH 1/2] clarified %undo error msg in clang-repl used grep -r "Too many undos" to locate all instances where the string was mentioned. Changed the string to the suggestion in issue 143668 --- clang/lib/Interpreter/Interpreter.cpp | 2 +- clang/unittests/Interpreter/InterpreterTest.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp index ed3bae59a144c..a2696f78cb510 100644 --- a/clang/lib/Interpreter/Interpreter.cpp +++ b/clang/lib/Interpreter/Interpreter.cpp @@ -754,7 +754,7 @@ llvm::Error Interpreter::Undo(unsigned N) { if (N > getEffectivePTUSize()) return llvm::make_error<llvm::StringError>("Operation failed. " - "Too many undos", + "No input left to undo", std::error_code()); for (unsigned I = 0; I < N; I++) { if (IncrExecutor) { diff --git a/clang/unittests/Interpreter/InterpreterTest.cpp b/clang/unittests/Interpreter/InterpreterTest.cpp index b97f5ae17c9f0..2ec65e2a9b2ef 100644 --- a/clang/unittests/Interpreter/InterpreterTest.cpp +++ b/clang/unittests/Interpreter/InterpreterTest.cpp @@ -158,12 +158,12 @@ TEST_F(InterpreterTest, UndoCommand) { // Fail to undo. auto Err1 = Interp->Undo(); - EXPECT_EQ("Operation failed. Too many undos", + EXPECT_EQ("Operation failed. No input left to undo", llvm::toString(std::move(Err1))); auto Err2 = Interp->Parse("int foo = 42;"); EXPECT_TRUE(!!Err2); auto Err3 = Interp->Undo(2); - EXPECT_EQ("Operation failed. Too many undos", + EXPECT_EQ("Operation failed. No input left to undo", llvm::toString(std::move(Err3))); // Succeed to undo. >From b0513a8a46e69b3d9753d6ada1ca8f71debc9fe3 Mon Sep 17 00:00:00 2001 From: Aaron Danen <aaron.da...@gmail.com> Date: Fri, 18 Jul 2025 18:18:27 -0700 Subject: [PATCH 2/2] implemented contextual error msg differentiate between the case of 0 inputs to undo and the case when there are X inputs and Y requested undos but Y > X --- clang/lib/Interpreter/Interpreter.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp index a2696f78cb510..5b4b73fd6490c 100644 --- a/clang/lib/Interpreter/Interpreter.cpp +++ b/clang/lib/Interpreter/Interpreter.cpp @@ -752,10 +752,17 @@ Interpreter::getSymbolAddressFromLinkerName(llvm::StringRef Name) const { llvm::Error Interpreter::Undo(unsigned N) { - if (N > getEffectivePTUSize()) + if (getEffectivePTUSize() == 0) { return llvm::make_error<llvm::StringError>("Operation failed. " "No input left to undo", std::error_code()); + } else if (N > getEffectivePTUSize()) { + return llvm::make_error<llvm::StringError>( + llvm::formatv("Wanted to undo {0} inputs, only have {1}.", + N, getEffectivePTUSize()), + std::error_code()); + } + for (unsigned I = 0; I < N; I++) { if (IncrExecutor) { if (llvm::Error Err = IncrExecutor->removeModule(PTUs.back())) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits