FileLineColLoc allows the column and line to be zero to represent unknown column and/or unknown line/column information. However, SourceMgr::FindLocForLineAndColumn treats line 0 and col 0 valid and pointing to the first line and col, respectively. To adapt this mismatch in semantics, we explicitly check line/col being zeros in SourceMgrDiagnosticHandler::convertLocToSMLoc
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/IR/Diagnostics.cpp | ||
---|---|---|
515 | How do we actually identify when the loc is referring really to the beginning of the file? There isn't a way to figure out? |
mlir/lib/IR/Diagnostics.cpp | ||
---|---|---|
515 | SourceMgr::FindLocForLineAndColumn assumes the indices are one-based, but treats line 0 specially that also points the first line. |
I found there are some internal tests (on diagnostics) that rely on column zero being the first column.
I am not so sure whether we should adopt that behavior and change API (i.e. treating only row zero being an unknown location) or fix the tests.
We should just fix the tests. zero line/zero column seems like a good enough indicator that it is the beginning of the file.
How do we actually identify when the loc is referring really to the beginning of the file? There isn't a way to figure out?