-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang][Driver] Add flag for setting SkipFunctionBodies #100135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang Author: kadir çetinkaya (kadircet) ChangesThis is an option set by certain tools (clangd and ASTUnit). Sometimes Full diff: https://github.com/llvm/llvm-project/pull/100135.diff 2 Files Affected:
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 69269cf7537b0..130b2bd68c8b4 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -7525,6 +7525,9 @@ def code_completion_brief_comments : Flag<["-"], "code-completion-brief-comments
def code_completion_with_fixits : Flag<["-"], "code-completion-with-fixits">,
HelpText<"Include code completion results which require small fix-its.">,
MarshallingInfoFlag<FrontendOpts<"CodeCompleteOpts.IncludeFixIts">>;
+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">>;
diff --git a/clang/test/Frontend/skip-function-bodies.cc b/clang/test/Frontend/skip-function-bodies.cc
new file mode 100644
index 0000000000000..dd5ad21424bac
--- /dev/null
+++ b/clang/test/Frontend/skip-function-bodies.cc
@@ -0,0 +1,8 @@
+// Trivial check to ensure skip-function-bodies flag is propagated.
+//
+// RUN: %clang_cc1 -verify -skip-function-bodies -pedantic-errors %s
+
+int f() {
+ // normally this should emit some diags, but we're skipping it!
+ this is garbage;
+}
|
I am generally supportive of the idea to expose this for more easily reproducing bugs in source tools, and clangd, in particular. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's give other folks a chance to reply before landing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My initial thinking was that this doesn't scale particularly well as there may be other options we want to also set at the same time to help produce a reproducer. But after looking through the existing options, I don't really see others that don't already have some form of option. But I'll still ask the question: would it make sense to name this -helpful-reproducers
or something more generic so we don't feel tempted to expose even more internal options this way?
That said, so long as this is a -cc1
-only option, it seems reasonable to me.
The subject could be clarified: "Add cc1 option for ..." so that readers are clear this is not a driver option. |
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.
5c7564d
to
884a272
Compare
this is a cc1-only option. added test, updated the commit message. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
||
// Make sure we only accept it as a cc1 arg. | ||
// RUN: not %clang -skip-function-bodies %s 2>&1 | FileCheck %s | ||
// CHECK: clang: error: unknown argument '-skip-function-bodies'; did you mean '-Xclang -skip-function-bodies'? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay for a diagnostic, boo for it suggesting -Xclang
in this instance, but I think we can live with it.
This is tricky as some issues reproduce only when we skip function bodies and sometimes when we don't. Sometimes we need a PCM that skips function bodies and another file consuming it that does not (this is a normal operation mode of Clangd). +1 to Fangrui's suggestion to mention this is a |
Summary: 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. Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60250597
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.