[PATCH] D57150: [HeaderSearch] don't immediately request that headers are opened in getFileAndSuggestModule().
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 24 05:29:37 PST 2019
sammccall updated this revision to Diff 183291.
sammccall added a comment.
Actually include the relevant code change :-\
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57150/new/
https://reviews.llvm.org/D57150
Files:
lib/Lex/HeaderSearch.cpp
test/PCH/leakfiles
Index: test/PCH/leakfiles
===================================================================
--- /dev/null
+++ test/PCH/leakfiles
@@ -0,0 +1,29 @@
+// Test that compiling using a PCH doesn't leak file descriptors.
+// https://bugs.chromium.org/p/chromium/issues/detail?id=924225
+
+// This test requires bash loops and ulimit.
+// REQUIRES: shell
+// UNSUPPORTED: win32
+//
+// Set up source files. lib/lib.h includes lots of lib*.h files in that dir.
+// client.c includes lib/lib.h, and also the individual files directly.
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: cd %t
+// RUN: mkdir lib
+// RUN: for i in {1..300}; do touch lib/lib$i.h; done
+// RUN: for i in {1..300}; do echo "#include \"lib$i.h\"" >> lib/lib.h; done
+// RUN: echo "#include \"lib/lib.h\"" > client.c
+// RUN: for i in {1..300}; do echo "#include \"lib/lib$i.h\"" >> client.c; done
+//
+// We want to verify that we don't hold all the files open at the same time.
+// This is important e.g. on mac, which has a low default FD limit.
+// RUN: ulimit -n 100
+//
+// Test without PCH.
+// RUN: %clang_cc1 -fsyntax-only -Ilib/ client.c
+//
+// Test with PCH.
+// RUN: %clang_cc1 -emit-pch -o pch -Ilib/ client.c
+// RUN: %clang_cc1 -include-pch pch -Ilib/ client.c -fsyntax-only
Index: lib/Lex/HeaderSearch.cpp
===================================================================
--- lib/Lex/HeaderSearch.cpp
+++ lib/Lex/HeaderSearch.cpp
@@ -310,7 +310,7 @@
ModuleMap::KnownHeader *SuggestedModule) {
// 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);
+ const FileEntry *File = getFileMgr().getFile(FileName, /*OpenFile=*/false);
if (!File)
return nullptr;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57150.183291.patch
Type: text/x-patch
Size: 1806 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190124/d6e768e1/attachment.bin>
More information about the cfe-commits
mailing list