Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

Allow formatting of C++ code - #840

Merged
jkotas merged 1 commit into
dotnet:masterfrom
manu-st:cpp_formatting
Feb 10, 2016
Merged

jkotas merged 1 commit into
dotnet:masterfrom
manu-st:cpp_formatting

Conversation

@manu-st

@manu-st manu-st commented Feb 10, 2016

Copy link
Copy Markdown

Added ability to indent properly the C++ generated code.
No 2 instructions on the same line.

I'm not sure if there are specific rules for formatting C++ code so the way I've formatted it might be subject to discussion.

See issue #833.

Size wise on my simple hello world, there is a size increase of about 5%. I did not benchmark the time spent in ilc nor to perform the C++ compilation.

@manu-st

manu-st commented Feb 10, 2016

Copy link
Copy Markdown
Author

I've put the formatted code currently being generated by this PR at: https://gist.github.com/manu-silicon/cea105dd7adb9ec0e7ba


// TODO: Write barrier as necessary!!!

AppendLine();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There extra lines will throw off the lines generated by #pragma line directives - so the stepping in C# code under debugger will not work well anymore. I think we may need different modes: one that produces nice readable C++, and other that has the #pragma line directives in it, but it is less readable.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll keep the formatting when -nolinenumbers is set, and reduce it otherwise to preserve a decent debugging experience when using the C# code.

@jkotas

jkotas commented Feb 10, 2016

Copy link
Copy Markdown
Member

LGTM modulo comment. Thanks for doing this!

@manu-st

manu-st commented Feb 10, 2016

Copy link
Copy Markdown
Author

I've fixed the debugging side, so when you do not specify -nolinenumbers it generates pretty much the same as before, even fixing a few debugging mishap with try/catch (to ensure we do not debug past the end of a routine try/catch clause).

@manu-st

manu-st commented Feb 10, 2016

Copy link
Copy Markdown
Author

I'm going to look at the Unix C++ compilation error.
I'm not sure why the Windows Release build failed.

@jkotas

jkotas commented Feb 10, 2016

Copy link
Copy Markdown
Member

The Windows build error looks like infrastructure problem.

@manu-st

manu-st commented Feb 10, 2016

Copy link
Copy Markdown
Author

It should be fixed now.

@jkotas

jkotas commented Feb 10, 2016

Copy link
Copy Markdown
Member

Could you please squash into a single commit?

Added ability to indent properly the C++ generated code.
No 2 instructions on the same line.
Forget about formatting when generating #line as we want accurate
debugging experience.
@manu-st

manu-st commented Feb 10, 2016

Copy link
Copy Markdown
Author

done

jkotas added a commit that referenced this pull request Feb 10, 2016
@jkotas
jkotas merged commit 2c057e7 into dotnet:master Feb 10, 2016
@manu-st
manu-st deleted the cpp_formatting branch February 10, 2016 04:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants