[clang] [clang] replaced the usage of `asctime` with `strftime` (PR #99075)

Yi-Chi Lee via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 16 17:32:58 PDT 2024


================
@@ -1722,10 +1722,12 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
     // MSVC, ICC, GCC, VisualAge C++ extension.  The generated string should be
     // of the form "Ddd Mmm dd hh::mm::ss yyyy", which is returned by asctime.
     const char *Result;
+    char TimeString[std::size("Ddd Mmm dd hh:mm:ss yyyy")];
     if (getPreprocessorOpts().SourceDateEpoch) {
       time_t TT = *getPreprocessorOpts().SourceDateEpoch;
       std::tm *TM = std::gmtime(&TT);
-      Result = asctime(TM);
+      strftime(TimeString, std::size(TimeString), "%c", TM);
----------------
yichi170 wrote:

I see. Do you mean if the result of `strftime` is zero, `Result` have to be set as "???...?"?

https://github.com/llvm/llvm-project/pull/99075


More information about the cfe-commits mailing list