Skip to content

Commit feb1fb5

Browse files
authored
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.
1 parent ce0c472 commit feb1fb5

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7889,9 +7889,13 @@ def code_completion_with_fixits : Flag<["-"], "code-completion-with-fixits">,
78897889
def skip_function_bodies : Flag<["-"], "skip-function-bodies">,
78907890
HelpText<"Skip function bodies when possible">,
78917891
MarshallingInfoFlag<FrontendOpts<"SkipFunctionBodies">>;
7892-
def disable_free : Flag<["-"], "disable-free">,
7893-
HelpText<"Disable freeing of memory on exit">,
7894-
MarshallingInfoFlag<FrontendOpts<"DisableFree">>;
7892+
defm disable_free : BoolOption<"",
7893+
"disable-free",
7894+
FrontendOpts<"DisableFree">,
7895+
DefaultFalse,
7896+
PosFlag<SetTrue, [], [ClangOption], "Disable">,
7897+
NegFlag<SetFalse, [], [ClangOption], "Don't disable">,
7898+
BothFlags<[], [ClangOption], " freeing of memory on exit">>;
78957899
defm clear_ast_before_backend : BoolOption<"",
78967900
"clear-ast-before-backend",
78977901
CodeGenOpts<"ClearASTBeforeBackend">,

clang/test/Driver/clang-translation.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
// I386: "-o"
1111
// I386: clang-translation
1212

13+
// RUN: %clang -target i386-unknown-unknown -### -S %s -o %t.s -Xclang -no-disable-free 2>&1 | FileCheck -check-prefix=FREE %s
14+
// FREE: "-disable-free"
15+
// FREE: "-no-disable-free"
16+
1317
// 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:
1418
// UNWIND-TABLES: "-funwind-tables=2"
1519

0 commit comments

Comments
 (0)