[clang] [Clang][Comments] Support for parsing headers in Doxygen \par commands (PR #91100)
via cfe-commits
cfe-commits at lists.llvm.org
Mon May 6 14:04:42 PDT 2024
================
@@ -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++;
----------------
hdoc wrote:
In this case we actually have to read the buffer backwards to find the `@par`, past `Pos.BufferStart` so it's a bit inconvenient to construct the `StringRef` which starts at some unknown position before `Pos.BufferStart`. In theory someone could have put 400 spaces between `@par` and the comment text, and we'd have to accommodate that when constructing the `StringRef`.
I think the solution as it's written right now handles that well enough. I could make it count spaces or look up the previous token containing the `@par` and compute the correct StringRef for it, but I think this is good enough.
https://github.com/llvm/llvm-project/pull/91100
More information about the cfe-commits
mailing list