From 8cc2c171d0ea6e07266b3891bf767b10762be5f5 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Tue, 20 Oct 2015 18:45:57 +0000 Subject: [PATCH] Add back null check removed accidentally in r250554 Fixes PR25262 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250844 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Lex/HeaderSearch.cpp | 2 ++ test/Frontend/force-include-not-found.c | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 test/Frontend/force-include-not-found.c diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp index 469d782deb..8a686a7f3d 100644 --- a/lib/Lex/HeaderSearch.cpp +++ b/lib/Lex/HeaderSearch.cpp @@ -256,6 +256,8 @@ const FileEntry *HeaderSearch::getFileAndSuggestModule( // If we have a module map that might map this header, load it and // check whether we'll have a suggestion for a module. const FileEntry *File = getFileMgr().getFile(FileName, /*OpenFile=*/true); + if (!File) + return nullptr; // If there is a module that corresponds to this header, suggest it. if (!findUsableModuleForHeader(File, Dir ? Dir : File->getDir(), diff --git a/test/Frontend/force-include-not-found.c b/test/Frontend/force-include-not-found.c new file mode 100644 index 0000000000..191cf9d403 --- /dev/null +++ b/test/Frontend/force-include-not-found.c @@ -0,0 +1,3 @@ +// RUN: not %clang_cc1 %s -include "/abspath/missing file with spaces.h" 2>&1 | FileCheck %s +// CHECK: file not found +int main() { } -- 2.50.1