-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[lldb] Fix po
alias by printing fix-its to the console.
#68452
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
Conversation
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.
Is this printed before or after the output? If it's printed after, past tense might make more sense?
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.
This is the only output.
Technically the print comes after the change, but it's all happening "now", in the present tense, from the developers perspective.
I can change it back to past tense, but I don't know that detail would be relevant to anyone other than someone working on LLDB itself. Even then, that person can just step through debugger and see when the change happened relative to the print statement.
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.
Changed phrasing to past tense because this message appears after the expression's result.
error_stream << " Evaluated this expression after applying Fix-It(s):\n";
error_stream << " " << fixed_expression << "\n";
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'm not sure I understand what the second sentence is trying to convey.
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 did my best to reword/convert this comment from CommandObjectExpression.cpp
by:
- Removing "we" to avoid 1st person narrative.
- Avoiding future tense with "will".
// We only tell you about the FixIt if we applied it. The compiler errors
// will suggest the FixIt if it parsed.
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.
Ah! The original comment makes more sense: I think what it's trying to say is:
LLDB only displays fixits if the expression evaluator applied them. Any compiler diagnostics LLDB displays refer to the modified expression with the fixit applied.
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.
Revised comments.
// Only mention Fix-Its if the expression evaluator applied them.
// Compiler errors refer to the final expression after applying Fix-It(s).
lldb/test/API/lang/cpp/dwim-print-fixit/TestCppDWIMPrintFixIt.py
Outdated
Show resolved
Hide resolved
lldb/test/API/lang/cpp/dwim-print-fixit/TestCppDWIMPrintFixIt.py
Outdated
Show resolved
Hide resolved
lldb/test/API/lang/cpp/expression-fixit/TestCppExpressionFixIt.py
Outdated
Show resolved
Hide resolved
lldb/test/API/lang/cpp/expression-fixit/TestCppExpressionFixIt.py
Outdated
Show resolved
Hide resolved
✅ With the latest revision this PR passed the C/C++ code formatter. |
The code is not something I am familiar with, but I did notice that the PR title and the commit title are quite different. Not sure which one is better, but it is generally nice to have them match (in particular it is nice to add the |
1d0ac08
to
3a17d92
Compare
lldb/test/API/lang/cpp/dwim-print-fixit/TestCppDWIMPrintFixIt.py
Outdated
Show resolved
Hide resolved
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.
This can be a multiline string, instead of using \
line continuations.
"Confirm that the `po` command (alias) applies a FixIt " \ | |
"and prints it out to the console, " \ | |
"just like the `expression` command." | |
""" | |
Confirm that the `po` command (alias) applies a FixIt | |
and prints it out to the console, | |
just like the `expression` command. | |
""" |
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 tried using a multiline string, but that adds hard returns and all the indentation spaces in the middle of the string, which gives you this string…
Confirm that the `po` command (alias) applies a FixIt
and prints it out to the console,
just like the `expression` command.
Instead of this string …
Confirm that the `po` command (alias) applies a FixIt and prints it out to the console, just like the `expression` command.
Plus, I noticed that running the single unit test only prints the string up until the first \n
to the console, which means it's truncating everything after it.
The \
line continuations make it so that:
- All the lines stay relatively short, just like a multiline string does.
- The the test shows the whole string without truncating it.
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.
Fixed with a """
string that's one line for doxygen.
"""Confirms `po` shows an expression after applying Fix-It(s)."""
3a17d92
to
7def3f8
Compare
7def3f8
to
08f4d4a
Compare
Thanks for the tip, @felipepiovezan . |
6ba636b
to
6d8f611
Compare
Modifying `po` alias to match outward FixIt behavior with `expression`. - Fix `po` alias so that it prints out a message when applying a FixIt, just like the `expression` command. - Add test cases for applying a FixIt with both `expression` command and `po` alias. - Reword console messages for readability.
6d8f611
to
60dbef7
Compare
The
po
alias now matches the behavior of theexpression
command when the it can apply a Fix-It to an expression.Modifications
m_fixed_expression
to theCommandObjectDWIMPrint
class aprotected
member that stores the post Fix-It expression, just like theCommandObjectExpression
class.po
andexpressions
rdar://115317419