Change the parsing logic to use StringRef instead of lower level
char* logic. Also, if emitting a diagnostic on the first token
in the file, we make sure to use that position instead of the
very start of the file.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Parser/Parser.cpp | ||
---|---|---|
202 | StringRef eol = startOfBuffer.detectEOL(); if (!startOfBuffer.endswith(eol)) ? | |
212 | size_t newLineIndex = prefLine.find_last_of(eol); // eol variable from above ? | |
217 | could you use rsplit on this? It'd just return a pair of stringrefs and then startOfBuffer is just the first (before the comment token). |
mlir/lib/Parser/Parser.cpp | ||
---|---|---|
202 | detectEOL is... interesting, but massive overkill for what we're doing. I think the existing code is simple and good. | |
212 | Likewise, it is fine to remove \n\r in any combination, and is simpler. | |
217 | I investigated, but not really. rsplit is the wrong thing for lines that contain multiple //'s. We need split from the start of the line. I just tried startOfBuffer = startOfBuffer.split("//").first; but that is of course wrong, as is prevLine.split(...) without weird gymnastics. I think the existing code is a reasonable solution here. |
Thanks for looking into it - if this is simpler than the other thing then by all means let's keep it simple!
?