[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
This commit is contained in:
Volodymyr Sapsai 2021-10-05 19:37:32 -07:00
parent 5e004b03f7
commit 91e19f66e5
2 changed files with 7 additions and 7 deletions

View File

@ -3573,11 +3573,11 @@ static void RenderModulesOptions(Compilation &C, const Driver &D,
llvm::sys::fs::file_status Status; llvm::sys::fs::file_status Status;
if (llvm::sys::fs::status(A->getValue(), Status)) if (llvm::sys::fs::status(A->getValue(), Status))
D.Diag(diag::err_drv_no_such_file) << A->getValue(); D.Diag(diag::err_drv_no_such_file) << A->getValue();
CmdArgs.push_back( CmdArgs.push_back(Args.MakeArgString(
Args.MakeArgString("-fbuild-session-timestamp=" + "-fbuild-session-timestamp=" +
Twine((uint64_t)Status.getLastModificationTime() Twine((uint64_t)std::chrono::duration_cast<std::chrono::seconds>(
.time_since_epoch() Status.getLastModificationTime().time_since_epoch())
.count()))); .count())));
} }
if (Args.getLastArg(options::OPT_fmodules_validate_once_per_build_session)) { if (Args.getLastArg(options::OPT_fmodules_validate_once_per_build_session)) {

View File

@ -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-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 // 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 // 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' // 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 // 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 // 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 // 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 // RUN: %clang -fmodules-validate-once-per-build-session -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_ONCE_ERR %s