[clang] [clang] Fix -Wunused-const-variable for AccessTimeRefreshInterval on Windows (PR #244002)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 18 13:06:25 PST 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Jinsong Ji (jsji)
<details>
<summary>Changes</summary>
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 <noreply@<!-- -->anthropic.com>
---
Full diff: https://github.com/llvm/llvm-project/pull/244002.diff
1 Files Affected:
- (modified) clang/lib/Serialization/ModuleCache.cpp (+4-4)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/244002
More information about the cfe-commits
mailing list