Diagnostics coming from a memory buffer (e.g. pragmas) don't have a

corresponding file buffer, don't dereference null pointers.  This
fixes a regression on test/Preprocessor/_Pragma-syshdr.c

llvm-svn: 39611
This commit is contained in:
Chris Lattner 2007-06-08 18:11:33 +00:00
parent 1abbd417be
commit c84413e0a8
1 changed files with 6 additions and 4 deletions

View File

@ -145,10 +145,12 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level,
Level == Diagnostic::Note) {
SourceLocation PhysLoc = SourceMgr.getPhysicalLoc(Pos);
const FileEntry *F = SourceMgr.getFileEntryForFileID(PhysLoc.getFileID());
DirectoryLookup::DirType DirInfo = TheHeaderSearch->getFileDirFlavor(F);
if (DirInfo == DirectoryLookup::SystemHeaderDir ||
DirInfo == DirectoryLookup::ExternCSystemHeaderDir)
return;
if (F) {
DirectoryLookup::DirType DirInfo = TheHeaderSearch->getFileDirFlavor(F);
if (DirInfo == DirectoryLookup::SystemHeaderDir ||
DirInfo == DirectoryLookup::ExternCSystemHeaderDir)
return;
}
}
// First, if this diagnostic is not in the main file, print out the