]> granicus.if.org Git - clang/commitdiff
Avoid accessing an invalid PresumedLoc.
authorJordan Rose <jordan_rose@apple.com>
Tue, 28 Jun 2016 01:02:31 +0000 (01:02 +0000)
committerJordan Rose <jordan_rose@apple.com>
Tue, 28 Jun 2016 01:02:31 +0000 (01:02 +0000)
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. This one must have been missed.

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.

rdar://problem/26099576

http://reviews.llvm.org/D21111

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@273976 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/DiagnosticRenderer.cpp

index c4365f9ce0223f06a0b2dc0651fe7f64ce06d77e..586d2e6167b3bd07bf76e8fcdb894730fcc1d833 100644 (file)
@@ -618,7 +618,7 @@ DiagnosticNoteRenderer::emitBuildingModuleLocation(SourceLocation Loc,
   // 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