[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 23 09:56:26 PDT 2024


================
@@ -1721,11 +1723,15 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
     Diag(Tok.getLocation(), diag::warn_pp_date_time);
     // 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;
+    std::string Result = "??? ??? ?? ??:??:?? ????";
+    std::stringstream TmpStream;
+    TmpStream.imbue(std::locale("C"));
+    TmpStream.setstate(std::ios_base::badbit);
----------------
yichi170 wrote:

Fixed it. Thanks for the advice.

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


More information about the cfe-commits mailing list