================
@@ -149,6 +149,63 @@ class TextTokenRetokenizer {
     addToken();
   }
 
+  /// Check if this line starts with @par or \par
+  bool startsWithParCommand() {
+    unsigned Offset = 1;
+
+    /// Skip all whitespace characters at the beginning.
+    /// This needs to backtrack because Pos has already advanced past the
+    /// actual \par or @par command by the time this function is called.
+    while (isWhitespace(*(Pos.BufferPtr - Offset)))
+      Offset++;
----------------
AaronBallman wrote:

Okay, I think what's got me confused is that you calculate `Offset` but never 
actually use it (or modify `Pos.BufferPtr`). I was thinking you would have been 
able to use `ltrim().starts_with(...)` but I see now that the issue is we're at 
the start of the comment, beyond seeing `par`, and we want to backtrack.

But the logic below seems to be that we already know we're parsing a par 
command, so why do we need to do this check in the first place? (e.g., we get 
into this code path via:
```
 else if (Info->IsParCommand)
      S.actOnBlockCommandArgs(BC,
                              parseParCommandArgs(Retokenizer, Info->NumArgs));
```
and eventually land here, so don't we already know this is a par command?)

https://github.com/llvm/llvm-project/pull/91100
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to