From 04e281fabe52181634313885e5ed850485a9877f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Apr 2026 20:57:59 +0000 Subject: [PATCH 1/3] Initial plan From 192a6e7cc887ee5b4d8024884e59341322e9d52c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Apr 2026 21:00:59 +0000 Subject: [PATCH 2/3] Use owning strings for transpile inputs and flags Agent-Logs-Url: https://github.com/Cpp2Rust/cpp2rust/sessions/b35e24ce-b7f8-4f5a-97dd-80c8f5f18730 Co-authored-by: nunoplopes <2998477+nunoplopes@users.noreply.github.com> --- cpp2rust/cpp2rust.cpp | 2 +- cpp2rust/cpp2rust_lib.cpp | 6 +++--- cpp2rust/cpp2rust_lib.h | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cpp2rust/cpp2rust.cpp b/cpp2rust/cpp2rust.cpp index f7943b6f..c38c2de2 100644 --- a/cpp2rust/cpp2rust.cpp +++ b/cpp2rust/cpp2rust.cpp @@ -140,7 +140,7 @@ int main(int argc, char *argv[]) { } } - std::vector cxx_flags(CXXFlags.begin(), CXXFlags.end()); + std::vector cxx_flags(CXXFlags.begin(), CXXFlags.end()); if (RulesDir.empty() && !ResolveRulesDir()) { llvm::errs() << "ERROR: rules directory not found. " diff --git a/cpp2rust/cpp2rust_lib.cpp b/cpp2rust/cpp2rust_lib.cpp index 7c2654ea..5880030a 100644 --- a/cpp2rust/cpp2rust_lib.cpp +++ b/cpp2rust/cpp2rust_lib.cpp @@ -11,8 +11,8 @@ #include "frontend_action.h" namespace cpp2rust { -std::string TranspileSrc(std::string_view cc_code, Model model, - const std::vector &cxx_flags, +std::string TranspileSrc(const std::string &cc_code, Model model, + const std::vector &cxx_flags, const std::string &rules_dir) { auto tool_args = getPlatformClangFlags(); tool_args.push_back("-fparse-all-comments"); @@ -25,7 +25,7 @@ std::string TranspileSrc(std::string_view cc_code, Model model, return rs_code; } -std::string TranspileDir(std::string_view build_dir, Model model, +std::string TranspileDir(const std::string &build_dir, Model model, const std::string &rules_dir) { std::string error_message; auto compile_dbase = clang::tooling::CompilationDatabase::loadFromDirectory( diff --git a/cpp2rust/cpp2rust_lib.h b/cpp2rust/cpp2rust_lib.h index 544d72a7..c61bae74 100644 --- a/cpp2rust/cpp2rust_lib.h +++ b/cpp2rust/cpp2rust_lib.h @@ -10,10 +10,10 @@ namespace cpp2rust { -std::string TranspileSrc(std::string_view cc_code, Model model, - const std::vector &cxx_flags, +std::string TranspileSrc(const std::string &cc_code, Model model, + const std::vector &cxx_flags, const std::string &rules_dir); -std::string TranspileDir(std::string_view build_dir, Model model, +std::string TranspileDir(const std::string &build_dir, Model model, const std::string &rules_dir); } // namespace cpp2rust From 455f7b12a013f5f316eba3507057176dd1599ed8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Apr 2026 21:09:01 +0000 Subject: [PATCH 3/3] Revert incorrect string_view fix; add ASan allow_user_poisoning=0 workaround Agent-Logs-Url: https://github.com/Cpp2Rust/cpp2rust/sessions/eefbdd47-230f-4e60-8b32-45c1188021f5 Co-authored-by: nunoplopes <2998477+nunoplopes@users.noreply.github.com> --- cpp2rust/cpp2rust.cpp | 13 ++++++++++++- cpp2rust/cpp2rust_lib.cpp | 6 +++--- cpp2rust/cpp2rust_lib.h | 6 +++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/cpp2rust/cpp2rust.cpp b/cpp2rust/cpp2rust.cpp index c38c2de2..2645f8f0 100644 --- a/cpp2rust/cpp2rust.cpp +++ b/cpp2rust/cpp2rust.cpp @@ -20,6 +20,17 @@ #include "cpp2rust_lib.h" +// LLVM's BumpPtrAllocator intentionally poisons freed slab memory via +// __asan_poison_memory_region. When ASan is enabled this can produce +// use-after-poison false positives inside clang/LLVM itself (e.g. during +// IdentifierTable initialisation). Opting out of user-poisoning suppresses +// those LLVM-internal false positives without affecting real UAF detection. +#if defined(__has_feature) && __has_feature(address_sanitizer) +extern "C" const char *__asan_default_options() { + return "allow_user_poisoning=0"; +} +#endif + namespace fs = std::filesystem; namespace { @@ -140,7 +151,7 @@ int main(int argc, char *argv[]) { } } - std::vector cxx_flags(CXXFlags.begin(), CXXFlags.end()); + std::vector cxx_flags(CXXFlags.begin(), CXXFlags.end()); if (RulesDir.empty() && !ResolveRulesDir()) { llvm::errs() << "ERROR: rules directory not found. " diff --git a/cpp2rust/cpp2rust_lib.cpp b/cpp2rust/cpp2rust_lib.cpp index 5880030a..7c2654ea 100644 --- a/cpp2rust/cpp2rust_lib.cpp +++ b/cpp2rust/cpp2rust_lib.cpp @@ -11,8 +11,8 @@ #include "frontend_action.h" namespace cpp2rust { -std::string TranspileSrc(const std::string &cc_code, Model model, - const std::vector &cxx_flags, +std::string TranspileSrc(std::string_view cc_code, Model model, + const std::vector &cxx_flags, const std::string &rules_dir) { auto tool_args = getPlatformClangFlags(); tool_args.push_back("-fparse-all-comments"); @@ -25,7 +25,7 @@ std::string TranspileSrc(const std::string &cc_code, Model model, return rs_code; } -std::string TranspileDir(const std::string &build_dir, Model model, +std::string TranspileDir(std::string_view build_dir, Model model, const std::string &rules_dir) { std::string error_message; auto compile_dbase = clang::tooling::CompilationDatabase::loadFromDirectory( diff --git a/cpp2rust/cpp2rust_lib.h b/cpp2rust/cpp2rust_lib.h index c61bae74..544d72a7 100644 --- a/cpp2rust/cpp2rust_lib.h +++ b/cpp2rust/cpp2rust_lib.h @@ -10,10 +10,10 @@ namespace cpp2rust { -std::string TranspileSrc(const std::string &cc_code, Model model, - const std::vector &cxx_flags, +std::string TranspileSrc(std::string_view cc_code, Model model, + const std::vector &cxx_flags, const std::string &rules_dir); -std::string TranspileDir(const std::string &build_dir, Model model, +std::string TranspileDir(std::string_view build_dir, Model model, const std::string &rules_dir); } // namespace cpp2rust