[clang] [clang][Driver] Add flag for setting SkipFunctionBodies (PR #100135)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 23 07:49:32 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: kadir çetinkaya (kadircet)

<details>
<summary>Changes</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.


---
Full diff: https://github.com/llvm/llvm-project/pull/100135.diff


2 Files Affected:

- (modified) clang/include/clang/Driver/Options.td (+3) 
- (added) clang/test/Frontend/skip-function-bodies.cc (+8) 


``````````diff
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; 
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/100135


More information about the cfe-commits mailing list