Author: kadir çetinkaya Date: 2024-07-25T11:27:14+02:00 New Revision: 456c5121f8e6f37881f236bdf573ef29cad5af1e
URL: https://github.com/llvm/llvm-project/commit/456c5121f8e6f37881f236bdf573ef29cad5af1e DIFF: https://github.com/llvm/llvm-project/commit/456c5121f8e6f37881f236bdf573ef29cad5af1e.diff LOG: [clang][Driver] Add cc1 flag for setting SkipFunctionBodies (#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. Added: clang/test/Frontend/skip-function-bodies.cpp Modified: clang/include/clang/Driver/Options.td Removed: ################################################################################ diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 28a5cb71d2219..26811bf948ae5 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -7534,6 +7534,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.cpp b/clang/test/Frontend/skip-function-bodies.cpp new file mode 100644 index 0000000000000..d0593b474bda2 --- /dev/null +++ b/clang/test/Frontend/skip-function-bodies.cpp @@ -0,0 +1,13 @@ +// Trivial check to ensure skip-function-bodies flag is propagated. +// +// RUN: %clang_cc1 -verify -skip-function-bodies -pedantic-errors %s +// expected-no-diagnostics + +int f() { + // normally this should emit some diags, but we're skipping it! + this is garbage; +} + +// 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'? _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits