[PATCH] D101923: [TableGen] Make the NUL character invalid in .td files
David Blaikie via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 5 13:06:11 PDT 2021
dblaikie added inline comments.
================
Comment at: llvm/lib/TableGen/TGLexer.cpp:420-424
+/// Or we may end up at the end of the buffer.
void TGLexer::SkipBCPLComment() {
++CurPtr; // skip the second slash.
- while (true) {
- switch (*CurPtr) {
- case '\n':
- case '\r':
- return; // Newline is end of comment.
- case 0:
- // If this is the end of the buffer, end the comment.
- if (CurPtr == CurBuf.end())
- return;
- break;
- }
- // Otherwise, skip the character.
- ++CurPtr;
- }
+ auto EOLPos = CurBuf.find_first_of("\r\n", CurPtr - CurBuf.data());
+ CurPtr = (EOLPos == StringRef::npos) ? CurBuf.end() : CurBuf.data() + EOLPos;
----------------
So previously a null character would terminate a comment - and with this change it won't terminate the comment anymore? Maybe this would be better in a separate patch (& maybe with a test demonstrating this behavior)
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101923/new/
https://reviews.llvm.org/D101923
More information about the llvm-commits
mailing list