emaste updated this revision to Diff 58977. emaste added a comment. Use gmtime to report in UTC when `SOURCE_DATE_EPOCH` is set. This follows GCC and makes sense given the purpose of `SOURCE_DATE_EPOCH`.
For reference here is discussion on the GCC list when this was introduced there: https://gcc.gnu.org/ml/gcc-patches/2015-06/msg02210.html http://reviews.llvm.org/D20791 Files: lib/Lex/PPMacroExpansion.cpp Index: lib/Lex/PPMacroExpansion.cpp =================================================================== --- lib/Lex/PPMacroExpansion.cpp +++ lib/Lex/PPMacroExpansion.cpp @@ -1013,8 +1013,16 @@ /// the identifier tokens inserted. static void ComputeDATE_TIME(SourceLocation &DATELoc, SourceLocation &TIMELoc, Preprocessor &PP) { - time_t TT = time(nullptr); - struct tm *TM = localtime(&TT); + time_t TT; + struct tm *TM; + const char *envValue = getenv("SOURCE_DATE_EPOCH"); + if (envValue != nullptr) { + TT = strtol(envValue, nullptr, 10); + TM = gmtime(&TT); + } else { + TT = time(nullptr); + TM = localtime(&TT); + } static const char * const Months[] = { "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
Index: lib/Lex/PPMacroExpansion.cpp =================================================================== --- lib/Lex/PPMacroExpansion.cpp +++ lib/Lex/PPMacroExpansion.cpp @@ -1013,8 +1013,16 @@ /// the identifier tokens inserted. static void ComputeDATE_TIME(SourceLocation &DATELoc, SourceLocation &TIMELoc, Preprocessor &PP) { - time_t TT = time(nullptr); - struct tm *TM = localtime(&TT); + time_t TT; + struct tm *TM; + const char *envValue = getenv("SOURCE_DATE_EPOCH"); + if (envValue != nullptr) { + TT = strtol(envValue, nullptr, 10); + TM = gmtime(&TT); + } else { + TT = time(nullptr); + TM = localtime(&TT); + } static const char * const Months[] = { "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits