Skip to content

Commit 456c512

Browse files
authored
[clang][Driver] Add cc1 flag for setting SkipFunctionBodies (llvm#100135)
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 f87e9d4 commit 456c512

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
@@ -7534,6 +7534,9 @@ def code_completion_brief_comments : Flag<["-"], "code-completion-brief-comments
75347534
def code_completion_with_fixits : Flag<["-"], "code-completion-with-fixits">,
75357535
HelpText<"Include code completion results which require small fix-its.">,
75367536
MarshallingInfoFlag<FrontendOpts<"CodeCompleteOpts.IncludeFixIts">>;
7537+
def skip_function_bodies : Flag<["-"], "skip-function-bodies">,
7538+
HelpText<"Skip function bodies when possible">,
7539+
MarshallingInfoFlag<FrontendOpts<"SkipFunctionBodies">>;
75377540
def disable_free : Flag<["-"], "disable-free">,
75387541
HelpText<"Disable freeing of memory on exit">,
75397542
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)