diff options
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index bcd5359..9cd6d86 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -4227,6 +4227,9 @@ static void GeneratePreprocessorArgs(PreprocessorOptions &Opts, for (const auto &RF : Opts.RemappedFiles) GenerateArg(Args, OPT_remap_file, RF.first + ";" + RF.second, SA); + if (Opts.SourceDateEpoch) + GenerateArg(Args, OPT_source_date_epoch, Twine(*Opts.SourceDateEpoch), SA); + // Don't handle LexEditorPlaceholders. It is implied by the action that is // generated elsewhere. } @@ -4309,14 +4312,15 @@ static bool ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args, Opts.addRemappedFile(Split.first, Split.second); } - if (const char *Epoch = std::getenv("SOURCE_DATE_EPOCH")) { + if (const Arg *A = Args.getLastArg(OPT_source_date_epoch)) { + StringRef Epoch = A->getValue(); // SOURCE_DATE_EPOCH, if specified, must be a non-negative decimal integer. // On time64 systems, pick 253402300799 (the UNIX timestamp of // 9999-12-31T23:59:59Z) as the upper bound. const uint64_t MaxTimestamp = std::min<uint64_t>(std::numeric_limits<time_t>::max(), 253402300799); uint64_t V; - if (StringRef(Epoch).getAsInteger(10, V) || V > MaxTimestamp) { + if (Epoch.getAsInteger(10, V) || V > MaxTimestamp) { Diags.Report(diag::err_fe_invalid_source_date_epoch) << Epoch << MaxTimestamp; } else { |