<div dir="ltr">I am not the authority here, but based on what I've seen this sounds good to me. I was once discouraged from adding an #undef in client code because Tokens.def does it already. Mentioning that behavior in the comments certainly can't hurt.<div class="gmail_extra"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><br></div></div></div></div>
<br><div class="gmail_quote">On Wed, Dec 28, 2016 at 2:37 PM, Micah Hainline via swift-dev <span dir="ltr"><<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm still wrapping my head around this, but we're doing some heavy<br>
macro programming in swift/Parse/Tokens.def. We define macros such as<br>
KEYWORD and then include the file, which allows different things to<br>
happen based on what macros we've defined beforehand.<br>
<br>
Because it's using macros, subsequent includes of Tokens.def will have<br>
those same old macros defined unless they are subsequently undefined.<br>
That is actually happening in the bottom of the Tokens.def now, but<br>
apparently that wasn't always the case and there is some leftover code<br>
floating around that tries to deal with it. Sometimes (see<br>
SyntaxModel.cpp lines 98-100) we then #undef the macro afterward, in<br>
effect manually cleaning up after ourselves. In Lexer.cpp line 546 we<br>
define KEYWORD just to redefine it to be empty on line 602 presumably<br>
to avoid the previous definition stepping on our toes in the next<br>
couple of lines. Of course, the include already cleaned that up.<br>
<br>
I think we should go through and try to be more consistent with this.<br>
Tokens.def should have a comment block explaining exactly which macros<br>
will be checked and just specifying they'll all be undefined<br>
afterward, and all include usages should get rid of empty defines and<br>
undefines. Does that make sense?<br>
______________________________<wbr>_________________<br>
swift-dev mailing list<br>
<a href="mailto:swift-dev@swift.org">swift-dev@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-dev" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-dev</a><br>
</blockquote></div><br></div></div>