[clang] feb1fb5 - Make the `-disable-free` flag more full featured (#136213)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 17 17:27:53 PDT 2025
Author: Chandler Carruth
Date: 2025-04-17T17:27:50-07:00
New Revision: feb1fb5f0473eb949b35fb25e15c4d32465cd6d7
URL: https://github.com/llvm/llvm-project/commit/feb1fb5f0473eb949b35fb25e15c4d32465cd6d7
DIFF: https://github.com/llvm/llvm-project/commit/feb1fb5f0473eb949b35fb25e15c4d32465cd6d7.diff
LOG: Make the `-disable-free` flag more full featured (#136213)
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.
Added:
Modified:
clang/include/clang/Driver/Options.td
clang/test/Driver/clang-translation.c
Removed:
################################################################################
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"
More information about the cfe-commits
mailing list