-
Notifications
You must be signed in to change notification settings - Fork 14.5k
[clang-repl] #149396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[clang-repl] #149396
Conversation
used grep -r "Too many undos" to locate all instances where the string was mentioned. Changed the string to the suggestion in issue 143668
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-clang Author: Aaron Danen (aadanen) ChangesHi all. This is my first pull request to an open source project. I am a student so have mercy on me! I have done my best to read all of the relevant documentation about how to contribute most effectively but its totally possible I've made a mistake or missed something. Please let me know so I can do better next time :) I found a simple issue and have done my best to resolve it. I believe this change resolves #143668 All i did was grep -r "Too many undos" and replace all instances of that string with the suggested replacement. thank you for your time Full diff: https://github.com/llvm/llvm-project/pull/149396.diff 2 Files Affected:
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.
|
Welcome!
Simple and effective but, there is a little bit more context in this case, which I'll explain in a review comment in a moment. Some admin stuff:
Having said that, I think you'll be better able to describe the change once we've gone through some review. So leave both of those as is, for now, and we'll make sure they're ok later. Another thing that you may not have had to do for the change as is, but will when I explain a bit more, is run the tests locally. So if you haven't already, follow https://llvm.org/docs/GettingStarted.html and get to the point where you can build clang. From there you can either use In addition to that, our CI will be running tests for you but it is much more useful to have them running locally so your edit -> run -> edit loop can be faster. |
|
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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The complication here is that although the clang-repl %undo
only undoes one input, the internal method can actually undo more than that. This test for example is trying to undo 2 things.
So the code needs to be a bit more intelligent. You have two situations:
- You have nothing left to undo.
- You have some things left to undo but want to undo more than that.
In both cases you error because you don't want to partially undo something, but the message should be specific. In the same order as above, I suggest:
- "No input left to undo"
- "Wanted to undo X inputs, only have Y" (with the message formatted with the correct numbers)
For formatting the error, we have some utilities to do that, I will find those for you.
Side note: "inputs" might not be the right noun, but stick with it for now and we can ask a clang-repl maintainer whether it's ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that the internal method can undo more than one input because you might be piping many lines at once into clang-repl? Anyway it's there so we should assume it is there for a good reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return llvm::make_error<llvm::StringError>( |
If you've seen Python's format strings, it works like those, automatically figuring out what the type of the parameters are so that you don't have to %<something>
each time like in printf. There's a bit more explanation in https://llvm.org/doxygen/FormatVariadic_8h_source.html but searching for other uses of it will be more informative than the formal grammar of it.
#149396 (comment) is one of our automated checks, please follow its guidance. The reason we do this is so we can attribute changes for reasons around the licensing of contributions, there's more info in those links. It can be any valid address, you don't have to use a "personal" one, for instance I use my email address provided by my employer (that and they require that I do, but beside the point). |
|
differentiate between the case of 0 inputs to undo and the case when there are X inputs and Y requested undos but Y > X
I put in inputs vs undo requests logic but I think the unit test might need to be edited as well |
Hi all. This is my first pull request to an open source project. I am a student so have mercy on me!
I have done my best to read all of the relevant documentation about how to contribute most effectively but its totally possible I've made a mistake or missed something. Please let me know so I can do better next time :)
I found a simple issue and have done my best to resolve it. I believe this change resolves #143668
All i did was grep -r "Too many undos" and replace all instances of that string with the suggested replacement.
thank you for your time
aadanen