[clang] 91e19f6 - [driver] Explicitly specify `-fbuild-session-timestamp` in seconds.
Volodymyr Sapsai via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 19 13:31:02 PDT 2021
Author: Volodymyr Sapsai
Date: 2021-10-19T13:30:26-07:00
New Revision: 91e19f66e51ac3fda2309f5e67b02fcccd4d58a0
URL: https://github.com/llvm/llvm-project/commit/91e19f66e51ac3fda2309f5e67b02fcccd4d58a0
DIFF: https://github.com/llvm/llvm-project/commit/91e19f66e51ac3fda2309f5e67b02fcccd4d58a0.diff
LOG: [driver] Explicitly specify `-fbuild-session-timestamp` in seconds.
Representation of the file's last modification time depends on the file
system and isn't guaranteed to be in seconds. Cast to seconds explicitly
and tighten the test case to check the magnitude of the calculated
value, so we can catch passing milliseconds or nanoseconds.
rdar://83915615
Differential Revision: https://reviews.llvm.org/D111205
Added:
Modified:
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/modules.m
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index b689301e9bb1..8dabfff64f80 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3573,11 +3573,11 @@ static void RenderModulesOptions(Compilation &C, const Driver &D,
llvm::sys::fs::file_status Status;
if (llvm::sys::fs::status(A->getValue(), Status))
D.Diag(diag::err_drv_no_such_file) << A->getValue();
- CmdArgs.push_back(
- Args.MakeArgString("-fbuild-session-timestamp=" +
- Twine((uint64_t)Status.getLastModificationTime()
- .time_since_epoch()
- .count())));
+ CmdArgs.push_back(Args.MakeArgString(
+ "-fbuild-session-timestamp=" +
+ Twine((uint64_t)std::chrono::duration_cast<std::chrono::seconds>(
+ Status.getLastModificationTime().time_since_epoch())
+ .count())));
}
if (Args.getLastArg(options::OPT_fmodules_validate_once_per_build_session)) {
diff --git a/clang/test/Driver/modules.m b/clang/test/Driver/modules.m
index 73db4e7e0fcc..67140926f176 100644
--- a/clang/test/Driver/modules.m
+++ b/clang/test/Driver/modules.m
@@ -11,7 +11,7 @@
// RUN: %clang -fbuild-session-file=%t.build-session-file -### %s 2>&1 | FileCheck -check-prefix=TIMESTAMP_ONLY %s
// RUN: %clang -fbuild-session-timestamp=1280703457 -### %s 2>&1 | FileCheck -check-prefix=TIMESTAMP_ONLY %s
-// TIMESTAMP_ONLY: -fbuild-session-timestamp=128
+// TIMESTAMP_ONLY: -fbuild-session-timestamp=128{{([[:digit:]]{7})[^[:digit:]]}}
// RUN: %clang -fbuild-session-file=%t.build-session-file -fbuild-session-timestamp=123 -### %s 2>&1 | FileCheck -check-prefix=CONFLICT %s
// CONFLICT: error: invalid argument '-fbuild-session-file={{.*}}.build-session-file' not allowed with '-fbuild-session-timestamp'
@@ -21,7 +21,7 @@
// MODULES_VALIDATE_ONCE: -fmodules-validate-once-per-build-session
// RUN: %clang -fbuild-session-file=%t.build-session-file -fmodules-validate-once-per-build-session -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_ONCE_FILE %s
-// MODULES_VALIDATE_ONCE_FILE: -fbuild-session-timestamp=128
+// MODULES_VALIDATE_ONCE_FILE: -fbuild-session-timestamp=128{{([[:digit:]]{7})[^[:digit:]]}}
// MODULES_VALIDATE_ONCE_FILE: -fmodules-validate-once-per-build-session
// RUN: %clang -fmodules-validate-once-per-build-session -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_ONCE_ERR %s
More information about the cfe-commits
mailing list