https://github.com/chandlerc created https://github.com/llvm/llvm-project/pull/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. >From 4e4ca5ab0f49252ea5a59c51fc1ddd0b43bcc5df 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 | 3 +++ 2 files changed, 10 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..1c9e3cfb2a5e5 100644 --- a/clang/test/Driver/clang-translation.c +++ b/clang/test/Driver/clang-translation.c @@ -10,6 +10,9 @@ // I386: "-o" // I386: clang-translation +// RUN: %clang -target i386-unknown-unknown -### -S -O0 -Os %s -o %t.s -fverbose-asm -fvisibility=hidden -no-disable-free 2>&1 | FileCheck -check-prefix=FREE %s +// FREE-NOT: "-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