Hi,<br><br>Has anyone has a chance to look at this? Updated patch attached.<br><br>Thanks,<br>Dan<br><div class="gmail_extra"><br><br><div class="gmail_quote">On 6 November 2012 19:18, Daniel Powell <span dir="ltr"><<a href="mailto:divot.powell@googlemail.com" target="_blank">divot.powell@googlemail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br><br>Original Context: <a href="http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-June/022120.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-June/022120.html</a><br>
<br>I
found an issue with the PragmaHandler class where those wishing to modify a
pragma statement did not have any access to the "#pragma" keyword. Doug asked that
a SourceRange parameter be added to the HandlePragma method specifying the range for the "#pragma" keyword. <br><br>I have made this change, along with handling for _pragma and __pragma introducers. FInally I have also updated all of the existing PragmaHandlers to receive this new SourceRange.<br>
<br>My apologies, I have been sat on this for longer than I should.<br><br>Cheers,<br><br>Dan<br><div class="gmail_extra"><div><div><br><br><div class="gmail_quote">On 19 June 2012 18:04, Douglas Gregor <span dir="ltr"><<a href="mailto:dgregor@apple.com" target="_blank">dgregor@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><div><div>On Jun 16, 2012, at 6:54 AM, Daniel Powell wrote:</div>
<br><blockquote type="cite">Hi,<br><br>
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">HandlePragma should take a SourceRange that covers the '#pragma' or '_Pragma', so that this information is available to the pragma handlers. It should be a fairly simple change to Clang; would you like to contribute a patch for it?<br>
</blockquote><div><br>Happy to. Just to check, you are suggesting I modify the current HandlePragma method to have the following prototype?<br>virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer, Token &FirstToken, SourceLocation IntroducerLoc) = 0;</div>
</div></blockquote><div><br></div></div>With the SourceRange change from your follow-up e-mail, yes.</div><div><div><br><blockquote type="cite">With the three types of pragma supported (#pragma, _Pragma and __Pragma) their locations only appear available when the preprocessor first discovers the token (HandleDirective, Handle_Pragma and HandleMicrosoft__pragma respectively), and is lost by the time HandlePragmaDirective is called so it's probably best to pass the location from those places to HandlePragmaDirective and onwards.<br>
<br>_Pragma and __Pragma are easy, they each have PragmaLoc pointing to the keyword. However, by the time #pragma is fully discovered it only has a location pointing to "pragma" not "#pragma". I could use the getLocWithOffset(-1) method, or catch it at the start of the HandleDirective method, which do you think is best?<br>
</blockquote><div><br></div></div>Please catch it at the start of HandleDirective and pass it down.</div><div><div><br><blockquote type="cite">I'll have to update the existing PragmaHandlers too.<br></blockquote>
<div><br></div></div>Yes, please!</div><div><div><br><blockquote type="cite">Does all this sound sane? First time someone's asked me to contribute something specific back to open source. :-D<br></blockquote>
</div><div><br></div></div><div>Yes, this sounds perfectly reasonable. Thanks for looking into it!</div><br><div><span style="white-space:pre-wrap"> </span>- Doug</div><div><br></div></div>
</blockquote></div><br><br clear="all"><br></div></div><div>-- <br>--------<br>Daniel Powell<br><a href="mailto:divot.powell@googlemail.com" target="_blank">divot.powell@googlemail.com</a><br><a href="http://tinyurl.com/powelld" target="_blank">http://tinyurl.com/powelld</a><br>
<br>The University of Edinburgh<br>Institute for Computer Systems Architecture<br>
</div></div>
</blockquote></div><br><br clear="all"><br>-- <br>--------<br>Daniel Powell<br><a href="mailto:divot.powell@googlemail.com" target="_blank">divot.powell@googlemail.com</a><br><a href="http://tinyurl.com/powelld" target="_blank">http://tinyurl.com/powelld</a><br>
<br>The University of Edinburgh<br>Institute for Computer Systems Architecture<br>
</div>