-
Notifications
You must be signed in to change notification settings - Fork 249
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
[BUG] Poor debugging experience of generated code #844
Comments
I've noticed that the Compiler Explorer output from cppfront doesn't contain the #line directives that cppfront puts out. I think it must be hardcoding the |
Clean Cpp1 files don't have the phase comments, like |
Then my other assumption is that it is stripping them out from the output itself. Is the experience any better with the #line directives there? |
I don't think there's |
There definitely is for generated constructors and assignment operators. |
Probably because that's emitted during lowering. |
Yes, Compiler Explorer is explicitly stripping them.. https://github.com/compiler-explorer/compiler-explorer/blob/main/lib/parsers/asm-parser-cpp.ts#L48 But it's an option you can turn off from the Filters menu. There are line numbers added for constructors and assignment operators, but only if they're written in the original source, not if they're added by a metafunction. |
I wasn't aware of that, thank you. |
So I would say that in general your report is accurate for metafunction generated code. The "keeps the cursor at the EOF" depends on the length of your file. It would be more accurate to say that it's on an unrelated line, which is often the last line of the file when the file contains a single small class that has a lot of added code. I wonder if this is something that metafunctions will be able to do once they have the ability to write to a file for generating other languages. Probably the hardest part would be tracking which line in the file backs each bit of AST. I guess that if mycode.cpp2 generates mycode.cpp it could also generate mycode-generated.cpp2 in the same directory. |
#478 fixes #422 by generating a default constructor.
|
An alternative expected result is for generated code to disable the effect of |
IIRC, |
Yes. I have also tinkered by passing it through clang-format as well, since code comes all packed or scrambled (specially confusing with metafunctions), I also do that mostly because tabs are not printed back as tabs, but as a single space, which misaligns everything. |
Title: Poor debugging experience of generated code.
Description:
A lot of Cpp2 can be generated, not visible in the Cpp2 source code itself.
For example, generated constructors and assignments,
as well as member functions generated by metafunctions.
When debugging the reproducer,
until you step into a standard function,
attempting to step into generated code
This results in a poor user experience.
I think we can and should do better.
Minimal reproducer (https://cpp2.godbolt.org/z/P7ssbdoYe):
Commands:
cppfront main.cpp2 clang++18 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -I . main.cpp
Expected result:
cppfront
to output a Cpp2 source file with the generated code.#line
directives of generated code to point to the new file.Actual result and error: Stepping into generated code jumps to the EOF.
Cpp2 lowered to Cpp1:
Output:
The text was updated successfully, but these errors were encountered: