[PATCH] D80258: Fix SourceMgrDiagnosticHandler::convertLocToSMLoc for unknown line/column scenerio.

Jing Pu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 19 17:06:42 PDT 2020


Jing created this revision.
Herald added subscribers: llvm-commits, jurahul, Kayjukh, frgossen, grosul1, Joonsoo, stephenneuendorffer, liufengdb, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, jpienaar, rriddle, mehdi_amini.
Herald added a reviewer: rriddle.
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80258

Files:
  mlir/lib/IR/Diagnostics.cpp


Index: mlir/lib/IR/Diagnostics.cpp
===================================================================
--- mlir/lib/IR/Diagnostics.cpp
+++ mlir/lib/IR/Diagnostics.cpp
@@ -509,6 +509,11 @@
 /// Get a memory buffer for the given file, or the main file of the source
 /// manager if one doesn't exist. This always returns non-null.
 llvm::SMLoc SourceMgrDiagnosticHandler::convertLocToSMLoc(FileLineColLoc loc) {
+  // The column and line may be zero to represent unknown column and/or unknown
+  /// line/column information.
+  if (loc.getLine() == 0 || loc.getColumn() == 0)
+    return llvm::SMLoc();
+
   unsigned bufferId = impl->getSourceMgrBufferIDForFile(mgr, loc.getFilename());
   if (!bufferId)
     return llvm::SMLoc();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80258.265088.patch
Type: text/x-patch
Size: 730 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200520/ba0fd134/attachment.bin>


More information about the llvm-commits mailing list