<div dir="ltr">PING.</div><br><div class="gmail_quote"><div dir="ltr">On Thu, Apr 14, 2016 at 1:52 PM Eric Liu <<a href="mailto:ioeric@google.com">ioeric@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">ioeric updated this revision to Diff 53691.<br>
ioeric added a comment.<br>
<br>
- Addressed reviewer comment.<br>
<br>
<br>
<a href="http://reviews.llvm.org/D19106" rel="noreferrer" target="_blank">http://reviews.llvm.org/D19106</a><br>
<br>
Files:<br>
lib/Format/TokenAnnotator.h<br>
<br>
Index: lib/Format/TokenAnnotator.h<br>
===================================================================<br>
--- lib/Format/TokenAnnotator.h<br>
+++ lib/Format/TokenAnnotator.h<br>
@@ -83,7 +83,7 @@<br>
/// \c true if this line starts with the given tokens in order, ignoring<br>
/// comments.<br>
template <typename... Ts> bool startsWith(Ts... Tokens) const {<br>
- return startsWith(First, Tokens...);<br>
+ return startsWithInternal(First, Tokens...);<br>
}<br>
<br>
/// \c true if this line looks like a function definition instead of a<br>
@@ -124,15 +124,24 @@<br>
void operator=(const AnnotatedLine &) = delete;<br>
<br>
template <typename A, typename... Ts><br>
- bool startsWith(FormatToken *Tok, A K1) const {<br>
+ bool startsWithInternal(const FormatToken *Tok, A K1) const {<br>
+ // Even though we skip comments in the outter `startWithInternal` function,<br>
+ // this loop is still necessary if it is invoked by the public interface<br>
+ // `startsWith`.<br>
while (Tok && Tok->is(tok::comment))<br>
Tok = Tok->Next;<br>
return Tok && Tok->is(K1);<br>
}<br>
<br>
template <typename A, typename... Ts><br>
- bool startsWith(FormatToken *Tok, A K1, Ts... Tokens) const {<br>
- return startsWith(Tok, K1) && startsWith(Tok->Next, Tokens...);<br>
+ bool startsWithInternal(const FormatToken *Tok, A K1, Ts... Tokens) const {<br>
+ // Skip comments before calling `startsWithInternal(Tok, K1)` so that the<br>
+ // second call to `startsWithInternal` takes the correct `Tok->Next`, which<br>
+ // should be the next token of the token checked in the first call.<br>
+ while (Tok && Tok->is(tok::comment))<br>
+ Tok = Tok->Next;<br>
+ return Tok && startsWithInternal(Tok, K1) &&<br>
+ startsWithInternal(Tok->Next, Tokens...);<br>
}<br>
};<br>
<br>
<br>
<br>
</blockquote></div>