https://github.com/jsji created https://github.com/llvm/llvm-project/pull/244002
AccessTimeRefreshInterval is only used inside the #ifndef _WIN32 block of refreshAccessTime(), so Windows builds with -Werror fail with -Wunused-const-variable. Move the constant into that block. Co-Authored-By: Claude Opus 5.5 <[email protected]> >From ec87dd04bc6a3a8d43c04c1107f572d6733d1113 Mon Sep 17 00:00:00 2001 From: Jinsong Ji <[email protected]> Date: Wed, 18 Nov 2026 22:01:27 +0100 Subject: [PATCH] [clang] Fix -Wunused-const-variable for AccessTimeRefreshInterval on Windows AccessTimeRefreshInterval is only used inside the #ifndef _WIN32 block of refreshAccessTime(), so Windows builds with -Werror fail with -Wunused-const-variable. Move the constant into that block. Co-Authored-By: Claude Opus 5.5 <[email protected]> --- clang/lib/Serialization/ModuleCache.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/lib/Serialization/ModuleCache.cpp b/clang/lib/Serialization/ModuleCache.cpp index c7f643c768c90..e174f6b223545 100644 --- a/clang/lib/Serialization/ModuleCache.cpp +++ b/clang/lib/Serialization/ModuleCache.cpp @@ -228,10 +228,6 @@ clang::writeImpl(StringRef Path, llvm::MemoryBufferRef Buffer, off_t &Size, return std::move(Written); } -/// The access time of a module file is only refreshed explicitly when it is -/// older than this interval so we avoid frequent yet unnecessary updates. -static constexpr std::chrono::seconds AccessTimeRefreshInterval(60); - /// Record that the module file open as \p FD has just been used by setting its /// access time to now, if it is older than AccessTimeRefreshInterval. Module /// cache pruning goes by access time, and file systems don't reliably update it @@ -242,6 +238,10 @@ refreshAccessTime([[maybe_unused]] llvm::sys::fs::file_t FD, // FIXME: Support Windows. The handle (FD) is opened for reading only, and // SetFileTime needs one with FILE_WRITE_ATTRIBUTES access. #ifndef _WIN32 + // The access time of a module file is only refreshed explicitly when it is + // older than this interval so we avoid frequent yet unnecessary updates. + constexpr std::chrono::seconds AccessTimeRefreshInterval(60); + llvm::sys::TimePoint<> Now = std::chrono::system_clock::now(); if (Now - Status.getLastAccessedTime() <= AccessTimeRefreshInterval) return; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
