@@ -38,21 +38,23 @@ MatchFinder::collectMatches(Operation *root, DynMatcher matcher) const {
3838
3939void MatchFinder::printMatch (llvm::raw_ostream &os, QuerySession &qs,
4040 Operation *op) const {
41- auto fileLoc = cast<FileLineColLoc>(op->getLoc ());
42- SMLoc smloc = qs.getSourceManager ().FindLocForLineAndColumn (
43- qs.getBufferId (), fileLoc.getLine (), fileLoc.getColumn ());
44- llvm::SMDiagnostic diag =
45- qs.getSourceManager ().GetMessage (smloc, llvm::SourceMgr::DK_Note, " " );
46- diag.print (" " , os, true , false , true );
41+ if (auto fileLoc = dyn_cast<FileLineColLoc>(op->getLoc ())) {
42+ SMLoc smloc = qs.getSourceManager ().FindLocForLineAndColumn (
43+ qs.getBufferId (), fileLoc.getLine (), fileLoc.getColumn ());
44+ llvm::SMDiagnostic diag =
45+ qs.getSourceManager ().GetMessage (smloc, llvm::SourceMgr::DK_Note, " " );
46+ diag.print (" " , os, true , false , true );
47+ }
4748}
4849
4950void MatchFinder::printMatch (llvm::raw_ostream &os, QuerySession &qs,
5051 Operation *op, const std::string &binding) const {
51- auto fileLoc = cast<FileLineColLoc>(op->getLoc ());
52- auto smloc = qs.getSourceManager ().FindLocForLineAndColumn (
53- qs.getBufferId (), fileLoc.getLine (), fileLoc.getColumn ());
54- qs.getSourceManager ().PrintMessage (os, smloc, llvm::SourceMgr::DK_Note,
55- " \" " + binding + " \" binds here" );
52+ if (auto fileLoc = dyn_cast<FileLineColLoc>(op->getLoc ())) {
53+ auto smloc = qs.getSourceManager ().FindLocForLineAndColumn (
54+ qs.getBufferId (), fileLoc.getLine (), fileLoc.getColumn ());
55+ qs.getSourceManager ().PrintMessage (os, smloc, llvm::SourceMgr::DK_Note,
56+ " \" " + binding + " \" binds here" );
57+ }
5658}
5759
5860std::vector<Operation *>
0 commit comments