# clangd user config for the Linux kernel workshop → ~/.config/clangd/config.yaml (install.sh links it). # A project's .clangd still applies on top of this. # compile_commands.json (bear, or `make compile_commands.json` in a kernel tree): Arch and lab kernels # are built with gcc. Drop the gcc-only flags clang rejects, and -Werror so clang-only warnings in # kernel headers stay warnings. CompileFlags: Remove: - -Werror - -mpreferred-stack-boundary=* - -mindirect-branch=* - -mindirect-branch-register - -mrecord-mcount - -mharden-sls=* - -fno-allow-store-data-races - -fzero-init-padding-bits=* - -fmin-function-alignment=* - -fconserve-stack - -fno-ipa-sra - -fno-partial-inlining - -fsanitize=bounds-strict - -fplugin=* - -fplugin-arg-* - -fdiagnostics-show-context* - --param=* Diagnostics: # kernel headers include each other on purpose UnusedIncludes: None MissingIncludes: None ClangTidy: Add: - bugprone-* - misc-redundant-expression Remove: - bugprone-easily-swappable-parameters - bugprone-reserved-identifier # kernel and libbpf live on __names - bugprone-macro-parentheses - bugprone-narrowing-conversions - bugprone-assignment-in-if-condition # `if ((err = ...))` is kernel style - bugprone-multi-level-implicit-pointer-conversion - bugprone-casting-through-void - bugprone-sizeof-expression # ARRAY_SIZE, offsetof tricks - bugprone-branch-clone - bugprone-implicit-widening-of-multiplication-result Completion: HeaderInsertion: Never --- # eBPF programs without a compile_commands.json entry: same flags as `clang -target bpf` in the decks If: PathMatch: .*\.bpf\.c CompileFlags: Add: [--target=bpf, -D__TARGET_ARCH_x86, -g, -O2]