[clang] e3adaf0 - [clang][modules] Close module file descriptors (#191227)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 9 09:32:58 PDT 2026
Author: Jan Svoboda
Date: 2026-04-09T09:32:52-07:00
New Revision: e3adaf0be8b71a66028ddcdb9897c67dd0804fd3
URL: https://github.com/llvm/llvm-project/commit/e3adaf0be8b71a66028ddcdb9897c67dd0804fd3
DIFF: https://github.com/llvm/llvm-project/commit/e3adaf0be8b71a66028ddcdb9897c67dd0804fd3.diff
LOG: [clang][modules] Close module file descriptors (#191227)
This was missed in the original PR and was causing "too many files open"
errors on real workloads.
Added:
Modified:
clang/lib/Serialization/ModuleCache.cpp
Removed:
################################################################################
diff --git a/clang/lib/Serialization/ModuleCache.cpp b/clang/lib/Serialization/ModuleCache.cpp
index dd0b4b845331e..9ea4223a2eb83 100644
--- a/clang/lib/Serialization/ModuleCache.cpp
+++ b/clang/lib/Serialization/ModuleCache.cpp
@@ -10,6 +10,7 @@
#include "clang/Serialization/InMemoryModuleCache.h"
#include "clang/Serialization/ModuleFile.h"
+#include "llvm/ADT/ScopeExit.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/IOSandbox.h"
@@ -151,6 +152,7 @@ clang::readImpl(StringRef FileName, off_t &Size, time_t &ModTime) {
llvm::sys::fs::openNativeFileForRead(FileName);
if (!FD)
return FD.takeError();
+ llvm::scope_exit CloseFD([&FD]() { llvm::sys::fs::closeFile(*FD); });
llvm::sys::fs::file_status Status;
if (std::error_code EC = llvm::sys::fs::status(*FD, Status))
return llvm::errorCodeToError(EC);
More information about the cfe-commits
mailing list