[Mlir-commits] [mlir] [mlir] Avoid crash in mlir-query by using dyn_cast instead of cast for FileLineColLoc (PR #145049)
Denzel-Brian Budii
llvmlistbot at llvm.org
Fri Jun 20 08:42:30 PDT 2025
================
@@ -38,21 +38,23 @@ MatchFinder::collectMatches(Operation *root, DynMatcher matcher) const {
void MatchFinder::printMatch(llvm::raw_ostream &os, QuerySession &qs,
Operation *op) const {
- auto fileLoc = cast<FileLineColLoc>(op->getLoc());
- SMLoc smloc = qs.getSourceManager().FindLocForLineAndColumn(
- qs.getBufferId(), fileLoc.getLine(), fileLoc.getColumn());
- llvm::SMDiagnostic diag =
- qs.getSourceManager().GetMessage(smloc, llvm::SourceMgr::DK_Note, "");
- diag.print("", os, true, false, true);
+ if (auto fileLoc = dyn_cast<FileLineColLoc>(op->getLoc())) {
----------------
chios202 wrote:
`auto fileLoc = op->getLoc()->findInstanceOf<FileLineColLoc>()` This seems to cause a segfault when calling `getStartLine()`
https://github.com/llvm/llvm-project/pull/145049
More information about the Mlir-commits
mailing list