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

via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 23 01:20:09 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);
----------------
cor3ntin wrote:

That is not needed afaik (the bad bit would be set automatically on failure)

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


More information about the cfe-commits mailing list