<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jul 27, 2011, at 10:47 AM, Chris Lattner wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jul 26, 2011, at 3:34 PM, Anna Zaks wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>Hi,</div><div><br></div><div>Attached are two patches, which add a fixit to remove an unused label.</div><div><br></div><div>1) Add a utility function to the Lexer, which makes it easier to find the ':' after the label as well as the new line and trailing spaces (It is a generalized version of <span class="Apple-style-span" style="font-family: Monaco; font-size: 11px; ">trans::findLocationAfterSemi</span><span class="Apple-style-span" style="font-family: Monaco; font-size: 11px; "> from A</span>rcMigrate, which will be changed to use the Lexer utility).</div><div></div></div></div>
<span><unusedLabel_LexSupport.diff></span><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div></div></div></div></blockquote></div><br><div>The Lexer part of this looks quite nice, with a few comments.  It's great to have this in a centralized place where lots of clients can use it.</div><div><br></div><div>In Lexer.h, please also add a non-static version of FindLocationAfterToken which doesn't require LangOpts and SourceMgr, just as a convenience (it should forward to the version you already have).</div><div><br></div></div></blockquote><div><br></div>Lexer does not currently have a SourceMgr member. Adding a non-static method just for the convenience of not passing LangOpts might be an overkill?</div><div><br></div><div><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">SourceLocation loc..</div></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">Please capitalize local variable names.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">+  // Lex from the start of the given location.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">+  Lexer lexer(SM.getLocForStartOfFile(locInfo.first), LangOpts, file.begin(),</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">+                                      tokenBegin, file.end());</div><div><br></div><div>it seems that it would be more convenient to use this Lexer ctor:</div><div><br></div><div><div><div>  Lexer(FileID FID, const llvm::MemoryBuffer *InputBuffer,</div><div>        const SourceManager &SM, const LangOptions &Features);</div></div></div><div><br></div></div></div></blockquote><div><br></div><div>We need the lexer to start processing the buffer starting from the specific position Loc. This constructor seems to be convenient if we were to start lexing from the beginning of the file.</div><br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">+    const char *tokenEnd = file.data() +</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">+                           SM.getDecomposedLoc(TokenLoc).second +</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">+                           tok.getLength();</div></div><div><br></div><div>This can use SM.getCharacterData(TokenLoc)</div><div><br></div><div><br></div><div>Otherwise, this looks great!</div></div></div></blockquote><div><br></div>Thanks for the review!</div><div>Anna.<br><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><div><br></div><div>-Chris</div><div><br></div><div><br></div></div></div></blockquote></div><br></body></html>