Token导航 LogoToken导航TokenDH.com
开发只读github未标认证来源可访问许可证需确认审计通过

clangclang 命令行

Agent Skill

clang 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

2,808

周安装

117

GitHub Stars

80

下载量

936
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:clang(clang 命令行)
来源仓库:https://github.com/mohitmishra786/low-level-dev-skills
仓库路径:skills/clang
安装命令:
npx skills add https://github.com/mohitmishra786/low-level-dev-skills --skill clang
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/mohitmishra786/low-level-dev-skills --skill clang

简介

指导 Agent 使用 Clang 编译器的高级特性与诊断工具。

  • 集成 sanitizer、优化 remark 与静态分析等 LLVM 生态组件。
  • 覆盖 macOS/FreeBSD 等平台差异与 clang-cl MSVC 兼容模式。
  • 优先采用 GCC 等效 flag,特殊场景才使用 Clang 专有选项。
  • clang 属于开发类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Clang

Purpose

Guide agents through Clang-specific features: superior diagnostics, sanitizer integration, optimization remarks, static analysis, and LLVM tooling. Covers divergences from GCC and Apple/FreeBSD specifics.

Triggers

  • "I want better compiler diagnostics/errors"
  • "How do I use clang-tidy / clang-format?"
  • "How do I see what the compiler optimised or didn't?"
  • "I'm on macOS / FreeBSD using clang"
  • "clang-cl for MSVC-compatible builds" — see skills/compilers/msvc-cl
  • Sanitizer queries — see skills/runtimes/sanitizers

Workflow

1. Build mode flags (identical to GCC)

Clang accepts most GCC flags. Key differences:

FeatureGCCClang
Min size-Os-Os or -Oz (more aggressive)
Optimise only hot-fprofile-instr-use (LLVM PGO)
Thin LTO-flto-flto=thin (faster)
Static analyser-fanalyzerclang --analyze or clang-tidy

2. Clang-specific diagnostic flags

# Show fix-it hints inline
clang -Wall -Wextra --show-fixits src.c

# Limit error count
clang -ferror-limit=5 src.c

# Verbose template errors (disable elision)
clang -fno-elide-type src.cpp

# Show tree diff for template mismatch
clang -fdiagnostics-show-template-tree src.cpp

Clang's diagnostics include exact range highlighting and fix-it suggestions that GCC lacks.

3. Optimization remarks

Optimization remarks let you see what Clang did or refused to do:

# Inliner decisions
clang -O2 -Rpass=inline src.c

# Missed vectorisation
clang -O2 -Rpass-missed=loop-vectorize src.c

# Why a loop was not vectorized
clang -O2 -Rpass-analysis=loop-vectorize src.c

# Save all remarks to YAML for post-processing
clang -O2 -fsave-optimization-record src.c
# Produces src.opt.yaml

Interpret remarks:

  • remark: foo inlined into bar — inlining happened; good for hot paths
  • remark: loop not vectorized: loop control flow is not understood — restructure the loop
  • remark: not vectorized: cannot prove it is safe to reorder... — add __restrict__ or #pragma clang loop vectorize(assume_safety)

4. Static analysis

# Built-in analyser (CSA)
clang --analyze -Xanalyzer -analyzer-output=text src.c

# clang-tidy (separate tool, richer checks)
clang-tidy src.c -- -std=c++17 -I/usr/include

# Enable specific check families
clang-tidy -checks='clang-analyzer-*,modernize-*,bugprone-*' src.cpp --

# Apply fixits automatically
clang-tidy -fix src.cpp --

Common clang-tidy check families:

  • bugprone-*: real bugs (use-after-move, dangling, etc.)
  • clang-analyzer-*: CSA checks (memory, null deref)
  • modernize-*: C++11/14/17 modernisation
  • performance-*: unnecessary copies, move candidates
  • readability-*: naming, complexity

5. LTO with lld

# Full LTO
clang -O2 -flto -fuse-ld=lld src.c -o prog

# Thin LTO (faster link, nearly same quality)
clang -O2 -flto=thin -fuse-ld=lld src.c -o prog

# Check lld is available
clang -fuse-ld=lld -Wl,--version 2>&1 | head -1

For large projects, ThinLTO is preferred: link times 5-10x faster than full LTO with comparable code quality.

6. PGO (LLVM instrumentation)

# Step 1: instrument
clang -O2 -fprofile-instr-generate prog.c -o prog_inst

# Step 2: run with representative input
./prog_inst < workload.input
# Generates default.profraw

# Step 3: merge profiles
llvm-profdata merge -output=prog.profdata default.profraw

# Step 4: use profile
clang -O2 -fprofile-instr-use=prog.profdata prog.c -o prog

AutoFDO (sampling-based, less intrusive): collect with perf, convert with create_llvm_prof, use with -fprofile-sample-use. See skills/profilers/linux-perf.

7. GCC compatibility

Clang is intentionally GCC-compatible for driver flags. Key differences:

  • Clang does not support all GCC-specific attributes; check with __has_attribute(foo)
  • -Weverything enables all Clang warnings (no GCC equivalent); too noisy for production, useful for one-off audits
  • Some GCC intrinsics need #include <x86intrin.h> on Clang too
  • __int128 is supported; __float128 requires -lquadmath on some targets

8. macOS specifics

On macOS, clang is the system compiler (Apple LLVM). Key points:

  • ld64 is the default linker; lld requires explicit -fuse-ld=lld and Homebrew LLVM
  • Use -mmacosx-version-min=X.Y to set deployment target
  • Sanitizers on macOS use DYLD_INSERT_LIBRARIES; do not strip the binary
  • xcrun clang resolves to the Xcode toolchain clang

For flag reference, see references/flags.md. For clang-tidy config examples, see references/clang-tidy.md.

Related skills

  • Use skills/compilers/gcc for GCC-equivalent flag mapping
  • Use skills/runtimes/sanitizers for -fsanitize=* workflows
  • Use skills/compilers/llvm for IR-level work (opt, llc, llvm-dis)
  • Use skills/compilers/msvc-cl for clang-cl on Windows
  • Use skills/binaries/linkers-lto for linker-level LTO details

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

32.89%
按下载量换算308

Claude

28.7%
按下载量换算269

Cursor

19.83%
按下载量换算186

Gemini CLI

10.24%
按下载量换算96

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills