From 2bfb8d80db405b26579b06a07bac25859fd4048a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 23 May 2026 23:16:39 +0000 Subject: [PATCH] Finish TPTP review cleanups Agent-Logs-Url: https://github.com/Z3Prover/z3/sessions/ca1df142-d992-4e45-a8b3-859fa70a5222 Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> --- src/cmd_context/tptp_frontend.cpp | 2 +- src/test/tptp.cpp | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/cmd_context/tptp_frontend.cpp b/src/cmd_context/tptp_frontend.cpp index 1589c539a..bc277de42 100644 --- a/src/cmd_context/tptp_frontend.cpp +++ b/src/cmd_context/tptp_frontend.cpp @@ -1660,7 +1660,7 @@ class tptp_parser { std::string role = to_lower(parse_name()); expect(token_kind::comma, "','"); - if (!m_name_filters.empty() && !m_name_filters.back().contains(formula_name)) { + if (!m_name_filters.empty() && m_name_filters.back().find(formula_name) == m_name_filters.back().end()) { skip_annotations_until_rparen(); expect(token_kind::rparen, "')'"); expect(token_kind::dot, "'.'"); diff --git a/src/test/tptp.cpp b/src/test/tptp.cpp index 889f31098..42bd79d12 100644 --- a/src/test/tptp.cpp +++ b/src/test/tptp.cpp @@ -49,16 +49,22 @@ static void write_file(char const* path, char const* contents) { class scoped_temp_file { std::string m_path; public: + scoped_temp_file(scoped_temp_file const&) = delete; + scoped_temp_file& operator=(scoped_temp_file const&) = delete; + scoped_temp_file(scoped_temp_file&&) = delete; + scoped_temp_file& operator=(scoped_temp_file&&) = delete; + scoped_temp_file(char const* contents) { static std::atomic counter(0); - auto stamp = std::chrono::steady_clock::now().time_since_epoch().count(); + auto stamp = std::chrono::duration_cast( + std::chrono::steady_clock::now().time_since_epoch()).count(); m_path = (std::filesystem::temp_directory_path() / ("z3-tptp-" + std::to_string(stamp) + "-" + std::to_string(counter.fetch_add(1)) + ".p")).string(); write_file(m_path.c_str(), contents); } ~scoped_temp_file() { - if (!m_path.empty()) - std::remove(m_path.c_str()); + if (!m_path.empty() && std::remove(m_path.c_str()) != 0) + std::cerr << "failed to remove temporary file: " << m_path << "\n"; } std::string const& path() const { return m_path; } };