Skip to content

Commit 884a272

Browse files
committed
[clang][Driver] Add cc1 flag for setting SkipFunctionBodies
This is an option set by certain tools (clangd and ASTUnit). Sometimes there are crashes in clang unique to this configuration and it's really hard to provide reproducers without invoking the tool.
1 parent fde27bd commit 884a272

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7525,6 +7525,9 @@ def code_completion_brief_comments : Flag<["-"], "code-completion-brief-comments
75257525
def code_completion_with_fixits : Flag<["-"], "code-completion-with-fixits">,
75267526
HelpText<"Include code completion results which require small fix-its.">,
75277527
MarshallingInfoFlag<FrontendOpts<"CodeCompleteOpts.IncludeFixIts">>;
7528+
def skip_function_bodies : Flag<["-"], "skip-function-bodies">,
7529+
HelpText<"Skip function bodies when possible">,
7530+
MarshallingInfoFlag<FrontendOpts<"SkipFunctionBodies">>;
75287531
def disable_free : Flag<["-"], "disable-free">,
75297532
HelpText<"Disable freeing of memory on exit">,
75307533
MarshallingInfoFlag<FrontendOpts<"DisableFree">>;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Trivial check to ensure skip-function-bodies flag is propagated.
2+
//
3+
// RUN: %clang_cc1 -verify -skip-function-bodies -pedantic-errors %s
4+
// expected-no-diagnostics
5+
6+
int f() {
7+
// normally this should emit some diags, but we're skipping it!
8+
this is garbage;
9+
}
10+
11+
// Make sure we only accept it as a cc1 arg.
12+
// RUN: not %clang -skip-function-bodies %s 2>&1 | FileCheck %s
13+
// CHECK: clang: error: unknown argument '-skip-function-bodies'; did you mean '-Xclang -skip-function-bodies'?

0 commit comments

Comments
 (0)