Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

[linux-port] Fix DiagnosticPrinter use of std::hex - #179

Merged
ehsannas merged 1 commit into
google:linuxfrom
pow2clk:pow2clk-fixup
May 17, 2018
Merged

ehsannas merged 1 commit into
google:linuxfrom
pow2clk:pow2clk-fixup

Conversation

@pow2clk

@pow2clk pow2clk commented May 16, 2018

Copy link
Copy Markdown

DiagnosticPrinter doesn't support io manipulators like std::hex,
in spite of that, including them in the output stream with MSVC
succeeded because it interpretted std::hex as a void pointer, which
is supported.

This adds support of it by adding an overloaded operator<< that takes
the type of std::hex and its friends and sets a base number which is
used when the base is not 10 to print numbers in the specified base,
which can only be 8 or 16 according to what is passed in.

Fixes #170

@googlebot

Copy link
Copy Markdown

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@pow2clk

pow2clk commented May 16, 2018

Copy link
Copy Markdown
Author

Well I signed the CLA. Hopefully it'll kick in. If not, I can upload again.

@googlebot

Copy link
Copy Markdown

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

@pow2clk

pow2clk commented May 16, 2018

Copy link
Copy Markdown
Author

@googlebot is confusing me. Is it upset about the throwaway email address generated for the commit?

@AppVeyorBot

Copy link
Copy Markdown

❌ Build DirectXShaderCompiler 1.0.18 failed (commit 4a0122db65 by @)

@googlebot

Copy link
Copy Markdown

CLAs look good, thanks!

@AppVeyorBot

Copy link
Copy Markdown

@AppVeyorBot

Copy link
Copy Markdown

@pow2clk

pow2clk commented May 17, 2018

Copy link
Copy Markdown
Author

If I'm reading the results correctly, the only failure is on a Windows test suite: CompilerTest::CompileWhenNoMemThenOOM. I've tried unsuccessfully to reproduce this locally on my Windows build. The only effect I can see this having on memory allocation is that I increased the size of raw_ostream objects by 4 bytes because I added an integer member variable. That doesn't seem likely to cause a failure.

@pow2clk

pow2clk commented May 17, 2018

Copy link
Copy Markdown
Author

The only remaining failure in the automated tests is the Windows failure acknowledged by the latest comment in #177. I think this is good to go barring any review feedback.

@antiagainst antiagainst left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for the fix! Generally it looks good to me. A few nits inlined.

Comment thread include/llvm/IR/DiagnosticPrinter.h Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing override.

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.

will do.

Comment thread include/llvm/IR/DiagnosticPrinter.h Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The convention is to wrap changes to existing LLVM code base with // HLSL Change.

Applies to the following cases.

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.

Hmm. There are some clear cases where I missed this, but it might get a bit ridiculous if I go too far with it. Should I put it on every line I changed and around multiline changes including those I just added something to or should I presume that certain corresponding changes can be inferred?

For example, if I comment that the new member variable is an HLSL addition, do I still need to mark every reference of it? Or can it be considered a given?

Happy to go either way. Just don't want to do too much or too little.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yeah. Microsoft does not give clear criteria on how this should be done. My understanding is that we need to wrap whatever code we've changed in existing LLVM/Clang codebase (no need for completely new source files). For single line code change, just use // HLSL Change. For multiple lines of code change, use // HLSL Change Starts and // HLSL Change Ends like /* and */.

We normally don't introduce new changes to existing LLVM/Clang code base; most of the time we are just changing what Microsoft had already touched. So it's a little bit hassle to have these markers, but I'd expect they don't occur that much.

Comment thread include/llvm/Support/raw_ostream.h Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Redundant empty lines? ;)

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.

Yeah. I was going to fix them if I had to fix something else. So it looks like I am.

DiagnosticPrinter doesn't support io manipulators like std::hex,
in spite of that, they were included in some invocations of it. MSVC
seemed to allow this because it interpretted std::hex as a void
pointer, which is supported.

This adds support of std::hex and similar manipulators by adding an
overloaded operator<< that takes the type of std::hex and its friends
and sets a base number which is used when the base is not 10 to print
numbers in the specified base, which can only be 8 or 16 according to
what is passed in.

Also while I was changing things in raw_ostream.h I added a
missing override keyword that produced a lot of warnings on clang.

Fixes google#170
@AppVeyorBot

Copy link
Copy Markdown

@antiagainst antiagainst left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM. Thanks!

@ehsannas
ehsannas merged commit 28a9a82 into google:linux May 17, 2018
@ehsannas ehsannas mentioned this pull request May 18, 2018
35 of 38 tasks
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.

5 participants