<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>On Apr 21, 2012, at 6:29 PM, Chandler Carruth wrote:</div><div><div><div><div><div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote">On Sat, Apr 21, 2012 at 1:58 PM, Seth Cantrell <span dir="ltr"><<a href="mailto:seth.cantrell@gmail.com">seth.cantrell@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; ">
Can a warning with options be created entirely in a .td warning file? I want a warning that can be enabled in three different ways, e.g. -Wfoobar, -Wfoobar=yes, and -Wfoobar=no, however the only examples of warnings that take options that I know of are all done specially in the command line parsing. Will I be able to create such a warning in tablegen, and are there any examples I missed that do this?<br>
</blockquote><div><br></div><div>I would really rather avoid this complexity in our warning options. Can you explain what you're actually trying to do?</div></div>
</blockquote></div><br></div></div></div></div><div>Yes, but I don't think I'll persuade you that it's a good idea...</div><div><br></div><div><div>The specific warning I'm thinking about deals with the so called 'UTF-8 signature'. It has two modes, and additionally can be enabled without selecting a mode, which selects a default based on the platform.</div><div><div><br></div><div> - Produce a warning for any file that has a signature: -Wutf8-signature=no or maybe 'never'</div> - Produce a warning for any file that does not have a signature: -Wutf8-siganture=yes or maybe 'always'</div><div><br><div> - Produce a warning for any file that does not conform the the platform's conventions, i.e. a warning on Windows for files missing a signature and a warning on other platforms for files where a signature has snuck in: -Wutf8-signature</div><div><div><br></div><div><div><div>A hopefully motivating reason to warn about utf-8 signatures:</div><div><br></div><div><div><div>Code developed for Windows may depend on cl.exe's behavior where the source code encoding is set to be the system locale encoding unless a 'UTF-8 signature' is found. Code intended to use the system locale encoding will compile on clang (which assumes UTF-8 source code encoding always), but may behave incorrectly, possibly in subtle ways.</div></div></div></div></div><div><br></div><div><div>The above case could be easily handled with a simple warning flag without options, but it's not actually the case I care about. (And come to think of it, that warning would encourage Windows users to put utf-8 signatures in their code which isn't what I want!) IMO a compiler parsing a source file that begins with a UTF-8 signature should see that the file begins with U+FEFF (ZERO WIDTH NO BREAK SPACE), consult the C++ grammar, determine that C++ does not allow this character in this location and produce a fatal error. Unfortunately I don't think anyone else finds this behavior desirable. However, combining -Werror with the warning -Wutf8-signature=no would be almost as good.</div><div><br></div><div><br></div><div>Another thing that occurs to me is that if I wanted to introduce a warning that handles my first 'motivating' example but without all the false positives, the warning would only occur when a file contains bytes outside the ascii range and the file doesn't have a utf-8 signature. And the warning would point directly at any non-ascii bytes.</div></div></div></div></div></body></html>