[PATCH] D21111: Avoid accessing an invalid PresumedLoc

Jordan Rose via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 7 17:48:20 PDT 2016


jordan_rose created this revision.
jordan_rose added a reviewer: rsmith.
jordan_rose added a subscriber: cfe-commits.
jordan_rose set the repository for this revision to rL LLVM.

DiagnosticNoteRenderer asserts trying to emit its "while building module Foo imported from bar.h:5" note when the presumed location of the import is invalid. This assertion was added in r267914, where //most// uses of `getFilename` were updated to test `isValid` instead.

I can't come up with a test because this location is always valid in C-based code, but external clients that manually import modules (*cough*Swift*cough*) sometimes provide invalid SourceLocations.

Repository:
  rL LLVM

http://reviews.llvm.org/D21111

Files:
  lib/Frontend/DiagnosticRenderer.cpp

Index: lib/Frontend/DiagnosticRenderer.cpp
===================================================================
--- lib/Frontend/DiagnosticRenderer.cpp
+++ lib/Frontend/DiagnosticRenderer.cpp
@@ -618,7 +618,7 @@
   // Generate a note indicating the include location.
   SmallString<200> MessageStorage;
   llvm::raw_svector_ostream Message(MessageStorage);
-  if (PLoc.getFilename())
+  if (PLoc.isValid())
     Message << "while building module '" << ModuleName << "' imported from "
             << PLoc.getFilename() << ':' << PLoc.getLine() << ":";
   else


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21111.59979.patch
Type: text/x-patch
Size: 560 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160608/245fbbb9/attachment.bin>


More information about the cfe-commits mailing list