https://github.com/chandlerc updated 
https://github.com/llvm/llvm-project/pull/136213

>From 6c53f36e9306d5abc50b9afcc1fe6a204d67c6e1 Mon Sep 17 00:00:00 2001
From: Chandler Carruth <chandl...@gmail.com>
Date: Wed, 16 Apr 2025 22:57:18 +0000
Subject: [PATCH] Make the `-disable-free` flag more full featured

This lets us pass `-no-disable-free` to re-enable freeing memory for
example. This is especially helpful for library users of Clang where it
is important to not slowly leak memory.
---
 clang/include/clang/Driver/Options.td | 10 +++++++---
 clang/test/Driver/clang-translation.c |  4 ++++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e9acb20348654..830d3459a1320 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -7889,9 +7889,13 @@ def code_completion_with_fixits : Flag<["-"], 
"code-completion-with-fixits">,
 def skip_function_bodies : Flag<["-"], "skip-function-bodies">,
   HelpText<"Skip function bodies when possible">,
   MarshallingInfoFlag<FrontendOpts<"SkipFunctionBodies">>;
-def disable_free : Flag<["-"], "disable-free">,
-  HelpText<"Disable freeing of memory on exit">,
-  MarshallingInfoFlag<FrontendOpts<"DisableFree">>;
+defm disable_free : BoolOption<"",
+  "disable-free",
+  FrontendOpts<"DisableFree">,
+  DefaultFalse,
+  PosFlag<SetTrue, [], [ClangOption], "Disable">,
+  NegFlag<SetFalse, [], [ClangOption], "Don't disable">,
+  BothFlags<[], [ClangOption], " freeing of memory on exit">>;
 defm clear_ast_before_backend : BoolOption<"",
   "clear-ast-before-backend",
   CodeGenOpts<"ClearASTBeforeBackend">,
diff --git a/clang/test/Driver/clang-translation.c 
b/clang/test/Driver/clang-translation.c
index a7343ea18b213..7fc41ff46ed28 100644
--- a/clang/test/Driver/clang-translation.c
+++ b/clang/test/Driver/clang-translation.c
@@ -10,6 +10,10 @@
 // I386: "-o"
 // I386: clang-translation
 
+// RUN: %clang -target i386-unknown-unknown -### -S %s -o %t.s -Xclang 
-no-disable-free 2>&1 | FileCheck -check-prefix=FREE %s
+// FREE: "-disable-free"
+// FREE: "-no-disable-free"
+
 // RUN: %clang -target i386-unknown-unknown -### -S %s 
-fasynchronous-unwind-tables -fno-unwind-tables 2>&1 | FileCheck 
--check-prefix=UNWIND-TABLES %s --implicit-check-not=warning:
 // UNWIND-TABLES: "-funwind-tables=2"
 

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to