]> granicus.if.org Git - clang/commitdiff
Add back null check removed accidentally in r250554
authorReid Kleckner <rnk@google.com>
Tue, 20 Oct 2015 18:45:57 +0000 (18:45 +0000)
committerReid Kleckner <rnk@google.com>
Tue, 20 Oct 2015 18:45:57 +0000 (18:45 +0000)
Fixes PR25262

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

lib/Lex/HeaderSearch.cpp
test/Frontend/force-include-not-found.c [new file with mode: 0644]

index 469d782deb316a78998281fea1089923f95ce698..8a686a7f3d74e5a91d3c996598aef93b8ef88924 100644 (file)
@@ -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 (file)
index 0000000..191cf9d
--- /dev/null
@@ -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() { }